当前位置: 首页>>代码示例>>PHP>>正文


PHP _adSelectCommon函数代码示例

本文整理汇总了PHP中_adSelectCommon函数的典型用法代码示例。如果您正苦于以下问题:PHP _adSelectCommon函数的具体用法?PHP _adSelectCommon怎么用?PHP _adSelectCommon使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_adSelectCommon函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_adSelect2


//.........这里部分代码省略.........
     $context = "";
     // case 8: priority_used limit reached
     $ads_copy = $test_ads;
     $ads_copy['priority_used']['ads'][9] = 0.5;
     $ads_copy['priority_used']['ads'][8] = 0.3;
     $ads_copy['priority_used']['ads'][6] = 0.3;
     // this will return -1, since we've already used the entire priority space
     $GLOBALS['rand_val'] = 0.51;
     $return = _adSelect($ads_copy, $context, $source, $richMedia, false, 'ads', 5);
     $this->assertEqual($return, $GLOBALS['OX_adSelect_SkipOtherPriorityLevels']);
     $this->assertTrue(!isset($ads_copy['priority_used']['ads'][5]));
     // case 9: cp5, 2 ads both 0.5, cp4, 2 ads both 0.2
     // one of the cp5 ads will be filtered out
     $ads_copy = $test_ads;
     $ads_copy['ads'][5][1022]['priority'] = 0;
     $ads_copy['ads'][5][1024]['priority'] = 0;
     // this will not pick from cp5 due to the ad exclusion
     $GLOBALS['rand_val'] = 0.51;
     $return = _adSelect($ads_copy, $context, $source, $richMedia, false, 'ads', 5);
     $this->assertNull($return);
     $this->assertEqual($ads_copy['priority_used']['ads'][5], 0);
     // case 10: cp5, 2 ads both 0.7, cp4, 2 ads both 0.2
     // cp5 ad will win, but confirm that the cp4 ads will be filtered
     $ads_copy = $test_ads;
     $ads_copy['ads'][5][1022]['priority'] = 0.7;
     $ads_copy['ads'][5][1024]['priority'] = 0.7;
     $ads_copy['ads'][4][1122]['priority'] = 0.2;
     $ads_copy['ads'][4][1124]['priority'] = 0.2;
     $context = array(array('!=' => 'bannerid:1124'));
     $GLOBALS['_MAX']['considered_ads'] = array();
     // this will not pick from cp5 due to the ad exclusion
     $GLOBALS['rand_val'] = 0.51;
     $GLOBALS['test_MAX_cacheGetAd_val'] = $ads_copy['ads'][5];
     $return = _adSelectCommon($ads_copy, $context, $source, $richMedia);
     $this->assertNotNull($return);
     $ads_ret =& $GLOBALS['_MAX']['considered_ads'][0];
     $this->assertEqual($ads_ret['priority_used']['ads'][5], (double) 1.4);
     $this->assertFalse(isset($ads_ret['ads'][4][1124]));
     $this->assertTrue(isset($ads_ret['ads'][4][1122]));
     // case 11: cp5, 2 ads both 0.7, ecpm enabled
     $GLOBALS['_MAX']['CONF']['delivery']['ecpmSelectionRate'] = 1;
     $ads_copy = $test_ads;
     $ads_copy['ads'][6] = $ads_copy['ads'][5];
     $ads_copy['ads'][6][1022]['priority'] = 0.7;
     $ads_copy['ads'][6][1022]['ecpm_enabled'] = 1;
     $ads_copy['ads'][6][1022]['ecpm'] = 2.0;
     $ads_copy['ads'][6][1024]['priority'] = 0.7;
     $ads_copy['ads'][6][1024]['ecpm_enabled'] = 1;
     $ads_copy['ads'][6][1024]['ecpm'] = 0.5;
     $GLOBALS['test_MAX_cacheGetAd_val'] = $ads_copy['ads'][6];
     $context = '';
     // after ecpm optimization, the priorities should be
     //   [1022] = 0.7 => 0.7
     //   [1024] = 0.7 => 0.3
     //
     // this should pick the first one
     $GLOBALS['rand_val'] = 0.49;
     $return = _adSelect($ads_copy, $context, $source, $richMedia, false, 'ads', 6);
     $this->assertTrue(array_key_exists($return['ad_id'], $ads_copy['ads'][6]));
     $this->assertEqual($return['ad_id'], 1022);
     $this->assertTrue($ads_copy['priority_used']['ads'][6] >= 1);
     $ads_copy = $test_ads;
     $ads_copy['ads'][6] = $ads_copy['ads'][5];
     $ads_copy['ads'][6][1022]['priority'] = 0.7;
     $ads_copy['ads'][6][1022]['ecpm_enabled'] = 1;
     $ads_copy['ads'][6][1022]['ecpm'] = 2.0;
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:67,代码来源:adSelect.del.test.php

