RE: [PHP] how to get page count when uploading files

2006-09-16 Thread Jian Fu
Oh, btw, I use PHP ftp function to upload the file, but there is no
information in $_FILES to tell me the total page for Word or PDF file. 

Really appreciated your time and help!

Thank you very much! Jian

-Original Message-
From: Stefan van der Linden [mailto:[EMAIL PROTECTED] 
Sent: 2006年9月17日 2:49
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] how to get page count when uploading files

>I really need help and after going through the help page, I don't know
where
>I can post my question.
>
> 
>
>When I upload a file (word or pdf), how can I know the page counts of that
>file immediately?
>
> 
>
>Thank you, Jian

There's no function in the PDF library to READ the file.
And about Word documents (.doc): Word calculates the amount of pages at
'parsetime'. Word documents are just RTF files, and they
don't describe the amount of pages in the files. 
So it's really tricky to make a script that counts the pages in Word
documents, as you would have to make an RTF parser. :/ 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] getting base domain and sub domains from url?

2006-09-16 Thread tedd

At 5:26 PM -0500 9/16/06, Kenneth Andresen wrote:

Thank you, Stut,

It gives the top level ones, but I can't seem to find the lower
specifications covering such as .co.uk  .com.mx  etc.

I am also starting to realize some countries may two levels of top
domains - in Norway for example you may get a .no domain, but there may
also be lower level top domains such as .mil.no.


You might check with ICANN -- I think they regulate all of that. But, 
I believe that specific countries, once awarded their TLD, have 
control over all sub domains.


That's my understanding.

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] getting base domain and sub domains from url?

2006-09-16 Thread Google Kreme

On 16 Sep 2006, at 16:26 , Kenneth Andresen wrote:

It gives the top level ones, but I can't seem to find the lower
specifications covering such as .co.uk  .com.mx  etc.


There is no lower 'specification' because each one is unique.

.mx is administered, for example, by www.nic.mx (I believe), so it is  
their option to subdivide the .mx tld however they see fit.  Each tld  
gets to do this however it wants.  Mexico chose .com.mx and .gob.mx  
(the latter for government sites), for example, while the UK  
chose .co.uk and .me.uk (the latter for personal pages), etc.  Since  
each one of these tlds is managed independently, it would be nearly  
impossible to construct a list of the possible second level domains  
for al the tlds.  Sure, you might be able to get .mx and .uk info  
fairly easily, but what about .cc or .cx or .fj?  And as soon as you  
do construct such a list, it will be out of date.


If you are trying to verify a valid email address or a valid domain,  
there are better ways.


--
Why can't you be in a good mood? How hard is it to decide to be in a  
good mood and be in a good mood once in a while?"


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] getting base domain and sub domains from url?

2006-09-16 Thread Kenneth Andresen
Thank you, Stut,

It gives the top level ones, but I can't seem to find the lower
specifications covering such as .co.uk  .com.mx  etc.

I am also starting to realize some countries may two levels of top
domains - in Norway for example you may get a .no domain, but there may
also be lower level top domains such as .mil.no.

I am not sure if there exists any general list for what I originally
looked for, but then again, then again, I am just realizing the specs I
looked at in fact does not require it this specific after all.

If there should be such a list somewhere I am still interested, but the
link you gave me is good enough for what I needed it for.

Again thank you!



Stut wrote:
> Kenneth Andresen wrote:
>   
>> What I would like to know is if there are some lists of all these base
>> domains, or maybe some function already doing what I would like to do?
>> 
>
> A full list of gTLDs and ccTLDs can be found here:
> http://www.iana.org/domain-names.htm
>
> -Stut
>
>
>   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] getting base domain and sub domains from url?

2006-09-16 Thread Stut
Kenneth Andresen wrote:
> What I would like to know is if there are some lists of all these base
> domains, or maybe some function already doing what I would like to do?

A full list of gTLDs and ccTLDs can be found here:
http://www.iana.org/domain-names.htm

-Stut

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] getting base domain and sub domains from url?

2006-09-16 Thread Kenneth Andresen
Hello all,

I am trying to extract base domains and sub domains from url's, and
expect there to exist something to do this already.

I used the parse_url($url) to get the host variable.

My thought is to use $domain_elements[]=array_reverse(explode('.',$url));

