[ Index ] |
PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /************************************************************************************* 4 Copyright notice 5 6 (c) 2002-2010 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 7 8 This script is part of PHPWCMS. The PHPWCMS web content management system is 9 free software; you can redistribute it and/or modify it under the terms of 10 the GNU General Public License as published by the Free Software Foundation; 11 either version 2 of the License, or (at your option) any later version. 12 13 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 14 A copy is found in the textfile GPL.txt and important notices to the license 15 from the author is found in LICENSE.txt distributed with these scripts. 16 17 This script is distributed in the hope that it will be useful, but WITHOUT ANY 18 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 19 PARTICULAR PURPOSE. See the GNU General Public License for more details. 20 21 This copyright notice MUST APPEAR in all copies of the script! 22 *************************************************************************************/ 23 24 // some mod ADS functions only needed in frontend 25 26 function renderAds($match) { 27 28 if(empty($match[1])) { 29 return ''; 30 } elseif(!($adID = intval($match[1]))) { 31 return ''; 32 } elseif($GLOBALS['IS_A_BOT']) { 33 return ''; 34 } elseif(BROWSER_OS == 'Other') { 35 return ''; 36 } 37 38 $sql = 'SELECT * FROM '.DB_PREPEND.'phpwcms_ads_campaign ac '; 39 $sql .= 'LEFT JOIN '.DB_PREPEND.'phpwcms_ads_place ap ON '; 40 $sql .= 'ap.adplace_id=ac.adcampaign_place '; 41 $sql .= 'WHERE ac.adcampaign_place='.$adID.' AND '; 42 $sql .= 'ac.adcampaign_status=1 AND ap.adplace_status=1 AND '; 43 $sql .= 'ac.adcampaign_datestart < NOW() AND '; 44 $sql .= 'ac.adcampaign_dateend > NOW() AND '; 45 $sql .= '(ac.adcampaign_maxview=0 OR (ac.adcampaign_maxview > 0 AND ac.adcampaign_maxview >= ac.adcampaign_curview)) AND '; 46 $sql .= '(ac.adcampaign_maxclick=0 OR (ac.adcampaign_maxclick > 0 AND ac.adcampaign_maxclick >= ac.adcampaign_curclick))'; 47 48 $ads = _dbQuery($sql); 49 50 if(is_array($ads) && count($ads) ) { 51 52 if(empty($_COOKIE['phpwcmsAdsUserId'])) { 53 54 $ad = $ads[array_rand($ads)]; 55 56 } else { 57 58 $ads_userid = $_COOKIE['phpwcmsAdsUserId']; 59 $ads_viewed = 0; 60 while(count($ads)) { 61 62 $ad_index = array_rand($ads); 63 $ad = $ads[$ad_index]; 64 65 if($ad['adcampaign_maxviewuser']) { 66 67 //check how often selected ad was viewed by user 68 $sql = 'SELECT COUNT(*) FROM '.DB_PREPEND.'phpwcms_ads_tracking WHERE '; 69 $sql .= 'adtracking_campaignid='.$ad['adcampaign_id'].' AND '; 70 $sql .= "adtracking_cookieid='".mysql_escape_string($ads_userid)."'"; 71 $ads_viewed = _dbQuery($sql, 'COUNT'); 72 73 if($ads_viewed <= $ad['adcampaign_maxviewuser']) { 74 break; 75 } else { 76 unset($ads[$ad_index]); 77 } 78 79 } else { 80 break; 81 } 82 83 } 84 if(!count($ads)) { 85 return ''; 86 } 87 88 } 89 90 } else { 91 return ''; 92 } 93 94 $ad['adcampaign_data'] = @unserialize($ad['adcampaign_data']); 95 $ad['dir'] = PHPWCMS_CONTENT.'ads/'.$ad['adcampaign_id']; 96 $ad['content_dir'] = CONTENT_PATH.'ads/'.$ad['adcampaign_id'].'/'; 97 if($ad['adcampaign_type']!=2 && $ad['adcampaign_type']!=4 && !is_dir($ad['dir'])) { 98 return ''; 99 } 100 $ad['dir'] .= '/'; 101 if(!empty($ad['adcampaign_data']['css']) && is_file($ad['dir'].$ad['adcampaign_data']['css'])) { 102 $GLOBALS['block']['custom_htmlhead'][] = ' <link rel="stylesheet" type="text/css" href="'.$ad['content_dir'].$ad['adcampaign_data']['css'].'"'.HTML_TAG_CLOSE; 103 } 104 105 $ad_media = ''; 106 $ad_title = ' title="'.html_specialchars($ad['adcampaign_data']['title_text'] ? $ad['adcampaign_data']['title_text'] : $ad['adcampaign_data']['url']).'"'; 107 $ad_alt = $ad['adcampaign_data']['alt_text'] ? ' alt="'.html_specialchars($ad['adcampaign_data']['alt_text']).'"' : ' alt=""'; 108 $ad_wxh = ' style="width:'.$ad['adplace_width'].'px;height:'.$ad['adplace_height'].'px;"'; 109 $ad_imgsrc = $ad['content_dir'].$ad['adcampaign_data']['image']; 110 $ad_swfsrc = $ad['content_dir'].$ad['adcampaign_data']['flash']; 111 $ad_random = md5( time().@microtime() ); 112 $ad_urldata = '&u='.PHPWCMS_USER_KEY.'&r='.(empty($_SERVER['HTTP_REFERER']) ? '' : urlencode($_SERVER['HTTP_REFERER'])).'&c='.$GLOBALS['aktion'][0].'&a='.$GLOBALS['aktion'][1].'&k='.$ad_random; 113 114 switch($ad['adcampaign_type']) { 115 116 case 0: //Bild 117 if(empty($ad['adcampaign_data']['image']) || !is_file($ad['dir'].$ad['adcampaign_data']['image'])) { 118 return ''; 119 } 120 $ad_imgsrc = html_entities($ad_imgsrc); 121 $ad_media .= '<a href="index.php?adclickval='.$ad['adcampaign_id'].'&url='.urlencode($ad['adcampaign_data']['url']).$ad_urldata.'"'; 122 $ad_media .= $ad_title; 123 if($ad['adcampaign_data']['target']) { 124 $ad_media .= ' target="'.$ad['adcampaign_data']['target'].'"'; 125 } 126 $ad_media .= '><img src="'.$ad_imgsrc.'" border="0"'.$ad_wxh.$ad_alt.HTML_TAG_CLOSE.'</a>'; 127 break; 128 129 case 1: //Flash 130 $ad['adcampaign_data']['url'] = urlencode($ad['adcampaign_data']['url']); 131 $ad_flashID = 'adsBannerFlash'.$adID; 132 $ad_so = 'adsInnerFlash'.$ad['adcampaign_id']; 133 $ad_media .= '<a href="index.php?adclickval='.$ad['adcampaign_id'].'&url='.$ad['adcampaign_data']['url'].$ad_urldata.'"'; 134 $ad_media .= $ad_title; 135 if($ad['adcampaign_data']['target']) { 136 $ad_media .= ' target="'.$ad['adcampaign_data']['target'].'"'; 137 } 138 $ad_media .= ' id="'.$ad_so.'">'; 139 if(is_file($ad['dir'].$ad['adcampaign_data']['image'])) { 140 $ad_media .= '<img src="'. html_entities($ad_imgsrc) .'" border="0"'.$ad_wxh.$ad_alt.HTML_TAG_CLOSE; 141 } else { 142 $ad_media .= $ad_title; 143 } 144 $ad_media .= '</a>'; 145 $ad_media = '<div id="'.$ad_flashID.'">'.$ad_media.'</div>'; 146 147 if(!empty($ad['adcampaign_data']['flash']) && is_file($ad['dir'].$ad['adcampaign_data']['flash'])) { 148 149 initSwfObject(); 150 151 $ad_urldata = urldecode(str_replace('&', '&', $ad_urldata)); 152 $ad_flash = ' <script type="text/javascript">'.LF.SCRIPT_CDATA_START.LF; 153 154 $ad_flash .= ' var flashvars_'.$ad_so.' = {clickTag: "'.urlencode('index.php?adclickval='.$ad['adcampaign_id'].'&url='.$ad['adcampaign_data']['url'].$ad_urldata).'", '; 155 $ad_flash .= 'clickTarget: "'.urlencode($ad['adcampaign_data']['target']).'"};' . LF; 156 $ad_flash .= ' var params_'.$ad_so.' = {wmode: "opaque", autoplay: true, quality: "autohigh", '; 157 $ad_flash .= 'play: true, menu: false, allowscriptaccess: "always", swliveconnect: true, scale: "exactfit"'; 158 if($ad['adcampaign_data']['bgcolor']) { 159 $ad_flash .= ', bgcolor: "'.$ad['adcampaign_data']['bgcolor'].'"'; 160 } 161 $ad_flash .= '};' . LF; 162 $ad_flash .= ' var attributes_'.$ad_so.' = {};' . LF; 163 164 $ad_flash .= ' swfobject.embedSWF("'.$ad_swfsrc.'", "'.$ad_so.'", '; 165 $ad_flash .= '"'.$ad['adplace_width'].'", "'.$ad['adplace_height'].'", '; 166 $ad_flash .= '"'.$ad['adcampaign_data']['flashversion'].'", false, '; 167 $ad_flash .= 'flashvars_'.$ad_so.', params_'.$ad_so.', attributes_'.$ad_so.');'; 168 169 $ad_flash .= LF.SCRIPT_CDATA_END.LF.' </script>'; 170 171 $GLOBALS['block']['custom_htmlhead'][$ad_so] = $ad_flash; 172 173 } 174 break; 175 176 case 2: //HTML 177 if(!empty($ad['adcampaign_data']['html'])) { 178 if($ad['adcampaign_data']['bordercolor']) { 179 $ad_wxh = ' style="width:'.($ad['adplace_width']-2).'px;height:'.($ad['adplace_height']-2).'px;'; 180 $ad_wxh .= 'border:1px solid '.$ad['adcampaign_data']['bordercolor'].';'; 181 } else { 182 $ad_wxh = ' style="width:'.$ad['adplace_width'].'px;height:'.$ad['adplace_height'].'px;'; 183 } 184 if($ad['adcampaign_data']['bgcolor']) { 185 $ad_wxh .= 'background-color:'.$ad['adcampaign_data']['bgcolor'].';'; 186 } 187 $ad_media .= '<div id="adBannerHTML'.$adID.'"'.$ad_wxh.'">'; 188 $ad_media .= '<a href="index.php?adclickval='.$ad['adcampaign_id'].'&url='.urlencode($ad['adcampaign_data']['url']).$ad_urldata.'"'; 189 $ad_media .= $ad_title; 190 if($ad['adcampaign_data']['target']) { 191 $ad_media .= ' target="'.$ad['adcampaign_data']['target'].'"'; 192 } 193 $ad_media .= ' style="width:'.$ad['adplace_width'].'px;height:'.$ad['adplace_height'].'px;display:block;">'; 194 $ad_media .= $ad['adcampaign_data']['html'] . '</a></div>'; 195 } 196 197 break; 198 199 case 3: //Flash Layer 200 $ad['adcampaign_data']['url'] = urlencode($ad['adcampaign_data']['url']); 201 $ad_flashID = 'adsBannerFL'.$adID; 202 $ad_so = 'adsInnerFlash'.$ad['adcampaign_id']; 203 if(!empty($ad['adcampaign_data']['flash']) && is_file($ad['dir'].$ad['adcampaign_data']['flash'])) { 204 205 $ad_media = '<div id="'.$ad_flashID.'" style="width:'.$ad['adplace_width'].'px;height:'.$ad['adplace_height'].'px;display:none;">'; 206 $ad_media .= '<div id="'.$ad_so.'"></div></div>'; 207 208 initSwfObject(); 209 210 $ad_urldata = urldecode(str_replace('&', '&', $ad_urldata)); 211 212 213 $ad_flash = ' <!--[if gte IE 5]><script type="text/javascript" event="FSCommand(command,args)" for="'.$ad_so.'">'; 214 $ad_flash .= $ad_so.'_DoFSCommand(command, args);</script><![endif]-->'.LF; 215 216 $ad_flash .= ' <script type="text/javascript">'.LF.SCRIPT_CDATA_START.LF; 217 218 $ad_flash .= ' function '.$ad_so.'_DoFSCommand(command,args){if(command=="adlayerhider")toggleLayerDisplay("'.$ad_flashID.'","none");}'.LF; 219 $ad_flash .= ' function show'.$ad_so.'(){toggleLayerDisplay("'.$ad_flashID.'", "block");}'.LF; 220 221 $ad_flash .= ' var flashvars_'.$ad_so.' = {clickTag: "'.urlencode('index.php?adclickval='.$ad['adcampaign_id'].'¤t='.$ad_random.'&u='.PHPWCMS_USER_KEY.'&url='.$ad['adcampaign_data']['url']).'", '; 222 $ad_flash .= 'clickTarget: "'.urlencode($ad['adcampaign_data']['target']).'"};' . LF; 223 $ad_flash .= ' var params_'.$ad_so.' = {wmode: "transparent", autoplay: true, quality: "autohigh", '; 224 $ad_flash .= 'play: true, menu: false, allowscriptaccess: "always", swliveconnect: true, scale: "exactfit"'; 225 if($ad['adcampaign_data']['bgcolor']) { 226 $ad_flash .= ', bgcolor: "'.$ad['adcampaign_data']['bgcolor'].'"'; 227 } 228 $ad_flash .= '};' . LF; 229 $ad_flash .= ' var attributes_'.$ad_so.' = {name: "'.$ad_so.'"};' . LF; 230 231 $ad_flash .= ' swfobject.embedSWF("'.$ad_swfsrc.'", "'.$ad_so.'", '; 232 $ad_flash .= '"'.$ad['adplace_width'].'", "'.$ad['adplace_height'].'", '; 233 $ad_flash .= '"'.$ad['adcampaign_data']['flashversion'].'", false, '; 234 $ad_flash .= 'flashvars_'.$ad_so.', params_'.$ad_so.', attributes_'.$ad_so.');' . LF; 235 236 $ad_flash .= ' window.setTimeout("show'.$ad_so.'()", 1000);'; 237 238 $ad_flash .= LF.SCRIPT_CDATA_END.LF.' </script>'; 239 240 $GLOBALS['block']['custom_htmlhead'][$ad_so] = $ad_flash; 241 242 } 243 break; 244 245 case 4: //Remote HTML Code 246 if(!empty($ad['adcampaign_data']['html'])) { 247 $ad_media .= $ad['adcampaign_data']['html']; 248 } 249 break; 250 251 } 252 253 //set ads tracking image here. 254 $GLOBALS['content']['ADS_ALL'][] = $ad['adcampaign_id']; 255 256 return $ad['adplace_prefix'].$ad_media.$ad['adplace_suffix']; 257 258 } 259 260 261 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Nov 16 22:51:00 2010 | Cross-referenced by PHPXref 0.7 |