- Impact
- 15
I have a problem with a script doubling a count of the view's of a image when I display it. When I take ImagePNG($img); out of the script. The counter only counts it as one hit, but when I have imagepng($img) it shows it as two hits. I am very confused as to why it might be doing this. I do have headers in the file that make the file non-cache'd by the browser. Do you think it is counting it twice, because it is revalidating the image?
Here is the code.
If I uncomment exit then it will update exposures by one. If I show the image ,imagepng($img), and comment the exit it will update exposures by two.
Why?
How can I stop this from happening?
Here is the code.
Code:
<Files view>
SetHandler application/x-httpd-php
</Files>
Code:
<?php
session_start();
include('connect_mysql.php');
mysql_query("update bannerstats set exposures=exposures+1'");
$bannerurl = "http://site.com/image.png";
$imagestuff = @getimagesize($bannerurl);
$imagetype = $imagestuff[2];
if ( $imagetype == '2') { $img = imagecreatefromjpeg($bannerurl); }
if ( $imagetype == '3') { $img = imagecreatefrompng($bannerurl); imageSaveAlpha($img, true); }
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header( "Content-type: image/png");
//exit;
ImagePNG($img);
ImageDestroy($img);
?>
If I uncomment exit then it will update exposures by one. If I show the image ,imagepng($img), and comment the exit it will update exposures by two.
Why?
How can I stop this from happening?
Last edited:






