conditional image generation problem
| From: | Alex Maslov | Date: | Thu, 25 Jul 2002 19:32:30 +0000 |
| Subject: | conditional image generation problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-109589@lists.php.net to get a copy of this message | ||
Hi,
I have a problem with conditional image generation. If I generate an
image without any conditional statments, then everything works fine. But
if i introduce conditional statment, then no image is generated in
either case of the condition.
Has anyone dealt with this dilema before?
Thanks in advance,
alex
P.S.
I am generating a hit-counter image.
The set-up is very basic:
if admin looks at the page, then image should be generated and displayed
if anyone else loads the page, no image should be generated.
my code goes smth like this:
<?php
if (! fromOffice() ) {
$image = ImageCreate(1,1);
$navyblue = ImageColorAllocate($image, 0, 0, 0);
ImageFilledRectangle($image, 0, 0, 1, 1, $navyblue);
} else {
$image = ImageCreate(125, 150);
//...
}
header("Content-Type: image/png");
header("Content-Disposition: inline; filename=counter.php");
ImagePng($image);
//have to destroy the image, otherwise will starve web-server's memory
ImageDestroy($image);
?>