Example #1
0
 public static function getCookieProcessor($siteID)
 {
     if (empty($siteID)) {
         return false;
     }
     $sites = getSitesData(array($siteID));
     $siteData = $sites[$siteID];
     $type = 'cookie';
     $action = 'get';
     $requestAction = 'get_cookie';
     $requestParams = array();
     $historyAdditionalData[] = array('uniqueName' => 'getCookie', 'detailedAction' => 'get');
     $PRP = array();
     $PRP['requestAction'] = $requestAction;
     $PRP['requestParams'] = $requestParams;
     $PRP['siteData'] = $siteData;
     $PRP['type'] = $type;
     $PRP['action'] = $action;
     $PRP['events'] = 1;
     $PRP['historyAdditionalData'] = $historyAdditionalData;
     $PRP['doNotExecute'] = false;
     $PRP['directExecute'] = true;
     $PRP['sendAfterAllLoad'] = false;
     $PRP['exitOnComplete'] = false;
     $PRP['doNotShowUser'] = true;
     $historyID = prepareRequestAndAddHistory($PRP);
     return $historyID;
 }
Example #2
0
 public static function updateAllProcessor($siteIDs, $allParams)
 {
     if (empty($allParams)) {
         return false;
     }
     $requestAction = 'do_upgrade';
     $type = 'PTC';
     $action = 'update';
     $sitesStats = DB::getFields("?:site_stats", "stats, siteID", "siteID IN (" . implode(',', array_keys($allParams)) . ")", "siteID");
     foreach ($sitesStats as $siteID => $sitesStat) {
         $sitesStats[$siteID] = unserialize(base64_decode($sitesStat));
     }
     $sitesData = getSitesData(array_keys($allParams));
     foreach ($allParams as $siteID => $siteParams) {
         $siteIDs = array($siteID);
         $events = 0;
         $requestParams = $historyAdditionalData = array();
         $timeout = DEFAULT_MAX_CLIENT_REQUEST_TIMEOUT;
         foreach ($siteParams as $PTC => $PTCParams) {
             if ($PTC == 'plugins') {
                 if (!empty($sitesStats[$siteID]['premium_updates'])) {
                     foreach ($sitesStats[$siteID]['premium_updates'] as $item) {
                         if (in_array($item['slug'], $PTCParams)) {
                             $uniqueName = $item['Name'];
                             $requestParams['upgrade_plugins'][] = array_change_key_case($item, CASE_LOWER);
                             $historyAdditionalData[] = array('uniqueName' => $uniqueName, 'detailedAction' => 'plugin');
                             $timeout += 20;
                             $events++;
                         }
                     }
                 }
                 if (!empty($sitesStats[$siteID]['upgradable_plugins'])) {
                     foreach ($sitesStats[$siteID]['upgradable_plugins'] as $item) {
                         if (in_array($item->file, $PTCParams)) {
                             $uniqueName = $item->file;
                             $requestParams['upgrade_plugins'][] = $item;
                             $historyAdditionalData[] = array('uniqueName' => $uniqueName, 'detailedAction' => 'plugin');
                             $timeout += 20;
                             $events++;
                         }
                     }
                 }
             } elseif ($PTC == 'themes') {
                 foreach ($sitesStats[$siteID]['upgradable_themes'] as $item) {
                     if (in_array($item['theme_tmp'], $PTCParams) || in_array($item['name'], $PTCParams)) {
                         $requestParams['upgrade_themes'][] = $item;
                         $uniqueName = $item['theme_tmp'] ? $item['theme_tmp'] : $item['name'];
                         $historyAdditionalData[] = array('uniqueName' => $uniqueName, 'detailedAction' => 'theme');
                         $timeout += 20;
                         $events++;
                     }
                 }
             } elseif ($PTC == 'core') {
                 if ($sitesStats[$siteID]['core_updates']->current == $PTCParams) {
                     $requestParams['wp_upgrade'] = $sitesStats[$siteID]['core_updates'];
                     $historyAdditionalData[] = array('uniqueName' => 'core', 'detailedAction' => 'core');
                     $timeout += 120;
                     $events++;
                 }
             } elseif ($PTC == 'translations') {
                 if ($sitesStats[$siteID]['upgradable_translations']) {
                     $requestParams['upgrade_translations'] = true;
                     $historyAdditionalData[] = array('uniqueName' => 'translations', 'detailedAction' => 'translations');
                     $timeout += 60;
                     $events++;
                 }
             }
         }
         $siteData = $sitesData[$siteID];
         $PRP = array();
         $PRP['requestAction'] = $requestAction;
         $PRP['requestParams'] = $requestParams;
         $PRP['siteData'] = $siteData;
         $PRP['type'] = $type;
         $PRP['action'] = $action;
         $PRP['events'] = $events;
         $PRP['historyAdditionalData'] = $historyAdditionalData;
         $PRP['timeout'] = $timeout;
         $PRP['doNotExecute'] = false;
         $PRP['sendAfterAllLoad'] = true;
         prepareRequestAndAddHistory($PRP);
     }
 }