示例2: _adSelectZone

function _adSelectZone($zoneId, $context = array(), $source = '', $richMedia = true)
{
    if ($zoneId === 0) {
        return false;
    }
    global $g_append, $g_prepend;
    while (!in_array($zoneId, $GLOBALS['_MAX']['followedChain'])) {
        $GLOBALS['_MAX']['followedChain'][] = $zoneId;
        $appendedThisZone = false;
        $aZoneInfo = MAX_cacheGetZoneInfo($zoneId);
        if (empty($aZoneInfo)) {
            return false;
        }
        if ($zoneId != 0 && MAX_limitationsIsZoneForbidden($zoneId, $aZoneInfo)) {
            $zoneId = _getNextZone($zoneId, $aZoneInfo);
            continue;
        }
        $aZoneLinkedAdInfos = MAX_cacheGetZoneLinkedAdInfos($zoneId);
        if (is_array($aZoneInfo)) {
            if (isset($aZoneInfo['forceappend']) && $aZoneInfo['forceappend'] == 't') {
                $g_prepend .= $aZoneInfo['prepend'];
                $g_append = $aZoneInfo['append'] . $g_append;
                $appendedThisZone = true;
            }
            $aZoneLinkedAdInfos += $aZoneInfo;
            $aLinkedAd = _adSelectCommon($aZoneLinkedAdInfos, $context, $source, $richMedia);
            if (is_array($aLinkedAd)) {
                $aLinkedAd['zoneid'] = $zoneId;
                $aLinkedAd['bannerid'] = $aLinkedAd['ad_id'];
                $aLinkedAd['storagetype'] = $aLinkedAd['type'];
                $aLinkedAd['campaignid'] = $aLinkedAd['placement_id'];
                $aLinkedAd['zone_companion'] = $aZoneLinkedAdInfos['zone_companion'];
                $aLinkedAd['block_zone'] = @$aZoneInfo['block_zone'];
                $aLinkedAd['cap_zone'] = @$aZoneInfo['cap_zone'];
                $aLinkedAd['session_cap_zone'] = @$aZoneInfo['session_cap_zone'];
                $aLinkedAd['affiliate_id'] = @$aZoneInfo['publisher_id'];
                if (!$appendedThisZone) {
                    $aLinkedAd['append'] .= @$aZoneInfo['append'] . $g_append;
                    $aLinkedAd['prepend'] = $g_prepend . @$aZoneInfo['prepend'] . $aLinkedAd['prepend'];
                } else {
                    $aLinkedAd['append'] .= $g_append;
                    $aLinkedAd['prepend'] = $g_prepend . $aLinkedAd['prepend'];
                }
                return $aLinkedAd;
            }
            $zoneId = _getNextZone($zoneId, $aZoneInfo);
        }
    }
    if (!empty($aZoneInfo['default_banner_image_url'])) {
        return array('default' => true, 'default_banner_image_url' => $aZoneInfo['default_banner_image_url'], 'default_banner_destination_url' => $aZoneInfo['default_banner_destination_url']);
    }
    return false;
}
开发者ID:hawodi,项目名称:revive-adserver,代码行数:53,代码来源:al.php

