/** * A method to test the MAX_cookieAdd() function. * * This function does not output cookies, instead it sets a global cookie array or ads to it if it exists * */ function test_MAX_cookieAdd() { //Unset the cookie cache array unset($GLOBALS['_MAX']['COOKIE']['CACHE']); // Set a test cookie MAX_cookieAdd('test', 'test'); $this->assertIsA($GLOBALS['_MAX']['COOKIE']['CACHE']['test'], 'array'); $this->assertEqual($GLOBALS['_MAX']['COOKIE']['CACHE']['test'][0], 'test'); $this->assertEqual($GLOBALS['_MAX']['COOKIE']['CACHE']['test'][1], 0); unset($GLOBALS['_MAX']['COOKIE']['CACHE']); // Set a test cookie with an expiry time MAX_cookieAdd('test', 'test', 60); $this->assertIsA($GLOBALS['_MAX']['COOKIE']['CACHE']['test'], 'array'); $this->assertEqual($GLOBALS['_MAX']['COOKIE']['CACHE']['test'][0], 'test'); $this->assertEqual($GLOBALS['_MAX']['COOKIE']['CACHE']['test'][1], 60); }
function MAX_Delivery_log_setClickBlocked($index, $aAdIds) { $aConf = $GLOBALS['_MAX']['CONF']; MAX_cookieAdd("_{$aConf['var']['blockLoggingClick']}[{$aAdIds[$index]}]", MAX_commonCompressInt(MAX_commonGetTimeNow()), _getTimeThirtyDaysFromNow()); }
function MAX_adSelect($what, $campaignid = '', $target = '', $source = '', $withtext = 0, $charset = '', $context = array(), $richmedia = true, $ct0 = '', $loc = '', $referer = '') { $conf = $GLOBALS['_MAX']['CONF']; if (empty($GLOBALS['source'])) { $GLOBALS['source'] = $source; } if (empty($GLOBALS['loc'])) { $GLOBALS['loc'] = $loc; } $originalZoneId = null; if (strpos($what, 'zone:') === 0) { $originalZoneId = intval(substr($what, 5)); } elseif (strpos($what, 'campaignid:') === 0) { $originalCampaignId = intval(substr($what, 11)); } elseif (strpos($what, 'bannerid:') === 0) { $originalBannerId = intval(substr($what, 9)); } $userid = MAX_cookieGetUniqueViewerId(); MAX_cookieAdd($conf['var']['viewerId'], $userid, _getTimeYearFromNow()); $outputbuffer = ''; $found = false; $GLOBALS['_MAX']['followedChain'] = array(); $GLOBALS['_MAX']['adChain'] = array(); $GLOBALS['_MAX']['considered_ads'] = array(); $first = true; global $g_append, $g_prepend; $g_append = ''; $g_prepend = ''; if (!empty($what)) { while ($first || $what != '' && $found == false) { $first = false; $ix = strpos($what, '|'); if ($ix === false) { $remaining = ''; } else { $remaining = substr($what, $ix + 1); $what = substr($what, 0, $ix); } if (strpos($what, 'zone:') === 0) { $zoneId = intval(substr($what, 5)); $row = _adSelectZone($zoneId, $context, $source, $richmedia); } else { if (strpos($what, '/') > 0) { if (strpos($what, '@') > 0) { list($what, $append) = explode('@', $what); } else { $append = ''; } $separate = explode('/', $what); $expanded = ''; $collected = array(); reset($separate); while (list(, $v) = each($separate)) { $expanded .= ($expanded != '' ? ',+' : '') . $v; $collected[] = $expanded . ($append != '' ? ',+' . $append : ''); } $what = strtok(implode('|', array_reverse($collected)), '|'); $remaining = strtok('') . ($remaining != '' ? '|' . $remaining : ''); } $row = _adSelectDirect($what, $campaignid, $context, $source, $richmedia, $remaining == ''); } if (is_array($row) && empty($row['default'])) { MAX_Delivery_log_logAdRequest($row['bannerid'], $row['zoneid'], $row); if (($row['adserver'] == 'max' || $row['adserver'] == '3rdPartyServers:ox3rdPartyServers:max') && preg_match("#{$conf['webpath']['delivery']}.*zoneid=([0-9]+)#", $row['htmltemplate'], $matches) && !stristr($row['htmltemplate'], $conf['file']['popup'])) { $GLOBALS['_MAX']['adChain'][] = $row; $found = false; $what = "zone:{$matches[1]}"; } else { $found = true; } } else { MAX_Delivery_log_logAdRequest(null, $originalZoneId, null); $what = $remaining; } } } if ($found) { $zoneId = empty($row['zoneid']) ? 0 : $row['zoneid']; if (!empty($GLOBALS['_MAX']['adChain'])) { foreach ($GLOBALS['_MAX']['adChain'] as $index => $ad) { if ($ad['ad_id'] != $row['ad_id'] && !empty($ad['append'])) { $row['append'] .= $ad['append']; } } } $outputbuffer = MAX_adRender($row, $zoneId, $source, $target, $ct0, $withtext, $charset, true, true, $richmedia, $loc, $referer, $context); $output = array('html' => $outputbuffer, 'bannerid' => $row['bannerid'], 'contenttype' => $row['contenttype'], 'alt' => $row['alt'], 'width' => $row['width'], 'height' => $row['height'], 'url' => $row['url'], 'campaignid' => $row['campaignid'], 'clickUrl' => $row['clickUrl'], 'logUrl' => $row['logUrl'], 'aSearch' => $row['aSearch'], 'aReplace' => $row['aReplace'], 'bannerContent' => $row['bannerContent'], 'clickwindow' => $row['clickwindow'], 'aRow' => $row, 'context' => _adSelectBuildContext($row, $context), 'iframeFriendly' => (bool) $row['iframe_friendly']); $row += array('block_ad' => 0, 'cap_ad' => 0, 'session_cap_ad' => 0, 'block_campaign' => 0, 'cap_campaign' => 0, 'session_cap_campaign' => 0, 'block_zone' => 0, 'cap_zone' => 0, 'session_cap_zone' => 0); if (MAX_Delivery_cookie_cappingOnRequest()) { if ($row['block_ad'] > 0 || $row['cap_ad'] > 0 || $row['session_cap_ad'] > 0) { MAX_Delivery_cookie_setCapping('Ad', $row['bannerid'], $row['block_ad'], $row['cap_ad'], $row['session_cap_ad']); } if ($row['block_campaign'] > 0 || $row['cap_campaign'] > 0 || $row['session_cap_campaign'] > 0) { MAX_Delivery_cookie_setCapping('Campaign', $row['campaign_id'], $row['block_campaign'], $row['cap_campaign'], $row['session_cap_campaign']); } if ($row['block_zone'] > 0 || $row['cap_zone'] > 0 || $row['session_cap_zone'] > 0) { MAX_Delivery_cookie_setCapping('Zone', $row['zoneid'], $row['block_zone'], $row['cap_zone'], $row['session_cap_zone']); } MAX_Delivery_log_setLastAction(0, array($row['bannerid']), array($zoneId), array($row['viewwindow'])); } } else { if (!empty($zoneId)) { $logUrl = _adRenderBuildLogURL(array('ad_id' => 0, 'placement_id' => 0), $zoneId, $source, $loc, $referer, '&'); $g_append = str_replace('{random}', MAX_getRandomNumber(), MAX_adRenderImageBeacon($logUrl)) . $g_append; } if (!empty($row['default'])) { if (empty($target)) { $target = '_blank'; } $outputbuffer = $g_prepend . '<a href=\'' . $row['default_banner_destination_url'] . '\' target=\'' . $target . '\'><img src=\'' . $row['default_banner_image_url'] . '\' border=\'0\' alt=\'\'></a>' . $g_append; $output = array('html' => $outputbuffer, 'bannerid' => '', 'default_banner_image_url' => $row['default_banner_image_url']); } else { if (!empty($conf['defaultBanner']['imageUrl'])) { if (empty($target)) { $target = '_blank'; } $outputbuffer = "{$g_prepend}<img src='{$conf['defaultBanner']['imageUrl']}' border='0' alt=''>{$g_append}"; $output = array('html' => $outputbuffer, 'bannerid' => '', 'default_banner_image_url' => $conf['defaultBanner']['imageUrl']); } else { $outputbuffer = $g_prepend . $g_append; $output = array('html' => $outputbuffer, 'bannerid' => ''); } } } OX_Delivery_Common_hook('postAdSelect', array(&$output)); return $output; }
/** * Destroy the current session * * @todo Determine how much of these steps are unnecessary, and remove them. */ function phpAds_SessionDataDestroy() { $dal = new MAX_Dal_Admin_Session(); global $session; $dal->deleteSession($_COOKIE['sessionID']); MAX_cookieAdd('sessionID', ''); MAX_cookieFlush(); unset($session); unset($_COOKIE['sessionID']); }
* @package MaxDelivery * @author Scott Switzer <*****@*****.**> * @author Andrew Hill <*****@*****.**> */ // Require the initialisation file require_once '../../init-delivery.php'; // Required files require_once MAX_PATH . '/lib/max/Delivery/querystring.php'; // Prevent the logging beacon from being cached by browsers MAX_commonSetNoCacheHeaders(); // Remove any special characters from the request variables MAX_commonRemoveSpecialChars($_REQUEST); // Get the viewer ID, and the ad, campaign, creative and zone variables to be logged // from the request variables $viewerId = MAX_cookieGetUniqueViewerId(); MAX_cookieAdd($conf['var']['viewerId'], $viewerId, _getTimeYearFromNow()); $aAdIds = MAX_Delivery_log_getArrGetVariable('adId'); $aCampaignIds = MAX_Delivery_log_getArrGetVariable('campaignId'); $aCreativeIds = MAX_Delivery_log_getArrGetVariable('creativeId'); $aZoneIds = MAX_Delivery_log_getArrGetVariable('zoneId'); // Get any ad, campaign and zone capping information from the request variables $aCapAd['block'] = MAX_Delivery_log_getArrGetVariable('blockAd'); $aCapAd['capping'] = MAX_Delivery_log_getArrGetVariable('capAd'); $aCapAd['session_capping'] = MAX_Delivery_log_getArrGetVariable('sessionCapAd'); $aCapCampaign['block'] = MAX_Delivery_log_getArrGetVariable('blockCampaign'); $aCapCampaign['capping'] = MAX_Delivery_log_getArrGetVariable('capCampaign'); $aCapCampaign['session_capping'] = MAX_Delivery_log_getArrGetVariable('sessionCapCampaign'); $aCapZone['block'] = MAX_Delivery_log_getArrGetVariable('blockZone'); $aCapZone['capping'] = MAX_Delivery_log_getArrGetVariable('capZone'); $aCapZone['session_capping'] = MAX_Delivery_log_getArrGetVariable('sessionCapZone'); $aSetLastSeen = MAX_Delivery_log_getArrGetVariable('lastView');
/** * A function to set any capping cookies (ie. block, cap or sessionCap) that are required * for an ad, a campaign or a zone. * * @param string $type The type of capping to set, one of "Ad", "Campaign" or "Zone". * @param integer $id The ID of the ad, campaign or zone that the capping cookies are for. * @param integer $block The number of seconds to block the ad, campaign or zone. * @param integer $cap The total number of times a viewer can see an ad, an ad from the * campaign, or an ad in a zone. * @param integer $sessionCap The number of times per session that a viewer can see an * ad, an ad from the campaign, or an ad in a zone. */ function MAX_Delivery_cookie_setCapping($type, $id, $block = 0, $cap = 0, $sessionCap = 0) { $conf = $GLOBALS['_MAX']['CONF']; $setBlock = false; if ($cap > 0) { // This capping cookie requires a "permanent" expiration time $expire = MAX_commonGetTimeNow() + $conf['cookie']['permCookieSeconds']; // The unpack capping cookies function adds this value to the counter, so to reset it we add a negative number if (!isset($_COOKIE[$conf['var']['cap' . $type]][$id])) { $value = 1; $setBlock = true; } else { if ($_COOKIE[$conf['var']['cap' . $type]][$id] >= $cap) { $value = -$_COOKIE[$conf['var']['cap' . $type]][$id] + 1; // Also reset the last-seen when resetting the frequency counter $setBlock = true; } else { $value = 1; } } MAX_cookieAdd("_{$conf['var']['cap' . $type]}[{$id}]", $value, $expire); } if ($sessionCap > 0) { // The unpack capping cookies function deals with imcrementing the counter // The expiry is set to 0 to make a session cookie // The unpack capping cookies function adds this value to the counter, so to reset it we add a negative number if (!isset($_COOKIE[$conf['var']['sessionCap' . $type]][$id])) { $value = 1; $setBlock = true; } else { if ($_COOKIE[$conf['var']['sessionCap' . $type]][$id] >= $sessionCap) { $value = -$_COOKIE[$conf['var']['sessionCap' . $type]][$id] + 1; // Also reset the last-seen when resetting the frequency counter $setBlock = true; } else { $value = 1; } } MAX_cookieAdd("_{$conf['var']['sessionCap' . $type]}[{$id}]", $value, 0); } if ($block > 0 || $setBlock) { // This blocking cookie is limited to 30 days // Store a cookie using the current time so that the system knows when // the last time this viewer saw this ad, an ad in this campaign or an // ad in this zone MAX_cookieAdd("_{$conf['var']['block' . $type]}[{$id}]", MAX_commonGetTimeNow(), _getTimeThirtyDaysFromNow()); } }
$creativeId[$i] = intval($creativeId[$i]); } else { $creativeId[$i] = 0; } if (($adId[$i] > 0 || $adId[$i] == -1) && $conf['logging']['adClicks'] && !(isset($_GET['log']) && $_GET['log'] == 'no')) { if (!MAX_Delivery_log_isClickBlocked($adId[$i], $aBlockLoggingClick)) { if (isset($GLOBALS['conf']['logging']['blockAdClicksWindow']) && $GLOBALS['conf']['logging']['blockAdClicksWindow'] != 0) { MAX_Delivery_log_setClickBlocked($i, $adId); } MAX_Delivery_log_logAdClick($adId[$i], $zoneId[$i]); MAX_Delivery_log_setLastAction($i, $adId, $zoneId, $lastClick, 'click'); } } } // Set the userid cookie MAX_cookieAdd($conf['var']['viewerId'], $viewerId, time() + $conf['cookie']['permCookieSeconds']); MAX_cookieFlush(); // Get the URL that we are going to redirect to $destination = MAX_querystringGetDestinationUrl($adId[0]); // Redirect to the destination url if (!empty($destination) && empty($_GET['trackonly'])) { // Prevent HTTP response split attacks if (!preg_match('/[\\r\\n]/', $destination)) { MAX_redirect($destination); } } /** * Get the ad information when only passed in a zone ID (for email zones) * * @param int $zoneId The Zone ID of the zone * @return int $adId The ad ID of the only linked banner, or 0 if <> 1 active ad linked
// be logged here if ($conf['logging']['adImpressions']) { MAX_Delivery_log_logAdImpression($row['bannerid'], $zoneid); } // Redirect to the banner MAX_cookieAdd($conf['var']['vars'] . "[{$n}]", serialize($cookie)); MAX_cookieFlush(); if ($row['bannerid'] == '') { if ($row['default_banner_image_url'] != '') { // Show default banner image url MAX_redirect($row['default_banner_image_url']); } else { // Show 1x1 Gif, to ensure not broken image icon is shown. MAX_commonDisplay1x1(); } } else { MAX_redirect($creativeURL); } } else { MAX_cookieAdd($conf['var']['vars'] . "[{$n}]", 'DEFAULT'); MAX_cookieFlush(); // Show 1x1 Gif, to ensure not broken image icon is shown. MAX_commonDisplay1x1(); } // Run automaintenance, if needed if (!empty($GLOBALS['_MAX']['CONF']['maintenance']['autoMaintenance']) && empty($GLOBALS['_MAX']['CONF']['lb']['enabled'])) { if (MAX_cacheCheckIfMaintenanceShouldRun()) { include MAX_PATH . '/lib/OA/Maintenance/Auto.php'; OA_Maintenance_Auto::run(); } }
/** * This is the main ad selection and rendering function * * @param string $what The ad-selection string, colon seperated name=value * e.g. bannerid=X, campaignid=Y, zone:Z or search:criteria * @param string $campaignid The campaign ID to fecth banners from, added in 2.3.32 to allow BC with 2.0 * @param string $target The target attribute for generated <a href> links * @param string $source The "source" parameter passed into the adcall * @param int $withtext Should "text below banner" be appended to the generated code * @param array $context The context of this ad selection * - used for companion positioning * - and excluding banner/campaigns from this ad-call * @param boolean $richmedia Does this invocation method allow for serving 3rd party/html ads * @param string $ct0 The 3rd party click tracking URL to redirect to after logging * @param string $loc The "current page" URL * @param string $referer The "referring page" URL * * @return array An array containing selected banner information, including generated HTML * example: * Array * ( * [html] => * <div id='m3_7e8d56ca8e5231613e0c41ab149b8cab' style='display: inline;'><a href='http://d.dev.m3.net/ck.php?maxparams=2__bannerid=123__zoneid=567__cb=7ff857d85a' target='_blank'><img src='http://max.images.example.net/backup_banner_468x60.gif' width='468' height='60' alt='' title='' border='0'></a></div> * <script type='text/javascript'> * var fo = new FlashObject('http://max.images.example.net/banner_468x60.swf?clickTARGET=_blank&clickTAG=http://delivery.max.example.com/ck.php?maxparams=2__bannerid=123__zoneid=567__cb=7ff857d85a', 'mymovie', '468', '60', '6'); * //fo.addParam('wmode','transparent'); * fo.write('m3_7e8d56ca8e5231613e0c41ab149b8cab'); * </script><div id='beacon_123' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http://delivery.max.example.com/lg.php?bannerid=123&campaignid=4&zoneid=567&source=&block=0&capping=0&session_capping=0&loc=http%3A%2F%2Flocalhost%2Ftest%2Finvocationh.html&referer=http%3A%2F%2Flocalhost%2Ftest%2F&cb=7ff857d85a' width='0' height='0' alt='' style='width: 0px; height: 0px;'></div> * [bannerid] => 123 * [contenttype] => swf * [alt] => * [width] => 468 * [height] => 60 * [url] => http://www.example.net/landing_page/ * [campaignid] => 4 * [context] => Array * ( * ) * ) */ function MAX_adSelect($what, $campaignid = '', $target = '', $source = '', $withtext = 0, $charset = '', $context = array(), $richmedia = true, $ct0 = '', $loc = '', $referer = '') { $conf = $GLOBALS['_MAX']['CONF']; // For local mode and XML-RPC calls the some parameters are not set in the global scope // So we need to override the empty globals with the values passed into this function. if (empty($GLOBALS['source'])) { $GLOBALS['source'] = $source; } if (empty($GLOBALS['loc'])) { $GLOBALS['loc'] = $loc; } // Store the original zone, campaign or banner IDs for later use $originalZoneId = null; if (strpos($what, 'zone:') === 0) { $originalZoneId = intval(substr($what, 5)); } elseif (strpos($what, 'campaignid:') === 0) { $originalCampaignId = intval(substr($what, 11)); } elseif (strpos($what, 'bannerid:') === 0) { $originalBannerId = intval(substr($what, 9)); } $userid = MAX_cookieGetUniqueViewerID(); MAX_cookieAdd($conf['var']['viewerId'], $userid, _getTimeYearFromNow()); $outputbuffer = ''; // Set flag $found = false; // Reset followed zone chain $GLOBALS['_MAX']['followedChain'] = array(); $GLOBALS['_MAX']['adChain'] = array(); // Reset considered ads set $GLOBALS['_MAX']['considered_ads'] = array(); $first = true; global $g_append, $g_prepend; $g_append = ''; $g_prepend = ''; if (!empty($what)) { while ($first || $what != '' && $found == false) { $first = false; // Get first part, store second part $ix = strpos($what, '|'); if ($ix === false) { $remaining = ''; } else { $remaining = substr($what, $ix + 1); $what = substr($what, 0, $ix); } if (strpos($what, 'zone:') === 0) { $zoneId = intval(substr($what, 5)); $row = _adSelectZone($zoneId, $context, $source, $richmedia); } else { // Expand paths to regular statements if (strpos($what, '/') > 0) { if (strpos($what, '@') > 0) { list($what, $append) = explode('@', $what); } else { $append = ''; } $separate = explode('/', $what); $expanded = ''; $collected = array(); reset($separate); while (list(, $v) = each($separate)) { $expanded .= ($expanded != '' ? ',+' : '') . $v; $collected[] = $expanded . ($append != '' ? ',+' . $append : ''); } $what = strtok(implode('|', array_reverse($collected)), '|'); $remaining = strtok('') . ($remaining != '' ? '|' . $remaining : ''); } $row = _adSelectDirect($what, $campaignid, $context, $source, $richmedia, $remaining == ''); } if (is_array($row) && empty($row['default'])) { // Log the ad request MAX_Delivery_log_logAdRequest($row['bannerid'], $row['zoneid'], $row); if (($row['adserver'] == 'max' || $row['adserver'] == '3rdPartyServers:ox3rdPartyServers:max') && preg_match("#{$conf['webpath']['delivery']}.*zoneid=([0-9]+)#", $row['htmltemplate'], $matches) && !stristr($row['htmltemplate'], $conf['file']['popup'])) { // The ad selected was an OpenX HTML ad on the same server... do internal redirecty stuff $GLOBALS['_MAX']['adChain'][] = $row; $found = false; $what = "zone:{$matches[1]}"; } else { $found = true; } } else { // Log the ad request MAX_Delivery_log_logAdRequest(null, $originalZoneId, null); $what = $remaining; } } } // Return the banner information if ($found) { $zoneId = empty($row['zoneid']) ? 0 : $row['zoneid']; // For internal redirected creatives, make sure that any appended code in the adChain is appended if (!empty($GLOBALS['_MAX']['adChain'])) { foreach ($GLOBALS['_MAX']['adChain'] as $index => $ad) { if ($ad['ad_id'] != $row['ad_id'] && !empty($ad['append'])) { $row['append'] .= $ad['append']; } } } $outputbuffer = MAX_adRender($row, $zoneId, $source, $target, $ct0, $withtext, $charset, true, true, $richmedia, $loc, $referer, $context); $output = array('html' => $outputbuffer, 'bannerid' => $row['bannerid'], 'contenttype' => $row['contenttype'], 'alt' => $row['alt'], 'width' => $row['width'], 'height' => $row['height'], 'url' => $row['url'], 'campaignid' => $row['campaignid'], 'clickUrl' => $row['clickUrl'], 'logUrl' => $row['logUrl'], 'aSearch' => $row['aSearch'], 'aReplace' => $row['aReplace'], 'bannerContent' => $row['bannerContent'], 'clickwindow' => $row['clickwindow'], 'aRow' => $row, 'context' => _adSelectBuildContext($row, $context)); // Init block/capping fields to avoid notices below $row += array('block_ad' => 0, 'cap_ad' => 0, 'session_cap_ad' => 0, 'block_campaign' => 0, 'cap_campaign' => 0, 'session_cap_campaign' => 0, 'block_zone' => 0, 'cap_zone' => 0, 'session_cap_zone' => 0); // If ad-logging is disabled, the log beacon won't be sent, so set the capping at request if (MAX_Delivery_cookie_cappingOnRequest()) { if ($row['block_ad'] > 0 || $row['cap_ad'] > 0 || $row['session_cap_ad'] > 0) { MAX_Delivery_cookie_setCapping('Ad', $row['bannerid'], $row['block_ad'], $row['cap_ad'], $row['session_cap_ad']); } if ($row['block_campaign'] > 0 || $row['cap_campaign'] > 0 || $row['session_cap_campaign'] > 0) { MAX_Delivery_cookie_setCapping('Campaign', $row['campaign_id'], $row['block_campaign'], $row['cap_campaign'], $row['session_cap_campaign']); } if ($row['block_zone'] > 0 || $row['cap_zone'] > 0 || $row['session_cap_zone'] > 0) { MAX_Delivery_cookie_setCapping('Zone', $row['zoneid'], $row['block_zone'], $row['cap_zone'], $row['session_cap_zone']); } // Store the last view action event om the cookie as well (if required) MAX_Delivery_log_setLastAction(0, array($row['bannerid']), array($zoneId), array($row['viewwindow'])); } } else { // No banner found if (!empty($row['default'])) { // Return the default banner if (empty($target)) { $target = '_blank'; // Default } $outputbuffer = $g_prepend . '<a href=\'' . $row['default_banner_destination_url'] . '\' target=\'' . $target . '\'><img src=\'' . $row['default_banner_image_url'] . '\' border=\'0\' alt=\'\'></a>' . $g_append; $output = array('html' => $outputbuffer, 'bannerid' => '', 'default_banner_image_url' => $row['default_banner_image_url']); } else { if (!empty($conf['defaultBanner']['imageUrl'])) { // Return the default banner if (empty($target)) { $target = '_blank'; // Default } $outputbuffer = "{$g_prepend}<img src='{$conf['defaultBanner']['imageUrl']}' border='0' alt=''>{$g_append}"; $output = array('html' => $outputbuffer, 'bannerid' => '', 'default_banner_image_url' => $conf['defaultBanner']['imageUrl']); } else { // No default banner was returned, return no banner $outputbuffer = $g_prepend . $g_append; $output = array('html' => $outputbuffer, 'bannerid' => ''); } } } // post adSelect hook OX_Delivery_Common_hook('postAdSelect', array(&$output)); return $output; }
$banner = MAX_adSelect($what, $campaignid, $target, $source, $withtext, $charset, $context, true, $ct0, $loc, $referer); // Send cookie if needed if (!empty($banner['html']) && !empty($n)) { // Send bannerid headers $cookie = array(); $cookie[$conf['var']['adId']] = $banner['bannerid']; // Send zoneid headers if ($zoneid != 0) { $cookie[$conf['var']['zoneId']] = $zoneid; } // Send source headers if (!empty($source)) { $cookie[$conf['var']['channel']] = $source; } // Set the cookie MAX_cookieAdd($conf['var']['vars'] . "[{$n}]", serialize($cookie)); } MAX_cookieFlush(); MAX_commonSendContentTypeHeader('text/html', $charset); // Rewrite targets in HTML code to make sure they are // local to the parent and not local to the iframe if (isset($rewrite) && $rewrite == 1) { $banner['html'] = preg_replace('#target\\s*=\\s*([\'"])_parent\\1#i', "target='_top'", $banner['html']); $banner['html'] = preg_replace('#target\\s*=\\s*([\'"])_self\\1#i', "target='_parent'", $banner['html']); } // Build HTML $outputHtml = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"; $outputHtml .= "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"; $outputHtml .= "<head>\n"; $outputHtml .= "<title>" . (!empty($banner['alt']) ? $banner['alt'] : 'Advertisement') . "</title>\n"; // Include the FlashObject script if required