Re: [PHP] Small LAMP install/distro

2007-06-23 Thread Crayon Shin Chan
On Saturday 23 June 2007 04:29, Tijnema wrote:

> > 3) This is basically the same as point 1, but I think it's still
> > worth making. I don't know about anyone else, but this is 1 of 14
> > lists I subscribe to. Keeping track of what's happening in all
> > current threads in all those lists is not possible, and it helps a
> > great deal if context is built into the messages.
> >
> > In my opinion these are the reasons why top posting is bad etiquette.
> > It devalues the usefulness of the discussion.
> >
> > -Stut
>
> I agree with you on all 3 points stut!
> For point 3, i'm not on 14 lists, but on 4, but it's the same problem
> for me.

Using personal problems to justify things is not going to cut any ice with 
the crowd that persists in top posting, eg TG has already cited his 
personal problems - the use of crappy mail clients, and "him knowing what 
you were talking about without having to read the question.. because he 
knew what was being discussed in this thread". If they're not going to 
listen to common sense and best practices then they're sure not going to 
care about others personal problems. This is the cue for Robert Cummmings 
to jump and proclaim that people are sheep for following best practices.

On Saturday 23 June 2007 02:19, [EMAIL PROTECTED] wrote:
> Bottom posting makes sense if you're using papyrus scrolls.  Or are
> forced into a linear discussion format for some reason.  Email is a
> little more flexible than that.

This is a mailing list, not email. What you do in your personal email is 
your own business. But when using a mailing list, following best 
practices makes things easier for everybody.

-- 
Crayon

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



Re: [PHP] Re: generate an etag header that apache can subsequentlyuse, how?

2007-06-23 Thread M. Sokolewicz

Hi Jochem,

in your post I see:
Last-Modified: Fri, 22 Jun 2007 19:20:30 GMT

and:

-rw-r--r-- 1 apache apache 11924 Jun 22 21:20 foo.jpg

Those two look like they're 2 hours off from eachother! Perhaps Apache 
does some magic on the unix timestamp first?


Just a thought there.
- Tul

Jochem Maas wrote:

hi Tul,

thanks for the feedback ... can I borrow your brain for a little longer? 

M. Sokolewicz wrote:

hey Jochem,
as far as I can see, this should work for you:



this is what I thought - actually I originally used dechex() - which gave the
same output as sprintf("%x", ...) ... which is not surprising.

sidenote: I'm actually only using the modification time in the etag right now.
I figure this keeps it a little faster - there is next to no chance to
that the filemtime will change and the file will be the same and using the inode
info is silly because moving the files locally (for whatever reason) shouldn't 
affect
whether a 304 can be given (imho). the fact that this may result in many files 
with
identical Etags maybe incorrect but I don't see the problem as the URL (and 
therefore
the local file) is going to be different.

BIG BUT: apache is not generating the same hexadecimal value for the filemtime 
of a
given file as I get from the various attempts with php

for a given file I get:

apache Etag : 8e6bbb80
mtime via stat(): 1182540030
mtime via filemtime()   : 1182540030
sprintf("%x") Etag: 467c20fe
dechex() Etag   : 467c20fe

the http headers for the URL of the file in question are:

Date: Fri, 22 Jun 2007 23:00:13 GMT
Server: Apache
Last-Modified: Fri, 22 Jun 2007 19:20:30 GMT
Etag: "8e6bbb80"
Accept-Ranges: bytes
Content-Length: 11924
Content-Type: image/jpeg
X-lori-time-2: 1182553213537

an 'ls -l' on the file in question gives (name of file changed to protect the 
innocent):

-rw-r--r-- 1 apache apache 11924 Jun 22 21:20 foo.jpg

I swear it's the same file but apache is generating the hexadecimal 
representation of the
filemtime differently than a 'straight' dec2hex conversion (ala dechex() and 
sprintf())

doing a hexdec() on the apache generated Etag shows that this is not a question
of mtimes being slightly off (for some reason):

hexdec("8e6bbb80") = 2389425024

I'm stumped, the comments for etag_ulong_to_hex() in the apache source even 
states:

"Generate the human-readable hex representation of an unsigned long
 (basically a faster version of 'sprintf("%lx")')"

I'm rather wary of the 'basically' it smells fishy to me ... rather like saying 
I'm basically
a women - sure there is a resemblance, but bit of investigation will show 
plenty of differences.

I have been checking with static image files (ones that go no where near a 
resampling script)
and the same problem occurs.




my desk is covered in hair :-/

PS - completely offtrack but what's "X-lori-time-2" - I've noticed since not 
long ago,
I have no idea what it is or what purpose it serves, and seemingly nor do the 
search engines.


Assuming your apache is configured to use the inode, modification time
and filesize in its etag.

The function you attached simply converts integers of type long to
hexadecimal strings. It is not the actual function creating the etag
itself.





I'd like to be able to generate an Etag header in php that matches
what Apache generates, I ended up in the apache source code here:

http://svn.apache.org/viewvc/httpd/httpd/branches/2.0.x/modules/http/http_protocol.c?view=markup







