本文整理汇总了PHP中MAX_cacheGetAd函数的典型用法代码示例。如果您正苦于以下问题:PHP MAX_cacheGetAd函数的具体用法?PHP MAX_cacheGetAd怎么用?PHP MAX_cacheGetAd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAX_cacheGetAd函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MAX_querystringGetDestinationUrl
function MAX_querystringGetDestinationUrl($adId = null)
{
$conf = $GLOBALS['_MAX']['CONF'];
$dest = isset($_REQUEST[$conf['var']['dest']]) ? $_REQUEST[$conf['var']['dest']] : '';
if (empty($dest) && !empty($adId)) {
// Get the destination from the banner
$aAd = MAX_cacheGetAd($adId);
if (!empty($aAd)) {
$dest = $aAd['url'];
}
}
// If no destination URL has been found by now, then we don't need to redirect
if (empty($dest)) {
return;
}
$aVariables = array();
$aValidVariables = array_values($conf['var']);
// See if any plugin-components have added items to the click url...
$componentParams = OX_Delivery_Common_hook('addUrlParams', array(array('bannerid' => $adId)));
if (!empty($componentParams) && is_array($componentParams)) {
foreach ($componentParams as $params) {
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
$aValidVariables[] = $key;
}
}
}
}
// We also need to ensure that any variables already present in the dest are not duplicated...
$destParams = parse_url($dest);
if (!empty($destParams['query'])) {
$destQuery = explode('&', $destParams['query']);
if (!empty($destQuery)) {
foreach ($destQuery as $destPair) {
list($destName, $destValue) = explode('=', $destPair);
$aValidVariables[] = $destName;
}
}
}
foreach ($_GET as $name => $value) {
if (!in_array($name, $aValidVariables)) {
$aVariables[] = $name . '=' . $value;
}
}
foreach ($_POST as $name => $value) {
if (!in_array($name, $aValidVariables)) {
$aVariables[] = $name . '=' . $value;
}
}
if (!empty($aVariables)) {
$dest .= (strpos($dest, '?') > 0 ? '&' : '?') . implode('&', $aVariables);
}
return $dest;
}
示例2: _adSelect
//.........这里部分代码省略.........
}
}
if ($used_priority >= 1) {
return $GLOBALS['OX_adSelect_SkipOtherPriorityLevels'];
}
$remaining_priority = 1 - $used_priority;
$total_priority_orig = 0;
foreach ($aAds as $ad) {
$total_priority_orig += $ad['priority'] * $ad['priority_factor'];
}
$aLinkedAdInfos['priority_used'][$adArrayVar][$i] = $total_priority_orig;
if ($total_priority_orig <= 0) {
return;
}
if ($total_priority_orig > $remaining_priority || $companion) {
$scaling_denom = $total_priority_orig;
if ($cp >= PRI_ECPM_FROM && $cp <= PRI_ECPM_TO && !empty($conf['delivery']['ecpmSelectionRate'])) {
$selection_rate = floatval($conf['delivery']['ecpmSelectionRate']);
if (!_controlTrafficEnabled($aAds) || mt_rand(0, $GLOBALS['_MAX']['MAX_RAND']) / $GLOBALS['_MAX']['MAX_RAND'] <= $selection_rate) {
$GLOBALS['_MAX']['ECPM_SELECTION'] = 1;
foreach ($aAds as $key => $ad) {
$ecpms[] = $ad['ecpm'];
$adids[] = $key;
}
array_multisort($ecpms, SORT_DESC, $adids);
$p_avail = $remaining_priority;
$ad_count = count($aAds);
$i = 0;
while ($i < $ad_count) {
$l = $i;
while ($l < $ad_count - 1 && $ecpms[$l + 1] == $ecpms[$i]) {
$l++;
}
$p_needed = 0;
for ($a_idx = $i; $a_idx <= $l; $a_idx++) {
$id = $adids[$a_idx];
$p_needed += $aAds[$id]['priority'] * $aAds[$id]['priority_factor'];
}
if ($p_needed > $p_avail) {
$scale = $p_avail / $p_needed;
for ($a_idx = $i; $a_idx <= $l; $a_idx++) {
$id = $adids[$a_idx];
$aAds[$id]['priority'] = $aAds[$id]['priority'] * $scale;
}
$p_avail = 0;
for ($a_idx = $l + 1; $a_idx < $ad_count; $a_idx++) {
$id = $adids[$a_idx];
$aAds[$id]['priority'] = 0;
}
break;
} else {
$p_avail -= $p_needed;
$i = $l + 1;
}
}
$scaling_denom = $remaining_priority;
} else {
$GLOBALS['_MAX']['ECPM_CONTROL'] = 1;
}
}
$scaling_factor = 1 / $scaling_denom;
} else {
$scaling_factor = 1 / $remaining_priority;
}
$total_priority = 0;
foreach ($aAds as $key => $ad) {
$newPriority = $ad['priority'] * $ad['priority_factor'] * $scaling_factor;
$aAds[$key]['priority'] = $newPriority;
$total_priority += $newPriority;
}
} else {
$total_priority = _setPriorityFromWeights($aAds);
}
}
global $n;
mt_srand(floor((isset($n) && strlen($n) > 5 ? hexdec($n[0] . $n[2] . $n[3] . $n[4] . $n[5]) : 1000000) * (double) microtime()));
$conf = $GLOBALS['_MAX']['CONF'];
$random_num = mt_rand(0, $GLOBALS['_MAX']['MAX_RAND']) / $GLOBALS['_MAX']['MAX_RAND'];
if ($random_num > $total_priority) {
return;
}
$low = 0;
$high = 0;
foreach ($aAds as $aLinkedAd) {
if (!empty($aLinkedAd['priority'])) {
$low = $high;
$high += $aLinkedAd['priority'];
if ($high > $random_num && $low <= $random_num) {
$ad = MAX_cacheGetAd($aLinkedAd['ad_id']);
$ad['tracker_status'] = !empty($aLinkedAd['tracker_status']) ? $aLinkedAd['tracker_status'] : null;
if ($ad['width'] == $ad['height'] && $ad['width'] == -1) {
$ad['width'] = $aLinkedAd['width'];
$ad['height'] = $aLinkedAd['height'];
}
return $ad;
}
}
}
return;
}
示例3: test_invalidateBannerCache
/**
* Method tests invalidateBannerCache method
*/
function test_invalidateBannerCache()
{
$cachedData = MAX_cacheGetAd($this->_aIds['banners'][0]);
$zoneLinkingCachedData = MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][0]);
// Change something in banner
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->get($this->_aIds['banners'][0]);
$doBanners->description = 'new description';
$doBanners->update();
// Expect no changes in cache
$this->assertEqual(MAX_cacheGetAd($this->_aIds['banners'][0]), $cachedData);
$this->assertEqual(MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][0]), $zoneLinkingCachedData);
$this->oDeliveryCacheManager->invalidateBannerCache($this->_aIds['banners'][0]);
// Now expect changes in cache
$this->assertNotEqual(MAX_cacheGetAd($this->_aIds['banners'][0]), $cachedData);
$this->assertNotEqual(MAX_cacheGetZoneLinkedAds($this->_aIds['zones'][0]), $zoneLinkingCachedData);
}
示例4: MAX_commonSendContentTypeHeader
require_once MAX_PATH . '/lib/max/Delivery/cache.php';
MAX_commonSendContentTypeHeader('text/html');
//Register any script specific input variables
MAX_commonRegisterGlobalsArray(array('timeout'));
$timeout = !empty($timeout) ? $timeout : 0;
if ($zoneid > 0) {
// Get the zone from cache
$aZone = MAX_cacheGetZoneInfo($zoneid);
} else {
// Direct selection, or problem with admin DB
$aZone = array();
$aZone['zoneid'] = $zoneid;
$aZone['append'] = '';
$aZone['prepend'] = '';
}
// Get the banner from cache
$aBanner = MAX_cacheGetAd($bannerid);
$prepend = !empty($aZone['prepend']) ? $aZone['prepend'] : '';
$html = MAX_adRender($aBanner, $zoneid, $source, $target, $ct0, $withtext);
$append = !empty($aZone['append']) ? $aZone['append'] : '';
$title = !empty($aBanner['alt']) ? $aBanner['alt'] : 'Advertisement';
echo "\n<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n<head>\n<title>{$title}</title>";
if ($timeout > 0) {
$timeoutMs = $timeout * 1000;
echo "\n<script type='text/javascript'>\n<!--// <![CDATA[\n window.setTimeout(\"window.close()\",{$timeoutMs});\n// ]]> -->\n</script>";
}
// Include the FlashObject script if required
if ($aBanner['contenttype'] == 'swf') {
echo MAX_flashGetFlashObjectExternal();
}
echo "\n<style type='text/css'>\nbody {margin:0; height:100%; width:100%}\n</style>\n</head>\n<body>\n{$prepend}{$html}{$append}\n</body>\n</html>";
示例5: _createTestCacheFiles
/**
* Creates all possible delivert cache files
*
* @param array $aIds array of DB Ids returned by _createTestData
* @see _createTestData
*/
function _createTestCacheFiles($aIds)
{
// Create cache files not related to DB Objects
MAX_cacheGetAccountTZs();
MAX_cacheCheckIfMaintenanceShouldRun();
MAX_cacheGetGoogleJavaScript();
// Create cache files for banners and images
foreach ($aIds['banners'] as $bannerId) {
MAX_cacheGetAd($bannerId);
}
foreach ($aIds['images'] as $filename) {
MAX_cacheGetCreative($filename);
}
// Create cache files for zones
foreach ($aIds['zones'] as $zoneId) {
MAX_cacheGetZoneLinkedAds($zoneId);
MAX_cacheGetZoneInfo($zoneId);
}
// Create cache files for websites
foreach ($aIds['affiliates'] as $affiliateid) {
OA_cacheGetPublisherZones($affiliateid);
}
// Create cache files for trackers
foreach ($aIds['trackers'] as $trackerid) {
MAX_cacheGetTracker($trackerid);
MAX_cacheGetTrackerVariables($trackerid);
}
// Create cache files for channels
foreach ($aIds['channel'] as $channelid) {
MAX_cacheGetChannelLimitations($channelid);
}
// cache files for direct-selection are not created
// due to problems with invalidating MAX_cacheGetLinkedAds
}
示例6: _adSelect
//.........这里部分代码省略.........
}
// how much priority space does this range of equal eCPM ads require?
$p_needed = 0;
for ($a_idx = $i; $a_idx <= $l; $a_idx++) {
$id = $adids[$a_idx];
$p_needed += $aAds[$id]['priority'] * $aAds[$id]['priority_factor'];
}
// if this range needs more priority space than is left, we'll scale
// these and zero out all ads with lower eCPM values
if ($p_needed > $p_avail) {
$scale = $p_avail / $p_needed;
for ($a_idx = $i; $a_idx <= $l; $a_idx++) {
$id = $adids[$a_idx];
$aAds[$id]['priority'] = $aAds[$id]['priority'] * $scale;
}
$p_avail = 0;
// zero out remaining ads priorities
for ($a_idx = $l + 1; $a_idx < $ad_count; $a_idx++) {
$id = $adids[$a_idx];
$aAds[$id]['priority'] = 0;
}
break;
} else {
$p_avail -= $p_needed;
$i = $l + 1;
}
}
$scaling_denom = $remaining_priority;
} else {
// set flag to indicate this request was eligible for ecpm optimization,
// but did not apply it in order to serve a control result set
$GLOBALS['_MAX']['ECPM_CONTROL'] = 1;
}
}
// scaling_denom is either remaining_priority or total_priority_orig, both of which
// have been guarded against being 0, so there's no risk of div by 0 here
$scaling_factor = 1 / $scaling_denom;
} else {
// in this case, we don't need to use the whole of the remaining
// space, but we scale to the remaining size, which leaves room to
// select a lower level, since $total_priority_orig / $remaining_priority < 1
$scaling_factor = 1 / $remaining_priority;
}
// recalculate the priorities (in place??), using the scaling factor.
$total_priority = 0;
foreach ($aAds as $key => $ad) {
$newPriority = $ad['priority'] * $ad['priority_factor'] * $scaling_factor;
$aAds[$key]['priority'] = $newPriority;
$total_priority += $newPriority;
}
} else {
// Rescale priorities by weights
$total_priority = _setPriorityFromWeights($aAds);
}
}
// Seed the random number generator
global $n;
mt_srand(floor((isset($n) && strlen($n) > 5 ? hexdec($n[0] . $n[2] . $n[3] . $n[4] . $n[5]) : 1000000) * (double) microtime()));
$conf = $GLOBALS['_MAX']['CONF'];
// Pick a float random number between 0 and 1, inclusive.
$random_num = mt_rand(0, $GLOBALS['_MAX']['MAX_RAND']) / $GLOBALS['_MAX']['MAX_RAND'];
###START_STRIP_DELIVERY
// testing support
if (function_exists('test_mt_rand')) {
$random_num = test_mt_rand(0, $GLOBALS['_MAX']['MAX_RAND']) / $GLOBALS['_MAX']['MAX_RAND'];
}
###END_STRIP_DELIVERY
// Is it higher than the sum of all the priority values?
if ($random_num > $total_priority) {
// No suitable ad found, proceed as usual
return;
}
// Perform selection of an ad, based on the random number
$low = 0;
$high = 0;
foreach ($aAds as $aLinkedAd) {
if (!empty($aLinkedAd['priority'])) {
$low = $high;
$high += $aLinkedAd['priority'];
if ($high > $random_num && $low <= $random_num) {
###START_STRIP_DELIVERY
// testing support
if (function_exists('test_MAX_cacheGetAd')) {
return test_MAX_cacheGetAd($aLinkedAd['ad_id']);
}
###END_STRIP_DELIVERY
$ad = MAX_cacheGetAd($aLinkedAd['ad_id']);
// Carry over for conversion tracking
$ad['tracker_status'] = !empty($aLinkedAd['tracker_status']) ? $aLinkedAd['tracker_status'] : null;
// Carry over for ad dimensions for market ads
if ($ad['width'] == $ad['height'] && $ad['width'] == -1) {
$ad['width'] = $aLinkedAd['width'];
$ad['height'] = $aLinkedAd['height'];
}
return $ad;
}
}
}
return;
}
示例7: array
$entityId = OA_Permission::getEntityId();
if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) {
$entityType = 'advertiser_id';
} else {
$entityType = 'agency_id';
}
// Display navigation
$aOtherCampaigns = Admin_DA::getPlacements(array($entityType => $entityId));
$aOtherBanners = Admin_DA::getAds(array('placement_id' => $campaignid), false);
// Setup a fake record for the "Apply to all" entry
$aOtherBanners[-1] = array('name' => '--' . $GLOBALS['strAllBannersInCampaign'] . '--', 'ad_id' => -1, 'placement_id' => $campaignid);
MAX_displayNavigationBanner($pageName, $aOtherCampaigns, $aOtherBanners, $aEntities);
/*-------------------------------------------------------*/
/* Main code */
/*-------------------------------------------------------*/
$aBanner = MAX_cacheGetAd($bannerid, false);
if (!isset($acl)) {
$acl = Admin_DA::getDeliveryLimitations(array('ad_id' => $bannerid));
// This array needs to be sorted by executionorder, this should ideally be done in SQL
// When we move to DataObject this should be addressed
ksort($acl);
}
$aParams = array('clientid' => $clientid, 'campaignid' => $campaignid, 'bannerid' => $bannerid);
MAX_displayAcls($acl, $aParams);
echo "\n<table border='0' width='100%' cellpadding='0' cellspacing='0' bgcolor='#FFFFFF'>";
$aParams = array('title' => $GLOBALS['strCampaign'], 'titleLink' => "campaign-edit.php?clientid={$clientid}&campaignid={$campaignid}", 'aText' => $GLOBALS['strCappingCampaign'], 'aCappedObject' => $aBanner, 'type' => 'Campaign');
$tabindex = _echoDeliveryCappingHtml($tabindex, $GLOBALS['strCappingBanner'], $aBanner, 'Ad', $aParams);
echo "\n<tr><td height='1' colspan='6' bgcolor='#888888'>\n<img src='" . OX::assetPath() . "/images/break.gif' height='1' width='100%'></td></tr>\n\n</table>\n<br /><br /><br />\n<input type='submit' name='submit' value='{$GLOBALS['strSaveChanges']}' tabindex='" . $tabindex++ . "'>\n\n</form>";
/*-------------------------------------------------------*/
/* Form requirements */
/*-------------------------------------------------------*/
示例8: test_invalidateGetAdCache
/**
* Method tests invalidateGetAdCache method
*/
function test_invalidateGetAdCache()
{
$aIds = $this->_createTestData();
$this->_createTestCacheFiles($aIds);
$cachedData = MAX_cacheGetAd($aIds['banners'][0]);
// Change something in banner
$doBanners = OA_Dal::factoryDO('banners');
$doBanners->get($aIds['banners'][0]);
$doBanners->description = 'new description';
$doBanners->update();
// Expect no changes in cache
$this->assertEqual(MAX_cacheGetAd($aIds['banners'][0]), $cachedData);
$this->oDeliveryCacheCommon->invalidateGetAdCache($aIds['banners'][0]);
// Now expect changes in cache
$this->assertNotEqual(MAX_cacheGetAd($aIds['banners'][0]), $cachedData);
}