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


PHP OA_setTimeZoneUTC函数代码示例

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


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

示例1: testDeliveryBlocked

 /**
  * A method to test the deliveryBlocked() method.
  */
 function testDeliveryBlocked()
 {
     OA_setTimeZoneUTC();
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '=~', 'data' => '1,5,7,20', 'executionorder' => 1);
     $oLimitationHour = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-07 23:15:45');
     for ($i = 0; $i < 24; $i++) {
         $oDate->addSeconds(SECONDS_PER_HOUR);
         if ($i == 1 || $i == 5 || $i == 7 || $i == 20) {
             $this->assertFalse($oLimitationHour->deliveryBlocked($oDate));
         } else {
             $this->assertTrue($oLimitationHour->deliveryBlocked($oDate));
         }
     }
     // Test timezone
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '=~', 'data' => '1,5,7,20@Europe/Rome', 'executionorder' => 1);
     $oLimitationHour = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-07 23:15:45');
     for ($i = 0; $i < 24; $i++) {
         $oDate->addSeconds(SECONDS_PER_HOUR);
         if ($i == 0 || $i == 4 || $i == 6 || $i == 19) {
             $this->assertFalse($oLimitationHour->deliveryBlocked($oDate));
         } else {
             $this->assertTrue($oLimitationHour->deliveryBlocked($oDate));
         }
     }
     OA_setTimeZoneLocal();
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:31,代码来源:MpeTimeHour.plg.test.php

示例2: setupConfigVariables

/**
 * Setup common variables - used by both delivery and admin part as well
 *
 * This function should be executed after the config file is read in.
 *
 * The reason behind using GLOBAL variables is that
 * there are faster than constants
 */
function setupConfigVariables()
{
    $GLOBALS['_MAX']['MAX_DELIVERY_MULTIPLE_DELIMITER'] = '|';
    $GLOBALS['_MAX']['MAX_COOKIELESS_PREFIX'] = '__';
    // Set the URL access mechanism
    if (!empty($GLOBALS['_MAX']['CONF']['openads']['requireSSL'])) {
        $GLOBALS['_MAX']['HTTP'] = 'https://';
    } else {
        if (isset($_SERVER['SERVER_PORT'])) {
            if (isset($GLOBALS['_MAX']['CONF']['openads']['sslPort']) && $_SERVER['SERVER_PORT'] == $GLOBALS['_MAX']['CONF']['openads']['sslPort']) {
                $GLOBALS['_MAX']['HTTP'] = 'https://';
            } else {
                $GLOBALS['_MAX']['HTTP'] = 'http://';
            }
        }
    }
    // Maximum random number (use default if doesn't exist - eg the case when application is upgraded)
    $GLOBALS['_MAX']['MAX_RAND'] = isset($GLOBALS['_MAX']['CONF']['priority']['randmax']) ? $GLOBALS['_MAX']['CONF']['priority']['randmax'] : 2147483647;
    list($micro_seconds, $seconds) = explode(" ", microtime());
    $GLOBALS['_MAX']['NOW_ms'] = round(1000 * ((double) $micro_seconds + (double) $seconds));
    // Always use UTC when outside the installer
    if (substr($_SERVER['SCRIPT_NAME'], -11) != 'install.php') {
        OA_setTimeZoneUTC();
    }
}
开发者ID:villos,项目名称:tree_admin,代码行数:33,代码来源:variables.php

