本文整理汇总了PHP中OX_Delivery_Common_hook函数的典型用法代码示例。如果您正苦于以下问题:PHP OX_Delivery_Common_hook函数的具体用法?PHP OX_Delivery_Common_hook怎么用?PHP OX_Delivery_Common_hook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OX_Delivery_Common_hook函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBannerCache
/**
* Return plugin cache
*
* @return string
*/
function getBannerCache($buffer, &$noScript)
{
$conf = $GLOBALS['_MAX']['CONF'];
if (preg_match('/<script.*?src=".*?ypn-js\\.overture\\.com/is', $buffer)) {
$new_buffer = "<span>" . "<script type='text/javascript'><!--// <![CDATA[\n" . "/* {$conf['var']['openads']}={url_prefix} {$conf['var']['adId']}={bannerid} {$conf['var']['zoneId']}={zoneid} {$conf['var']['channel']}={source} ";
// addUrlParams hook for plugins to add key=value pairs to the log/click URLs
$componentParams = OX_Delivery_Common_hook('addUrlParams', array());
foreach ($componentParams as $params) {
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
$new_buffer .= urlencode($key) . '={' . urlencode($key) . '} ';
}
}
}
$new_buffer .= "*/\n" . "// ]]> --></script>" . $buffer . "<script type='text/javascript' src='{url_prefix}/" . $conf['file']['google'] . "'></script>" . "</span>";
return $new_buffer;
}
return $buffer;
}
示例2: MAX_Delivery_log_logVariableValues
/**
* A function to log tracker impression variable values.
*
* Note that the $aConf['rawDatabase'] variables will only be defined
* in the event that OpenX is configured for multiple databases. Normally,
* this will not be the case, so the server_ip field will be 'singleDB'.
*
* @param array $aVariables An array of variables as returned by
* MAX_cacheGetTrackerVariables().
* @param integer $trackerId The tracker ID.
* @param integer $serverConvId The unique conversion ID value of the
* conversion as logged on the raw database
* server.
* @param string $serverRawIp The IP address of the raw database server,
* or the single server setup identifier.
*/
function MAX_Delivery_log_logVariableValues($aVariables, $trackerId, $serverConvId, $serverRawIp)
{
$aConf = $GLOBALS['_MAX']['CONF'];
// Get the variable information, including the Variable ID
foreach ($aVariables as $aVariable) {
if (isset($_GET[$aVariable['name']])) {
$value = $_GET[$aVariable['name']];
// Do not save variable if empty or if the JS engine set it to "undefined"
if (!strlen($value) || $value == 'undefined') {
unset($aVariables[$aVariable['variable_id']]);
continue;
}
// Sanitize by datatype
switch ($aVariable['type']) {
case 'int':
case 'numeric':
// Strip useless chars, such as currency
$value = preg_replace('/[^0-9.]/', '', $value);
$value = floatval($value);
break;
case 'date':
if (!empty($value)) {
$value = date('Y-m-d H:i:s', strtotime($value));
} else {
$value = '';
}
break;
}
} else {
// Do not save anything if the variable isn't set
unset($aVariables[$aVariable['variable_id']]);
continue;
}
$aVariables[$aVariable['variable_id']]['value'] = $value;
}
if (count($aVariables)) {
OX_Delivery_Common_hook('logConversionVariable', array($aVariables, $trackerId, $serverConvId, $serverRawIp, _viewersHostOkayToLog(null, null, $trackerId)));
}
}
示例3: OX_Delivery_logMessage
function OX_Delivery_logMessage($message, $priority = 6)
{
$conf = $GLOBALS['_MAX']['CONF'];
// Don't even try if the deliveryLog is not enabled...
if (empty($conf['deliveryLog']['enabled'])) {
return true;
}
// Only log messages above the configured priority level (See lib/pear/Log.php for a description of the levels)
$priorityLevel = is_numeric($conf['deliveryLog']['priority']) ? $conf['deliveryLog']['priority'] : 6;
if ($priority > $priorityLevel && empty($_REQUEST[$conf['var']['trace']])) {
return true;
}
// Log the error message
error_log('[' . date('r') . "] {$conf['log']['ident']}-delivery-{$GLOBALS['_MAX']['thread_id']}: {$message}\n", 3, MAX_PATH . '/var/' . $conf['deliveryLog']['name']);
// Call any plugins registered on the "logMessage" hook
OX_Delivery_Common_hook('logMessage', array($message, $priority));
return true;
}
示例4: array_search
$conf = $GLOBALS['_MAX']['CONF'];
// Set this script's identifier (from the config file) in the global scope
$GLOBALS['_OA']['invocationType'] = array_search(basename($_SERVER['SCRIPT_FILENAME']), $conf['file']);
// Disable all notices and warnings,
// as some PAN code still generates PHP warnings in places
if (!empty($conf['debug']['production'])) {
error_reporting(E_ALL & ~(E_NOTICE | E_WARNING | E_DEPRECATED | E_STRICT));
} else {
// show all errors when developing
error_reporting(E_ALL & ~(E_DEPRECATED | E_STRICT));
}
require_once MAX_PATH . '/lib/max/Delivery/common.php';
require_once MAX_PATH . '/lib/max/Delivery/cache.php';
OX_Delivery_logMessage('starting delivery script: ' . basename($_SERVER['REQUEST_URI']), 7);
if (!empty($_REQUEST[$conf['var']['trace']])) {
OX_Delivery_logMessage('trace enabled: ' . $_REQUEST[$conf['var']['trace']], 7);
}
// Set the viewer's remote information used in logging and delivery limitation evaluation
MAX_remotehostSetInfo();
// Set common delivery parameters in the global scope
MAX_commonInitVariables();
// Load cookie data from client/plugin
MAX_cookieLoad();
// Unpack the packed capping cookies
MAX_cookieUnpackCapping();
// Run any plugins which have registered themselves at postInit,
// with the exception of XML-RPC invocation that will call the hook
// explicitly after overriding the $_SERVER variables
if (empty($GLOBALS['_OA']['invocationType']) || $GLOBALS['_OA']['invocationType'] != 'xmlrpc') {
OX_Delivery_Common_hook('postInit');
}
示例5: 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;
}
示例6: OA_Delivery_XmlRpc_SPC
/**
* A function to handle XML-RPC advertisement SPC requests.
*
* @param XML_RPC_Message $params An XML_RPC_Message containing the parameters. The expected parameters
* are (in order):
* - An XML_RPC_Value of type "struct" containing remote informations
* which needs at least two members:
* - remote_addr (string) and
* - cookies (struct);
* - An XML_RPC_Value of type "string" containing the "what" value;
* - An XML_RPC_Value of type "string" containing the "target" value;
* - An XML_RPC_Value of type "string" containing the "source" value;
* - An XML_RPC_Value of type "boolean" containing the "withtext" value;
* - An XML_RPC_Value of type "boolean" containing the "block" value;
* - An XML_RPC_Value of type "boolean" containing the "blockcampaign" value;
* @return XML_RPC_Response The response. The XML_RPC_Value of the response can be one of
* a number of different values:
* - Error Code 21: wrong number of parameters.
* - Error Code 22: remote_addr element missing from the remote info struct.
* - Error Code 23: cookies element missing from the remote info struct.
* - An XML_RPC_Value of type "struct" with the HTML details required
* for displaying the advertisement stored as in XML_RPC_Value of
* type "string" in the "html" index, and other elements returned by the
* MAX_asSelect call. A special "cookies" element is either:
* - An empty XML_RPC_Value if there are no cookies to be set, or
* - An XML_RPC_Value of type "array", containing a number of XML_RPC_Values
* of tpye "array", each with 3 items:
* - An XML_RPC_Value of type "string" with the cookie name;
* - An XML_RPC_Value of type "string" with the cookie value; and
* - An XML_RPC_Value of type "string" with the cookie expiration time.
*/
function OA_Delivery_XmlRpc_SPC($params)
{
global $XML_RPC_erruser;
global $XML_RPC_String, $XML_RPC_Struct, $XML_RPC_Array;
// Check the parameters exist
$numParams = $params->getNumParams();
if ($numParams != 7) {
// Return an error
$errorCode = $XML_RPC_erruser + 21;
$errorMsg = 'Incorrect number of parameters';
return new XML_RPC_Response(0, $errorCode, $errorMsg);
}
// Set the XML values into their correct variables to make life easier
$vars = array(1 => 'what', 2 => 'target', 3 => 'source', 4 => 'withtext', 5 => 'block', 6 => 'blockcampaign');
// Parse parameters
for ($i = 0; $i < $numParams; $i++) {
$p = $params->getParam($i);
if ($i) {
// Put the decoded value the view arg array
${$vars}[$i] = XML_RPC_decode($p);
} else {
// First parameter: environment information supplied be XML-RPC client
$p = XML_RPC_decode($p);
if (!isset($p['remote_addr'])) {
// Return an error
$errorCode = $XML_RPC_erruser + 22;
$errorMsg = "Missing 'remote_addr' member";
return new XML_RPC_Response(0, $errorCode, $errorMsg);
}
if (!isset($p['cookies']) || !is_array($p['cookies'])) {
// Return an error
$errorCode = $XML_RPC_erruser + 23;
$errorMsg = "Missing 'cookies' member";
return new XML_RPC_Response(0, $errorCode, $errorMsg);
}
$aServerVars = array('remote_addr' => 'REMOTE_ADDR', 'remote_host' => 'REMOTE_HOST', 'request_uri' => 'REQUEST_URI', 'https' => 'HTTPS', 'server_name' => 'SERVER_NAME', 'http_host' => 'HTTP_HOST', 'accept_language' => 'HTTP_ACCEPT_LANGUAGE', 'referer' => 'HTTP_REFERER', 'user_agent' => 'HTTP_USER_AGENT', 'via' => 'HTTP_VIA', 'forwarded' => 'HTTP_FORWARDED', 'forwarded_for' => 'HTTP_FORWARDED_FOR', 'x_forwarded' => 'HTTP_X_FORWARDED', 'x_forwarded_for' => 'HTTP_X_FORWARDED_FOR', 'client_ip' => 'HTTP_CLIENT_IP');
// Extract environment vars to $_SERVER
foreach ($aServerVars as $xmlName => $varName) {
if (isset($p[$xmlName])) {
$_SERVER[$varName] = $p[$xmlName];
}
}
// Extract cookie vars to $_COOKIE
foreach ($p['cookies'] as $key => $value) {
$_COOKIE[$key] = MAX_commonAddslashesRecursive($value);
}
MAX_remotehostSetInfo(true);
OX_Delivery_Common_hook('postInit');
MAX_cookieUnpackCapping();
}
}
// Add defaults for not-applicable values
$richmedia = true;
$ct0 = '';
$context = array();
// Make loc and referer global to ensure that the delivery limitations work correctly
global $loc, $referer;
$loc = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . OX_getHostName() . $_SERVER['REQUEST_URI'];
// Add $referer parameter
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
// If the what parameter is an int, it is the affiliateid, otherwise it's a serialized array of name=zone pairs
// This convention is inline with the parameters passed into local-mode SPC
if (is_numeric($what)) {
$zones = OA_cacheGetPublisherZones($what);
$nz = false;
} else {
$zones = unserialize($what);
$nz = true;
}
//.........这里部分代码省略.........
示例7: MAX_remotehostSetGeoInfo
/**
* A function to set the viewer's geotargeting information in the
* $GLOBALS['_MAX']['CLIENT_GEO'] global variable, if a plugin for
* geotargeting information is configured.
*
* @todo This is a workaround to avoid having to include the entire plugin architecure
* just to be able to load the config information. The plugin system should be
* refactored to allow the Delivery Engine to load the information independently
*/
function MAX_remotehostSetGeoInfo()
{
if (!function_exists('parseDeliveryIniFile')) {
require_once MAX_PATH . '/init-delivery-parse.php';
}
$aConf = $GLOBALS['_MAX']['CONF'];
$type = !empty($aConf['geotargeting']['type']) ? $aConf['geotargeting']['type'] : null;
if (!is_null($type) && $type != 'none') {
$aComponent = explode(':', $aConf['geotargeting']['type']);
if (!empty($aComponent[1]) && !empty($aConf['pluginGroupComponents'][$aComponent[1]])) {
$GLOBALS['_MAX']['CLIENT_GEO'] = OX_Delivery_Common_hook('getGeoInfo', array(), $type);
}
}
}
示例8: array
<?php
/*
+---------------------------------------------------------------------------+
| Revive Adserver |
| http://www.revive-adserver.com |
| |
| Copyright: See the COPYRIGHT.txt file. |
| License: GPLv2 or later, see the LICENSE.txt file. |
+---------------------------------------------------------------------------+
*/
/*
* NOTE: If this list of event ever changes (IDs or names), the Video Reports must be updated as well
*/
$aVastEventStrToIdMap = array('start' => 1, 'midpoint' => 2, 'firstquartile' => 3, 'thirdquartile' => 4, 'complete' => 5, 'mute' => 6, 'replay' => 7, 'fullscreen' => 8, 'stop' => 9, 'unmute' => 10, 'resume' => 11, 'pause' => 12);
MAX_commonRegisterGlobalsArray(array('event', 'video_time_posn'));
// Prevent the logging beacon from being cached by browsers
MAX_commonSetNoCacheHeaders();
// if its a vast tracking event
if (!empty($bannerid) && isset($aVastEventStrToIdMap[$event])) {
// Remove any special characters from the request variables
MAX_commonRemoveSpecialChars($_REQUEST);
$time = MAX_commonGetTimeNow();
$oi = $GLOBALS['_MAX']['CONF']['maintenance']['operationInterval'];
$GLOBALS['_MAX']['deliveryData'] = array('interval_start' => gmdate('Y-m-d H:i:s', $time - $time % ($oi * 60)), 'creative_id' => (int) $bannerid, 'zone_id' => (int) $zoneid, 'vast_event_id' => $aVastEventStrToIdMap[$event]);
OX_Delivery_Common_hook('logImpressionVast', array($bannerid, $zoneid, _viewersHostOkayToLog()));
}
MAX_cookieFlush();
MAX_commonDisplay1x1();
示例9: OA_Delivery_XmlRpc_SPC
function OA_Delivery_XmlRpc_SPC($params)
{
global $XML_RPC_erruser;
global $XML_RPC_String, $XML_RPC_Struct, $XML_RPC_Array;
$numParams = $params->getNumParams();
if ($numParams != 7) {
$errorCode = $XML_RPC_erruser + 21;
$errorMsg = 'Incorrect number of parameters';
return new XML_RPC_Response(0, $errorCode, $errorMsg);
}
$vars = array(1 => 'what', 2 => 'target', 3 => 'source', 4 => 'withtext', 5 => 'block', 6 => 'blockcampaign');
for ($i = 0; $i < $numParams; $i++) {
$p = $params->getParam($i);
if ($i) {
${$vars}[$i] = XML_RPC_decode($p);
} else {
$p = XML_RPC_decode($p);
if (!isset($p['remote_addr'])) {
$errorCode = $XML_RPC_erruser + 22;
$errorMsg = "Missing 'remote_addr' member";
return new XML_RPC_Response(0, $errorCode, $errorMsg);
}
if (!isset($p['cookies']) || !is_array($p['cookies'])) {
$errorCode = $XML_RPC_erruser + 23;
$errorMsg = "Missing 'cookies' member";
return new XML_RPC_Response(0, $errorCode, $errorMsg);
}
$aServerVars = array('remote_addr' => 'REMOTE_ADDR', 'remote_host' => 'REMOTE_HOST', 'request_uri' => 'REQUEST_URI', 'https' => 'HTTPS', 'server_name' => 'SERVER_NAME', 'http_host' => 'HTTP_HOST', 'accept_language' => 'HTTP_ACCEPT_LANGUAGE', 'referer' => 'HTTP_REFERER', 'user_agent' => 'HTTP_USER_AGENT', 'via' => 'HTTP_VIA', 'forwarded' => 'HTTP_FORWARDED', 'forwarded_for' => 'HTTP_FORWARDED_FOR', 'x_forwarded' => 'HTTP_X_FORWARDED', 'x_forwarded_for' => 'HTTP_X_FORWARDED_FOR', 'client_ip' => 'HTTP_CLIENT_IP');
foreach ($aServerVars as $xmlName => $varName) {
if (isset($p[$xmlName])) {
$_SERVER[$varName] = $p[$xmlName];
}
}
foreach ($p['cookies'] as $key => $value) {
$_COOKIE[$key] = MAX_commonAddslashesRecursive($value);
}
MAX_remotehostSetInfo(true);
OX_Delivery_Common_hook('postInit');
MAX_cookieUnpackCapping();
}
}
$richmedia = true;
$ct0 = '';
$context = array();
global $loc, $referer;
$loc = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . OX_getHostName() . $_SERVER['REQUEST_URI'];
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
if (is_numeric($what)) {
$zones = OA_cacheGetPublisherZones($what);
$nz = false;
} else {
$zones = unserialize($what);
$nz = true;
}
$spc_output = array();
foreach ($zones as $zone => $data) {
if (empty($zone)) {
continue;
}
if ($nz) {
$varname = $zone;
$zoneid = $data;
} else {
$varname = $zoneid = $zone;
}
unset($GLOBALS['_MAX']['deliveryData']);
$output = MAX_adSelect('zone:' . $zoneid, '', $target, $source, $withtext, '', $context, $richmedia, $ct0, $GLOBALS['loc'], $GLOBALS['referer']);
$spc_output[$varname] = $output;
if (!empty($block) && !empty($output['bannerid'])) {
$output['context'][] = array('!=' => 'bannerid:' . $output['bannerid']);
}
if (!empty($blockcampaign) && !empty($output['campaignid'])) {
$output['context'][] = array('!=' => 'campaignid:' . $output['campaignid']);
}
if (!empty($output['context'])) {
foreach ($output['context'] as $id => $contextArray) {
if (!in_array($contextArray, $context)) {
$context[] = $contextArray;
}
}
}
}
return new XML_RPC_Response(XML_RPC_encode($spc_output));
$output = call_user_func_array('MAX_adSelect', $view_params);
if (!is_array($output)) {
$output = array();
} elseif (isset($output['contenttype']) && $output['contenttype'] == 'swf') {
$output['html'] = MAX_flashGetFlashObjectExternal() . $output['html'];
}
MAX_cookieFlush();
$output['cookies'] = $GLOBALS['_OA']['COOKIE']['XMLRPC_CACHE'];
return new XML_RPC_Response(XML_RPC_encode($output));
}
示例10: array
// Send bannerid headers
$cookie = array();
$cookie[$conf['var']['adId']] = $row['bannerid'];
// Send zoneid headers
if ($zoneid != 0) {
$cookie[$conf['var']['zoneId']] = $zoneid;
}
// Send source headers
if (!empty($source)) {
$cookie[$conf['var']['channel']] = $source;
}
if (!empty($row['clickwindow'])) {
$cookie[$conf['var']['lastClick']] = 1;
}
// addUrlParams hook for plugins to add key=value pairs to the log/click URLs
$componentParams = OX_Delivery_Common_hook('addUrlParams', array($row));
if (!empty($componentParams) && is_array($componentParams)) {
foreach ($componentParams as $params) {
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
$cookie[$key] = $value;
}
}
}
}
if (isset($row['aSearch']) && isset($row['aReplace'])) {
$cookie[$conf['var']['dest']] = str_replace($row['aSearch'], $row['aReplace'], $row['url']);
}
// if there is a fallback defined for this banner, we try and use it
$creativeURL = '';
if (!empty($row['contenttype']) && $row['contenttype'] == 'swf') {
示例11: _adSelectInnerLoop
/**
* This internal function selects an ad cyclying through exclusive, paid, low-pri etc.
* taking into account companion positioning as requested
*
* @param callback $adSelectFunction The plugin callback function
* @param string $aAds The array of ads to pick 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
* @param boolean $companion Should ad selection only return companion ads?
*
* @return array|false Returns an ad-array (see page DocBlock) or false if no ad found
*/
function _adSelectInnerLoop($adSelectFunction, $aAds, $context, $source, $richMedia, $companion = false)
{
// Array of campaign types sorted by priority
$aCampaignTypes = array('xAds' => false, 'ads' => array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1), 'lAds' => false, 'eAds' => array(-2));
$GLOBALS['_MAX']['considered_ads'][] =& $aAds;
foreach ($aCampaignTypes as $type => $aPriorities) {
if ($aPriorities) {
$ad_picked = false;
foreach ($aPriorities as $pri) {
// Even though we've selected an ad, we need to continue
// applying filtering rules in order to construct a valid
// qualified ad set, which MPE 2.x needs to know.
if (!$ad_picked) {
$aLinkedAd = OX_Delivery_Common_hook('adSelect', array(&$aAds, &$context, &$source, &$richMedia, $companion, $type, $pri), $adSelectFunction);
// Did we pick an ad from this campaign-priority level?
if (is_array($aLinkedAd)) {
$ad_picked = true;
}
// Should we skip the next campaign-priority level?
if ($aLinkedAd == $GLOBALS['OX_adSelect_SkipOtherPriorityLevels']) {
$ad_picked = true;
}
} else {
if (!empty($aAds[$type][$pri])) {
// Build preconditions
$aContext = _adSelectBuildContextArray($aAds[$type][$pri], $type, $context);
// New delivery algorithm: discard all invalid ads before iterating over them
// $aAds passed by ref here
_adSelectDiscardNonMatchingAds($aAds[$type][$pri], $aContext, $source, $richMedia);
}
}
}
if ($ad_picked && is_array($aLinkedAd)) {
return $aLinkedAd;
}
} else {
$aLinkedAd = OX_Delivery_Common_hook('adSelect', array(&$aAds, &$context, &$source, &$richMedia, $companion, $type), $adSelectFunction);
// Did we pick an ad from this campaign type?
if (is_array($aLinkedAd)) {
return $aLinkedAd;
}
}
}
return false;
}
示例12: MAX_Delivery_log_setLastAction
/**
* This function sets or updates the last action (cookie) record
* This value is used to track conversions for a campaign
*
* @param integer $index
* @param array $aAdIds
* @param array $aZoneIds
* @param array $aSetLastSeen
* @param integer $action
*/
function MAX_Delivery_log_setLastAction($index, $aAdIds, $aZoneIds, $aSetLastSeen, $action = 'view')
{
$aConf = $GLOBALS['_MAX']['CONF'];
if (!empty($aSetLastSeen[$index])) {
$cookieData = MAX_commonCompressInt(MAX_commonGetTimeNow()) . "-" . $aZoneIds[$index];
// See if any plugin-components have added items to the conversion cookie...
$conversionParams = OX_Delivery_Common_hook('addConversionParams', array(&$index, &$aAdIds, &$aZoneIds, &$aSetLastSeen, &$action, &$cookieData));
if (!empty($conversionParams) && is_array($conversionParams)) {
foreach ($conversionParams as $params) {
if (!empty($params) && is_array($params)) {
foreach ($params as $key => $value) {
// Note: We have to use space as a delimiter, if your plugin
// requires spaces in the data, you may need to encode them.
$cookieData .= " {$value}";
}
}
}
}
MAX_cookieAdd("_{$aConf['var']['last' . ucfirst($action)]}[{$aAdIds[$index]}]", $cookieData, _getTimeThirtyDaysFromNow());
}
}
示例13: _adSelectInnerLoop
function _adSelectInnerLoop($adSelectFunction, $aAds, $context, $source, $richMedia, $companion = false)
{
$aCampaignTypes = array('xAds' => false, 'ads' => array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1), 'lAds' => false, 'eAds' => array(-2));
$GLOBALS['_MAX']['considered_ads'][] =& $aAds;
foreach ($aCampaignTypes as $type => $aPriorities) {
if ($aPriorities) {
$ad_picked = false;
foreach ($aPriorities as $pri) {
if (!$ad_picked) {
$aLinkedAd = OX_Delivery_Common_hook('adSelect', array(&$aAds, &$context, &$source, &$richMedia, $companion, $type, $pri), $adSelectFunction);
if (is_array($aLinkedAd)) {
$ad_picked = true;
}
if ($aLinkedAd == $GLOBALS['OX_adSelect_SkipOtherPriorityLevels']) {
$ad_picked = true;
}
} else {
if (!empty($aAds[$type][$pri])) {
$aContext = _adSelectBuildContextArray($aAds[$type][$pri], $type, $context);
_adSelectDiscardNonMatchingAds($aAds[$type][$pri], $aContext, $source, $richMedia);
}
}
}
if ($ad_picked && is_array($aLinkedAd)) {
return $aLinkedAd;
}
} else {
$aLinkedAd = OX_Delivery_Common_hook('adSelect', array(&$aAds, &$context, &$source, &$richMedia, $companion, $type), $adSelectFunction);
if (is_array($aLinkedAd)) {
return $aLinkedAd;
}
}
}
return false;
}
示例14: _adRenderBuildParams
function _adRenderBuildParams($aBanner, $zoneId = 0, $source = '', $ct0 = '', $logClick = true, $overrideDest = false)
{
// HACK - sometimes $aBanner has the banner ID as bannerid, and others it is ad_id. This needs
// to be sorted in all parts of the application to reference ad_id rather than bannerid.
if (isset($aBanner['ad_id']) && empty($aBanner['bannerid'])) {
$aBanner['bannerid'] = $aBanner['ad_id'];
}
$conf = $GLOBALS['_MAX']['CONF'];
$delimiter = $GLOBALS['_MAX']['MAX_DELIVERY_MULTIPLE_DELIMITER'];
$logLastClick = !empty($aBanner['clickwindow']) ? '1' : '';
// If there is an OpenX->OpenX internal redirect, log both zones information
if (!empty($GLOBALS['_MAX']['adChain'])) {
foreach ($GLOBALS['_MAX']['adChain'] as $index => $ad) {
$aBanner['bannerid'] .= $delimiter . $ad['bannerid'];
$aBanner['placement_id'] .= $delimiter . $ad['placement_id'];
$zoneId .= $delimiter . $ad['zoneid'];
$logLastClick .= !empty($aBanner['clickwindow']) ? '1' : '0';
}
}
$maxparams = '';
if (!empty($aBanner['url']) || $overrideDest) {
// There is a link
$del = $conf['delivery']['ctDelimiter'];
$delnum = strlen($del);
$random = "{$del}{$conf['var']['cacheBuster']}={random}";
$bannerId = !empty($aBanner['bannerid']) ? "{$del}{$conf['var']['adId']}={$aBanner['bannerid']}" : '';
$zoneId = "{$del}{$conf['var']['zoneId']}={$zoneId}";
$source = !empty($source) ? "{$del}source=" . urlencode($source) : '';
$log = $logClick ? '' : "{$del}{$conf['var']['logClick']}=no";
// Determine the destination
$dest = !empty($aBanner['url']) ? $aBanner['url'] : '';
// If the passed in a ct0= value that is not a valid URL (simple checking), then ignore it
if (!empty($ct0) && strtolower(substr($ct0, 0, 4)) == 'http') {
$dest = $ct0 . urlencode($dest);
}
// Urlencode, but allow magic macros
$dest = preg_replace('/%7B(.*?)%7D/', '{$1}', urlencode($dest));
$maxdest = "{$del}{$conf['var']['dest']}={$dest}";
$log .= !empty($logLastClick) ? $del . $conf['var']['lastClick'] . '=' . $logLastClick : '';
$maxparams = $delnum . $bannerId . $zoneId . $source . $log . $random;
// 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) {
$maxparams .= $del . urlencode($key) . '=' . urlencode($value);
}
}
}
}
$maxparams .= $maxdest;
}
return $maxparams;
}
示例15: OA_Delivery_Cache_store_return
function OA_Delivery_Cache_store_return($name, $cache, $isHash = false, $expireAt = null)
{
OX_Delivery_Common_hook('preCacheStore_' . OA_Delivery_Cache_getHookName($name), array($name, &$cache));
if (OA_Delivery_Cache_store($name, $cache, $isHash, $expireAt)) {
return $cache;
}
$currentCache = OA_Delivery_Cache_fetch($name, $isHash);
if ($currentCache === false) {
return $cache;
}
return $currentCache;
}