On 23-Jul-2001 Matt Greer wrote:
> I don't think that's the best subject, but I'm not really sure how to phrase
> it.
>
> I'm not familiar with php's image capabilities. I've read about them a bit,
> but never really used them.
>
> I'd like to have an image that when accessed would cause php to kick in and
> do a few things before sending the image along to whoever is requesting it.
> Basically I'd like to keep a running tally of how many times a website is
> accessing an image on my server. Which functionally speaking is identical to
> a hit counter I guess.
>
> Is it possible to have on a webpage something like <img
> src="image.php?website=awebsite.com">
>
> and then image.php takes note of the website variable, does a few things
> with mysql, then passes on the image that is wanted, utilizing something
> from the gd library?
>
Sure,
/php/fetchimg.php?img=da_image.jpeg
/php/fetchimg.php
---
<?php
$ftype = strtolower(strrchr($img, '.'));
$types = array(
'.gif' => 'image/gif',
'.jpg' => 'image/jpeg',
'.mov' => 'video/quicktime',
'.mpe' => 'video/mpeg',
'.mpeg' => 'video/mpeg',
'.mpg' => 'video/mpeg'
);
$fname = "$DOCUMENT_ROOT/images/$img";
Header("Content-type: " .$types[$ftype]);
Header("Content-length: " .filesize($fname));
@readfile($fname);
$qry ="insert into foo (da_time,da_name) values (NOW(), '$img');
@mysql_query($qry);
?>
Regards,
--
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]