static char *etag_ulong_to_hex(char *next, unsigned long u)
{
int printing = 0;
int shift = sizeof(unsigned long) * 8 - 4;
do {
unsigned long next_digit = ((u >> shift) & (unsigned long)0xf);
if (next_digit) {
*next++ = HEX_DIGITS[next_digit];
printing = 1;
}
else if (printing) {
*next++ = HEX_DIGITS[next_digit];
}
shift -= 4;
} while (shift);
*next++ = HEX_DIGITS[u & (unsigned long)0xf];
return next;
}






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



Re: [PHP] generate an etag header that apache can subsequently use, how?

2007-06-23 Thread Richard Heyes

Jochem Maas wrote:


but ... I need more speed ...


Don't we all? Try these:

1. stat() is slow, try not to use it
2. Don't pass images through PHP if at all possible
3. Get Fiddler (www.fiddlertool.com) - It will let you see the HTTP
   response headers. It will show what's actually being requested from
   you server. Typically, images are cached by the user agent , whereas
   PHP files are not.
4. Don't use mod_rewrite if at all possible
5. Recompile Apache with just the modules you need
6. Recompile PHP with just the stuff you need
   NB: You can always recompile later if your needs change
7. Don't use off the shelf components when you don't need to. PEAR::DB
   is one example - I was using this but then mimicked the API saving
   50k of code. Quite significant if you're not using an accelerator.

--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software

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



Re: [PHP] Problems with matrix

2007-06-23 Thread Jochem Maas
Andres Rojas wrote:
> Hi all,
> 
> I'm new in PHP programming and I have a problem with this script. I need
> to read a large file around 2Mb and several lines (28000). All start Ok,
> but suddenly the script stop without message error.

1. check your error log (apache error log probably)
2. check phpinfo() for what your memory limit is
3. how many 'lines' are output before the script dies?

it seems very much like your hitting the set memory limit.
have you tried running the script from the cmdline? (cmdline php does
have a memory limit set by default)

