コード例 #1
0
ファイル: db.php プロジェクト: peterleger/db-table-output
            $rS .= ") > div:before { content: '";
            $rS .= $field->name;
            $rS .= "' !important; ";
            $rS .= "display: block; ";
            $rS .= "font-weight: bold; ";
            $rS .= "margin: 0 -15px; ";
            $rS .= "border-bottom: 2px solid #ddd; ";
            $rS .= "padding-left: 15px; ";
            $rS .= "padding-bottom: 5px; } ";
            $counter++;
        }
        $rS .= ".small-screen { display: block; } ";
        $rS .= ".big-screen { display: none; } ";
        $rS .= ".list-info .row { margin: 30px; } ";
        $rS .= ".value { margin: 0 -15px 10px -15px; ";
        $rS .= "padding: 10px 0 10px 15px; ";
        $rS .= "background: #f9f9f9; ";
        $rS .= "border-bottom: 1px solid #ddd; }";
        $rS .= "}";
        // End of media query
        $style = "<style>";
        $style .= $rS;
        $style .= "</style>";
        return $style;
    }
}
$db = new DB();
$db->setFields();
$fields = $db->getFields();
$style = $db->getStyle();
$rows = $db->getRows();
コード例 #2
0
ファイル: Form.php プロジェクト: mbassan/backstage2
 function startRestricted($groups = false, $only_admin = false, $users = false, $user_id_equals_field = false, $group_id_equals_field = false, $condition = false, $exclude_groups = false, $exclude_admin = false, $exclude_users = false)
 {
     global $CFG;
     if ($CFG->pm_editor) {
         $method_name = self::peLabel($CFG->method_id, 'startRestricted');
     }
     $is_admin = User::$info['is_admin'] == 'Y';
     if ($CFG->pm_editor) {
         $this->HTML[] = "\n\t\t\t{$legend} [start_restricted] {$method_name}";
     } else {
         if ($only_admin) {
             if ($condition) {
                 $condition = String::doFormulaReplacements($condition, $this->info, 1, 1);
                 $restricted = $restricted ? $restricted : @eval("if ({$condition}) { return 0;} else { return 1;}");
             }
         } else {
             if (is_array($users)) {
                 $restricted = !array_key_exists(User::$info['id'], $users) && !$is_admin;
             }
             if (is_array($groups)) {
                 $restricted = !$restricted ? !array_key_exists(User::$info['f_id'], $groups) && !$is_admin : $restricted;
             }
             if (is_array($exclude_users)) {
                 $restricted = !$restricted ? array_key_exists(User::$info['id'], $exclude_users) : $restricted;
             }
             if (is_array($exclude_groups)) {
                 $restricted = !$restricted ? array_key_exists(User::$info['f_id'], $exclude_groups) : $restricted;
             }
             if ($exclude_admin) {
                 $restricted = !$restricted ? User::$info['is_admin'] == 'Y' : $restricted;
             }
             if ($user_id_equals_field) {
                 if (strstr($user_id_equals_field, ',')) {
                     $parts = explode(',', $user_id_equals_field);
                     $parts1 = explode('.', $parts[0]);
                     $first_table = $parts1[0];
                     $first_field = $parts1[1];
                     $c = count($parts) - 1;
                     $parts2 = explode('.', $parts[$c]);
                     $last_table = $parts2[0];
                     $last_field = $parts2[1];
                     $row = DB::getFields($last_table, $this->info[$first_field], array($last_field), $user_id_equals_field, false, false, false, false, 1);
                     $restricted = !$restricted ? $restricted : User::$info['id'] != $row[$last_field];
                 } else {
                     $restricted = !$restricted ? $restricted : User::$info['id'] != $this->info[$user_id_equals_field];
                 }
             }
             if ($group_id_equals_field) {
                 if (strstr($group_id_equals_field, ',')) {
                     $parts = explode(',', $group_id_equals_field);
                     $parts1 = explode('.', $parts[0]);
                     $first_table = $parts1[0];
                     $first_field = $parts1[1];
                     $c = count($parts) - 1;
                     $parts2 = explode('.', $parts[$c]);
                     $last_table = $parts2[0];
                     $last_field = $parts2[1];
                     $row = DB::getFields($last_table, $this->info[$first_field], array($last_field), $group_id_equals_field, false, false, false, false, 1);
                     $restricted = !$restricted ? $restricted : User::$info['f_id'] != $row[$last_field];
                 } else {
                     $restricted = !$restricted ? $restricted : User::$info['f_id'] != $this->info[$group_id_equals_field];
                 }
             }
             if ($condition) {
                 $condition = String::doFormulaReplacements($condition, $this->info, 1, 1);
                 $restricted = $restricted ? $restricted : eval("if ({$condition}) { return 0;} else { return 1;}");
             }
         }
         if ($restricted) {
             $this->HTML[] = "<restricted>";
         }
     }
 }
