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


PHP MAX_getRandomNumber函数代码示例

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


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

示例1: MAX_adSelect


//.........这里部分代码省略.........
    $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;
}
开发者ID:hawodi,项目名称:revive-adserver,代码行数:101,代码来源:al.php

示例2: MAX_adRender

/**
 * This is the code that renders the HTML required to display an ad
 *
 * @param array   $aBanner      The array of banner properties for the banner to be rendered
 * @param int     $zoneId       The zone ID of the zone used to select this ad (if zone-selected)
 * @param string  $source       The "source" parameter passed into the adcall
 * @param string  $target       The target attribute for generated <a href> links
 * @param string  $ct0          The 3rd party click tracking URL to redirect to after logging
 * @param boolean $withtext     Should "text below banner" be appended to the generated code
 * @param string  $charset      Character set to convert the rendered output into
 * @param bookean $logClick     Should this click be logged (clicks in admin should not be logged)
 * @param boolean $logView      Should this view be logged (views in admin should not be logged
 *                              also - 3rd party callback logging should not be logged at view time)
 * @param boolean $richMedia    Does this invocation method allow for serving 3rd party/html ads
 * @param string  $loc          The "current page" URL
 * @param string  $referer      The "referring page" URL
 * @param array   $context      The context of this ad selection
 *                              - used for companion positioning
 *                              - and excluding banner/campaigns from this ad-call
 *
 * @return string   The HTML to display this ad
 */