then simply check $domain_element[0] against some base of
international+country specific extensions, if they have sub-extensions
like "co.uk" then add
a third level to the domain list , and set this up as base domain. Any
levels beyond the registrable domain names would count as sub domains.

What I would like to know is if there are some lists of all these base
domains, or maybe some function already doing what I would like to do?


In advance, thanks!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how to get page count when uploading files

2006-09-16 Thread Stefan van der Linden

I really need help and after going through the help page, I don't know where
I can post my question.



When I upload a file (word or pdf), how can I know the page counts of that
file immediately?



Thank you, Jian


There's no function in the PDF library to READ the file.
And about Word documents (.doc): Word calculates the amount of pages at 
'parsetime'. Word documents are just RTF files, and they
don't describe the amount of pages in the files. 
So it's really tricky to make a script that counts the pages in Word documents, as you would have to make an RTF parser. :/ 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Odd PHP memory issue

2006-09-16 Thread Matthew H. North
On 9/15/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
> On Fri, September 15, 2006 10:42 am, Matthew H. North wrote:
> > We're developing a web application that involves traversal of a
> > hierarchical database structure (MySQL, PEAR::DB, and
> > PEAR::DB::DataObject).  Currently that traversal is done recursively,
> > and involves visiting thousands of nodes in the tree.  However, the
> > tree is relatively flat, and the recursion never gets more than 4 or 5
> > calls deep.  A severely truncated but illustrative version of the code
> > of interest is:
>
> So you are just visiting the nodes, and not doing anything with them?

We're appending certain fields to put together a total result.  However, as 
mentioned, the amount of data collected is not anywhere near even 1MB, and in 
any event, all references to the result variable are unset (AFAIK) when I 
come up w/ the final 5.5MB number.

>
> It's entirely possible that PEAR::DB and/or DataObject are trying to
> cache something to "help" you...
>
> You should be able to quickly hack a *BAD* page of code with minimal
> error checking to do whatever queries PEAR::DB is doing for you.

Yeah -- I was hoping to expand my understanding of PHP internals so I could 
avoid doing this, but based on more of your comments below I think I'm out of 
luck.

I did note that DataObject was keeping a running cache of result sets (even 
ones that I was done with for some reason), so I added a destructor on my 
DataObject extending classes that cleans those up.  That helps keep the 
running peak mem down, but is not part of the 5.5MB that I can't get rid of.

>
> > trigger_error(memory_get_usage());
> > $result = traverse_hierarchy();
>
> At crucial points within the hierarchy, perhaps at nodes/leaves you
> expect to be at specific milestones (halfway, 25%, 75%, ...) start
> adding code that does crude things like:
>
> if ($node->name == 'This one node we think is halfway through')
> trigger_error(memory_get_usage());
>
> Log the numbers into a db with the node names and then later graph it
> to see if the memory is getting chewed up in a straight line or if it
> jumps at some point.
>
> If there's a big jump somewhere, you know where to look.
>
> If it's a straight line, then you can start doing the same thing line
> by line to find where the RAM is going.

Great idea -- I just completed a degree in computational physics, which 
included courses that involved dumping loads of data and graphing them using 
tools like gnuplot and OpenDx... you'd think I would have thought of this one 
myself (rolling my eyes).

I _had_ thought of dumping the state at various, noted points throughout the 
process, but was hoping to avoid doing this kind of lengthy analysis.

>
> Did you close down the DB connection and kill the PEAR objects?...
>
> PHP's garbage collection has had... issues... in the past.

All of my classes that extend DataObject inherit a common destructor that 
calls the DataObject::free() method, which, supposedly, frees result 
resources.  I'm not sure what you mean by 'kill the PEAR objects', but all 
references go out of scope or are unset.

>
> > The question is this: Given the following assumptions:
> >
> > 1) PHP's memory manager reclaims memory when all references to that
> > memory are
> > gone.
>
> Well, it tries to anyway...
>
> It's not always that simple, particular with variable variables and
> other dynamic features.
>
> > 2) A reference is 'gone' when it goes out of scope or is 'unset'.
>
> Scope seems like it should be simple, but it's not.
>
> Use unset to be certain.
>
> > 3) The only references that remain in the global context are
> > references to globals (all non-global variables have gone out of scope
> > and that memory reclaimed)
>
> See #1.
>
> PHP "scope" is not as clean-cut as C.
>
> A simple "for" loop in PHP leaves the iterator variable, last I checked.
>
> Inside a function, that should go out of scope.  Outside a function,
> it stays around.  foreach, I think, correctly un-scopes the vars.