示例3: testCheckTimeDay

 function testCheckTimeDay()
 {
     OA_setTimeZoneUTC();
     // =~ and !~ - Single value
     $this->assertTrue(MAX_checkTime_Day('3', '=~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     $this->assertTrue(MAX_checkTime_Day('3', '!~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     // =~ and !~ - Multiple value
     $this->assertTrue(MAX_checkTime_Day('1,3,4', '=~', array('timestamp' => mktime(0, 0, 0, 7, 6, 2009))));
     // Mon
     $this->assertTrue(MAX_checkTime_Day('1,3,4', '=~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     $this->assertTrue(MAX_checkTime_Day('1,3,4', '!~', array('timestamp' => mktime(0, 0, 0, 7, 3, 2009))));
     // Fri
     $this->assertFalse(MAX_checkTime_Day('1,3,4', '!~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     // =~ and !~ - Single value with TZ
     $this->assertTrue(MAX_checkTime_Day('2@America/New_York', '=~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     $this->assertTrue(MAX_checkTime_Day('2@America/New_York', '!~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     // =~ and !~ - Multiple value with TZ
     $this->assertTrue(MAX_checkTime_Day('0,2,3@America/New_York', '=~', array('timestamp' => mktime(0, 0, 0, 7, 6, 2009))));
     // Mon
     $this->assertTrue(MAX_checkTime_Day('0,2,3@America/New_York', '=~', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // Thu
     $this->assertTrue(MAX_checkTime_Day('0,2,3@America/New_York', '!~', array('timestamp' => mktime(0, 0, 0, 7, 3, 2009))));
     // Fri
     $this->assertFalse(MAX_checkTime_Day('0,2,3@America/New_York', '!~', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     // Wed
     OA_setTimeZoneLocal();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:33,代码来源:DeliveryLimitationsTimeDay.plg.test.php

示例4: run

 /**
  * A method to run maintenance.
  */
 function run()
 {
     // Print a blank line in the debug log file when maintenance starts
     OA::debug();
     // Do not run if distributed stats are enabled
     if (!empty($this->aConf['lb']['enabled'])) {
         OA::debug('Distributed stats enabled, not running maintenance tasks', PEAR_LOG_INFO);
         return;
     }
     // Acquire the maintenance lock
     $oLock =& OA_DB_AdvisoryLock::factory();
     if ($oLock->get(OA_DB_ADVISORYLOCK_MAINTENANCE)) {
         OA::switchLogIdent('maintenance');
         OA::debug();
         OA::debug('Running Maintenance Engine', PEAR_LOG_INFO);
         // Attempt to increase PHP memory
         OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('maintenance'));
         // Set UTC timezone
         OA_setTimeZoneUTC();
         // Get last run
         $oLastRun = $this->getLastRun();
         // Update the timestamp for old maintenance code and auto-maintenance
         $this->updateLastRun();
         // Record the current time, and register with the OA_ServiceLocator
         $oDate = new Date();
         $oServiceLocator =& OA_ServiceLocator::instance();
         $oServiceLocator->register('now', $oDate);
         // Check the operation interval is valid
         $result = OX_OperationInterval::checkOperationIntervalValue($this->aConf['maintenance']['operationInterval']);
         if (PEAR::isError($result)) {
             // Unable to continue!
             $oLock->release();
             OA::debug('Aborting maintenance: Invalid Operation Interval length', PEAR_LOG_CRIT);
             exit;
         }
         // Run the Maintenance Statistics Engine (MSE) process
         $this->_runMSE();
         // Run the "midnight" tasks, if required
         if ($this->isMidnightMaintenance($oLastRun)) {
             $this->_runMidnightTasks();
         }
         // Release lock before starting MPE
         $oLock->release();
         // Run the Maintenance Priority Engine (MPE) process, ensuring that the
         // process always runs, even if instant update of priorities is disabled
         $this->_runMPE();
         // Log the completion of the entire ME process
         OA::switchLogIdent('maintenance');
         $oEndDate = new Date();
         $oDateSpan = new Date_Span();
         $oDateSpan->setFromDateDiff($oDate, $oEndDate);
         OA::debug('Maintenance Engine Completed (Started at ' . $oDate->format('%Y-%m-%d %H:%M:%S') . ' ' . $oDate->tz->getShortName() . ', taking ' . $oDateSpan->format('%H:%M:%S') . ')', PEAR_LOG_INFO);
         OA::switchLogIdent();
     } else {
         OA::switchLogIdent('maintenance');
         OA::debug('Maintenance Engine not run: could not acquire lock', PEAR_LOG_INFO);
         OA::switchLogIdent();
     }
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:62,代码来源:Maintenance.php

示例5: Test_OA_Maintenance_Priority_DeliveryLimitation

 /**
  * The constructor method.
  */
 function Test_OA_Maintenance_Priority_DeliveryLimitation()
 {
     $this->UnitTestCase();
     Mock::generatePartial('OA_Maintenance_Priority_DeliveryLimitation', 'Partial_MockOA_Maintenance_Priority_DeliveryLimitation', array('_getOperationInterval'));
     // Install the openXDeliveryLog plugin
     TestEnv::uninstallPluginPackage('openXDeliveryLimitations', false);
     TestEnv::installPluginPackage('openXDeliveryLimitations', false);
     OA_setTimeZoneUTC();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:12,代码来源:DeliveryLimitation.mtp.test.php

示例6: _testImageServe

 function _testImageServe($timeZone)
 {
     OA_setTimeZone($timeZone);
     $fileName = 'tz_test.gif';
     $doImages = OA_Dal::factoryDO('images');
     $doImages->filename = $fileName;
     $doImages->contents = '';
     $this->assertTrue(DataGenerator::generateOne($doImages));
     $now = time();
     $this->assertTrue($timeZone == 'UTC' || date('Z', $now), 'Time zone not correctly set');
     // Simulate delivery
     OA_setTimeZoneUTC();
     $aCreative = OA_Dal_Delivery_getCreative($fileName);
     $this->assertTrue($aCreative);
     // Serve with no If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
         $this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
     }
     // 1-day old If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now - 86400) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
         $this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
     }
     // 1-day future If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now + 86400) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 1, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^HTTP\\/1.0 304/i', $GLOBALS['_HEADERS'][0]);
     }
     // 1 minute ago If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now - 60) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 2, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^Last-Modified: /i', $GLOBALS['_HEADERS'][0]);
         $this->assertPattern('/^Content-Type: /i', $GLOBALS['_HEADERS'][1]);
     }
     // 1 minute in future If-Modified-Since header
     unset($GLOBALS['_HEADERS']);
     $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s', $now + 60) . ' GMT';
     MAX_imageServe($aCreative, $fileName, 'gif');
     if ($this->assertEqual(count($GLOBALS['_HEADERS']), 1, 'Mismatching headers with ' . $timeZone)) {
         $this->assertPattern('/^HTTP\\/1.0 304/i', $GLOBALS['_HEADERS'][0]);
     }
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:53,代码来源:DeliveryDB_Image.dal.test.php

示例7: testDeliveryBlocked

 /**
  * A method to test the deliveryBlocked() method.
  */
 function testDeliveryBlocked()
 {
     OA_setTimeZoneUTC();
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Day', 'comparison' => '=~', 'data' => '1,5,4,6', 'executionorder' => 1);
     $oLimitationDay = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-05');
     // Sunday
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-06');
     // Monday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-07');
     // Tuesday
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-08');
     // Wednesday
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-09');
     // Thursday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-10');
     // Friday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-11');
     // Saturday
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     // Test timezone
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Day', 'comparison' => '=~', 'data' => '1,5,4,6@America/New_York', 'executionorder' => 1);
     $oLimitationDay = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-05');
     // Sunday, but Saturday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-06');
     // Monday, but Sunday in GMT-5
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-07');
     // Tuesday, but Monday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-08');
     // Wednesday, but Tuesday in GMT-5
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-09');
     // Thursday, but Wednesday in GMT-5
     $this->assertTrue($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-10');
     // Friday, but Friday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     $oDate = new Date('2006-02-11');
     // Saturday, but Friday in GMT-5
     $this->assertFalse($oLimitationDay->deliveryBlocked($oDate));
     OA_setTimeZoneLocal();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:55,代码来源:MpeTimeDay.plg.test.php

示例8: MAX_checkTime_Date

/**
 * Check to see if this impression contains the valid date.
 *
 * @param string $limitation The date limitation
 * @param string $op The operator (either '==' or '!=')
 * @param array $aParams An array of additional parameters to be checked
 * @return boolean Whether this impression's date passes this limitation's test.
 */
function MAX_checkTime_Date($limitation, $op, $aParams = array())
{
    // Get timezone, if any
    $offset = strpos($limitation, '@');
    if ($offset !== false) {
        $tz = substr($limitation, $offset + 1);
        $limitation = substr($limitation, 0, $offset);
    } else {
        $tz = false;
    }
    if ($limitation == '' && $limitation == '00000000') {
        return true;
    }
    $timestamp = !empty($aParams['timestamp']) ? $aParams['timestamp'] : time();
    if ($tz && $tz != 'UTC') {
        OA_setTimeZone($tz);
        $date = date('Ymd', $timestamp);
        OA_setTimeZoneUTC();
    } else {
        $date = gmdate('Ymd', $timestamp);
    }
    switch ($op) {
        case '==':
            return $date == $limitation;
            break;
        case '!=':
            return $date != $limitation;
            break;
        case '<=':
            return $date <= $limitation;
            break;
        case '>=':
            return $date >= $limitation;
            break;
        case '<':
            return $date < $limitation;
            break;
        case '>':
            return $date > $limitation;
            break;
    }
    return true;
}
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:51,代码来源:Date.delivery.php

示例9: testCheckTimeHour

 function testCheckTimeHour()
 {
     OA_setTimeZoneUTC();
     // =~ and !~ - Single value
     $this->assertTrue(MAX_checkTime_Hour('3', '=~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('3', '!~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     // =~ and !~ - Multiple value
     $this->assertTrue(MAX_checkTime_Hour('1,3,4', '=~', array('timestamp' => mktime(1, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('1,3,4', '=~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('1,3,4', '!~', array('timestamp' => mktime(5, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Hour('1,3,4', '!~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     // =~ and !~ - Single value with TZ
     $this->assertTrue(MAX_checkTime_Hour('5@Europe/Rome', '=~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('5@Europe/Rome', '!~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     // =~ and !~ - Multiple value with TZ
     $this->assertTrue(MAX_checkTime_Hour('3,5,6@Europe/Rome', '=~', array('timestamp' => mktime(1, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('3,5,6@Europe/Rome', '=~', array('timestamp' => mktime(4, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Hour('3,5,6@Europe/Rome', '!~', array('timestamp' => mktime(5, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Hour('3,5,6@Europe/Rome', '!~', array('timestamp' => mktime(3, 0, 0, 7, 1, 2009))));
     OA_setTimeZoneLocal();
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:21,代码来源:DeliveryLimitationsTimeHour.plg.test.php

示例10: setupConfigVariables

/**
 * Setup common variables - used by both delivery and admin part as well
 *
 * This function should be executed after the config file is read in.
 *
 * The reason behind using GLOBAL variables is that
 * there are faster than constants
 */
function setupConfigVariables()
{
    $GLOBALS['_MAX']['MAX_DELIVERY_MULTIPLE_DELIMITER'] = '|';
    $GLOBALS['_MAX']['MAX_COOKIELESS_PREFIX'] = '__';
    $GLOBALS['_MAX']['thread_id'] = uniqid();
    // Set a flag if this request was made over an SSL connection (used more for delivery rather than UI)
    $GLOBALS['_MAX']['SSL_REQUEST'] = false;
    if (!empty($_SERVER['SERVER_PORT']) && !empty($GLOBALS['_MAX']['CONF']['openads']['sslPort']) && $_SERVER['SERVER_PORT'] == $GLOBALS['_MAX']['CONF']['openads']['sslPort'] || !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == 1) || !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower($_SERVER['HTTP_X_FORWARDED_SSL']) == 'on' || !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) == 'on' || !empty($_SERVER['FRONT-END-HTTPS']) && strtolower($_SERVER['FRONT-END-HTTPS']) == 'on') {
        // This request should be treated as if it was received over an SSL connection
        $GLOBALS['_MAX']['SSL_REQUEST'] = true;
    }
    // Maximum random number (use default if doesn't exist - eg the case when application is upgraded)
    $GLOBALS['_MAX']['MAX_RAND'] = isset($GLOBALS['_MAX']['CONF']['priority']['randmax']) ? $GLOBALS['_MAX']['CONF']['priority']['randmax'] : 2147483647;
    list($micro_seconds, $seconds) = explode(" ", microtime());
    $GLOBALS['_MAX']['NOW_ms'] = round(1000 * ((double) $micro_seconds + (double) $seconds));
    // Always use UTC when outside the installer
    if (substr($_SERVER['SCRIPT_NAME'], -11) != 'install.php') {
        // Save server timezone for auto-maintenance
        $GLOBALS['serverTimezone'] = date_default_timezone_get();
        OA_setTimeZoneUTC();
    }
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:30,代码来源:variables.php

示例11: testCheckTimeDay

 function testCheckTimeDay()
 {
     OA_setTimeZoneUTC();
     // All operators, active
     $this->assertTrue(MAX_checkTime_Date('20090701', '==', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '!=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '!=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '<', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '>', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '<=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '<=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '>=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701', '>=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // All operators, inactive
     $this->assertFalse(MAX_checkTime_Date('20090701', '==', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '!=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '<', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '>', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '<=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701', '>=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     // All operators, active with TZ
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '==', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '!=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '!=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '<', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '>', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '<=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '<=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '>=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertTrue(MAX_checkTime_Date('20090701@Europe/Rome', '>=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     // All operators, inactive with TZ
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '==', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '!=', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '<', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '>', array('timestamp' => mktime(0, 0, 0, 7, 1, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '<=', array('timestamp' => mktime(0, 0, 0, 7, 2, 2009))));
     $this->assertFalse(MAX_checkTime_Date('20090701@Europe/Rome', '>=', array('timestamp' => mktime(0, 0, 0, 6, 30, 2009))));
     OA_setTimeZoneLocal();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:39,代码来源:DeliveryLimitationsTimeDate.plg.test.php

示例12: MAX_checkTime_Day

/**
 * Check to see if this impression contains the valid day.
 *
 * @param string $limitation The day limitation
 * @param string $op The operator (either '==' or '!=')
 * @param array $aParams An array of additional parameters to be checked
 * @return boolean Whether this impression's day passes this limitation's test.
 */
function MAX_checkTime_Day($limitation, $op, $aParams = array())
{
    // Get timezone, if any
    $offset = strpos($limitation, '@');
    if ($offset !== false) {
        $tz = substr($limitation, $offset + 1);
        $limitation = substr($limitation, 0, $offset);
    } else {
        $tz = false;
    }
    if ($limitation == '') {
        return true;
    }
    $timestamp = !empty($aParams['timestamp']) ? $aParams['timestamp'] : time();
    if ($tz && $tz != 'UTC') {
        OA_setTimeZone($tz);
        $day = date('w', $timestamp);
        OA_setTimeZoneUTC();
    } else {
        $day = gmdate('w', $timestamp);
    }
    return MAX_limitationsMatchArrayValue($day, $limitation, $op, $aParams);
}
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:31,代码来源:Day.delivery.php

示例13: setupConfigVariables

function setupConfigVariables()
{
    $GLOBALS['_MAX']['MAX_DELIVERY_MULTIPLE_DELIMITER'] = '|';
    $GLOBALS['_MAX']['MAX_COOKIELESS_PREFIX'] = '__';
    $GLOBALS['_MAX']['thread_id'] = uniqid();
    $GLOBALS['_MAX']['SSL_REQUEST'] = false;
    if (!empty($_SERVER['SERVER_PORT']) && !empty($GLOBALS['_MAX']['CONF']['openads']['sslPort']) && $_SERVER['SERVER_PORT'] == $GLOBALS['_MAX']['CONF']['openads']['sslPort'] || !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on' || $_SERVER['HTTPS'] == 1) || !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower($_SERVER['HTTP_X_FORWARDED_SSL']) == 'on' || !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) == 'on' || !empty($_SERVER['FRONT-END-HTTPS']) && strtolower($_SERVER['FRONT-END-HTTPS']) == 'on') {
        $GLOBALS['_MAX']['SSL_REQUEST'] = true;
    }
    $GLOBALS['_MAX']['MAX_RAND'] = isset($GLOBALS['_MAX']['CONF']['priority']['randmax']) ? $GLOBALS['_MAX']['CONF']['priority']['randmax'] : 2147483647;
    list($micro_seconds, $seconds) = explode(" ", microtime());
    $GLOBALS['_MAX']['NOW_ms'] = round(1000 * ((double) $micro_seconds + (double) $seconds));
    if (substr($_SERVER['SCRIPT_NAME'], -11) != 'install.php') {
        $GLOBALS['serverTimezone'] = date_default_timezone_get();
        OA_setTimeZoneUTC();
    }
}
开发者ID:JackyKit,项目名称:revive-adserver,代码行数:17,代码来源:ti.php

示例14: testDeliveryBlocked

 /**
  * A method to test the deliveryBlocked() method.
  *
  * Test 1: Test date == delivery requirement
  * Test 2: Test date != delivery requirement
  * Test 3: Test date <= delivery requirement
  * Test 4: Test date >= delivery requirement
  * Test 5: Test date <  delivery requirement
  * Test 6: Test date >  delivery requirement
  * Test 7: Bad input, no date object passed to method
  */
 function testDeliveryBlocked()
 {
     // Set timezone to UTC
     OA_setTimeZoneUTC();
     $oDate = new Date('2005-04-03');
     $oEarlierDate = new Date('2005-04-02');
     $oLaterDate = new Date('2005-04-04');
     $limitationData = $oDate->format('%Y%m%d@%Z');
     // Test 1
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '==', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 2
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '!=', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 3
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '<=', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 4
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '>=', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 5
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '<', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 6
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '>', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date: true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date: false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Test 7
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '>', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     PEAR::pushErrorHandling(null);
     $this->assertTrue(is_a($oLimitationDate->deliveryBlocked('not a date'), 'pear_error'));
     PEAR::popErrorHandling();
     // Test with PST timezone
     $limitationData = $oDate->format('%Y%m%d') . '@America/New_York';
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Date', 'comparison' => '==', 'data' => $limitationData, 'executionorder' => 1);
     $oLimitationDate = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     // Test with same date (-1 day, 19pm in EST): true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oDate));
     // Test with ealier date (-2 days, 19pm in EST): true, ad is inactive
     $this->assertTrue($oLimitationDate->deliveryBlocked($oEarlierDate));
     // Test with later date (-0 days, 19pm in EST): false, ad is active
     $this->assertFalse($oLimitationDate->deliveryBlocked($oLaterDate));
     // Reset timezone
     OA_setTimeZoneLocal();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:92,代码来源:MpeTimeDate.plg.test.php

示例15: OA_setTimeZoneUTC

<?php

/*
+---------------------------------------------------------------------------+
| Revive Adserver                                                           |
| http://www.revive-adserver.com                                            |
|                                                                           |
| Copyright: See the COPYRIGHT.txt file.                                    |
| License: GPLv2 or later, see the LICENSE.txt file.                        |
+---------------------------------------------------------------------------+
*/
// Require the initialisation file
require_once '../../init.php';
// Required files
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/lib/OA/Maintenance/Priority.php';
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN);
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
// Set timezone to UTC
OA_setTimeZoneUTC();
// Run the Maintenance Priority Engine process
OA_Maintenance_Priority::run();
// Rebuild cache
// include_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php';
// phpAds_cacheDelete();
OX_Admin_Redirect::redirect('maintenance-priority.php');
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:29,代码来源:maintenance-priority-calculate.php


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