at the *very* least your going to use 4 Megs for the data (2M for the
and 2M for the data your sticking in the $mday (etc) arrays - thats on top
of the base memory overhead and overhead for the underlying variable structures
themselves.

> 
>$fichero="62007lg.txt";
> $buffer = file($fichero);
> $lineas = count($buffer);
> 
>foreach($buffer as $linea){
>   
> list($day, $month, $year, $hour, $min, $temp, $hum, $dew, $baro,
> $wind, $gust, $wdir, $rlastm, $rdai, $rmon, $ryear,
> $heat)=sscanf($linea,"%d %d %d %d %d %f %d %f %f %d %d %d %f %f %f %f %f \n");
> 
>   $mday[]=$day;
>   $mmonth[]=$month;
>   $myear[]=$year; 
>   $mhour[]=$hour;
>   $mmin[]=$min;
>   $mtemp[]=$temp;
>   $mhum[]=$hum;
>   $mdew[]=$dew;
>   $mbaro[]=$baro;
>   $mwind[]=$wind;
>   $mgust[]=$gust;
>   $mwdir[]=$wdir;
>   $mrlastm[]=$rlastm;
>   $mdai[]=$rdai;
>   $mrmon[]=$rmon;
>   $mryear[]=$ryear;
>   $mheat[]=$heat;
>   echo"$day $month $year $hour $min $temp $hum $dew $baro $wind $gust
> $wdir $rlastm $rdai $rmon $ryear $heat ";
>   }
>   
>   ?>
> 
> If only I print the variable $buffer all it's ok, but when I try to fill
> all the matrix the script doesn't work. If I reduce the number of matrix
> only a 3 o 4 it's Ok, but If I increase number of this matrix the script
> crash again.
> 
> Perhaps it's a problem of memory of server, but my  service provider say
> me that this is not the problem.
> 
> 
> Thank you very much
> 

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



Re: [PHP] generate an etag header that apache can subsequently use, how?

2007-06-23 Thread Jochem Maas
Richard Heyes wrote:
> Jochem Maas wrote:
> 
>> but ... I need more speed ...
> 
> Don't we all? Try these:
> 
> 1. stat() is slow, try not to use it

ack.

> 2. Don't pass images through PHP if at all possible

for dynamically, resampled images:
I only do this on the initial request - php generates the image 
after that apache+mod_rewrite spit them out.

> 3. Get Fiddler (www.fiddlertool.com) - It will let you see the HTTP
>response headers. It will show what's actually being requested from
>you server. Typically, images are cached by the user agent , whereas
>PHP files are not.

I've happily used 'tail -f access.log' and the webdeveloper toolbar and firebug
upto now. but I'll look into Fiddler.

> 4. Don't use mod_rewrite if at all possible

I need mod_rewrite.

> 5. Recompile Apache with just the modules you need

this is a tough one - I don't know most of the apache modules, find out
which ones I'm actually using is a time consuming task.

> 6. Recompile PHP with just the stuff you need
>NB: You can always recompile later if your needs change
> 7. Don't use off the shelf components when you don't need to. PEAR::DB
>is one example - I was using this but then mimicked the API saving
>50k of code. Quite significant if you're not using an accelerator.

pretty much everything I run is handmade. the page scripts on the server/sites
in question are outputting at 50-250ms - so that pretty good - it's the tons of
images and other stuff (e.g. google maps api js) that's killing the page load 
time.

I use the latest version of APC (thanks to Greg Beaver for the help on setting
up a 'custom' PEAR install) with 'stat check' turned off.

still leaves me with the Etag weirdness.

> 

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



[PHP] path finder

2007-06-23 Thread elk dolk
  Hi all,
When I test my photo album in my IIS testing server relative path in the 
following code works fine :
echo " ";
but when I upload it to the web server I don’t see my photos, my  /home 
directory on the web server contains
  public_ftp and public_html where my web site is stored I modify the path to 
this :
echo " ";
it doesn’t function  
please comment
  
   
-
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
and lay it on us.

Re: [PHP] path finder

2007-06-23 Thread Tijnema

On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:

 Hi all,
   When I test my photo album in my IIS testing server relative path in the 
following code works fine :
   echo " ";
   but when I upload it to the web server I don't see my photos, my  /home 
directory on the web server contains
 public_ftp and public_html where my web site is stored I modify the path to 
this :
   echo " ";
   it doesn't function
   please comment

/home/. is the path on your filesystem, not the path you should
use in your URL.
The code you used on your IIS testing server should work fine.

Tijnema

--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



[PHP] Re: path finder

2007-06-23 Thread elk dolk

On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
>  Hi all,
>   When I test my photo album in my IIS testing server relative path in the 
> following
>   code works fine :

>echo " height='160'
 border='0' /> ";

>but when I upload it to the web server I don't see my photos, my  /home 
> directory on
>the web server contains

>public_ftp and public_html where my web site is stored I modify the path 
> to this :

>echo "width='120' height='160' border='0' /> ";
>it doesn't function

>please comment
-
 /home/. is the path on your filesystem, not the path you should
use in your URL.
The code you used on your IIS testing server should work fine.
-
no it does not work !



   
-
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
and lay it on us.

Re: [PHP] Re: path finder

2007-06-23 Thread Tijnema

On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:


On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
>  Hi all,
>   When I test my photo album in my IIS testing server relative path in the 
following
>   code works fine :

>echo " ";

>but when I upload it to the web server I don't see my photos, my  /home 
directory on
>the web server contains

>public_ftp and public_html where my web site is stored I modify the path 
to this :

>echo "width='120' height='160' border='0' /> ";
>it doesn't function

>please comment
-
 /home/. is the path on your filesystem, not the path you should
use in your URL.
The code you used on your IIS testing server should work fine.
-
no it does not work !



Hmm, try full URL to the images, like this:
echo " ";

Also, make sure that you can see the photos when going to
http://www.mydomain.com/something/img/the_name_of_a_photo.ext

Tijnema

--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



[PHP] Re: path finder

2007-06-23 Thread elk dolk

On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
>
> On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
> >  Hi all,
> >   When I test my photo album in my IIS testing server relative path in the 
> > following
> >   code works fine :
>
> >echo " > height='160'
> border='0' /> ";
>
> >but when I upload it to the web server I don't see my photos, my  /home 
> > directory
 on
> >the web server contains
>
> >public_ftp and public_html where my web site is stored I modify the path 
> > to this :
>
> >echo " >width='120' height='160' border='0' /> ";
> >it doesn't function
>
> >please comment
> -
>  /home/. is the path on your filesystem, not the path you should
> use in your URL.
> The code you used on your IIS testing server should work fine.
> -
> no it does not work !
>
--
>Hmm, try full URL to the images, like this:
echo " ";

it does not function as well!
--
>Also, make sure that you can see the photos when going to
http://www.mydomain.com/something/img/the_name_of_a_photo.ext

this is O.K. I can see my photos does it tell you something?


 
-
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.

Re: [PHP] Re:path finder

2007-06-23 Thread Tijnema

On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:


> Sorry I have to correct it the above path works :
> img
> > src='http://www.mydomain.com/something/img/{$photoFileName}'
> but I can see some of my photos! and when I right click on them
> I see the properties : url://mydomain/img/26.jpg
> size 2976 bytes
> dim 120x160
>
> when I right click on [X]s I see the url also, only the size is not available!
>

Are you sure the photo is actually there? What happens if you copy the
URL of one of the [X] and place it in your browser? Does it display
you the photo?
And if you refresh, are the same photos missing each time? or is it
different each refresh?
-
Yes the photos are there.If I copy the url to my browser I can see them and
when I refresh the same photos are missing!



Well, seems like a client side problem.. Try different browser, cleaning cache,

Well, this has nothing to do with your PHP code, if you still need
help with this, contact me offlist with the URL of your site.

Tijnema


--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] Re: path finder

2007-06-23 Thread Tijnema

On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:


> > On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
> > >  Hi all,
> > >   When I test my photo album in my IIS testing server relative path in the
 following
> > >   code works fine :
> >
> > >echo " > border='0' /> ";
> >
> > >but when I upload it to the web server I don't see my photos, my  /home
 directory
>  on
> > >the web server contains
> >
> > >public_ftp and public_html where my web site is stored I modify the 
path to this
 :
