本文整理汇总了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;
}
示例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;
}