示例3: _adSelectZone

/**
 * This function selects an ad selected from a specific zone
 *
 * @param int     $zoneId       The ID of the zone to select an ad from
 * @param array   $context      The context of this ad selection
 *                              - used for companion positioning
 *                              - and excluding banner/campaigns from this ad-call
 * @param string  $source       The "source" parameter passed into the adcall
 * @param boolean $richMedia    Does this invocation method allow for serving 3rd party/html ads
 *
 * @return array|false          Returns an ad-array (see page DocBlock) or false if no ad found
 */
function _adSelectZone($zoneId, $context = array(), $source = '', $richMedia = true)
{
    // ZoneID zero is used for direct selected adRequests only
    if ($zoneId === 0) {
        return false;
    }
    global $g_append, $g_prepend;
    while (!in_array($zoneId, $GLOBALS['_MAX']['followedChain'])) {
        $GLOBALS['_MAX']['followedChain'][] = $zoneId;
        $appendedThisZone = false;
        // first get zone info
        $aZoneInfo = MAX_cacheGetZoneInfo($zoneId);
        if (empty($aZoneInfo)) {
            // the zone does not exist, sorry!
            return false;
        }
        //check zone level limitations
        if ($zoneId != 0 && MAX_limitationsIsZoneForbidden($zoneId, $aZoneInfo)) {
            $zoneId = _getNextZone($zoneId, $aZoneInfo);
            continue;
        }
        // Get all ads which are linked to the zone
        $aZoneLinkedAdInfos = MAX_cacheGetZoneLinkedAdInfos($zoneId);
        if (is_array($aZoneInfo)) {
            if (isset($aZoneInfo['forceappend']) && $aZoneInfo['forceappend'] == 't') {
                $g_prepend .= $aZoneInfo['prepend'];
                $g_append = $aZoneInfo['append'] . $g_append;
                $appendedThisZone = true;
            }
            // merge zone info and banner info
            $aZoneLinkedAdInfos += $aZoneInfo;
            $aLinkedAd = _adSelectCommon($aZoneLinkedAdInfos, $context, $source, $richMedia);
            if (is_array($aLinkedAd)) {
                $aLinkedAd['zoneid'] = $zoneId;
                $aLinkedAd['bannerid'] = $aLinkedAd['ad_id'];
                $aLinkedAd['storagetype'] = $aLinkedAd['type'];
                $aLinkedAd['campaignid'] = $aLinkedAd['placement_id'];
                $aLinkedAd['zone_companion'] = $aZoneLinkedAdInfos['zone_companion'];
                $aLinkedAd['block_zone'] = @$aZoneInfo['block_zone'];
                $aLinkedAd['cap_zone'] = @$aZoneInfo['cap_zone'];
                $aLinkedAd['session_cap_zone'] = @$aZoneInfo['session_cap_zone'];
                $aLinkedAd['affiliate_id'] = @$aZoneInfo['publisher_id'];
                if (!$appendedThisZone) {
                    $aLinkedAd['append'] .= @$aZoneInfo['append'] . $g_append;
                    $aLinkedAd['prepend'] = $g_prepend . @$aZoneInfo['prepend'] . $aLinkedAd['prepend'];
                } else {
                    $aLinkedAd['append'] .= $g_append;
                    $aLinkedAd['prepend'] = $g_prepend . $aLinkedAd['prepend'];
                }
                return $aLinkedAd;
            }
            $zoneId = _getNextZone($zoneId, $aZoneInfo);
        }
    }
    if (!empty($aZoneInfo['default_banner_image_url'])) {
        return array('default' => true, 'default_banner_image_url' => $aZoneInfo['default_banner_image_url'], 'default_banner_destination_url' => $aZoneInfo['default_banner_destination_url']);
    }
    return false;
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:71,代码来源:adSelect.php


注:本文中的_adSelectCommon函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。