> >
> > >echo " > >width='120' height='160' border='0' /> ";
> > >it doesn't function
> >
> > >please comment
> > -
> >  /home/. is the path on your filesystem, not the path you should
> > use in your URL.
> > The code you used on your IIS testing server should work fine.
> > -
> > no it does not work !
> >
> --
> >Hmm, try full URL to the images, like this:
> echo " src='http://www.mydomain.com/something/img/{$photoFileName}'
> width='120' height='160' border='0' /> ";
>
> it does not function as well!

>So, when you go to the page with this code, you see one of more [X]
right? What do you see when you right click on one of them and click
properties?
>Do you see the url to the image? or are there some kind of weird
tokens in the URL?
--
Sorry I have to correct it the above path works :
img
> src='http://www.mydomain.com/something/img/{$photoFileName}'
but I can see some of my photos! and when I right click on them
I see the properties : url://mydomain/img/26.jpg
size 2976 bytes
dim 120x160

when I right click on [X]s I see the url also, only the size is not available!



Are you sure the photo is actually there? What happens if you copy the
URL of one of the [X] and place it in your browser? Does it display
you the photo?
And if you refresh, are the same photos missing each time? or is it
different each refresh?

Tijnema

--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] Re: path finder

2007-06-23 Thread Tijnema

On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:


On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
>
> On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
> >  Hi all,
> >   When I test my photo album in my IIS testing server relative path in the 
following
> >   code works fine :
>
> >echo " border='0' /> ";
>
> >but when I upload it to the web server I don't see my photos, my  /home 
directory
 on
> >the web server contains
>
> >public_ftp and public_html where my web site is stored I modify the path 
to this :
>
> >echo " >width='120' height='160' border='0' /> ";
> >it doesn't function
>
> >please comment
> -
>  /home/. is the path on your filesystem, not the path you should
> use in your URL.
> The code you used on your IIS testing server should work fine.
> -
> no it does not work !
>
--
>Hmm, try full URL to the images, like this:
echo " ";

it does not function as well!


So, when you go to the page with this code, you see one of more [X]
right? What do you see when you right click on one of them and click
properties?
Do you see the url to the image? or are there some kind of weird
tokens in the URL?


--
>Also, make sure that you can see the photos when going to
http://www.mydomain.com/something/img/the_name_of_a_photo.ext

this is O.K. I can see my photos does it tell you something?


Yes, I know that you're images are at the correct place and that they
are viewable from outside.

Tijnema

--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

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



Re: [PHP] Re: generate an etag header that apache can subsequentlyuse, how?

2007-06-23 Thread Jochem Maas
M. Sokolewicz wrote:
> Hi Jochem,
> 
> in your post I see:
> Last-Modified: Fri, 22 Jun 2007 19:20:30 GMT
> 
> and:
> 
> -rw-r--r-- 1 apache apache 11924 Jun 22 21:20 foo.jpg
> 
> Those two look like they're 2 hours off from eachother! Perhaps Apache
> does some magic on the unix timestamp first?

I noticed it too - I tested Etag generation with filemtime - 2 hours and
that didn't give me anything near the result apache is generating (neither
did '+ 2 hours' btw :-).

additionally I checked with the values for FileSize and Inode and php is giving
identical values for those.

the filemtime differences must be due simply to timezone differences -
if I run the value of the Last-Modified header for any given image file through
strtotime() (on the server in question) I get the exact same integer as I do 
when
I run filemtime() on the image file in question.

what the frak is apache using for the file modification time?

