Esempio n. 1
0
function partTwo($input)
{
    $coords = [0, 0];
    $roboCoords = [0, 0];
    $history = [];
    $history[CK] = 0;
    $history = updateHistory($coords, $history);
    $inputArray = str_split($input);
    $santasMove = true;
    foreach ($inputArray as $direction) {
        if ($santasMove) {
            $coords = move($direction, $coords);
            $history = updateHistory($coords, $history);
            $santasMove = false;
        } else {
            $roboCoords = move($direction, $roboCoords);
            $history = updateHistory($roboCoords, $history);
            $santasMove = true;
        }
    }
    return $history[CK];
}
Esempio n. 2
0
<?php

session_start();
include 'inc/engine.php';
$action = $_SERVER['QUERY_STRING'];
switch ($action) {
    case 'getSessions':
        $sessions = getSessions();
        $json = array('sessions' => $sessions);
        break;
    case 'getSession':
        $session = getSession($_POST['session']);
        $json = $session;
        break;
    case 'updateHistory':
        updateHistory($_POST);
        exit;
        break;
}
print json_encode($json);
exit;
Esempio n. 3
0
 public static function loadSiteProcessor($siteIDs, $params)
 {
     $timeout = DEFAULT_MAX_CLIENT_REQUEST_TIMEOUT;
     //$siteID = reset($siteIDs);
     $siteID = $_REQUEST['siteID'];
     if (empty($siteID)) {
         echo 'Invalid Site ID';
     }
     //$where = $params['where'] ? $params['where'].".php" : '';
     $where = $_REQUEST['where'] ? $_REQUEST['where'] . ".php" : '';
     $loadSiteVars = array();
     if (isset($_REQUEST['var_0'])) {
         for ($i = 0; $i < 5; $i++) {
             if (isset($_REQUEST['var_' . $i]) && strpos($_REQUEST['var_' . $i], '__IWPVAR__') !== false) {
                 $temp = explode('__IWPVAR__', $_REQUEST['var_' . $i]);
                 $loadSiteVars[$temp[0]] = $temp[1];
             }
         }
     }
     //if(!empty($params['vars']) && is_array($params['vars'])){
     //			$loadSiteVars = $params['vars'];
     //		}
     $siteData = DB::getRow("?:sites", "*", "siteID=" . DB::realEscapeString($siteID));
     if (empty($siteData)) {
         echo 'Invalid Site ID';
     }
     $type = 'site';
     $action = 'load';
     $events = 1;
     $historyData = array('siteID' => $siteData['siteID'], 'actionID' => Reg::get('currentRequest.actionID'), 'userID' => $GLOBALS['userID'], 'type' => $type, 'action' => $action, 'events' => $events, 'URL' => $siteData['URL'], 'status' => 'completed', 'timeout' => $timeout);
     $historyAdditionalData[] = array('detailedAction' => 'loadSite', 'uniqueName' => 'loadSite', 'status' => 'success');
     $historyID = addHistory($historyData, $historyAdditionalData);
     $signature = signData($where . $historyID, $siteData['isOpenSSLActive'], $siteData['privateKey'], $siteData['randomSignature']);
     $URLQueryArray = array('auto_login' => 1, 'iwp_goto' => $where, 'signature' => base64_encode($signature), 'message_id' => $historyID, 'username' => $siteData['adminUsername']);
     //signature urlencode will be taken care by httpBuildURLCustom()
     if (!empty($loadSiteVars) && is_array($loadSiteVars)) {
         $URLQueryArray = array_merge($URLQueryArray, $loadSiteVars);
     }
     $adminURLArray = parse_url($siteData['adminURL']);
     if (!empty($adminURLArray['query'])) {
         $parsedQuery = array();
         parse_str($adminURLArray['query'], $parsedQuery);
         if (!empty($parsedQuery) && is_array($parsedQuery)) {
             $URLQueryArray = array_merge($parsedQuery, $URLQueryArray);
         }
     }
     $adminURLArray['query'] = $URLQueryArray;
     $adminURLArray['path'] .= $where ? $where : '';
     $URL = httpBuildURLCustom($adminURLArray);
     $argSeparator = ini_get('arg_separator.output');
     if ($argSeparator == "&amp;" || $argSeparator == "&amp") {
         $URL = str_replace($argSeparator, "&", $URL);
     }
     //$URL .='&signature='.$tempSignature;
     //$URL = $siteData['adminURL'].$where.'?'."auto_login=1&iwp_goto=".$where."&signature=".urlencode(base64_encode($signature))."&message_id=".$historyID."&username="******"Location: " . $URL);
     exit;
 }
