/**
  * A method to update maintenance last run information for
  * old maintenance code.
  */
 function updateLastRun($bScheduled = false)
 {
     $sField = $bScheduled ? 'maintenance_cron_timestamp' : 'maintenance_timestamp';
     OA_Dal_ApplicationVariables::set($sField, OA::getNow('U'));
     // Make sure that the maintenance delivery cache is regenerated
     MAX_cacheCheckIfMaintenanceShouldRun(false);
 }
Example #2
0
        $adId = $aAdIds[$index];
        // Log the ad impression, if required
        if ($GLOBALS['_MAX']['CONF']['logging']['adImpressions']) {
            MAX_Delivery_log_logAdImpression($adId, $aZoneIds[$index]);
        }
        if ($aAdIds[$index] == $adId) {
            // Set the capping cookies, if required
            MAX_Delivery_log_setAdLimitations($index, $aAdIds, $aCapAd);
            MAX_Delivery_log_setCampaignLimitations($index, $aCampaignIds, $aCapCampaign);
            MAX_Delivery_log_setLastAction($index, $aAdIds, $aZoneIds, $aSetLastSeen);
            if ($aZoneIds[$index] != 0) {
                MAX_Delivery_log_setZoneLimitations($index, $aZoneIds, $aCapZone);
            }
        }
    }
}
MAX_cookieFlush();
MAX_querystringConvertParams();
if (!empty($_REQUEST[$GLOBALS['_MAX']['CONF']['var']['dest']])) {
    MAX_redirect($_REQUEST[$GLOBALS['_MAX']['CONF']['var']['dest']]);
} else {
    // Display a 1x1 pixel gif
    MAX_commonDisplay1x1();
}
// Run automaintenance, if needed
if (!empty($GLOBALS['_MAX']['CONF']['maintenance']['autoMaintenance']) && empty($GLOBALS['_MAX']['CONF']['lb']['enabled'])) {
    if (MAX_cacheCheckIfMaintenanceShouldRun()) {
        include MAX_PATH . '/lib/OA/Maintenance/Auto.php';
        OA_Maintenance_Auto::run();
    }
}
 /**
  * Creates all possible delivert cache files
  *
  * @param array $aIds array of DB Ids returned by _createTestData
  * @see _createTestData
  */
 function _createTestCacheFiles($aIds)
 {
     // Create cache files not related to DB Objects
     MAX_cacheGetAccountTZs();
     MAX_cacheCheckIfMaintenanceShouldRun();
     MAX_cacheGetGoogleJavaScript();
     // Create cache files for banners and images
     foreach ($aIds['banners'] as $bannerId) {
         MAX_cacheGetAd($bannerId);
     }
     foreach ($aIds['images'] as $filename) {
         MAX_cacheGetCreative($filename);
     }
     // Create cache files for zones
     foreach ($aIds['zones'] as $zoneId) {
         MAX_cacheGetZoneLinkedAds($zoneId);
         MAX_cacheGetZoneInfo($zoneId);
     }
     // Create cache files for websites
     foreach ($aIds['affiliates'] as $affiliateid) {
         OA_cacheGetPublisherZones($affiliateid);
     }
     // Create cache files for trackers
     foreach ($aIds['trackers'] as $trackerid) {
         MAX_cacheGetTracker($trackerid);
         MAX_cacheGetTrackerVariables($trackerid);
     }
     // Create cache files for channels
     foreach ($aIds['channel'] as $channelid) {
         MAX_cacheGetChannelLimitations($channelid);
     }
     // cache files for direct-selection are not created
     // due to problems with invalidating MAX_cacheGetLinkedAds
 }
 /**
  * Method tests invalidateSystemSettingsCache method
  */
 function test_invalidateSystemSettingsCache()
 {
     $interval = $GLOBALS['_MAX']['CONF']['maintenance']['operationInterval'] * 60;
     $delay = intval($GLOBALS['_MAX']['CONF']['maintenance']['operationInterval'] / 12 * 60);
     // store orginal settings
     $currentClick = $GLOBALS['_MAX']['CONF']['file']['click'];
     // Set maintenace timestamp to 48h ago
     $doAppVar = OA_Dal::factoryDO('application_variable');
     $doAppVar->name = 'maintenance_timestamp';
     $doAppVar->value = MAX_commonGetTimeNow() - 2 * $interval;
     $doAppVar->insert();
     // Remember current cache
     $cachedJSData = MAX_cacheGetGoogleJavaScript();
     $cachedTZData = MAX_cacheGetAccountTZs();
     $cachedMaintenanceData = MAX_cacheCheckIfMaintenanceShouldRun();
     // Change JS settings, Time Zone, and time of Last Run of maintenace
     $GLOBALS['_MAX']['CONF']['file']['click'] = 'click.php';
     $doAppVar->name = 'maintenance_timestamp';
     $doAppVar->value = MAX_commonGetTimeNow() + $delay + 1;
     $doAppVar->update();
     // Add Admin user and set time zone in his preferences
     $doAccount = OA_Dal::factoryDO('accounts');
     $doAccount->account_type = 'ADMIN';
     $accountId = DataGenerator::generateOne($doAccount);
     $doPreferences = OA_Dal::factoryDO('preferences');
     $doPreferences->preference_name = 'timezone';
     $doPreferences->value = 'new value';
     $doPreferences->account_type = 'ADMIN';
     $preferencesId = DataGenerator::generateOne($doPreferences);
     $doAccountPreferenceAssoc = OA_Dal::factoryDO('account_preference_assoc');
     $doAccountPreferenceAssoc->account_id = $accountId;
     $doAccountPreferenceAssoc->preference_id = $preferencesId;
     $doAccountPreferenceAssoc->value = 'new value';
     DataGenerator::generateOne($doAccountPreferenceAssoc);
     // Expect no changes in cache files
     $this->assertEqual(MAX_cacheGetGoogleJavaScript(), $cachedJSData);
     $this->assertEqual(MAX_cacheGetAccountTZs(), $cachedTZData);
     $this->assertEqual(MAX_cacheCheckIfMaintenanceShouldRun(), $cachedMaintenanceData);
     $this->oDeliveryCacheManager->invalidateSystemSettingsCache();
     // Now expect changes in cache files
     $this->assertNotEqual(MAX_cacheGetGoogleJavaScript(), $cachedJSData);
     $this->assertNotEqual(MAX_cacheGetAccountTZs(), $cachedTZData);
     $this->assertNotEqual(MAX_cacheCheckIfMaintenanceShouldRun(), $cachedMaintenanceData);
     // restore orginal settings
     $GLOBALS['_MAX']['CONF']['file']['click'] = $currentClick;
 }
 /**
  * Method tests invalidateCheckIfMaintenanceShouldRunCache method
  */
 function test_invalidateCheckIfMaintenanceShouldRunCache()
 {
     $interval = $GLOBALS['_MAX']['CONF']['maintenance']['operationInterval'] * 60;
     $delay = intval($GLOBALS['_MAX']['CONF']['maintenance']['operationInterval'] / 12 * 60);
     // Set value for maintenace_timestamp that maintenace should run now
     $doAppVar = OA_Dal::factoryDO('application_variable');
     $doAppVar->name = 'maintenance_timestamp';
     $doAppVar->value = MAX_commonGetTimeNow() - 2 * $interval;
     $doAppVar->insert();
     $cachedData = MAX_cacheCheckIfMaintenanceShouldRun();
     // Set value for maintenace_timestamp that maintenace shouldn't be run
     $doAppVar = OA_Dal::factoryDO('application_variable');
     $doAppVar->name = 'maintenance_timestamp';
     $doAppVar->value = MAX_commonGetTimeNow() + $delay + 1;
     $doAppVar->update();
     // Expect no changes in cache
     $this->assertEqual(MAX_cacheCheckIfMaintenanceShouldRun(), $cachedData);
     $this->oDeliveryCacheCommon->invalidateCheckIfMaintenanceShouldRunCache();
     // Now expect changes in cache
     $this->assertNotEqual(MAX_cacheCheckIfMaintenanceShouldRun(), $cachedData);
 }