[nycphp-talk] Double Loading PHP as image - Firefox or PHP?
Russ Demarest
rsd at electronink.com
Wed Nov 30 19:32:36 EST 2005
I do something similar and have not noticed a problem. You may want
to try passthru instead of readfile.
Hope it helps.
Russ
On Nov 30, 2005, at 6:39 PM, Mark Armendariz wrote:
> I have a hit counter script that I've been growing in the back yard
> for a
> few months. I decided to go back and water it today, just after
> upgrading
> to the latest Firefox release (1.5) and while testing I noticed an
> oddity...
>
> Now, the basics of how the script works. You call count.php as an
> image
> from your site (<img src="count.php" />), it adds the hit (and other
> wonderful data) to the db and then outputs a 1 px transparent gif.
> There's
> more to it with js and all kinds of fun stuff, but that has NOTHING
> to do
> with this particular problem...
>
> While testing other browsers (IE, FF 1.07, Opera, etc - all pc),
> Everything
> was working great, but with firefox 1.5, I was getting 2 hits every
> time. I
> removed the image code, and It would hit once. Put it back... Twice.
>
> I combed through my code, found nothing and decided, what the hell,
> take my
> code out... And so here's what's left - nice and simple:
>
> --------------
> count.php
> --------------
> <?php
> require_once 'function.file_put_contents.php'; // PHP5 magic
> in good
> ol' 4
> file_put_contents('./output.txt', date('m/d/Y G:i:s') . ': ' .
> $_SERVER['HTTP_USER_AGENT'] . "\n");
>
> header('Content-Type: image/gif');
> header('Content-Disposition: inline; filename=count.gif');
> readfile ('./count.gif');
> ?>
> --------------
>
> And when I load count.php into the browser, I get this:
> - the first one is FF 1.0.7
> - the second is IE whatever (latest from windows update)
> - the third and fourth are one load from FF 1.5
> - the 5th and 6th are a single refresh on FF 1.5
> --------------
> output.txt
> --------------
> 11/30/2005 15:26:46: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> rv:1.7.12) Gecko/20050915 Firefox/1.0.7
> 11/30/2005 15:27:00: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
> 5.1; SV1;
> .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
> 11/30/2005 15:27:04: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
> US; rv:1.8)
> Gecko/20051111 Firefox/1.5
> 11/30/2005 15:27:04: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
> US; rv:1.8)
> Gecko/20051111 Firefox/1.5
> 11/30/2005 15:32:34: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
> US; rv:1.8)
> Gecko/20051111 Firefox/1.5
> 11/30/2005 15:32:35: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
> US; rv:1.8)
> Gecko/20051111 Firefox/1.5
> --------------
>
> So, since it's a brand new version of FF, and my test code's too
> damned slim
> to find anything 'off', AND, with all other browsers I've tested -
> getting
> one hit per load, I'm beginning to figure this to be a bug/feature
> of the
> latest greatest FF. But before I begin barking up that tree, I
> wanted to
> ask the local gurus if my headers are whacky (I've tried a few
> combos, this
> one's just the shortest - and the original, which I've had for
> months), or
> if for some reason browsers are supposed to do this and they all just
> haven't been.
>
> In the end, I figure I'll have to try caching the image for a
> second or two
> and hopefully that'll calm FF's load-crazy ways. But oh how wrong
> it would
> feel to do so.
>
> Happy belated Turkeys...
>
> Thanks!!!
>
> Mark Armendariz
>
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>
More information about the talk
mailing list