> 
> Just a thought there.
> - Tul
> 
> Jochem Maas wrote:
>> hi Tul,
>>
>> thanks for the feedback ... can I borrow your brain for a little
>> longer? 
>>
>> M. Sokolewicz wrote:
>>> hey Jochem,
>>> as far as I can see, this should work for you:
>>> >> $stats = stat('/dev/shm/file');
>>> $etag = sprintf('"%x-%x-%x"', $stats['ino'], $stats['size'],
>>> $stats['mtime']); // lowercase hexadecimal numbers separated by dashes
>>> header('Etag: '.$etag);
>>> ?>
>>
>> this is what I thought - actually I originally used dechex() - which
>> gave the
>> same output as sprintf("%x", ...) ... which is not surprising.
>>
>> sidenote: I'm actually only using the modification time in the etag
>> right now.
>> I figure this keeps it a little faster - there is next to no chance to
>> that the filemtime will change and the file will be the same and using
>> the inode
>> info is silly because moving the files locally (for whatever reason)
>> shouldn't affect
>> whether a 304 can be given (imho). the fact that this may result in
>> many files with
>> identical Etags maybe incorrect but I don't see the problem as the URL
>> (and therefore
>> the local file) is going to be different.
>>
>> BIG BUT: apache is not generating the same hexadecimal value for the
>> filemtime of a
>> given file as I get from the various attempts with php
>>
>> for a given file I get:
>>
>> apache Etag: 8e6bbb80
>> mtime via stat() : 1182540030
>> mtime via filemtime(): 1182540030
>> sprintf("%x") Etag: 467c20fe
>> dechex() Etag: 467c20fe
>>
>> the http headers for the URL of the file in question are:
>>
>> Date: Fri, 22 Jun 2007 23:00:13 GMT
>> Server: Apache
>> Last-Modified: Fri, 22 Jun 2007 19:20:30 GMT
>> Etag: "8e6bbb80"
>> Accept-Ranges: bytes
>> Content-Length: 11924
>> Content-Type: image/jpeg
>> X-lori-time-2: 1182553213537
>>
>> an 'ls -l' on the file in question gives (name of file changed to
>> protect the innocent):
>>
>> -rw-r--r-- 1 apache apache 11924 Jun 22 21:20 foo.jpg
>>
>> I swear it's the same file but apache is generating the hexadecimal
>> representation of the
>> filemtime differently than a 'straight' dec2hex conversion (ala
>> dechex() and sprintf())
>>
>> doing a hexdec() on the apache generated Etag shows that this is not a
>> question
>> of mtimes being slightly off (for some reason):
>>
>> hexdec("8e6bbb80") = 2389425024
>>
>> I'm stumped, the comments for etag_ulong_to_hex() in the apache source
>> even states:
>>
>> "Generate the human-readable hex representation of an unsigned long
>>  (basically a faster version of 'sprintf("%lx")')"
>>
>> I'm rather wary of the 'basically' it smells fishy to me ... rather
>> like saying I'm basically
>> a women - sure there is a resemblance, but bit of investigation will
>> show plenty of differences.
>>
>> I have been checking with static image files (ones that go no where
>> near a resampling script)
>> and the same problem occurs.
>>
>>
>>
>>
>> my desk is covered in hair :-/
>>
>> PS - completely offtrack but what's "X-lori-time-2" - I've noticed
>> since not long ago,
>> I have no idea what it is or what purpose it serves, and seemingly nor
>> do the search engines.
>>
>>> Assuming your apache is configured to use the inode, modification time
>>> and filesize in its etag.
>>>
>>> The function you attached simply converts integers of type long to
>>> hexadecimal strings. It is not the actual function creating the etag
>>> itself.
>>
>> 
>>
 I'd like to be able to generate an Etag header in php that matches
 what Apache generates, I ended up in the apache source code here:

 http://svn.apache.org/viewvc/httpd/httpd/branches/2.0.x/modules/http/http_protocol.c?view=markup