function MAX_adRender(&$aBanner, $zoneId = 0, $source = '', $target = '', $ct0 = '', $withText = false, $charset = '', $logClick = true, $logView = true, $richMedia = true, $loc = '', $referer = '', &$context = array())
{
    $conf = $GLOBALS['_MAX']['CONF'];
    // Sanitize these user-inputted variables before passing to the _adRenderX calls
    if (empty($target)) {
        $target = !empty($aBanner['target']) ? $aBanner['target'] : '_blank';
    }
    $target = htmlspecialchars($target, ENT_QUOTES);
    $source = htmlspecialchars($source, ENT_QUOTES);
    $aBanner['bannerContent'] = "";
    // Pre adRender hook
    OX_Delivery_Common_hook('preAdRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer));
    $functionName = _getAdRenderFunction($aBanner, $richMedia);
    $code = OX_Delivery_Common_hook('adRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer), $functionName);
    // Transform any code
    // Get a timestamp
    list($usec, $sec) = explode(' ', microtime());
    $time = (double) $usec + (double) $sec;
    // Get a random number
    $random = MAX_getRandomNumber();
    global $cookie_random;
    // Temporary fix to get doubleclick tracking working (Bug # 88)
    $cookie_random = $random;
    // Get the click URL
    $clickUrl = _adRenderBuildClickUrl($aBanner, $zoneId, $source, $ct0, $logClick, true);
    // Get URL prefix, stripping the traling slash
    $urlPrefix = substr(MAX_commonGetDeliveryUrl(), 0, -1);
    $code = str_replace('{clickurl}', $clickUrl, $code);
    // This step needs to be done separately because {clickurl} can contain {random}...
    if (strpos($code, '{logurl}') !== false) {
        $logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
        $code = str_replace('{logurl}', $logUrl, $code);
        // This step needs to be done separately because {logurl} does contain {random}...
    }
    if (strpos($code, '{logurl_enc}') !== false) {
        $logUrl_enc = urlencode(_adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&'));
        $code = str_replace('{logurl_enc}', $logUrl_enc, $code);
        // This step needs to be done separately because {logurl} does contain {random}...
    }
    if (strpos($code, '{clickurlparams}')) {
        $maxparams = _adRenderBuildParams($aBanner, $zoneId, $source, urlencode($ct0), $logClick, true);
        $code = str_replace('{clickurlparams}', $maxparams, $code);
        // This step needs to be done separately because {clickurlparams} does contain {random}...
    }
    $search = array('{timestamp}', '{random}', '{target}', '{url_prefix}', '{bannerid}', '{zoneid}', '{source}', '{pageurl}', '{width}', '{height}', '{websiteid}', '{campaignid}', '{advertiserid}', '{referer}');
    $locReplace = isset($GLOBALS['loc']) ? $GLOBALS['loc'] : '';
    $websiteid = !empty($aBanner['affiliate_id']) ? $aBanner['affiliate_id'] : '0';
    $replace = array($time, $random, $target, $urlPrefix, $aBanner['ad_id'], $zoneId, $source, urlencode($locReplace), $aBanner['width'], $aBanner['height'], $websiteid, $aBanner['campaign_id'], $aBanner['client_id'], $referer);
    preg_match_all('#{(.*?)(_enc)?}#', $code, $macros);
    for ($i = 0; $i < count($macros[1]); $i++) {
        if (!in_array($macros[0][$i], $search) && isset($_REQUEST[$macros[1][$i]])) {
            $search[] = $macros[0][$i];
            $replace[] = !empty($macros[2][$i]) ? urlencode(stripslashes($_REQUEST[$macros[1][$i]])) : stripslashes($_REQUEST[$macros[1][$i]]);
        }
    }
    // addUrlParams hook for plugins to add key=value pairs to the log/click URLs
    $componentParams = OX_Delivery_Common_hook('addUrlParams', array($aBanner));
    if (!empty($componentParams) && is_array($componentParams)) {
        foreach ($componentParams as $params) {
            if (!empty($params) && is_array($params)) {
                foreach ($params as $key => $value) {
                    $search[] = '{' . $key . '}';
                    $replace[] = urlencode($value);
                }
            }
        }
    }
    $code = str_replace($search, $replace, $code);
    $clickUrl = str_replace($search, $replace, $clickUrl);
    $aBanner['clickUrl'] = $clickUrl;
    // Now we can finally replace {clickurl_enc}
    if (strpos($code, '{clickurl_enc}') !== false) {
        $code = str_replace('{clickurl_enc}', urlencode($clickUrl), $code);
    }
    $logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
    $logUrl = str_replace($search, $replace, $logUrl);
    $aBanner['logUrl'] = $logUrl;
    // Pass over the search / replace patterns
//.........这里部分代码省略.........
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:101,代码来源:adRender.php

示例3: MAX_adRender

function MAX_adRender(&$aBanner, $zoneId = 0, $source = '', $target = '', $ct0 = '', $withText = false, $charset = '', $logClick = true, $logView = true, $richMedia = true, $loc = '', $referer = '', &$context = array())
{
    $conf = $GLOBALS['_MAX']['CONF'];
    if (empty($target)) {
        $target = !empty($aBanner['target']) ? $aBanner['target'] : '_blank';
    }
    $target = htmlspecialchars($target, ENT_QUOTES);
    $source = htmlspecialchars($source, ENT_QUOTES);
    $aBanner['bannerContent'] = "";
    OX_Delivery_Common_hook('preAdRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer));
    $functionName = _getAdRenderFunction($aBanner, $richMedia);
    $code = OX_Delivery_Common_hook('adRender', array(&$aBanner, &$zoneId, &$source, &$ct0, &$withText, &$logClick, &$logView, null, &$richMedia, &$loc, &$referer), $functionName);
    list($usec, $sec) = explode(' ', microtime());
    $time = (double) $usec + (double) $sec;
    $random = MAX_getRandomNumber();
    global $cookie_random;
    $cookie_random = $random;
    $clickUrl = _adRenderBuildClickUrl($aBanner, $zoneId, $source, $ct0, $logClick, true);
    $urlPrefix = substr(MAX_commonGetDeliveryUrl(), 0, -1);
    $code = str_replace('{clickurl}', $clickUrl, $code);
    if (strpos($code, '{logurl}') !== false) {
        $logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
        $code = str_replace('{logurl}', $logUrl, $code);
    }
    if (strpos($code, '{logurl_enc}') !== false) {
        $logUrl_enc = urlencode(_adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&'));
        $code = str_replace('{logurl_enc}', $logUrl_enc, $code);
    }
    if (strpos($code, '{clickurlparams}')) {
        $maxparams = _adRenderBuildParams($aBanner, $zoneId, $source, urlencode($ct0), $logClick, true);
        $code = str_replace('{clickurlparams}', $maxparams, $code);
    }
    $search = array('{timestamp}', '{random}', '{target}', '{url_prefix}', '{bannerid}', '{zoneid}', '{source}', '{pageurl}', '{width}', '{height}', '{websiteid}', '{campaignid}', '{advertiserid}', '{referer}');
    $locReplace = isset($GLOBALS['loc']) ? $GLOBALS['loc'] : '';
    $websiteid = !empty($aBanner['affiliate_id']) ? $aBanner['affiliate_id'] : '0';
    $replace = array($time, $random, $target, $urlPrefix, $aBanner['ad_id'], $zoneId, $source, urlencode($locReplace), $aBanner['width'], $aBanner['height'], $websiteid, $aBanner['campaign_id'], $aBanner['client_id'], $referer);
    preg_match_all('#{(.*?)(_enc)?}#', $code, $macros);
    for ($i = 0; $i < count($macros[1]); $i++) {
        if (!in_array($macros[0][$i], $search) && isset($_REQUEST[$macros[1][$i]])) {
            $search[] = $macros[0][$i];
            $replace[] = !empty($macros[2][$i]) ? urlencode(stripslashes($_REQUEST[$macros[1][$i]])) : stripslashes($_REQUEST[$macros[1][$i]]);
        }
    }
    $componentParams = OX_Delivery_Common_hook('addUrlParams', array($aBanner));
    if (!empty($componentParams) && is_array($componentParams)) {
        foreach ($componentParams as $params) {
            if (!empty($params) && is_array($params)) {
                foreach ($params as $key => $value) {
                    $search[] = '{' . $key . '}';
                    $replace[] = urlencode($value);
                }
            }
        }
    }
    $code = str_replace($search, $replace, $code);
    $clickUrl = str_replace($search, $replace, $clickUrl);
    $aBanner['clickUrl'] = $clickUrl;
    if (strpos($code, '{clickurl_enc}') !== false) {
        $code = str_replace('{clickurl_enc}', urlencode($clickUrl), $code);
    }
    $logUrl = _adRenderBuildLogURL($aBanner, $zoneId, $source, $loc, $referer, '&');
    $logUrl = str_replace($search, $replace, $logUrl);
    $aBanner['logUrl'] = $logUrl;
    $aBanner['aSearch'] = $search;
    $aBanner['aReplace'] = $replace;
    OX_Delivery_Common_hook('postAdRender', array(&$code, $aBanner, &$context));
    return MAX_commonConvertEncoding($code, $charset);
}
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:68,代码来源:ax.php

示例4: MAX_adSelect


//.........这里部分代码省略.........
                    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), 'iframeFriendly' => (bool) $row['iframe_friendly']);
        // 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 {
        // Blank impression beacon
        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;
        }
        // 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;
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:101,代码来源:adSelect.php


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