| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:31:32 2008 ] | [ phpAdsNew 2.0.8 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php // $Revision: 2.2.2.18 $ 2 3 /************************************************************************/ 4 /* phpAdsNew 2 */ 5 /* =========== */ 6 /* */ 7 /* Copyright (c) 2000-2006 by the phpAdsNew developers */ 8 /* For more information visit: http://www.phpadsnew.com */ 9 /* */ 10 /* This program is free software. You can redistribute it and/or modify */ 11 /* it under the terms of the GNU General Public License as published by */ 12 /* the Free Software Foundation; either version 2 of the License. */ 13 /************************************************************************/ 14 15 16 17 // Figure out our location 18 define ('phpAds_path', '.'); 19 20 21 // Set invocation type 22 define ('phpAds_invocationType', 'adview'); 23 24 25 26 /*********************************************************/ 27 /* Include required files */ 28 /*********************************************************/ 29 30 require (phpAds_path."/config.inc.php"); 31 require (phpAds_path."/libraries/lib-io.inc.php"); 32 require (phpAds_path."/libraries/lib-db.inc.php"); 33 34 if ($phpAds_config['log_adviews'] || $phpAds_config['acl']) 35 { 36 require (phpAds_path."/libraries/lib-remotehost.inc.php"); 37 38 if ($phpAds_config['acl']) 39 require (phpAds_path."/libraries/lib-limitations.inc.php"); 40 } 41 42 require (phpAds_path."/libraries/lib-log.inc.php"); 43 require (phpAds_path."/libraries/lib-view-main.inc.php"); 44 require (phpAds_path."/libraries/lib-cache.inc.php"); 45 46 47 48 /*********************************************************/ 49 /* Register input variables */ 50 /*********************************************************/ 51 52 phpAds_registerGlobal ('clientid', 'clientID', 'what', 'source', 53 'n'); 54 55 56 57 /*********************************************************/ 58 /* Main code */ 59 /*********************************************************/ 60 61 $url = parse_url($phpAds_config['url_prefix']); 62 63 64 if (isset($clientID) && !isset($clientid)) $clientid = $clientID; 65 if (!isset($clientid)) $clientid = 0; 66 if (!isset($what)) $what = ''; 67 if (!isset($source)) $source = ''; 68 if (!isset($n)) $n = 'default'; 69 70 // Remove referer, to be sure it doesn't cause problems with limitations 71 if (isset($HTTP_SERVER_VARS['HTTP_REFERER'])) unset($HTTP_SERVER_VARS['HTTP_REFERER']); 72 if (isset($HTTP_REFERER)) unset($HTTP_REFERER); 73 74 75 if (phpAds_dbConnect()) 76 { 77 mt_srand(floor((isset($n) && strlen($n) > 5 ? hexdec($n[0].$n[2].$n[3].$n[4].$n[5]): 1000000) * (double)microtime())); 78 79 // Reset followed zone chain 80 $phpAds_followedChain = array(); 81 82 $found = false; 83 $first = true; 84 85 while (($first || $what != '') && $found == false) 86 { 87 $first = false; 88 89 if (substr($what,0,5) == 'zone:') 90 { 91 if (!defined('LIBVIEWZONE_INCLUDED')) 92 require (phpAds_path.'/libraries/lib-view-zone.inc.php'); 93 94 $row = phpAds_fetchBannerZone($what, $clientid, '', $source, false); 95 } 96 else 97 { 98 if (!defined('LIBVIEWDIRECT_INCLUDED')) 99 require (phpAds_path.'/libraries/lib-view-direct.inc.php'); 100 101 $row = phpAds_fetchBannerDirect($what, $clientid, '', $source, false); 102 } 103 104 if (is_array ($row)) 105 $found = true; 106 else 107 $what = $row; 108 } 109 } 110 else 111 { 112 $found = false; 113 } 114 115 116 if ($found) 117 { 118 // Get the data we need to display the banner 119 $row = array_merge($row, phpAds_getBannerDetails($row['bannerid'])); 120 121 // Log this impression 122 if ($phpAds_config['block_adviews'] == 0 || 123 ($phpAds_config['block_adviews'] > 0 && 124 (!isset($HTTP_COOKIE_VARS['phpAds_blockView'][$row['bannerid']]) || 125 $HTTP_COOKIE_VARS['phpAds_blockView'][$row['bannerid']] <= time()))) 126 { 127 if ($phpAds_config['log_adviews']) 128 phpAds_logImpression ($row['bannerid'], $row['clientid'], $row['zoneid'], $source); 129 130 // Send block cookies 131 if ($phpAds_config['block_adviews'] > 0) 132 phpAds_setCookie ("phpAds_blockView[".$row['bannerid']."]", time() + $phpAds_config['block_adviews'], 133 time() + $phpAds_config['block_adviews'] + 43200); 134 } 135 136 137 // Set delivery cookies 138 phpAds_setDeliveryCookies($row); 139 140 141 // Send bannerid headers 142 $cookie = array(); 143 $cookie['bannerid'] = $row["bannerid"]; 144 145 // Send zoneid headers 146 if ($row['zoneid'] != 0) 147 $cookie['zoneid'] = $row['zoneid']; 148 149 // Send source headers 150 if (isset($source) && $source != '') 151 $cookie['source'] = $source; 152 153 154 switch ($row['storagetype']) 155 { 156 case 'url': 157 $row['imageurl'] = str_replace ('{timestamp}', time(), $row['imageurl']); 158 $row['url'] = str_replace ('{timestamp}', time(), $row['url']); 159 160 161 // Replace random 162 if (preg_match ('#\{random(:([0-9]+)){0,1}\}#i', $row['imageurl'], $matches)) 163 { 164 if ($matches[2]) 165 $lastdigits = $matches[2]; 166 else 167 $lastdigits = 8; 168 169 $lastrandom = ''; 170 171 for ($r=0; $r<$lastdigits; $r=$r+9) 172 $lastrandom .= (string)mt_rand (111111111, 999999999); 173 174 $lastrandom = substr($lastrandom, 0 - $lastdigits); 175 $row['imageurl'] = str_replace ($matches[0], $lastrandom, $row['imageurl']); 176 } 177 178 if (preg_match ('#\{random(:([0-9]+)){0,1}\}#i', $row['url'], $matches)) 179 { 180 if ($matches[2]) 181 $randomdigits = $matches[2]; 182 else 183 $randomdigits = 8; 184 185 if (isset($lastdigits) && $lastdigits == $randomdigits) 186 $randomnumber = $lastrandom; 187 else 188 { 189 $randomnumber = ''; 190 191 for ($r=0; $r<$randomdigits; $r=$r+9) 192 $randomnumber .= (string)mt_rand (111111111, 999999999); 193 194 $randomnumber = substr($randomnumber, 0 - $randomdigits); 195 } 196 197 $row['url'] = str_replace ($matches[0], $randomnumber, $row['url']); 198 } 199 200 // Store destination URL 201 $cookie['dest'] = $row['url']; 202 203 // Redirect to the banner 204 phpAds_setCookie ("phpAds_banner[".$n."]", serialize($cookie), 0); 205 phpAds_flushCookie (); 206 207 header ("Location: ".$row['imageurl']); 208 break; 209 210 211 case 'web': 212 $cookie['dest'] = $row['url']; 213 214 // Redirect to the banner 215 phpAds_setCookie ("phpAds_banner[".$n."]", serialize($cookie), 0); 216 phpAds_flushCookie (); 217 218 header ("Location: ".$row['imageurl']); 219 break; 220 221 222 case 'sql': 223 $cookie['dest'] = $row['url']; 224 225 if (isset($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) 226 { 227 if (preg_match ("#Mozilla/(1|2|3|4)#", $HTTP_SERVER_VARS['HTTP_USER_AGENT']) && !preg_match("#compatible#", $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) 228 { 229 // Workaround for Netscape 4 problem 230 // with animated GIFs. Redirect to 231 // adimage to prevent banner changing 232 // at the end of each animation loop 233 234 phpAds_setCookie ("phpAds_banner[".$n."]", serialize($cookie), 0); 235 phpAds_flushCookie (); 236 237 if ($HTTP_SERVER_VARS['SERVER_PORT'] == 443) $phpAds_config['url_prefix'] = str_replace ('http://', 'https://', $phpAds_config['url_prefix']); 238 header ("Location: ".str_replace('{url_prefix}', $phpAds_config['url_prefix'], $row['imageurl'])); 239 } 240 else 241 { 242 // Workaround for IE 4-5.5 problem 243 // Load the banner from the database 244 // and show the image directly to prevent 245 // broken images when shown during a 246 // form submit 247 248 $res = phpAds_dbQuery(" 249 SELECT 250 contents 251 FROM 252 ".$phpAds_config['tbl_images']." 253 WHERE 254 filename = '".$row['filename']."' 255 "); 256 257 if ($image = phpAds_dbFetchArray($res)) 258 { 259 phpAds_setCookie ("phpAds_banner[".$n."]", serialize($cookie), 0); 260 phpAds_flushCookie (); 261 262 header ('Content-Type: image/'.$row['contenttype'].'; name='.md5(microtime()).'.'.$row['contenttype']); 263 header ('Content-Length: '.strlen($image['contents'])); 264 echo $image['contents']; 265 } 266 } 267 } 268 269 break; 270 } 271 } 272 else 273 { 274 phpAds_setCookie ("phpAds_banner[".$n."]", 'DEFAULT', 0); 275 phpAds_flushCookie (); 276 277 if ($phpAds_config['default_banner_url'] != '') 278 header ("Location: ".$phpAds_config['default_banner_url']); 279 else 280 { 281 // Show 1x1 Gif, to ensure not broken image icon 282 // is shown. 283 284 header ("Content-Type: image/gif"); 285 286 echo chr(0x47).chr(0x49).chr(0x46).chr(0x38).chr(0x39).chr(0x61).chr(0x01).chr(0x00). 287 chr(0x01).chr(0x00).chr(0x80).chr(0x00).chr(0x00).chr(0x04).chr(0x02).chr(0x04). 288 chr(0x00).chr(0x00).chr(0x00).chr(0x21).chr(0xF9).chr(0x04).chr(0x01).chr(0x00). 289 chr(0x00).chr(0x00).chr(0x00).chr(0x2C).chr(0x00).chr(0x00).chr(0x00).chr(0x00). 290 chr(0x01).chr(0x00).chr(0x01).chr(0x00).chr(0x00).chr(0x02).chr(0x02).chr(0x44). 291 chr(0x01).chr(0x00).chr(0x3B); 292 } 293 } 294 295 phpAds_dbClose(); 296 297 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |