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


PHP OX_Delivery_Common_Hook函数代码示例

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


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

示例1: _viewersHostOkayToLog

function _viewersHostOkayToLog($adId = 0, $zoneId = 0, $trackerId = 0)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $okToLog = true;
    if (!empty($aConf['logging']['enforceUserAgents'])) {
        $aKnownBrowsers = explode('|', strtolower($aConf['logging']['enforceUserAgents']));
        $allowed = false;
        foreach ($aKnownBrowsers as $browser) {
            if (strpos($agent, $browser) !== false) {
                $allowed = true;
                break;
            }
        }
        OX_Delivery_logMessage('user-agent browser : ' . $agent . ' is ' . ($allowed ? '' : 'not ') . 'allowed', 7);
        if (!$allowed) {
            $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'enforceUserAgents';
            $okToLog = false;
        }
    }
    if (!empty($aConf['logging']['ignoreUserAgents'])) {
        $aKnownBots = explode('|', strtolower($aConf['logging']['ignoreUserAgents']));
        foreach ($aKnownBots as $bot) {
            if (strpos($agent, $bot) !== false) {
                OX_Delivery_logMessage('user-agent ' . $agent . ' is a known bot ' . $bot, 7);
                $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'ignoreUserAgents';
                $okToLog = false;
            }
        }
    }
    if (!empty($aConf['logging']['ignoreHosts'])) {
        $hosts = str_replace(',', '|', $aConf['logging']['ignoreHosts']);
        $hosts = '#^(' . $hosts . ')$#i';
        $hosts = str_replace('.', '\\.', $hosts);
        $hosts = str_replace('*', '[^.]+', $hosts);
        if (preg_match($hosts, $_SERVER['REMOTE_ADDR'])) {
            OX_Delivery_logMessage('viewer\'s ip is in the ignore list ' . $_SERVER['REMOTE_ADDR'], 7);
            $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'ignoreHosts_ip';
            $okToLog = false;
        }
        if (preg_match($hosts, $_SERVER['REMOTE_HOST'])) {
            OX_Delivery_logMessage('viewer\'s host is in the ignore list ' . $_SERVER['REMOTE_HOST'], 7);
            $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'ignoreHosts_host';
            $okToLog = false;
        }
    }
    if ($okToLog) {
        OX_Delivery_logMessage('viewer\'s host is OK to log', 7);
    }
    $result = OX_Delivery_Common_Hook('filterEvent', array($adId, $zoneId, $trackerId));
    if (!empty($result) && is_array($result)) {
        foreach ($result as $pci => $value) {
            if ($value == true) {
                $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = $pci;
                $okToLog = false;
            }
        }
    }
    return $okToLog;
}
开发者ID:JackyKit,项目名称:revive-adserver,代码行数:60,代码来源:ti.php

示例2: _viewersHostOkayToLog

/**
 * A "private" function to check if the information to be logged should be
 * logged or ignored, on the basis of the viewer's IP address or hostname.
 *
 * @access private
 * @param integer $adId      The id of the ad being logged
 * @param integer $zoneId    The id of the zone being logged
 * @param integer $trackerId The id of the tracker being logged
 * @return boolean True if the information should be logged, or false if the
 *                 IP address or host name is in the list of hosts for which
 *                 information should not be logged.
 */
function _viewersHostOkayToLog($adId = 0, $zoneId = 0, $trackerId = 0)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $okToLog = true;
    // Check the user-agent against the list of known browsers (if set)
    if (!empty($aConf['logging']['enforceUserAgents'])) {
        $aKnownBrowsers = explode('|', strtolower($aConf['logging']['enforceUserAgents']));
        $allowed = false;
        foreach ($aKnownBrowsers as $browser) {
            if (strpos($agent, $browser) !== false) {
                $allowed = true;
                break;
            }
        }
        ###START_STRIP_DELIVERY
        OA::debug('user-agent browser : ' . $agent . ' is ' . ($allowed ? '' : 'not ') . 'allowed');
        ###END_STRIP_DELIVERY
        if (!$allowed) {
            $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'enforceUserAgents';
            $okToLog = false;
        }
    }
    // Check the user-agent against the list of known bots (if set)
    if (!empty($aConf['logging']['ignoreUserAgents'])) {
        $aKnownBots = explode('|', strtolower($aConf['logging']['ignoreUserAgents']));
        foreach ($aKnownBots as $bot) {
            if (strpos($agent, $bot) !== false) {
                ###START_STRIP_DELIVERY
                OA::debug('user-agent ' . $agent . ' is a known bot ' . $bot);
                ###END_STRIP_DELIVERY
                $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'ignoreUserAgents';
                $okToLog = false;
            }
        }
    }
    // Check if this IP address has been blocked
    if (!empty($aConf['logging']['ignoreHosts'])) {
        $hosts = str_replace(',', '|', $aConf['logging']['ignoreHosts']);
        $hosts = '#^(' . $hosts . ')$#i';
        // Format the hosts to ignore in a PCRE format
        $hosts = str_replace('.', '\\.', $hosts);
        $hosts = str_replace('*', '[^.]+', $hosts);
        // Check if the viewer's IP address is in the ignore list
        if (preg_match($hosts, $_SERVER['REMOTE_ADDR'])) {
            ###START_STRIP_DELIVERY
            OA::debug('viewer\'s ip is in the ignore list ' . $_SERVER['REMOTE_ADDR']);
            ###END_STRIP_DELIVERY
            $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'ignoreHosts_ip';
            $okToLog = false;
        }
        // Check if the viewer's hostname is in the ignore list
        if (preg_match($hosts, $_SERVER['REMOTE_HOST'])) {
            ###START_STRIP_DELIVERY
            OA::debug('viewer\'s host is in the ignore list ' . $_SERVER['REMOTE_HOST']);
            ###END_STRIP_DELIVERY
            $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = 'ignoreHosts_host';
            $okToLog = false;
        }
    }
    ###START_STRIP_DELIVERY
    if ($okToLog) {
        OA::debug('viewers host is OK to log');
    }
    ###END_STRIP_DELIVERY
    $result = OX_Delivery_Common_Hook('filterEvent', array($adId, $zoneId, $trackerId));
    if (!empty($result) && is_array($result)) {
        foreach ($result as $pci => $value) {
            if ($value == true) {
                $GLOBALS['_MAX']['EVENT_FILTER_FLAGS'][] = $pci;
                $okToLog = false;
            }
        }
    }
    return $okToLog;
}
开发者ID:villos,项目名称:tree_admin,代码行数:88,代码来源:log.php


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