This collection of statements is very illuminating.  Part of my goal in 
posting this question was to find out more about how PHP internals work, esp. 
wrt GC.  Sounds like there really isn't any hope of getting a solid set of 
rules that I can follow, and I have to allow for a little slop.

Good -- that just means I can stop agonizing over this issue and 'deal with 
it'.

>
> > 5) By doing unset($GLOBALS[$varname]) and unset($$varname), where
> > $varname
> > is
> > each key of the $GLOBALS array, I am effectively eliminating all
> > remaining
> > references, and all allocated memory should be reclaimed by the memory
> > manager (except perhaps for memory associated with function and class
> > definitions).
>
> No.
>
> Dangling pointers and references not correctly cleaned up from a
> function are left out in limbo.

This I find VERY odd.  So if I don't unset all references in a function before 
it exits I lose that memory?

>
> > 6) Resources (think databa

[PHP] how to get page count when uploading files

2006-09-16 Thread Jian Fu
I really need help and after going through the help page, I don't know where
I can post my question.

 

When I upload a file (word or pdf), how can I know the page counts of that
file immediately?

 

Thank you, Jian



[PHP] Re: php and session issues continued...

2006-09-16 Thread Tom Atkinson

How are you setting the location?

If the user starts at www.yoursite.com and you redirect to yoursite.com 
after the first form then you'll lose the session since it's a different 
domain.




Dave Goodchild wrote:

Hi all. I have a session issue and wondered if anyone else has encountered
this:

I have an app where a user fills out 3 forms. In each case, after 
validation

and cleaning the form data is passed into session variables and after the
final submission the data is entered into the database. I am using both
Firefox and IE6 on Windows XP and the system works like a dream. However, a
user testing on IE6/XP is having some problems. The values from the first
form are not being passed into the session.

When each form is successfully processed the user is redirected to the next
stage using header('Location...'). I call session_write_close before 
that to

ensure the session data is written out before the redirect, but the problem
persists.

Anyone recognise this issue. It is not IE-specific as it happens to me on
Firefox intermittently. I am at my wits end! Thanks in advance for any 
help!




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Please tell me I dont know regex

2006-09-16 Thread Tom Atkinson

See http://uk.php.net/manual/en/function.eregi.php#57824

Basically you don't need to escape the dash, just place it somewhere 
where it cannot be interpreted as indicating a range. It will then be 
treated literally.


They do work the same using preg_match() which requires escaping.


william(at)elan.net wrote:


Please try below page/program on your system entering "ab-cd" and
please tell me I dont know regex - because the way I see it the
results of those tests should have been the same...

---


Please enter something with a dash here: 
name='regex_test' />



  if (ereg("^[A-Za-z0-9\._\-]{3,63}$",$_REQUEST['regex_test'])) print " 
Ok";

  else print " Nak";
 print "";
 print "Testing ".$_REQUEST['regex_test'].' with regex 
/^[A-Za-z0-9\.\-_]{3,63}$/ ... :';
  if (ereg("^[A-Za-z0-9\.\-_]{3,63}$",$_REQUEST['regex_test'])) print " 
Ok";

  else print " Nak";
}
print "Current PHP Version is: ".phpversion();
?>




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php and session issues continued...

2006-09-16 Thread Dave Goodchild

Hi all. I have a session issue and wondered if anyone else has encountered
this:

I have an app where a user fills out 3 forms. In each case, after validation
and cleaning the form data is passed into session variables and after the
final submission the data is entered into the database. I am using both
Firefox and IE6 on Windows XP and the system works like a dream. However, a
user testing on IE6/XP is having some problems. The values from the first
form are not being passed into the session.

When each form is successfully processed the user is redirected to the next
stage using header('Location...'). I call session_write_close before that to
ensure the session data is written out before the redirect, but the problem
persists.

Anyone recognise this issue. It is not IE-specific as it happens to me on
Firefox intermittently. I am at my wits end! Thanks in advance for any help!

--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk