pierre@0: . pierre@0: */ pierre@0: pierre@0: /** pierre@0: * Generate a tiny image with GD, used to count when an ad has been displayed pierre@0: * on a cached page. pierre@0: */ pierre@0: function adserve_counter_image() { pierre@0: adserve_variable('variable_load'); pierre@0: adserve_bootstrap(0); pierre@0: sly@2: if (adserve_variable('aid')) { sly@2: $ad->aid = adserve_variable('aid'); sly@2: } sly@2: if (isset($ad->aid) && $ad->aid) { sly@2: _debug_echo("adserve_counter_image: increment 'view' counter for aid: $ad->aid"); sly@2: adserve_cache('increment', 'view', $ad->aid); pierre@0: } pierre@0: else { sly@2: _debug_echo("adserve_counter_image: increment 'count' counter for no aid"); sly@2: adserve_cache('increment', 'count', NULL); pierre@0: } pierre@0: pierre@0: if (function_exists('imagecreate')) { pierre@0: $image = imagecreate(1, 1); pierre@0: // Tell the web browser not to cache this image so we register a count each pierre@0: // time the page is viewed. pierre@0: // Expires in the past: pierre@0: header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); pierre@0: // Last loud: pierre@0: header('Last-Modified: '. gmdate('D, d M Y H:i:s') .' GMT'); pierre@0: // HTTP 1.1: pierre@0: header('Cache-Control: no-store, no-cache, must-revalidate'); pierre@0: header('Cache-Control: post-check=0, pre-check=0', FALSE); pierre@0: // HTTP 1.0: pierre@0: header('Pragma: no-cache'); pierre@0: } pierre@0: else { pierre@0: // GD not installed, report error and exit. pierre@0: exit(); pierre@0: } pierre@0: pierre@0: if (function_exists('imagejpeg')) { pierre@0: header("Content-type: image/jpeg"); pierre@0: imagejpeg($image); pierre@0: } pierre@0: else if (function_exists('imagepng')) { pierre@0: header("Content-type: image/png"); pierre@0: imagepng($image); pierre@0: } pierre@0: else if (function_exists('imagegif')) { pierre@0: header("Content-type: image/gif"); pierre@0: imagegif($image); pierre@0: } pierre@0: imagedestroy($image); pierre@0: exit(0); pierre@0: }