예제 #1
0
function MAX_Delivery_log_logVariableValues($aVariables, $trackerId, $serverConvId, $serverRawIp)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    foreach ($aVariables as $aVariable) {
        if (isset($_GET[$aVariable['name']])) {
            $value = $_GET[$aVariable['name']];
            if (!strlen($value) || $value == 'undefined') {
                unset($aVariables[$aVariable['variable_id']]);
                continue;
            }
            switch ($aVariable['type']) {
                case 'int':
                case 'numeric':
                    $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 {
            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)));
    }
}
예제 #2
0
파일: log.php 프로젝트: villos/tree_admin
/**
 * 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)));
    }
}
<?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();
예제 #4
0
 /**
  * A method to test the _viewersHostOkayToLog() function.
  */
 function test_viewersHostOkayToLog()
 {
     // Use a reference to $GLOBALS['_MAX']['CONF'] so that the configuration
     // options can be changed while the test is running
     $conf =& $GLOBALS['_MAX']['CONF'];
     // Save the $_SERVER so we don't affect other tests
     $serverSave = $_SERVER;
     // Set a fake, known IP address and host name
     $_SERVER['REMOTE_ADDR'] = '24.24.24.24';
     $_SERVER['REMOTE_HOST'] = '';
     // Disable reverse lookups
     $conf['logging']['reverseLookup'] = false;
     // Set no hosts to ignore
     $conf['logging']['ignoreHosts'] = '';
     // Test
     $this->assertTrue(_viewersHostOkayToLog());
     // Set different IP addresses to ignore
     $conf['logging']['ignoreHosts'] = '23.23.23.23,127.0.0.1';
     // Test
     $this->assertTrue(_viewersHostOkayToLog());
     // Set different and same IP addresses to ignore
     $conf['logging']['ignoreHosts'] = '23.23.23.23,24.24.24.24,127.0.0.1';
     // Test
     $this->assertFalse(_viewersHostOkayToLog());
     // Set a fake, known IP address and host name
     $_SERVER['REMOTE_ADDR'] = '24.24.24.24';
     $_SERVER['REMOTE_HOST'] = 'example.com';
     // Set different IP addresses to ignore
     $conf['logging']['ignoreHosts'] = '23.23.23.23,www.example.com,127.0.0.1';
     // Test
     $this->assertTrue(_viewersHostOkayToLog());
     // Set different and same IP addresses to ignore
     $conf['logging']['ignoreHosts'] = '23.23.23.23,example.com,127.0.0.1';
     // Test
     $this->assertFalse(_viewersHostOkayToLog());
     // Set a fake, known IP address and host name
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['REMOTE_HOST'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
     // Enable revers lookups
     $conf['logging']['reverseLookup'] = true;
     // Set different IP addresses to ignore
     $conf['logging']['ignoreHosts'] = '23.23.23.23,example.com';
     // Test
     $this->assertTrue(_viewersHostOkayToLog());
     // Set a fake, known IP address and host name
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['REMOTE_HOST'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
     // Set different and same IP addresses to ignore
     $conf['logging']['ignoreHosts'] = '23.23.23.23,' . gethostbyaddr($_SERVER['REMOTE_ADDR']);
     // Test
     $this->assertFalse(_viewersHostOkayToLog());
     // Test that 24.24.24.24 doesn't permit 124.24.24.24
     $conf['logging']['ignoreHosts'] = '24.24.24.24';
     $_SERVER['REMOTE_ADDR'] = '124.24.24.24';
     $this->assertTrue(_viewersHostOkayToLog());
     // Reset the configuration
     TestEnv::restoreConfig();
     // Test the ignore/enforce User-Agent features
     $browserUserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) ';
     $botUserAgent = 'Yahoo! Slurp';
     // Nothing in either restriction list, should return true
     $conf['logging']['ignoreUserAgents'] = '';
     $conf['logging']['enforceUserAgents'] = '';
     // Empty user-agent
     $_SERVER['HTTP_USER_AGENT'] = '';
     $this->assertTrue(_viewersHostOkayToLog());
     // Valid user-agent:
     $_SERVER['HTTP_USER_AGENT'] = $browserUserAgent;
     $this->assertTrue(_viewersHostOkayToLog());
     // Bot
     $_SERVER['HTTP_USER_AGENT'] = $botUserAgent;
     $this->assertTrue(_viewersHostOkayToLog());
     // Enforce valid
     $conf['logging']['enforceUserAgents'] = $browserUserAgent;
     $conf['logging']['ignoreUserAgents'] = '';
     // Empty user-agent
     $_SERVER['HTTP_USER_AGENT'] = '';
     $this->assertFalse(_viewersHostOkayToLog());
     // Valid user-agent:
     $_SERVER['HTTP_USER_AGENT'] = $browserUserAgent;
     $this->assertTrue(_viewersHostOkayToLog());
     // Bot
     $_SERVER['HTTP_USER_AGENT'] = $botUserAgent;
     $this->assertFalse(_viewersHostOkayToLog());
     // Ignore bots
     $conf['logging']['enforceUserAgents'] = '';
     $conf['logging']['ignoreUserAgents'] = $botUserAgent;
     // Empty user-agent
     $_SERVER['HTTP_USER_AGENT'] = '';
     $this->assertTrue(_viewersHostOkayToLog());
     // Valid user-agent:
     $_SERVER['HTTP_USER_AGENT'] = $browserUserAgent;
     $this->assertTrue(_viewersHostOkayToLog());
     // Bot
     $_SERVER['HTTP_USER_AGENT'] = $botUserAgent;
     $this->assertFalse(_viewersHostOkayToLog());
     // Ignore bots
     $conf['logging']['enforceUserAgents'] = $browserUserAgent;
     $conf['logging']['ignoreUserAgents'] = $botUserAgent;
     // Empty user-agent
     $_SERVER['HTTP_USER_AGENT'] = '';
     $this->assertFalse(_viewersHostOkayToLog());
     // Valid user-agent:
     $_SERVER['HTTP_USER_AGENT'] = $browserUserAgent;
     $this->assertTrue(_viewersHostOkayToLog());
     // Bot
     $_SERVER['HTTP_USER_AGENT'] = $botUserAgent;
     $this->assertFalse(_viewersHostOkayToLog());
     // Check that valid and bot conf settings can be | delimited strings
     $conf['logging']['enforceUserAgents'] = 'BlackBerry|HotJava|' . $browserUserAgent . '|iCab';
     $conf['loggnig']['ignoreUserAgents'] = 'AdsBot-Google|ask+jeeves|' . $botUserAgent . '|YahooSeeker';
     // Empty user-agent
     $_SERVER['HTTP_USER_AGENT'] = '';
     $this->assertFalse(_viewersHostOkayToLog());
     // Valid user-agent:
     $_SERVER['HTTP_USER_AGENT'] = $browserUserAgent;
     $this->assertTrue(_viewersHostOkayToLog());
     // Bot
     $_SERVER['HTTP_USER_AGENT'] = $botUserAgent;
     $this->assertFalse(_viewersHostOkayToLog());
     // Reset the configuration
     TestEnv::restoreConfig();
     $_SERVER = $serverSave;
 }
function bumpVastEventTrackingBucketCounter($data)
{
    $aQuery = array('interval_start' => $data['interval_start'], 'creative_id' => $data['creative_id'], 'zone_id' => $data['zone_id'], 'vast_event_id' => $data['vast_event_id']);
    return OX_bucket_updateTable('data_bkt_vast_e', $aQuery);
}
###START_STRIP_DELIVERY
OX_Delivery_logMessage('starting delivery script ' . __FILE__, 7);
###END_STRIP_DELIVERY
MAX_commonRegisterGlobalsArray(array('vast_event'));
// if its a vast tracking event
if ($vast_event) {
    // NB: videotimeposn is not yet supported by the player
    MAX_commonRegisterGlobalsArray(array('video_time_posn', 'banner_id', 'zone_id'));
    // Prevent the logging beacon from being cached by browsers
    MAX_commonSetNoCacheHeaders();
    // Remove any special characters from the request variables
    MAX_commonRemoveSpecialChars($_REQUEST);
    $time = getTimeNow();
    $oi = $GLOBALS['_MAX']['CONF']['maintenance']['operationInterval'];
    $intervalStart = gmdate('Y-m-d H:i:s', $time - $time % ($oi * 60));
    $viewerIsOkToLog = _viewersHostOkayToLog();
    $aQuery = array('creative_id' => intVal($banner_id), 'zone_id' => intVal($zone_id), 'vast_event_id' => getVastEventIdFromVastEventStr($vast_event), 'interval_start' => $intervalStart, 'is_host_ok' => $viewerIsOkToLog);
    if ($viewerIsOkToLog) {
        bumpVastEventTrackingBucketCounter($aQuery);
    }
    if (!empty($_REQUEST[$GLOBALS['_MAX']['CONF']['var']['dest']])) {
        MAX_redirect($_REQUEST[$GLOBALS['_MAX']['CONF']['var']['dest']]);
        exit;
    }
}
MAX_commonDisplay1x1();