コード例 #3
0
ファイル: appFunctions.php プロジェクト: Trideon/gigolo
function updatesNotificationMailSend($force = false)
{
    if ($force == false) {
        $getAllNotifications = DB::getArray("?:users", "userID, accessLevel, permissions, notifications, updatesNotificationMailLastSent", 1, "userID");
    } else {
        $getAllNotifications = DB::getArray("?:users", "userID, accessLevel, permissions, notifications, updatesNotificationMailLastSent", "userID = '" . $GLOBALS['userID'] . "'", "userID");
    }
    $run = 1;
    if (!empty($getAllNotifications)) {
        foreach ($getAllNotifications as $userID => $userData) {
            if (empty($userData['notifications'])) {
                continue;
            }
            $UID = '';
            if ($userData['accessLevel'] == 'manager') {
                $permissions = unserialize($userData['permissions']);
                if (empty($permissions['access']) || !empty($permissions['access']) && !in_array('updates', $permissions['access'])) {
                    continue;
                }
                $UID = $userID;
            }
            $updatesNotificationMail = unserialize($userData['notifications']);
            $updatesNotificationMail = $updatesNotificationMail['updatesNotificationMail'];
            //check setting
            if ($force == false) {
                if ($updatesNotificationMail['frequency'] == 'never' || empty($updatesNotificationMail['coreUpdates']) && empty($updatesNotificationMail['pluginUpdates']) && empty($updatesNotificationMail['themeUpdates'])) {
                    continue;
                    //updatesNotificationMail is disabled in the settings
                }
            }
            if ($force == false && $run == 1) {
                //for test mail(i.e $force == true) dont need to get new data
                Reg::set('currentRequest.actionID', uniqid('', true));
                $lastNHours = time() - 60 * 60 * 2;
                //2 hours
                $getRemainingSiteIDsQuery = "SELECT S.siteID FROM ?:sites S LEFT OUTER JOIN ?:history H on S.siteID = H.siteID and H.type = 'stats' and H.action = 'getStats' and H.microtimeInitiated >= " . $lastNHours . " and H.status IN('completed', 'error', 'netError') where H.siteID is null";
                $remainingSiteIDs = DB::getFields($getRemainingSiteIDsQuery);
                //Assuming for all the sites reload data can happen in 2 hours.
                if (!empty($remainingSiteIDs) && is_array($remainingSiteIDs)) {
                    foreach ($remainingSiteIDs as $siteID) {
                        $isAlreadyAdded = DB::getExists("?:history H", "H.historyID", "H.siteID = " . $siteID . " AND H.type = 'stats' AND H.action = 'getStats'and H.microtimeInitiated >= " . $lastNHours . " AND showUser = '******'");
                        if ($isAlreadyAdded) {
                            continue;
                            //no need to trigger new one, has one is already in place.
                        }
                        $extras = array('directExecute' => true, 'sendAfterAllLoad' => false, 'doNotShowUser' => true);
                        //'directExecute' => true reload data calls will be executed directly blocking mode
                        manageClientsFetch::getStatsProcessor(array($siteID), array(), $extras);
                        $run = 0;
                        if ($GLOBALS['cronStartTime'] + CRON_TIMEOUT < time()) {
                            break;
                        }
                    }
                }
                $remainingSiteIDs = DB::getFields($getRemainingSiteIDsQuery);
                if (!empty($remainingSiteIDs)) {
                    return false;
                }
                //If all sites reload data not completed as per above criteria, then go out of this function. In the next cron call it will continue from where it left. As the above while function this case will come from CRON_TIMEOUT meets.
            }
            //getting updateInformation
            $sitesUpdates = panelRequestManager::getSitesUpdates($UID);
            $hiddenUpdates = panelRequestManager::getHide();
            foreach ($hiddenUpdates as $siteID => $value) {
                foreach ($value as $d) {
                    unset($sitesUpdates['siteView'][$siteID][$d['type']][$d['URL']]);
                    //this will fix the site name shows even all update items are hidden
                    if (empty($sitesUpdates['siteView'][$siteID][$d['type']])) {
                        unset($sitesUpdates['siteView'][$siteID][$d['type']]);
                    }
                    if (empty($sitesUpdates['siteView'][$siteID])) {
                        unset($sitesUpdates['siteView'][$siteID]);
                    }
                }
            }
            if (!empty($sitesUpdates['siteView']) && (empty($updatesNotificationMail['coreUpdates']) || empty($updatesNotificationMail['pluginUpdates']) || empty($updatesNotificationMail['themeUpdates']))) {
                //this will fix  when the "plugin" not selected in settings. Site name shows with empty list when plugin update is available
                foreach ($sitesUpdates['siteView'] as $siteID => $value) {
                    if (empty($updatesNotificationMail['coreUpdates'])) {
                        unset($sitesUpdates['siteView'][$siteID]['core']);
                    }
                    if (empty($updatesNotificationMail['pluginUpdates'])) {
                        unset($sitesUpdates['siteView'][$siteID]['plugins']);
                    }
                    if (empty($updatesNotificationMail['themeUpdates'])) {
                        unset($sitesUpdates['siteView'][$siteID]['themes']);
                    }
                    if (empty($sitesUpdates['siteView'][$siteID])) {
                        unset($sitesUpdates['siteView'][$siteID]);
                    }
                }
            }
            $params = array('userID' => $userID, 'sitesUpdates' => $sitesUpdates, 'updatesNotificationMail' => $updatesNotificationMail, 'updateNotificationDynamicContent' => getOption('updateNotificationDynamicContent'));
            $isSent = sendAppMail($params, '/templates/email/updatesNotification.tpl.php');
            if ($isSent) {
                if (!$force) {
                    DB::update("?:users", array('updatesNotificationMailLastSent' => time()), "userID = '" . $userID . "'");
                }
            } else {
                if (!$force) {
                    DB::update("?:users", array('updatesNotificationMailLastSent' => time()), "userID = '" . $userID . "'");
                    //even mail sending failed mark as sent this will avoid re-trying, customer will be notified if mail not sent using offline notification
                }
            }
        }
    }
    return true;
}
コード例 #4
0
?>
" style="display: inline-block;   float: right;  border: 0;  background-color: #2988b4;  color: #fff;  font-weight: bold;  font-size: 11px; padding: 5px 11px 6px;  border-radius: 20px; cursor:pointer;">OPEN ADMIN PANEL</a> 
          <div style="clear:both;"></div></div>
          
  <?php 
