コード例 #1
0
ファイル: tracker.php プロジェクト: Jaree/revive-adserver
/**
 * This function checks if the specified tracker connects back to a valid action
 *
 * @param integer $trackerid The ID of the tracker to look up in the database
 * @return mixed If action occurred: array indexed on [#s since action] => array('type' => <connection type>, 'id' => <creative ID>
 *               else false
 */
function MAX_trackerCheckForValidAction($trackerid)
{
    // Get all creatives that are linked to this tracker
    $aTrackerLinkedAds = MAX_cacheGetTrackerLinkedCreatives($trackerid);
    // This tracker is not linked to any creatives
    if (empty($aTrackerLinkedAds)) {
        return false;
    }
    // Note: Constants are not included n the delivery engine, the values below map to the values defined in constants.php
    $aPossibleActions = _getActionTypes();
    $now = MAX_commonGetTimeNow();
    $aConf = $GLOBALS['_MAX']['CONF'];
    $aMatchingActions = array();
    // Iterate over all creatives linked to this tracker...
    foreach ($aTrackerLinkedAds as $creativeId => $aLinkedInfo) {
        // Iterate over all possible actions (currently only "view" and "click")
        foreach ($aPossibleActions as $actionId => $action) {
            // If there is both a connection window set, and this creative has been actioned
            if (!empty($aLinkedInfo[$action . '_window']) && !empty($_COOKIE[$aConf['var']['last' . ucfirst($action)]][$creativeId])) {
                // Check for any custom data which a plugin may have stored in the cookie
                if (stristr($_COOKIE[$aConf['var']['last' . ucfirst($action)]][$creativeId], ' ')) {
                    list($value, $extra) = explode(' ', $_COOKIE[$aConf['var']['last' . ucfirst($action)]][$creativeId], 2);
                    $_COOKIE[$aConf['var']['last' . ucfirst($action)]][$creativeId] = $value;
                } else {
                    $extra = '';
                }
                list($lastAction, $zoneId) = explode('-', $_COOKIE[$aConf['var']['last' . ucfirst($action)]][$creativeId]);
                // Decode the base32 timestamp
                $lastAction = MAX_commonUnCompressInt($lastAction);
                // Calculate how long ago this action occurred
                $lastSeenSecondsAgo = $now - $lastAction;
                // If the action occurred within the window (and sanity check that it's > 0), record this as a matching action
                if ($lastSeenSecondsAgo <= $aLinkedInfo[$action . '_window'] && $lastSeenSecondsAgo > 0) {
                    // Index the matching array against the # seconds ago that the action occurred
                    $aMatchingActions[$lastSeenSecondsAgo] = array('action_type' => $actionId, 'tracker_type' => $aLinkedInfo['tracker_type'], 'status' => $aLinkedInfo['status'], 'cid' => $creativeId, 'zid' => $zoneId, 'dt' => $lastAction, 'window' => $aLinkedInfo[$action . '_window'], 'extra' => $extra);
                }
            }
        }
    }
    // If no actions matched, return false
    if (empty($aMatchingActions)) {
        return false;
    }
    // Sort by ascending #seconds since action
    ksort($aMatchingActions);
    // Return the first matching action
    return array_shift($aMatchingActions);
}
コード例 #2
0
ファイル: ti.php プロジェクト: JackyKit/revive-adserver
function MAX_Delivery_log_isClickBlocked($adId, $aBlockLoggingClick)
{
    if (isset($GLOBALS['conf']['logging']['blockAdClicksWindow']) && $GLOBALS['conf']['logging']['blockAdClicksWindow'] != 0) {
        if (isset($aBlockLoggingClick[$adId])) {
            $endBlock = MAX_commonUnCompressInt($aBlockLoggingClick[$adId]) + $GLOBALS['conf']['logging']['blockAdClicksWindow'];
            if ($endBlock >= MAX_commonGetTimeNow()) {
                OX_Delivery_logMessage('adID ' . $adId . ' click is still blocked by block logging window ', 7);
                return true;
            }
        }
    }
    return false;
}
コード例 #3
0
ファイル: log.php プロジェクト: villos/tree_admin
/**
 * This function check if the click logging for an add is blocked
 * when the block logging is active
 *
 * @param integer $adId              The add's id of the add that the function checks
 *                                   if is blocked for click logging
 * @param array $aBlockLoggingClick  And array with the timestamps of the last click logged
 *                                   for every add that has been clicked
 * @return boolean                   Returns true when the click block logging window for
 *                                   and add hasn't expired yet
 */
function MAX_Delivery_log_isClickBlocked($adId, $aBlockLoggingClick)
{
    if (isset($GLOBALS['conf']['logging']['blockAdClicksWindow']) && $GLOBALS['conf']['logging']['blockAdClicksWindow'] != 0) {
        if (isset($aBlockLoggingClick[$adId])) {
            $endBlock = MAX_commonUnCompressInt($aBlockLoggingClick[$adId]) + $GLOBALS['conf']['logging']['blockAdClicksWindow'];
            if ($endBlock >= MAX_commonGetTimeNow()) {
                ###START_STRIP_DELIVERY
                OA::debug('adID ' . $adId . ' click is still blocked by block logging window ');
                ###END_STRIP_DELIVERY
                return true;
            }
        }
    }
    return false;
}