Example #1
0
 public static function triggerRecheckProcessor($siteIDs, $params, $extras)
 {
     $type = "backup";
     $action = "trigger";
     $requestAction = "trigger_backup_multi";
     $timeout = 60;
     if (empty($params['backupParentHID'])) {
         return;
     }
     $parentHistoryIDStatus = DB::getField("?:history", "status", "historyID='" . $params['backupParentHID'] . "'");
     if ($parentHistoryIDStatus != 'multiCallWaiting') {
         return;
     }
     $getCount = DB::getField("?:history", "count(historyID)", "type='backup' AND action = 'trigger' AND parentHistoryID = '" . $params['backupParentHID'] . "'");
     if ($getCount >= 300) {
         updateHistory(array('status' => 'error', 'error' => 'max_trigger_calls_reached'), $params['backupParentHID'], array('status' => 'error', 'error' => 'max_trigger_calls_reached', 'errorMsg' => 'Multi-call limit reached.'));
         return;
     }
     if (DB::getExists("?:history", "historyID", "type='backup' AND action = 'trigger' AND parentHistoryID = '" . $params['backupParentHID'] . "' AND status not IN('completed', 'error', 'netError')")) {
         return;
     }
     $requestParams = array('mechanism' => 'multiCall', 'backupParentHID' => $params['backupParentHID'], 'params' => $params['responseData']);
     $historyAdditionalData = array();
     $historyAdditionalData[] = array('uniqueName' => "backupTrigger", 'detailedAction' => $action);
     $doNotShowUser = true;
     foreach ($siteIDs as $siteID) {
         $siteData = getSiteData($siteID);
         $events = 1;
         $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['doNotShowUser'] = $doNotShowUser;
         $PRP['parentHistoryID'] = $params['backupParentHID'];
         prepareRequestAndAddHistory($PRP);
     }
 }
Example #2
0
function showBrowserCloseWarning()
{
    $isMultiCallJobActive = DB::getExists("?:history H", "H.historyID", "H.status = 'multiCallWaiting'");
    if ($isMultiCallJobActive) {
        if (!manageEasyCron::isActive()) {
            return true;
        }
    }
    return false;
}
Example #3
0
 public static function getSendNextAjaxCallAfter()
 {
     $time = time();
     $isTaskActive = DB::getExists("?:history H", "H.historyID", "(H.status IN('writingRequest','pending','multiCallWaiting','initiated','running','processingResponse') OR (H.status = 'scheduled' AND H.timescheduled <= " . ($time - 120) . " AND H.timescheduled > 0)) LIMIT 1");
     $slowDownAjaxCallFrom = manageCookies::cookieGet('slowDownAjaxCallFrom');
     if ($isTaskActive) {
         manageCookies::cookieUnset('slowDownAjaxCallFrom');
         return 0;
     } elseif (!empty($slowDownAjaxCallFrom)) {
         if ($slowDownAjaxCallFrom['sec60'] < $time) {
             return 60;
         } elseif ($slowDownAjaxCallFrom['sec30'] < $time) {
             return 30;
         } elseif ($slowDownAjaxCallFrom['sec10'] < $time) {
             return 10;
         }
     } else {
         $slowDownAjaxCallFrom = array();
         $slowDownAjaxCallFrom['sec10'] = $time + 12;
         //two calls of 10 sec
         $slowDownAjaxCallFrom['sec30'] = $time + 35;
         //two calls of 30 sec
         $slowDownAjaxCallFrom['sec60'] = $time + 105;
         //from there 60 sec each call
         manageCookies::cookieSet('slowDownAjaxCallFrom', $slowDownAjaxCallFrom, array('expire' => 0));
         return 0;
     }
     return 0;
     //safe
 }
Example #4
0
function isTaskRunConditionSatisfied($runCondition)
{
    if (empty($runCondition)) {
        return true;
    }
    $runCondition = unserialize($runCondition);
    if (empty($runCondition['satisfyType'])) {
        $runCondition['satisfyType'] = 'OR';
    }
    if ($runCondition['satisfyType'] != 'AND' && $runCondition['satisfyType'] != 'OR') {
        return;
    }
    $OK = true;
    if (!empty($runCondition['query'])) {
        $query = $runCondition['query'];
        $tempResult = DB::getExists('?:' . $query['table'], $query['select'], $query['where']);
        if ($runCondition['satisfyType'] == 'OR' && !empty($tempResult)) {
            return true;
        } elseif ($runCondition['satisfyType'] == 'AND' && empty($tempResult)) {
            $OK = false;
        }
    }
    if (!empty($runCondition['maxWaitTime'])) {
        $tempResult = $runCondition['maxWaitTime'] <= time();
        if ($runCondition['satisfyType'] == 'OR' && !empty($tempResult)) {
            return true;
        } elseif ($runCondition['satisfyType'] == 'AND' && empty($tempResult)) {
            $OK = false;
        }
    }
    if ($runCondition['satisfyType'] == 'OR') {
        return false;
    } elseif ($runCondition['satisfyType'] == 'AND') {
        return $OK;
    }
    return;
}
Example #5
0
    echo 'same_url_connection';
    sleep(5);
    updateOption('fsockSameURLCheckUsingDBValue', $_REQUEST['fsockSameURLCheckUsingDBValue']);
    exit;
}
set_time_limit(3600);
//3600 = 1hr, this is only for safety, we are controlling timeout in CURL
if ($_REQUEST['runOffBrowserLoad'] == 'true') {
    runOffBrowserLoad();
    exit;
} elseif (!empty($_POST['historyID']) && !empty($_POST['actionID'])) {
    $historyID = $_POST['historyID'];
    $actionID = $_POST['actionID'];
    //if(empty($historyID) || empty($actionID)){ echo 'invalidRequest'; exit; }
    //fix: add some security
    $isValid = DB::getExists("?:history", "historyID", "historyID = '" . $historyID . "' AND actionID = '" . $actionID . "'");
    if ($isValid) {
        if (empty($GLOBALS['userID'])) {
            //setting userID of the task to session, because when this file running by fsock, it will not have the same session IWP Admin Panel
            $userID = DB::getField("?:history", "userID", "historyID = '" . $historyID . "' AND actionID = '" . $actionID . "'");
            $GLOBALS['userID'] = $userID;
            $GLOBALS['offline'] = true;
        }
        echo 'executingRequest';
        executeRequest($historyID);
        $isExecuteJobs = true;
    }
}
if ($isExecuteJobs || $_REQUEST['executeJobs'] == 'true') {
    $noNewTaskAfterNSecs = 25;
    //do additional jobs
Example #6
0
 public static function backupStatusCheck($responseData)
 {
     $backupArray = $responseData['success']['iwp_backups'];
     if (!empty($backupArray)) {
         foreach ($backupArray as $key => $value) {
             foreach ($value as $key => $data) {
                 $backupStatus = $data['backhack_status'];
                 $historyID = $backupStatus['adminHistoryID'];
                 if (!empty($historyID) && DB::getExists("?:history", "status", "historyID = '" . $historyID . "' AND status = 'netError' AND error IN('28', '500', '502', '504', 'timeoutClear')")) {
                     if (array_key_exists('finished', $backupStatus)) {
                         DB::update("?:history_additional_data", array('status' => 'success'), "historyID='" . $historyID . "' AND status = 'netError' AND error IN('28', '500', '502', '504', 'timeoutClear')");
                         DB::update("?:history", array('status' => 'completed', 'error' => ''), "historyID ='" . $historyID . "' AND status = 'netError' AND error IN('28', '500', '502', '504', 'timeoutClear')");
                     }
                 }
             }
         }
     }
 }