>>
>> 
>>
 static char *etag_ulong_to_hex(char *next, unsigned long u)
 {
 int printing = 0;
 int shift = sizeof(unsigned long) * 8 - 4;
 do {
 unsigned long next_digit = ((u >> shift) & (unsigned long)0xf);
 if (next_digit) {
 *next++ = HEX_DIGITS[next

[PHP] Re: path finder

2007-06-23 Thread elk dolk

> > On 6/23/07, elk dolk <[EMAIL PROTECTED]> wrote:
> > >  Hi all,
> > >   When I test my photo album in my IIS testing server relative path in the
 following
> > >   code works fine :
> >
> > >echo " > border='0' /> ";
> >
> > >but when I upload it to the web server I don't see my photos, my  /home
 directory
>  on
> > >the web server contains
> >
> > >public_ftp and public_html where my web site is stored I modify the 
> > > path to this
 :
> >
> > >echo " > > src='/home/public_html/img/{$photoFileName}'
> > >width='120' height='160' border='0' /> ";
> > >it doesn't function
> >
> > >please comment
> > -
> >  /home/. is the path on your filesystem, not the path you should
> > use in your URL.
> > The code you used on your IIS testing server should work fine.
> > -
> > no it does not work !
> >
> --
> >Hmm, try full URL to the images, like this:
> echo " src='http://www.mydomain.com/something/img/{$photoFileName}'
> width='120' height='160' border='0' /> ";
>
> it does not function as well!

>So, when you go to the page with this code, you see one of more [X]
right? What do you see when you right click on one of them and click
properties?
>Do you see the url to the image? or are there some kind of weird
tokens in the URL?
--
Sorry I have to correct it the above path works :
img
> src='http://www.mydomain.com/something/img/{$photoFileName}' 
but I can see some of my photos! and when I right click on them 
I see the properties : url://mydomain/img/26.jpg
size 2976 bytes
dim 120x160

when I right click on [X]s I see the url also, only the size is not available!  

> --
> >Also, make sure that you can see the photos when going to
> http://www.mydomain.com/something/img/the_name_of_a_photo.ext
>
> this is O.K. I can see my photos does it tell you something?

>Yes, I know that you're images are at the correct place and that they
are viewable from outside.

   
-
Need a vacation? Get great deals to amazing places on Yahoo! Travel. 

[PHP] Re:path finder

2007-06-23 Thread elk dolk

> Sorry I have to correct it the above path works :
> img
> > src='http://www.mydomain.com/something/img/{$photoFileName}'
> but I can see some of my photos! and when I right click on them
> I see the properties : url://mydomain/img/26.jpg
> size 2976 bytes
> dim 120x160
>
> when I right click on [X]s I see the url also, only the size is not available!
>

Are you sure the photo is actually there? What happens if you copy the
URL of one of the [X] and place it in your browser? Does it display
you the photo?
And if you refresh, are the same photos missing each time? or is it
different each refresh?
-
Yes the photos are there.If I copy the url to my browser I can see them and
when I refresh the same photos are missing!



   
-
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out. 

Re: [PHP] foreach() using current() strange beahvior

2007-06-23 Thread Nathan Nobbe

Julien,

i reproduced your experiment and got a different result on the first one.  i
found that the internal pointer does not seem to be affected if there is a
check on the index of the internal pointer during iteration, but if there is
no check on the index during iteration the
pointer seems to get incremented.  needless to say this is rather strange. *
*also *turadg at berkeley dot edu* describes his experience w/ this issue on
the foreach 
documentationin
the user comments section.  he found that by aliasing the original
array
variable the behavior described in the documentation is realized.
i have summarized these findings in the following code segment, which you
can run yourself as well for corroboration

 $v) {
if(current($a) != false) {
echo current($a) . PHP_EOL;
} else {
var_dump(current($a));
}
}
/// check the internal pointer after iteration is complete (should be
pointing at last index)
if(current($a) != false) { // strangely this is still the first index of the
array
echo current($a) . PHP_EOL;
} else {
var_dump(current($a));
}

echo 'experiment 1b.' . PHP_EOL;
/// another run through the array where there is no check on the value of
the internal pointer during each iteration
foreach($a as $k => $v) {}
/// check the internal pointer after iteration this time
if(current($a) != false) { // and now the pointer is the last index of the
array (as expected)
echo current($a) . PHP_EOL;
} else {
var_dump(current($a));
}

echo 'experiment 2a.' . PHP_EOL;
 ALIAS THE ORIGINAL ARRAY VARIABLE
$a2 =& $a; // create an alias of $a for further experimentation
foreach($a as $k => $v) { // first experiment
if(current($a) != false) { // now the internal index is being incremented
echo current($a) . PHP_EOL;
} else {
var_dump(current($a));
}
}

if(current($a) != false) { // and here the internal pointer is the last
index
echo current($a) . PHP_EOL;
} else {
var_dump(current($a));
}

echo 'experiment 2b.' . PHP_EOL;
/// second experiment (no checking of the index during iteration)
foreach($a as $k => $v) {}
if(current($a) != false) { // and the internal pointer is the last index
echo current($a) . PHP_EOL;
} else {
var_dump(current($a));
}
?>

/// this is the output on my machine
experiment 1a.
one
one
one
one
experiment 1b.
bool(false)
experiment 2a.
two
three
bool(false)
bool(false)
experiment 2b.
bool(false)

in summary, COW or not; i think the documentation could be revised a bit to
clarify these subtleties.

-nathan


On 6/23/07, Julien Pauli <[EMAIL PROTECTED]> wrote:


Please consider this code :

$v) {
}

var_dump(current($a));
// outputs boll(false);

that's expected as foreach moves the internal array pointer, it's
documented.

now consider this :

$v) {
current($a);
}

var_dump(current($a));
// outputs string("One");

When using the internal pointer just by calling current() (so not moving
it), the output of the foreach loop has changed ...
Can someone explain that ?

regards.



Re: [PHP] foreach() using current() strange beahvior

2007-06-23 Thread Robert Cummings
On Sat, 2007-06-23 at 19:15 +0200, Julien Pauli wrote:
> Please consider this code :
> 
>  $a = array("One","Two","Three");
> 
> foreach ($a AS $k=>$v) {
> }
> 
> var_dump(current($a));
> // outputs boll(false);
> 
> that's expected as foreach moves the internal array pointer, it's
> documented.
> 
> now consider this :
> 
>  $a = array("One","Two","Three");
> 
> foreach ($a AS $k=>$v) {
> current($a);
> }
> 
> var_dump(current($a));
> // outputs string("One");
> 
> When using the internal pointer just by calling current() (so not moving
> it), the output of the foreach loop has changed ...
> Can someone explain that ?

The answers lies in the following although it's not terribly clear why
the behaviour is as it is:


Note: Unless the array is referenced, foreach operates on a copy of the
specified array and not the array itself. Therefore, the array pointer
is not modified as with the each() construct, and changes to the array
element returned are not reflected in the original array. However, the
internal pointer of the original array is advanced with the processing
of the array. Assuming the foreach loop runs to completion, the array's
internal pointer will be at the end of the array.


If you understand how PHP copies values then it makes sense. Let me
explain... When the foreach loop is entered $a is copied for use by the
foreach itrator; however, a copy in PHP is a lazy copy. This means that
the the copy is still referencing the original value, and this is why
the internal pointer is still advanced.

Now what probably happens is that when the current() function is used on
$a something internally tells the PHP engine that a modification has
occurred, as such the COW (copy on write) policy comes into effect. This
essentially differentiates a copy since a change is occurring such that
there is now a real and distinct copy. So internally $a had the internal
pointer reset on entry to the foreach loop, current() somehow invokes
the COW policy causing a real copy to be generated, and then the foreach
continues merrily forward with the real copy leaving current() to work
with the original copy. Hope that make sense to you :)

