comparison imageserve.inc @ 0:d8a3998dac8e ad

ajout module ad
author pierre
date Fri, 20 Feb 2009 14:04:09 +0000
parents
children e5584a19768b
comparison
equal deleted inserted replaced
-1:000000000000 0:d8a3998dac8e
1 <?php
2 // $Id: imageserve.inc,v 1.1.2.8.2.2 2009/02/16 17:06:47 jeremy Exp $
3
4 /**
5 * @file
6 * Image serving lib.
7 *
8 * Copyright (c) 2008-2009.
9 * Jeremy Andrews <jeremy@tag1consulting.com>.
10 */
11
12 /**
13 * Generate a tiny image with GD, used to count when an ad has been displayed
14 * on a cached page.
15 */
16 function adserve_counter_image() {
17 adserve_variable('variable_load');
18 adserve_bootstrap(0);
19
20 $ad->aid = adserve_variable('aid');
21 if ($ad->aid) {
22 adserve_increment($ad);
23 }
24 else {
25 adserve_increment($ad, 'count');
26 }
27
28 if (function_exists('imagecreate')) {
29 $image = imagecreate(1, 1);
30 // Tell the web browser not to cache this image so we register a count each
31 // time the page is viewed.
32 // Expires in the past:
33 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
34 // Last loud:
35 header('Last-Modified: '. gmdate('D, d M Y H:i:s') .' GMT');
36 // HTTP 1.1:
37 header('Cache-Control: no-store, no-cache, must-revalidate');
38 header('Cache-Control: post-check=0, pre-check=0', FALSE);
39 // HTTP 1.0:
40 header('Pragma: no-cache');
41 }
42 else {
43 // GD not installed, report error and exit.
44 exit();
45 }
46
47 if (function_exists('imagejpeg')) {
48 header("Content-type: image/jpeg");
49 imagejpeg($image);
50 }
51 else if (function_exists('imagepng')) {
52 header("Content-type: image/png");
53 imagepng($image);
54 }
55 else if (function_exists('imagegif')) {
56 header("Content-type: image/gif");
57 imagegif($image);
58 }
59 imagedestroy($image);
60 exit(0);
61 }