예제 #1
0
파일: ag.php 프로젝트: villos/tree_admin
}
function MAX_cacheGetGoogleJavaScript($cached = true)
{
    $sName = OA_Delivery_Cache_getName(__FUNCTION__);
    if (!$cached || ($output = OA_Delivery_Cache_fetch($sName)) === false) {
        $file = '/lib/max/Delivery/google.php';
        if (!isset($GLOBALS['_MAX']['FILES'][$file])) {
            include MAX_PATH . $file;
        }
        $output = MAX_googleGetJavaScript();
        $output = OA_Delivery_Cache_store_return($sName, $output);
    }
    return $output;
}
function OA_cacheGetPublisherZones($affiliateid, $cached = true)
{
    $sName = OA_Delivery_Cache_getName(__FUNCTION__, $affiliateid);
    if (!$cached || ($output = OA_Delivery_Cache_fetch($sName)) === false) {
        MAX_Dal_Delivery_Include();
        $output = OA_Dal_Delivery_getPublisherZones($affiliateid);
        $output = OA_Delivery_Cache_store_return($sName, $output);
    }
    return $output;
}
// Get JS
$output = MAX_cacheGetGoogleJavaScript();
// Output JS
MAX_commonSendContentTypeHeader("application/x-javascript");
MAX_header("Content-Size: " . strlen($output));
MAX_header("Expires: " . gmdate('r', time() + 86400));
echo $output;
 /**
  * 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 invalidateGetGoogleJavaScriptCache method
  */
 function test_invalidateGetGoogleJavaScriptCache()
 {
     $cachedData = MAX_cacheGetGoogleJavaScript();
     $currentClick = $GLOBALS['_MAX']['CONF']['file']['click'];
     $GLOBALS['_MAX']['CONF']['file']['click'] = 'newclick.php';
     // Expect no changes in cache
     $this->assertEqual(MAX_cacheGetGoogleJavaScript(), $cachedData);
     $this->oDeliveryCacheCommon->invalidateGetGoogleJavaScriptCache();
     // Now expect changes in cache
     $this->assertNotEqual(MAX_cacheGetGoogleJavaScript(), $cachedData);
     $GLOBALS['_MAX']['CONF']['file']['click'] = $currentClick;
 }