For what it's worth, COW is why if you have a variable consuming 100
megabytes stored in $x and you assign it to $y that you don't end up
consuming 200 megs of memory. Now if $x is a string and you change
append one character to $y, you should find that now you are consuming
200 megs of memory since a real copy is generated when the change is
incurred. This is an optimization strategy.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] foreach() using current() strange beahvior

2007-06-23 Thread Robert Cummings
On Sat, 2007-06-23 at 15:15 -0400, Nathan Nobbe wrote:
>
> in summary, COW or not; i think the documentation could be revised a bit to
> clarify these subtleties.

Regardless of additional documentation or not, I think it's rather poor
choice of programming style to mix the foreach construct with the older,
lower level, internal array manipulation and probing functions. I think
that is what should be documented since you just might get weird
results :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] foreach() using current() strange beahvior

2007-06-23 Thread Julien Pauli

Please consider this code :

$v) {
}

var_dump(current($a));
// outputs boll(false);

that's expected as foreach moves the internal array pointer, it's
documented.

now consider this :

$v) {
current($a);
}

var_dump(current($a));
// outputs string("One");

When using the internal pointer just by calling current() (so not moving
it), the output of the foreach loop has changed ...
Can someone explain that ?

regards.


Re: [PHP] foreach() using current() strange beahvior

2007-06-23 Thread Nathan Nobbe

On 6/23/07, Robert Cummings <[EMAIL PROTECTED]> wrote:
Regardless of additional documentation or not, I think it's rather poor
choice of programming style to mix the foreach construct with the older,
lower level, internal array manipulation and probing functions. I think
that is what should be documented since you just might get weird
results :)


i agree; at least i have never had a need to determine the current index of
the internal array pointer in nearly 3 years working w/ php.
although it is somewhat interesting to experiment w/ the language to see how
it behaves :)

-nathan


On 6/23/07, Robert Cummings <[EMAIL PROTECTED]> wrote:


On Sat, 2007-06-23 at 15:15 -0400, Nathan Nobbe wrote:
>
> in summary, COW or not; i think the documentation could be revised a bit
to
> clarify these subtleties.

Regardless of additional documentation or not, I think it's rather poor
choice of programming style to mix the foreach construct with the older,
lower level, internal array manipulation and probing functions. I think
that is what should be documented since you just might get weird
results :)

Cheers,
Rob.
--
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'




[PHP] Convert Date time into Seconds

2007-06-23 Thread kvigor
Good Day,

I'm chech if 24hrs has passed between these 2 datetimes:

$dTime1 = 2007-06-21 11:08:09;

$dTime2 = 2007-06-22 07:08:09;

I'd really like to convert the datetimes above into a format I can do 
regular math them.

Browsing around I've found the following code.  But both weren't clear on 
what to pass to them.  Because when I pass a datetime var to them and echo 
the value I get no output please help.
==
function datetime_to_epoch($date)
{
  $break = explode(" ", $date);
  $datebreak = explode("-", $break[0]);
  $time = explode(":", $break[1]);
  $epoch = date("U", 
mktime($time[0],$time[1],$time[2],$datebreak[1],$datebreak[2],$datebreak[0]));
  $datetime = date("Y-m-d H:i:s", 
mktime($time[0],$time[1],$time[2],$datebreak[1],$datebreak[2],$datebreak[0]));
}
?>
===
function convert_datetime($varStamp) {

list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);

$timestamp = mktime($hour, $minute, $second, $month, $day, $year);

return $timestamp;
}

//If anyone could elaborate, would be appreciated.

 

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



Re: [PHP] Convert Date time into Seconds

2007-06-23 Thread Robert Cummings
On Sat, 2007-06-23 at 21:29 -0500, kvigor wrote:
> Good Day,
> 
> I'm chech if 24hrs has passed between these 2 datetimes:
> 
> $dTime1 = 2007-06-21 11:08:09;
> 
> $dTime2 = 2007-06-22 07:08:09;
> 
> I'd really like to convert the datetimes above into a format I can do 
> regular math them.



$foo contains a unix timestamp (the time in seconds since the Epoch).

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Convert Date time into Seconds

2007-06-23 Thread kvigor
Cool,

Like Ambien, It worked like a dream.