function hipayUpdateOrder($cart = null, $newOrderStatusId = _PS_OS_ERROR_)
{
    echo '-fnUO';
    checkStatus116();
    $hipay = new HiPay_Tpp();
    $order_id = retrieveOrderId($cart->id);
    $order = new Order((int) $order_id);
    echo '/Oid_' . $order_id;
    if ($newOrderStatusId == 'skip') {
        // Simply log the callback
        $msg = new Message();
        $message = $hipay->l('HiPay - Callback initiated');
        $message .= ' - ' . $hipay->l('Transaction_reference : ') . $_POST['transaction_reference'];
        $message .= ' - ' . $hipay->l('State : ') . $_POST['state'];
        $message .= ' - ' . $hipay->l('Status : ') . $_POST['status'];
        $message .= ' - ' . $hipay->l('Message : ') . $_POST['message'];
        $message .= ' - ' . $hipay->l('data : ') . $_POST['cdata1'];
        $message = strip_tags($message, '<br>');
        if (Validate::isCleanHtml($message)) {
            $msg->message = $message;
            $msg->id_order = intval($order->id);
            $msg->private = 1;
            $msg->add();
        }
        HipayLogger::addLog($hipay->l('Callback process', 'hipay'), HipayLogger::ERROR, 'hipayUpdateOrder status skip - cid : ' . (int) $_POST['order']->id);
        die;
        return;
    }
    if ($_POST['status'] == '124') {
        $amount = -1 * $_POST['refunded_amount'];
        $msg = new Message();
        $message = $hipay->l('HiPay - Refund request Callback initiated - ');
        $message .= ' - ' . $hipay->l('Refund amount requested : ') . $amount;
        $message .= ' - ' . $hipay->l('Transaction_reference : ') . $_POST['transaction_reference'];
        $message .= ' - ' . $hipay->l('State : ') . $_POST['state'];
        $message .= ' - ' . $hipay->l('Status : ') . $_POST['status'];
        $message .= ' - ' . $hipay->l('Message : ') . $_POST['message'];
        $message .= ' - ' . $hipay->l('data : ') . $_POST['cdata1'];
        $message = strip_tags($message, '<br>');
        if (Validate::isCleanHtml($message)) {
            $msg->message = $message;
            $msg->id_order = intval($order->id);
            $msg->private = 1;
            $msg->add();
        }
    }
    if ($newOrderStatusId == Configuration::get('HIPAY_REFUNDED')) {
        refundOrder($order);
    }
    checkStatus116();
    updateHistory($order_id, $newOrderStatusId);
    return true;
}
Esempio n. 5
0
 public static function triggerRecheckResponseProcessor($historyID, $responseData)
 {
     responseDirectErrorHandler($historyID, $responseData);
     if (!empty($responseData)) {
         $historyData = DB::getRow("?:history", "*", "historyID='" . $historyID . "'");
         $siteID = $historyData['siteID'];
         if ($responseData['success']['status'] == 'partiallyCompleted') {
             DB::update("?:history_additional_data", array('status' => 'success'), "historyID='" . $historyID . "'");
             DB::update("?:history", array('status' => 'completed'), "historyID='" . $historyID . "'");
             $allParams = array('action' => 'triggerRecheck', 'args' => array('params' => array('backupParentHID' => $historyData['parentHistoryID']), 'siteIDs' => array($siteID), 'extras' => array('sendAfterAllLoad' => false, 'doNotShowUser' => true)));
             panelRequestManager::handler($allParams);
         } elseif ($responseData['success']['status'] == 'completed') {
             DB::update("?:history_additional_data", array('status' => 'success'), "historyID='" . $historyID . "'");
             DB::update("?:history_additional_data", array('status' => 'success'), "historyID='" . $historyData['parentHistoryID'] . "'");
             updateHistory(array('status' => 'completed'), $historyData['parentHistoryID']);
             $allParams = array('action' => 'getStats', 'args' => array('siteIDs' => array($siteID), 'extras' => array('sendAfterAllLoad' => false, 'doNotShowUser' => true)));
             panelRequestManager::handler($allParams);
         } else {
             DB::update("?:history_additional_data", array('status' => 'error'), "historyID='" . $historyID . "'");
             $errorMsg = isset($responseData['error']) ? $responseData['error'] : 'Unknown error occurred';
             $errorCode = isset($responseData['error_code']) ? $responseData['error_code'] : 'unknown_error_occurred';
             DB::update("?:history_additional_data", array('status' => 'error', 'errorMsg' => isset($responseData['success']['error']) ? $responseData['success']['error'] : $errorMsg, 'error' => isset($responseData['success']['error_code']) ? $responseData['success']['error_code'] : $errorCode), "historyID=" . $historyData['parentHistoryID']);
             updateHistory(array('status' => 'completed'), $historyData['parentHistoryID']);
             return;
         }
     }
 }
Esempio n. 6
0
function checkTriggerStatus()
{
    $data = DB::getArray("?:history", "siteID, historyID", "recheck = 0 AND type IN('backup', 'scheduleBackup') AND status = 'multiCallWaiting'");
    foreach ($data as $key => $value) {
        $subTaskData = DB::getArray("?:history", "historyID, status, recheck", "parentHistoryID = '" . $value['historyID'] . "' AND (\r\n\t\t(status = 'netError' AND error IN('28', '52', '500', '502', '504', 'timeoutClear')) OR\r\n\t\t(status = 'error' AND error IN('main_plugin_connection_error'))\r\n\t) ORDER BY historyID DESC LIMIT 3");
        $errorCount = 0;
        foreach ($subTaskData as $subTaskKey => $subTaskValue) {
            //trying to find three consecutive error
            if ($subTaskValue['status'] == 'completed') {
                $errorCount = 0;
            } else {
                $errorCount++;
            }
            if ($errorCount == 3) {
                $errorMsg = DB::getRow("?:history_additional_data", "error, errorMsg", "historyID = '" . $subTaskValue['historyID'] . "' ");
                updateHistory(array('status' => 'error', 'error' => 'consecutiveError', 'recheck' => '1'), $value['historyID'], array('status' => 'error', 'error' => $errorMsg['error'], 'errorMsg' => $errorMsg['errorMsg']));
                break;
            } else {
                if ($subTaskValue['recheck'] == 1) {
                    continue;
                }
                $params['parentHistoryID'] = $value['historyID'];
                $actionID = uniqid('', true);
                Reg::set('currentRequest.actionID', $actionID);
                manageClientsBackup::triggerRecheck($params, $value['siteID']);
                DB::update("?:history", array('recheck' => 1), "historyID = '" . $subTaskValue['historyID'] . "'");
                break;
                //DB::update("?:history", array('recheck' => '1'), "historyID =".$value['historyID']);
            }
        }
    }
}
Esempio n. 7
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);
             }
         }
     }
 }