Esempio n. 1
0
function outputStringAndCloseConnection($stringToOutput)
{
    @set_time_limit(3600);
    @ignore_user_abort(true);
    ini_set('zlib.output_compression', 'Off');
    if (ini_get('zlib.output_compression') == 1 || ini_get('zlib.output_compression') == 'On' || ini_get('zlib.output_compression') === true) {
        $isGzipped = false;
    } else {
        $isGzipped = true;
        $stringToOutput = gzencode($stringToOutput, 9, FORCE_GZIP);
    }
    @ob_start();
    echo $stringToOutput;
    $size = ob_get_length();
    if ($isGzipped) {
        header("Content-Encoding: gzip");
    }
    header("Content-Length: {$size}");
    header('Connection: close');
    @ob_end_flush();
    @ob_flush();
    @flush();
    if (function_exists('fastcgi_finish_request')) {
        fastcgi_finish_request();
    }
    if (Reg::get('currentRequest.runOffBrowserLoad') === 'true') {
        //this will be first ajax call after Panel loaded in browser
        runOffBrowserLoad();
    }
    $noNewTaskAfterNSecs = 25;
    if ($GLOBALS['ajaxPageTimeStart'] + $noNewTaskAfterNSecs > time()) {
        do {
            autoPrintToKeepAlive("keepAliveExecuteJobs");
            $status = executeJobs();
        } while ($status['requestInitiated'] > 0 && $status['requestPending'] > 0 && $GLOBALS['ajaxPageTimeStart'] + $noNewTaskAfterNSecs > time());
    }
    exit;
}
Esempio n. 2
0
function cronRun()
{
    ob_start();
    ignore_user_abort(true);
    set_time_limit(0);
    //$userID = DB::getField("?:users", "userID", "1 ORDER BY userID ASC LIMIT 1");
    $userID = DB::getField("?:users", "userID", "accessLevel = 'admin' ORDER BY userID ASC LIMIT 1");
    if (empty($userID)) {
        return false;
    }
    $GLOBALS['userID'] = $userID;
    $GLOBALS['offline'] = true;
    $time = time();
    updateOption('cronLastRun', $time);
    //sometime cron may take long time to complete, so updating first last cron run
    if (CRON_MODE == 'systemCronShortTime' || CRON_MODE == 'systemCronDefault') {
        systemCronRunLog($time);
    }
    updatesNotificationMailRunCheck();
    $temp = array();
    setHook('cronRun', $temp);
    $settings = Reg::get('settings');
    //if($settings['executeUsingBrowser'] == 1){//this condition is commented to fix #0000221
    do {
        $status = executeJobs();
    } while ($status['requestInitiated'] > 0 && $status['requestPending'] > 0 && $GLOBALS['cronStartTime'] + CRON_TIMEOUT > time());
    //}
    //before ending
    if (CRON_MODE == 'easyCronTask') {
        //if no more new task(jobs) self disable task cron of easy cron
        if (!isAnyActiveOrPendingJobs()) {
            $getNextTaskScheduleTime = getNextTaskScheduleTime();
            if (!(!empty($getNextTaskScheduleTime) && $getNextTaskScheduleTime < time() + 30 * 60)) {
                //no new task for next 30 mins
                //disable here
                manageEasyCron::taskCronDisable();
            }
        }
    }
    ob_end_clean();
}
Esempio n. 3
0
 public static function handler($requestData)
 {
     $requestStartTime = microtime(true);
     /* Checking the condition for this action is allowed to user (JS INJECTION ) */
     $userData = DB::getRow("?:users", "userID, accessLevel, permissions", "userID = '" . $GLOBALS['userID'] . "'");
     $Restrict = FALSE;
     if ($userData['accessLevel'] != 'admin') {
         if (function_exists('userRestrictChecking')) {
             $Restrict = userRestrictChecking($userData, $requestData);
         }
     }
     //$GLOBALS['printAll'] = true;
     $clearPrint = empty($GLOBALS['printAll']) ? true : false;
     if ($clearPrint) {
         ob_start();
     }
     $actionResult = $data = array();
     $action = $requestData['action'];
     $args = $requestData['args'];
     $siteIDs = $requestData['args']['siteIDs'];
     $params = $requestData['args']['params'];
     $extras = $requestData['args']['extras'];
     $requiredData = $requestData['requiredData'];
     $actionID = uniqid('', true);
     Reg::set('currentRequest.actionID', $actionID);
     if (!$Restrict) {
         //Checking restriction here
         if (manageClients::methodExists($action)) {
             manageCookies::cookieUnset('slowDownAjaxCallFrom');
             if (!empty($siteIDs)) {
                 if (function_exists('multiUserAccess')) {
                     multiUserAccess($siteIDs);
                 }
             }
             manageClients::execute($action, array('siteIDs' => $siteIDs, 'params' => $params, 'extras' => $extras));
             if (Reg::get('currentRequest.exitOnComplete') === true) {
                 if (Reg::get('settings.executeUsingBrowser') != 1) {
                     //to fix update notification going "everything up to date" for fsock users
                     executeJobs();
                 }
                 $exitOnCompleteT = microtime(true);
                 exitOnComplete();
                 $exitOnCompleteTT = microtime(true) - $exitOnCompleteT;
             }
             if (Reg::get('currentRequest.sendAfterAllLoad') === true) {
                 sendAfterAllLoad($requiredData);
             }
             $actionResult = self::getActionStatus($actionID, $action);
         }
         if (Reg::get('settings.executeUsingBrowser') != 1 && !defined('CRON_MODE') && !defined('IS_EXECUTE_FILE')) {
             // && !defined('CRON_MODE') && !defined('IS_EXECUTE_FILE') //panelRequestManager::handler() has been called in many places in app. inorder to avoid executeJobs()
             executeJobs();
         }
     }
     $data = self::requiredData($requiredData);
     $finalResponse = array();
     $finalResponse = array('actionResult' => $actionResult, 'data' => $data);
     if (empty($requestData['noGeneralCheck'])) {
         self::generalCheck($finalResponse);
     }
     $finalResponse['sendNextAjaxCallAfter'] = self::getSendNextAjaxCallAfter();
     $finalResponse['showBrowserCloseWarning'] = showBrowserCloseWarning();
     if ($clearPrint) {
         $printedText = ob_get_clean();
     }
     $finalResponse['debug'] = array('exitOnCompleteTimeTaken' => $exitOnCompleteTT, 'currentRequest.exitOnComplete' => var_export(Reg::get('currentRequest.exitOnComplete'), true), 'totalRequestTimeTaken' => microtime(true) - $requestStartTime);
     $finalResponse = self::changeToUTF8($finalResponse);
     return json_encode($finalResponse);
 }
Esempio n. 4
0
    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
    if ($GLOBALS['executeFileTimeStart'] + $noNewTaskAfterNSecs > time()) {
        do {
            autoPrintToKeepAlive("keepAliveExecuteJobs");
            $status = executeJobs();
        } while ($status['requestInitiated'] > 0 && $status['requestPending'] > 0 && $GLOBALS['executeFileTimeStart'] + $noNewTaskAfterNSecs > time());
    }
    exit;
}