php-general Digest 18 Aug 2007 22:33:48 -0000 Issue 4969
Topics (messages 260991 through 261004):
Re: Cookies and sent headers
260991 by: Wouter van Vliet / Interpotential
260993 by: Bastien Koert
260994 by: Otto Wyss
260995 by: Bastien Koert
260996 by: M. Sokolewicz
260997 by: Sanjeev N
261004 by: M. Sokolewicz
Re: html to jpeg conversion.
260992 by: Al
260999 by: brian
Re: About Session And Cookies
260998 by: Sanjeev N
Photo upload framework/library for PHP
261000 by: Steve Finkelstein
261003 by: Wouter van Vliet / Interpotential
Capturing shell command output.
261001 by: shiplu
261002 by: Wouter van Vliet / Interpotential
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
You best option would be to go through all of your include'd or require'd
files and make sure there is no whitespace before and after you open your
php tags. Those are often the cause for such problems. The easy way would
indeed be to use output buffering. In that case, put the call to ob_start();
on the first line of the file you're calling. You will still have to make
sure to not have any whitespace before your <?php opening.
To even bypass that, the output_buffering ini setting might be useful. Alter
it in your php.ini if you can, otherwise try your apache vhost configuration
or .htaccess. The syntax there is:
php_flag output_buffering On
Good luck!
On 18/08/07, Kelvin Park <[EMAIL PROTECTED]> wrote:
>
> Kelvin Park wrote:
> > Otto Wyss wrote:
> >> If built a simple login page and store any information within
> >> $_SESSION's. Yet I'd like to move these into cookies but I always get
> >> an error about sent headers. Is there a way to circumvent this
> >> problem without changing too much in the page?
> >>
> >> The setting of the cookies happens just at the end of the page.
> >>
> >> if (!$errortext and $Anmelden) {
> >> if (!empty($Permanent)) {
> >> $expires = time()+ 365 * 86400; // 365 days
> >> setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires);
> >> setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires);
> >> setcookie ("l.Email1", $_SESSION['l_Email1'], $expires);
> >> setcookie ("l.Email2", $_SESSION['l_Email2'], $expires);
> >> }
> >> echo "<script type=\"text/javascript\">
> >> parent.location.replace('$index_php";
> >> </script>";
> >> exit;
> >> }
> >>
> >> O. Wyss
> >>
> > ob_start() might help
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Interpotential.com
Phone: +31615397471
--- End Message ---
--- Begin Message ---
sessions and cookies either need to be set at the beginning of the page, or you
can look into the ob_start(), ob_flush() functions to use output buffering
bastien
----------------------------------------
> To: [EMAIL PROTECTED]
> Date: Sat, 18 Aug 2007 11:25:54 +0200
> From: [EMAIL PROTECTED]
> Subject: [PHP] Cookies and sent headers
>
> If built a simple login page and store any information within
> $_SESSION's. Yet I'd like to move these into cookies but I always get an
> error about sent headers. Is there a way to circumvent this problem
> without changing too much in the page?
>
> The setting of the cookies happens just at the end of the page.
>
> if (!$errortext and $Anmelden) {
> if (!empty($Permanent)) {
> $expires = time()+ 365 * 86400; // 365 days
> setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires);
> setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires);
> setcookie ("l.Email1", $_SESSION['l_Email1'], $expires);
> setcookie ("l.Email2", $_SESSION['l_Email2'], $expires);
> }
> echo "";
> exit;
> }
>
> O. Wyss
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
--- End Message ---
--- Begin Message ---
ob_start() at the beginning and ob_end_flush() at the end of the PHP
section seems to do the trick albeit I've still problems to understand
why. The description in the manual is rather sparse unfortunately. Is
there any more information about what's going on?
O. Wyss
Wouter van Vliet / Interpotential wrote:
You best option would be to go through all of your include'd or require'd
files and make sure there is no whitespace before and after you open your
php tags. Those are often the cause for such problems. The easy way would
indeed be to use output buffering. In that case, put the call to ob_start();
on the first line of the file you're calling. You will still have to make
sure to not have any whitespace before your <?php opening.
To even bypass that, the output_buffering ini setting might be useful. Alter
it in your php.ini if you can, otherwise try your apache vhost configuration
or .htaccess. The syntax there is:
php_flag output_buffering On
Good luck!
On 18/08/07, Kelvin Park <[EMAIL PROTECTED]> wrote:
Kelvin Park wrote:
Otto Wyss wrote:
If built a simple login page and store any information within
$_SESSION's. Yet I'd like to move these into cookies but I always get
an error about sent headers. Is there a way to circumvent this
problem without changing too much in the page?
The setting of the cookies happens just at the end of the page.
if (!$errortext and $Anmelden) {
if (!empty($Permanent)) {
$expires = time()+ 365 * 86400; // 365 days
setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires);
setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires);
setcookie ("l.Email1", $_SESSION['l_Email1'], $expires);
setcookie ("l.Email2", $_SESSION['l_Email2'], $expires);
}
echo "<script type=\"text/javascript\">
parent.location.replace('$index_php";
</script>";
exit;
}
O. Wyss
ob_start() might help
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
The commands start and use an output buffer, a chunk of memory that stores all
the output on the server until the ob_flush, the buffer flush, function is
called. You need to be aware that in high load situations this may adversly
affect performance since it loads the servers memory, also be aware that you
may hit a memory limit for large pages. This is server / OS depandant so you
may want to read up on server documentation
bastien
----------------------------------------
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Date: Sat, 18 Aug 2007 16:39:29 +0200
> From: [EMAIL PROTECTED]
> CC: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] Cookies and sent headers
>
> ob_start() at the beginning and ob_end_flush() at the end of the PHP
> section seems to do the trick albeit I've still problems to understand
> why. The description in the manual is rather sparse unfortunately. Is
> there any more information about what's going on?
>
> O. Wyss
>
> Wouter van Vliet / Interpotential wrote:
> > You best option would be to go through all of your include'd or require'd
> > files and make sure there is no whitespace before and after you open your
> > php tags. Those are often the cause for such problems. The easy way would
> > indeed be to use output buffering. In that case, put the call to ob_start();
> > on the first line of the file you're calling. You will still have to make
> > sure to not have any whitespace before your >
> > To even bypass that, the output_buffering ini setting might be useful. Alter
> > it in your php.ini if you can, otherwise try your apache vhost configuration
> > or .htaccess. The syntax there is:
> >
> > php_flag output_buffering On
> >
> > Good luck!
> >
> > On 18/08/07, Kelvin Park wrote:
> >> Kelvin Park wrote:
> >>> Otto Wyss wrote:
> >>>> If built a simple login page and store any information within
> >>>> $_SESSION's. Yet I'd like to move these into cookies but I always get
> >>>> an error about sent headers. Is there a way to circumvent this
> >>>> problem without changing too much in the page?
> >>>>
> >>>> The setting of the cookies happens just at the end of the page.
> >>>>
> >>>> if (!$errortext and $Anmelden) {
> >>>> if (!empty($Permanent)) {
> >>>> $expires = time()+ 365 * 86400; // 365 days
> >>>> setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires);
> >>>> setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires);
> >>>> setcookie ("l.Email1", $_SESSION['l_Email1'], $expires);
> >>>> setcookie ("l.Email2", $_SESSION['l_Email2'], $expires);
> >>>> }
> >>>> echo "";
> >>>> exit;
> >>>> }
> >>>>
> >>>> O. Wyss
> >>>>
> >>> ob_start() might help
> >>>
> >> --
> >> 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
>
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
--- End Message ---
--- Begin Message ---
On a sidenote, 99% of the world never calls ob_flush (or any such
function) since PHP flushes the buffer automatically at the end of its
execution.
The reason why setting cookies for you doesn't work is because of the
way a HTTP response is structured. It consists of 2 parts: header and
body separated by 2 new lines (\n\n). It is _required_ that _all_
headers come _before_ the body. Cookies are actually headers (a
set-cookie: [...] header) aswell as any headers set via php's header()
function. Any output made by the script (be it a single whitespace, a
bunch of text, etc.) will automatically flush the headers, followed by
the separator (\n\n) followed by the specified output. After that has
been sent, everything outputted will be dumped into the body of the
response (simply because you can't "go back" to the headers which were
already sent earlier), so you can't set cookies (which are headers
themselves).
So, why does output buffering help here? Simply put, instead of dumping
headers and any other output directly to the client, PHP buffers it all
into memory. As such, since it hasn't been sent yet, PHP can still
alter/add headers even though it also has body-output. Once it receives
the command, PHP will send all headers, the separator and the output to
the client. This is done when PHP encounters an ob_flush or ob_end_flush
call, _and_ when the script has finished execution automatically.
The documentation seems pretty clear to me, however, if you feel it
should be clarified better, feel free to send a patch to the
[EMAIL PROTECTED] list.
- Tul
Bastien Koert wrote:
The commands start and use an output buffer, a chunk of memory that stores all
the output on the server until the ob_flush, the buffer flush, function is
called. You need to be aware that in high load situations this may adversly
affect performance since it loads the servers memory, also be aware that you
may hit a memory limit for large pages. This is server / OS depandant so you
may want to read up on server documentation
bastien
----------------------------------------
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Date: Sat, 18 Aug 2007 16:39:29 +0200
From: [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] Cookies and sent headers
ob_start() at the beginning and ob_end_flush() at the end of the PHP
section seems to do the trick albeit I've still problems to understand
why. The description in the manual is rather sparse unfortunately. Is
there any more information about what's going on?
O. Wyss
Wouter van Vliet / Interpotential wrote:
You best option would be to go through all of your include'd or require'd
files and make sure there is no whitespace before and after you open your
php tags. Those are often the cause for such problems. The easy way would
indeed be to use output buffering. In that case, put the call to ob_start();
on the first line of the file you're calling. You will still have to make
sure to not have any whitespace before your >
To even bypass that, the output_buffering ini setting might be useful. Alter
it in your php.ini if you can, otherwise try your apache vhost configuration
or .htaccess. The syntax there is:
php_flag output_buffering On
Good luck!
On 18/08/07, Kelvin Park wrote:
Kelvin Park wrote:
Otto Wyss wrote:
If built a simple login page and store any information within
$_SESSION's. Yet I'd like to move these into cookies but I always get
an error about sent headers. Is there a way to circumvent this
problem without changing too much in the page?
The setting of the cookies happens just at the end of the page.
if (!$errortext and $Anmelden) {
if (!empty($Permanent)) {
$expires = time()+ 365 * 86400; // 365 days
setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires);
setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires);
setcookie ("l.Email1", $_SESSION['l_Email1'], $expires);
setcookie ("l.Email2", $_SESSION['l_Email2'], $expires);
}
echo "";
exit;
}
O. Wyss
ob_start() might help
--
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
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
--- End Message ---
--- Begin Message ---
Hi,
Its not the problem of cookies. Its problem of redirection or the
parent.location.replace function. I mean if you already output something on
the page and tries to redirect then this problem happens.
Redirect before outputting anything on the page.. like space is also an
output.
Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan
-----Original Message-----
From: Otto Wyss [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 18, 2007 2:56 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Cookies and sent headers
If built a simple login page and store any information within
$_SESSION's. Yet I'd like to move these into cookies but I always get an
error about sent headers. Is there a way to circumvent this problem
without changing too much in the page?
The setting of the cookies happens just at the end of the page.
if (!$errortext and $Anmelden) {
if (!empty($Permanent)) {
$expires = time()+ 365 * 86400; // 365 days
setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires);
setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires);
setcookie ("l.Email1", $_SESSION['l_Email1'], $expires);
setcookie ("l.Email2", $_SESSION['l_Email2'], $expires);
}
echo "<script type=\"text/javascript\">
parent.location.replace('$index_php";
</script>";
exit;
}
O. Wyss
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
bullshit,
what he sees is a warning emitted by PHP, his redirect is done using
JavaScript (which is clientside and has no, 0.0 effect on what PHP
emits). Now, I'm not going to go into how redirecting that way won't
work (or at least shouldn't), but a hint would be to do it properly
using header('Location: [...]') instead.
- Tul
Sanjeev N wrote:
Hi,
Its not the problem of cookies. Its problem of redirection or the
parent.location.replace function. I mean if you already output something on
the page and tries to redirect then this problem happens.
Redirect before outputting anything on the page.. like space is also an
output.
Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan
-----Original Message-----
From: Otto Wyss [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 18, 2007 2:56 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Cookies and sent headers
If built a simple login page and store any information within
$_SESSION's. Yet I'd like to move these into cookies but I always get an
error about sent headers. Is there a way to circumvent this problem
without changing too much in the page?
The setting of the cookies happens just at the end of the page.
if (!$errortext and $Anmelden) {
if (!empty($Permanent)) {
$expires = time()+ 365 * 86400; // 365 days
setcookie ("l.Lastname", $_SESSION['l_Lastname'], $expires);
setcookie ("l.Firstname", $_SESSION['l_Firstname'], $expires);
setcookie ("l.Email1", $_SESSION['l_Email1'], $expires);
setcookie ("l.Email2", $_SESSION['l_Email2'], $expires);
}
echo "<script type=\"text/javascript\">
parent.location.replace('$index_php";
</script>";
exit;
}
O. Wyss
--- End Message ---
--- Begin Message ---
I didn't check; but seem to recall that Imagemagick will do it.
If it does, then I'd suggest using the new php Imagick API for it. Works great.
Don't be put off by the CVS status. Thats' most because of the lac of
documentation so far. http://us3.php.net/manual/en/ref.imagick.
Bindu Walia wrote:
Hi,
I am looking for a way to convert a html page to a jpeg image. The html
page is a file with images and text. Could someone please suggest a method
or point me to any existing work on this?
Thanks,
Bindu
--- End Message ---
--- Begin Message ---
Bindu Walia wrote:
Hi,
I am looking for a way to convert a html page to a jpeg image. The html
page is a file with images and text. Could someone please suggest a method
or point me to any existing work on this?
Keep in mind that any server-side application that can create
screenshots will require its own HTML/CSS engine in order to interpret
the markup. Gecko would seem to be the way to go but i don't know of any
PHP scripts that interface with it. I believe there's been some work
done with Java.
Or, if you can install KDE on the server (really not a great idea) you
could use kwebdesktop, which uses Konqueror's layout engine to create
PNGs (a better choice for this than JPEG, IMO).
brian
--- End Message ---
--- Begin Message ---
Hi Kelvin,
You can use the session for your ecommerce website..
Cookies also good, but if it is disabled then it is of no use.
I basically use session variable to particular member for accessing his
data.
Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan
-----Original Message-----
From: Kelvin Park [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 18, 2007 3:32 AM
To: [EMAIL PROTECTED]
Subject: [PHP] About Session And Cookies
I am trying to setup a secure login system.
I've heard that if I use just cookies for login, members without cookie
turned out won't be able to see the member pages.
Is using session recommended for e-commerce websites with shopping carts?
Or, using both of them might be more effective in some way.
--- End Message ---
--- Begin Message ---
Hi all,
Can anyone suggest a photo upload/framework type library I can incorporate
seamlessly into a PHP project I'm working on?
I'd like for users to have an elegant UI to upload photos of their vehicles
into my application. Mutli-file and progress bars would be a plus. I'm
looking to integrate this code using the Code Igniter framework.
Thanks all for any suggestions.
- sf
--- End Message ---
--- Begin Message ---
I often use MCImageManager, by moxiecode:
http://tinymce.moxiecode.com/paypal/item_imagemanager.php. Integrates well
into tinyMCE, but can be used without that as well.
I'm not entirely sure it's what you are looking for, but I think it very
well may be. And if it doesn't help you now, it may do so at some other
point ;-)
On 18/08/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> Can anyone suggest a photo upload/framework type library I can incorporate
> seamlessly into a PHP project I'm working on?
>
> I'd like for users to have an elegant UI to upload photos of their
> vehicles
> into my application. Mutli-file and progress bars would be a plus. I'm
> looking to integrate this code using the Code Igniter framework.
>
> Thanks all for any suggestions.
>
> - sf
>
--
Interpotential.com
Phone: +31615397471
--- End Message ---
--- Begin Message ---
HI,
I am working on a PHP project that interacts with command line utilities.
My php is running by apache. Means I am not running any php CLI.
here is the function that I am using for capturing command output.
function run_command($comamnd){
$ret=`$command 1> COMMAND.OUT 2>1`;
$contents=get_file_contents("COMMAND.OUT");
return $contents;
}
The function does not work. If I use any shell command like ls, cat,
echo, set. it works.
But If I use any utility like, mpg321, cd-info. It does not work. It
outputs a blank string.
I used system(), passthru() with both "2&>1" and "2>1". But no out put.
All the time, its blank.
Even I used a shell script "run.sh"
run.sh contents:
=====================================
#!/bin/sh
sh COMMAND 1> COMMAND.OUT 2&>1
cat COMMAND.OUT
echo 0 > COMMAND
=====================================
I called this script by this function
function run_command($command){
$h=fopen("COMMAND","w");
fwrite($h,$command);
fclose($h);
ob_start();
passthru("./run.sh");
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
and by this.
function run_command($command){
$h=fopen("COMMAND","w");
fwrite($h,$command);
fclose($h);
return system("./run.sh");
}
Please help me. or show me some way.
--
shout at http://shiplu.awardspace.com/
Available for Hire/Contract/Full Time
--- End Message ---
--- Begin Message ---
You may want to look into shell_exec, which executes a command and returns
the output. If you're accepting arguments from user input, don't forget
proper use of escapeshellcmd and escapeshellarg ;-).
Something else that might cause your commands from failing, is that the
utilities are not inside apache's PATH - trying to call them by there
absolute filename can help out. Have you inspected your error_log? There
often tends to be a lot of useful stuff in there.
Good luck!
Wouter
On 18/08/07, shiplu <[EMAIL PROTECTED]> wrote:
>
> HI,
> I am working on a PHP project that interacts with command line utilities.
> My php is running by apache. Means I am not running any php CLI.
>
> here is the function that I am using for capturing command output.
>
> function run_command($comamnd){
> $ret=`$command 1> COMMAND.OUT 2>1`;
> $contents=get_file_contents("COMMAND.OUT");
> return $contents;
> }
>
> The function does not work. If I use any shell command like ls, cat,
> echo, set. it works.
> But If I use any utility like, mpg321, cd-info. It does not work. It
> outputs a blank string.
> I used system(), passthru() with both "2&>1" and "2>1". But no out put.
> All the time, its blank.
> Even I used a shell script "run.sh"
> run.sh contents:
> =====================================
> #!/bin/sh
> sh COMMAND 1> COMMAND.OUT 2&>1
> cat COMMAND.OUT
> echo 0 > COMMAND
> =====================================
>
> I called this script by this function
> function run_command($command){
> $h=fopen("COMMAND","w");
> fwrite($h,$command);
> fclose($h);
> ob_start();
> passthru("./run.sh");
> $ret = ob_get_contents();
> ob_end_clean();
> return $ret;
> }
>
> and by this.
>
> function run_command($command){
> $h=fopen("COMMAND","w");
> fwrite($h,$command);
> fclose($h);
> return system("./run.sh");
> }
>
> Please help me. or show me some way.
>
>
> --
> shout at http://shiplu.awardspace.com/
>
> Available for Hire/Contract/Full Time
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Interpotential.com
Phone: +31615397471
--- End Message ---