"Robert Cummings" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Sat, 2007-06-23 at 21:29 -0500, kvigor wrote:
>> Good Day,
>>
>> I'm chech if 24hrs has passed between these 2 datetimes:
>>
>> $dTime1 = 2007-06-21 11:08:09;
>>
>> $dTime2 = 2007-06-22 07:08:09;
>>
>> I'd really like to convert the datetimes above into a format I can do
>> regular math them.
>
> 
> echo ($foo = strtotime( '2007-06-21 11:08:09' ))."\n";
> echo date( 'Y/m/d H:i:s', $foo )."\n";
>
> ?>
>
> $foo contains a unix timestamp (the time in seconds since the Epoch).
>
> Cheers,
> Rob.
> -- 
> ..
> | InterJinn Application Framework - http://www.interjinn.com |
> ::
> | An application and templating framework for PHP. Boasting  |
> | a powerful, scalable system for accessing system services  |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for   |
> | creating re-usable components quickly and easily.  |
> `' 

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



[PHP] Hi. I need your help here

2007-06-23 Thread J S
Hi. I came across your contact info at php.zend.com and was hoping you could 
help me out with this question.
  I recently installed Rubberwall10, a free software that protects from 
hotlinking and although I managed to installed the software correctly at my 
site, I came across the fact that when I tried to download an image from the 
site to my computer, the image came out with 0 kbs.
   
  Someone who also installed the software made a comment on the internet 
stating he solved the problem adding a trim function to three of the variables 
in the filescrapper.php file. 
   
  My question to you is, how can I do that. I am not familiar with php, 
although I have understood some minimal basics. Adding trim function to $ct, 
$webaddress and $wantedfilename seemed to have solved the problem according to 
the user who solved the problem but did not specify how he did it. Can you tell 
me how I can add trim function to the above three variables?. Your help is 
greatly appreciated. The code is below. Thanks. John
  /***
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***/
$allowed = 0;
include('config.php');
  if($allowblank > 0) { if($_SERVER['HTTP_REFERER']=="") { $allowed = 1; }}
  $domains = count($alloweddomains);
  for($y=0;$y<$domains+1;$y++) {
 if((stristr($_SERVER['HTTP_REFERER'], $alloweddomains[$y]))) { $allowed = 1;}
}
  if($allowed > 0) {
  $namenumberarray = file($webaddress."fileindex.txt");
  $numberoffiles = count($namenumberarray);
  $filenames = array();
  
  for($x=0;$x<$numberoffiles+1;$x++) {
   $temporary = explode(":",$namenumberarray[$x]);
   $tempname = explode("\n",$temporary[1]);
   $filenames[$temporary[0]] = $tempname[0];
  }
  
  if(!isset($filenames[$_GET['serve']])) { 
   if($logging > 0){
$status = "ReqNF";
include('logit.php');
   }
   echo('That number wasnt found!');
   exit;
  }
  
  $wantedfilename = $filenames[$_GET['serve']];
  
  
  $extension = explode(".", $wantedfilename);
  $numberinarray = count($extension);
  
  $lcext = strtolower($extension[$numberinarray-1]);
  
  //BEGIN CONTENT TYPES BLOCK. ADD OR REMOVE FILE TYPES HERE, AS SHOWN //
  //DON'T EDIT THIS UNLESS YOU KNOW WHAT YOU ARE DOING!//
  //MOST COMMON FILE TYPES ARE ALREADY INCLUDED//
  
  switch($lcext) {
   case ($lcext == "swf"): 
$commonname="flash"; 
$ct = "Content-type: application/x-shockwave-flash";
   break;
   case ($lcext == "wmv"): 
$commonname="wmv"; 
$ct = "Content-type: video/x-ms-wmv";
   break;
   case ($lcext == "mov"): 
$commonname="quicktime movie"; 
$ct = "Content-type: video/quicktime";
   break;
   case ($lcext == "avi"): 
$commonname="avi video"; 
$ct = "Content-type: video/avi";
   break;
   case ($lcext == "rar"): 
$commonname="winrar"; 
$ct = "Content-type: application/octet-stream";
   break;
   case ($lcext == "zip"): 
$commonname="zip"; 
$ct = "Content-type: application/octet-stream";
   break;
   case ($lcext == "bmp"): 
$commonname="bitmap"; 
$ct = "Content-type: image/bmp";
   break;
   case ($lcext == "gif"): 
$commonname="gif"; 
$ct = "Content-type: image/gif";
   break;
   case ($lcext == "jpeg" || $lcext == "jpg" || $lcext == "jpe"): 
$commonname="jpeg"; 
$ct = "Content-type: image/jpeg";
   break;
   case ($lcext == "mpeg" || $lcext == "mpg" || $lcext == "mpe"): 
$commonname="mpeg"; 
$ct = "Content-type: video/mpeg";
   break;
   case ($lcext == "png"): 
$commonname="png"; 
$ct = "Content-type: image/png";
   break;
   
   //END//
   
   default: 
$commonname="Generic Filetype"; 
$ct = "Content-type: application/octet-stream";

if($logging > 0){
 $status = "Generic_Filetype";
 include('logit.php');
}
   
  }
  
  $handle = fopen($webaddress.$wantedfilename, "rb");
  header("Cache-Control: "); //keeps ie happy
  header("Pragma: "); //keeps ie happy
  header($ct); //content type as set above from explode();
  
  if(!stristr($lcext, "swf")){//flash plays, it isnt downloaded as an 
actual file.
   header("Content-Disposition: attachment; 
filename=\"".$wantedfilename."\"");
  }
  
  header("Content-Length: ".filesize($path.$wantedfilename));
  
  fpassthru($handle);
  if($lo

[PHP] Setting Different Temp Directory for Different Application Users

2007-06-23 Thread zareef

Hi All,


I want to set different temp directory to every users of my  
application. Is it possible. TEMP_DIR is only configurable at system  
level, so I can do it only in PHP.INI or in apache as PHP_VALUE.


Any Idea how this can be achieved using combination of things?

Thanks in Advance.

Zareef Ahmed

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