if (empty($siteView)) {
    ?>
      <table width="100%" border="0" cellspacing="50" style="border-top:1px solid #cdcdcd;">
      <tr>
      <td align="center">Everything is up to date.</td>
      </tr>
     </table>
<?php 
} else {
    $siteIDs = array_keys($siteView);
    $sitesName = DB::getFields("?:sites", "name, siteID", "siteID IN (" . implode(",", $siteIDs) . ")", "siteID");
    foreach ($siteView as $siteID => $updateData) {
        ?>
 
        
         <table width="100%" border="0" cellspacing="10" style="border-top:1px solid #cdcdcd;margin-bottom:10px;">
		<?php 
        ?>
  <tr>
    <td colspan="2">
      <div style="padding-bottom: 10px;"><a href="<?php 
        echo $sitesName[$siteID];
        ?>
" style="color:#465053;font-size:13px;font-weight:bold;text-decoration:none"><?php 
        echo $sitesName[$siteID];
        ?>
コード例 #5
0
 public static function clearHistoryTasks($params)
 {
     if (isset($params) && isset($params['clearWhat'])) {
         if ($params['clearWhat'] == 'uncomplete') {
             $accessUsers = " ";
             setHook('historyHTML', $accessUsers);
             $historyData = DB::getArray("?:history", "historyID", "status NOT IN ('completed','error','netError') AND " . $accessUsers . " showUser = '******' ");
             $error = 'task_cleared';
             $errorMsg = 'Task cleared by user';
             if (!empty($historyData) && is_array($historyData)) {
                 foreach ($historyData as $key => $history) {
                     updateHistory(array("status" => "error", "error" => $error, 'userIDCleared' => $GLOBALS['userID']), $history['historyID'], array("status" => "error", "errorMsg" => $errorMsg));
                 }
             }
         } elseif ($params['clearWhat'] == 'searchList') {
             $where = "showUser='******'";
             if (!empty($params['dates'])) {
                 $dates = explode('-', $params['dates']);
                 $fromDate = strtotime(trim($dates[0]));
                 $toDate = strtotime(trim($dates[1]));
                 if (!empty($fromDate) && !empty($toDate) && $fromDate != -1 && $toDate != -1) {
                     $toDate += 86399;
                     $where .= " AND microtimeAdded >= " . $fromDate . " AND  microtimeAdded <= " . $toDate . " ";
                 }
             }
             $getKeyword = "";
             if (!empty($params['getKeyword'])) {
                 $keyword = "'" . implode("','", explode(',', $params['getKeyword'])) . "'";
                 $getKeyword = " AND type IN (" . $keyword . ") ";
             }
             if (!empty($params['userID'])) {
                 $where .= " AND userID = '" . $params['userID'] . "' ";
             }
             $where2 = " ";
             if (empty($params['searchByUser'])) {
                 setHook('historyHTML', $where2);
             }
             if (trim($where2 . $where . $getKeyword) != "showUser='******'") {
                 $historyIDs = DB::getFields("?:history", "historyID", $where2 . $where . $getKeyword);
                 self::clearHistoryByIDs($historyIDs);
                 // $historyIDs = implode("','", $historyIDs);
                 // DB::delete("?:history", "historyID IN ('".$historyIDs."')");
                 // DB::delete("?:history_additional_data", "historyID IN ('".$historyIDs."')");
                 // DB::delete("?:history_raw_details", "historyID IN ('".$historyIDs."')");
             } else {
                 DB::delete("?:history", "1");
                 DB::delete("?:history_additional_data", "1");
                 DB::delete("?:history_raw_details", "1");
                 DB::doQuery("OPTIMIZE TABLE `?:history`");
                 DB::doQuery("OPTIMIZE TABLE `?:history_additional_data`");
                 DB::doQuery("OPTIMIZE TABLE `?:history_raw_details`");
             }
         } elseif ($params['clearWhat'] == 'autoDeleteLog') {
             if (!empty($params['time'])) {
                 $where = " microtimeAdded <= '" . $params['time'] . "' ";
                 $accessUsers = " ";
                 setHook('historyHTML', $accessUsers);
                 if ($accessUsers != " ") {
                     $accessUsers = " AND " . $accessUsers;
                 }
                 $historyIDs = DB::getFields("?:history", "historyID", $where . $accessUsers);
                 self::clearHistoryByIDs($historyIDs);
                 // if(!empty($historyIDs)){
                 // 	$historyIDs = implode("','", $historyIDs);
                 // 	DB::delete("?:history", "historyID IN ('".$historyIDs."')");
                 // 	DB::delete("?:history_additional_data", "historyID IN ('".$historyIDs."')");
                 // 	DB::delete("?:history_raw_details", "historyID IN ('".$historyIDs."')");
                 // 	DB::doQuery("OPTIMIZE TABLE `?:history`");
                 // 	DB::doQuery("OPTIMIZE TABLE `?:history_additional_data`");
                 // 	DB::doQuery("OPTIMIZE TABLE `?:history_raw_details`");
                 // }
                 if (!empty($params['LastAutoDeleteLogTime'])) {
                     $now = $params['LastAutoDeleteLogTime'];
                 } else {
                     $now = time();
                 }
                 updateOption('LastAutoDeleteLogTime', $now);
             }
         } elseif ($params['clearWhat'] == 'singleAct') {
             if (!empty($params['actionID'])) {
                 $historyIDs = DB::getFields("?:history", "historyID", "actionID='" . $params['actionID'] . "'");
                 self::clearHistoryByIDs($historyIDs);
             }
         }
     }
 }
コード例 #6
0
ファイル: processManager.php プロジェクト: Trideon/gigolo
function executeJobs()
{
    if (isset($GLOBALS['IS_EXECUTE_JOBS_OPEN']) && $GLOBALS['IS_EXECUTE_JOBS_OPEN']) {
        echo 'recurrsive execute jobs call';
        return false;
        //recurrsive call
    }
    $GLOBALS['IS_EXECUTE_JOBS_OPEN'] = true;
    $settings = Reg::get('settings');
    $noRequestRunning = true;
    $requestInitiated = 0;
    $requestPending = 0;
    $isExecuteRequest = false;
    static $lastIPRequestInitiated = '';
    $totalCurrentRunningRequest = DB::getField("?:history H LEFT JOIN ?:sites S ON H.siteID = S.siteID", "COUNT(H.historyID)", "H.status IN ('initiated', 'running')");
    if ($totalCurrentRunningRequest >= MAX_SIMULTANEOUS_REQUEST) {
        echo 'MAX_SIMULTANEOUS_REQUEST';
        $GLOBALS['IS_EXECUTE_JOBS_OPEN'] = false;
        return false;
    }
    //dont execute any request
    $runningRequestByIP = DB::getFields("?:history H LEFT JOIN ?:sites S ON H.siteID = S.siteID", "COUNT(H.historyID), S.IP", "H.status IN ('initiated', 'running') AND H.isPluginResponse = '1' GROUP BY S.IP", "IP");
    //H.isPluginResponse = 1 only WP sites call
    if (!empty($runningRequestByIP)) {
        //some request(s) are running
        $noRequestRunning = false;
        $runningRequestByServer = DB::getFields("?:history H LEFT JOIN ?:sites S ON H.siteID = S.siteID", "COUNT(H.historyID), S.serverGroup", "H.status IN ('initiated', 'running') GROUP BY S.serverGroup", "serverGroup");
    }
    //get pending request
    $pendingRequests = DB::getArray("?:history H LEFT JOIN ?:sites S ON H.siteID = S.siteID", "H.historyID, S.IP, S.serverGroup, H.actionID, H.runCondition, H.isPluginResponse", "(H.status = 'pending' OR (H.status = 'scheduled' AND H.timescheduled <= " . time() . " AND H.timescheduled > 0)) ORDER BY H.historyID");
    if ($noRequestRunning) {
        $runningRequestByIP = array();
        $runningRequestByServer = array();
    }
    if (!empty($runningRequestByIP) && $settings['CONSIDER_3PART_IP_ON_SAME_SERVER'] == 1) {
        //running IP information
        $tempRunningRequestByIP = $runningRequestByIP;
        $runningRequestByIP = array();
        foreach ($tempRunningRequestByIP as $tempIP => $tempCount) {
            //only for IPv4
            $IP3Part = explode('.', $tempIP);
            array_pop($IP3Part);
            $newTempIP = implode('.', $IP3Part);
            $runningRequestByIP[$newTempIP] = $tempCount;
        }
    }
    if (!empty($pendingRequests) && is_array($pendingRequests)) {
        foreach ($pendingRequests as $request) {
            $checkIPRestriction = true;
            $IPConsidered = $request['IP'];
            if ($request['isPluginResponse'] === '0') {
                $request['IP'] = '';
                $checkIPRestriction = false;
            }
            if ($checkIPRestriction && $settings['CONSIDER_3PART_IP_ON_SAME_SERVER'] == 1) {
                //only for IPv4
                $IP3Part = explode('.', $IPConsidered);
                array_pop($IP3Part);
                $IP3Part = implode('.', $IP3Part);
                $IPConsidered = $IP3Part;
            }
            if (!empty($request['runCondition']) && !isTaskRunConditionSatisfied($request['runCondition'])) {
                continue;
            }
            if ($checkIPRestriction && !isset($runningRequestByIP[$IPConsidered])) {
                $runningRequestByIP[$IPConsidered] = 0;
            }
            // if(!isset($runningRequestByServer[ $request['serverGroup'] ])) $runningRequestByServer[ $request['serverGroup'] ] = 0;
            if ($totalCurrentRunningRequest >= MAX_SIMULTANEOUS_REQUEST) {
                echo 'MAX_SIMULTANEOUS_REQUEST';
                $GLOBALS['IS_EXECUTE_JOBS_OPEN'] = false;
                return false;
            }
            //check already request are running in allowed level
            if ($checkIPRestriction && $runningRequestByIP[$IPConsidered] >= MAX_SIMULTANEOUS_REQUEST_PER_IP) {
                if ($runningRequestByIP[$IPConsidered] >= MAX_SIMULTANEOUS_REQUEST_PER_IP) {
                    echo 'MAX_SIMULTANEOUS_REQUEST_PER_IP<br>';
                }
                /* if($runningRequestByServer[ $request['serverGroup'] ] >=  MAX_SIMULTANEOUS_REQUEST_PER_SERVERGROUP)
                	  echo 'MAX_SIMULTANEOUS_REQUEST_PER_SERVERGROUP<br>';*/
                continue;
                //already request are running on the limits
            }
            $updateRequest = array('H.status' => 'initiated', 'H.microtimeInitiated' => microtime(true));
            $isUpdated = DB::update("?:history H", $updateRequest, "(H.status = 'pending' OR (H.status = 'scheduled' AND H.timescheduled <= " . time() . " AND H.timescheduled > 0)) AND H.historyID = " . $request['historyID']);
            $isUpdated = DB::affectedRows();
            if ($isUpdated) {
                //ready to run a child php to run the request
                if ($lastIPRequestInitiated == $IPConsidered) {
                    usleep(TIME_DELAY_BETWEEN_REQUEST_PER_IP * 1000);
                }
                //(defined('CRON_MODE')  && ( CRON_MODE == 'systemCronShortTime'  || CRON_MODE == 'systemCronDefault') ) //need to avoid balance idle time when systemCron is triggered. so that new trigger call(multiCall) can be called soon
                // echo '<br>executing child process';
                if (defined('IS_EXECUTE_FILE') || defined('CRON_MODE') && (CRON_MODE == 'systemCronShortTime' || CRON_MODE == 'systemCronDefault') || $settings['executeUsingBrowser'] == 1) {
                    //this will also statisfy Reg::get('settings.executeUsingBrowser') == 1
                    //echo '<br>executing_directly';
                    executeRequest($request['historyID']);
                    $isExecuteRequest = true;
                    $requestPending++;
                } else {
                    // echo '<br>executing_async';
                    $callAsyncInfo = callURLAsync(APP_URL . EXECUTE_FILE, array('historyID' => $request['historyID'], 'actionID' => $request['actionID']));
                    onAsyncFailUpdate($request['historyID'], $callAsyncInfo);
                    // echo '<pre>callExecuted:'; var_dump($callAsyncInfo); echo'</pre>';
                }
                $requestInitiated++;
                if ($checkIPRestriction) {
                    $runningRequestByIP[$IPConsidered]++;
                }
                // $runningRequestByServer[ $request['serverGroup'] ] ++;
                $totalCurrentRunningRequest++;
                if ($checkIPRestriction) {
                    $lastIPRequestInitiated = $IPConsidered;
                }
                if ($isExecuteRequest) {
                    break;
                }
                //breaking here once executeRequest runs(direct call) next forloop job might be executed by other instance because that job loaded in array which already loaded from DB, still only the job inititated here will run  $isUpdated = DB::affectedRows();
            } else {
                echo 'update error, this request might be executed by someother instance.';
            }
        }
    }
    //return process
    $GLOBALS['IS_EXECUTE_JOBS_OPEN'] = false;
    return array('requestInitiated' => $requestInitiated, 'requestPending' => $requestPending);
}
コード例 #7
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);
     }
 }