Example #1
0
 public function prepare()
 {
     $user = new User(1);
     if (!$user->isAuthorized()) {
         $this->redirect('?r=auth');
     }
     $fileName = str_replace('/', '', $_GET['fileName']);
     $folder = str_replace('.', '', $_GET['folder']);
     $taskId = str_replace('.', '', $_GET['taskId']);
     $serverId = '';
     if (isset($_GET['serverId'])) {
         $serverId = (int) $_GET['serverId'];
     }
     if (!$user->checkRights('manager')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         $this->redirect('?r=store/' . $folder . '/folder&fid=' . $taskId . '&sid=' . $serverId);
     }
     switch ($folder) {
         case 'local':
             $path = __archiveDIR . "local/{$taskId}/{$fileName}";
             break;
         case 'remote':
             $path = __archiveDIR . "servers/{$serverId}/{$taskId}/{$fileName}";
             break;
     }
     //echo $path;
     if (file_exists($path)) {
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header('Content-Length: ' . filesize($path));
         header('Content-Disposition: attachment; filename=' . basename($path));
         readfile($path);
     }
     die;
 }
Example #2
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $usersDB = new JsonDB(__userdb);
     $id = (int) $_POST['id'];
     $login = htmlspecialchars($_POST['login'], ENT_QUOTES);
     $email = htmlspecialchars($_POST['email'], ENT_QUOTES);
     $password1 = md5($_POST['password1']);
     $password2 = md5($_POST['password2']);
     $accessGroup = htmlspecialchars($_POST['accessGroup'], ENT_QUOTES);
     $alerts = htmlspecialchars($_POST['alerts'], ENT_QUOTES);
     $user = $usersDB->data[$id];
     $_SESSION['formSent'] = $_POST;
     if ($password1 != $password2) {
         $this->redirect('?r=users/edit&id=' . $id . '&error=Passwords do not much!');
     }
     $user['login'] = $login;
     $user['email'] = $email;
     $user['accessGroup'] = $accessGroup;
     $user['alerts'] = $alerts;
     if ($_POST['password1'] != '') {
         $user['password'] = $password1;
     }
     $usersDB->data[$id] = $user;
     $usersDB->saveToFile(__userdb);
     $_SESSION['formSent'] = array();
     $this->redirect('?r=users/list');
 }
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $frequency = array();
     $frequency['type'] = $_POST['n-start'];
     switch ($_POST['n-start']) {
         case 'n-minutes':
             $frequency['n-minutes-minute'] = (int) $_POST['n-minutes-minute'];
             break;
         case 'n-every-hour':
             $frequency['n-every-hour-minute'] = (int) $_POST['n-every-hour-minute'];
             break;
         case 'n-day':
             $frequency['n-day-hour'] = (int) $_POST['n-day-hour'];
             $frequency['n-day-minute'] = (int) $_POST['n-day-minute'];
             break;
         case 'n-month':
             $frequency['n-month-day'] = (int) $_POST['n-month-day'];
             $frequency['n-month-hour'] = (int) $_POST['n-month-hour'];
             $frequency['n-month-minutes'] = (int) $_POST['n-month-minutes'];
             break;
         case 'n-once':
             $frequency['n-once-month'] = (int) $_POST['n-once-month'];
             $frequency['n-once-day'] = (int) $_POST['n-once-day'];
             $frequency['n-once-year'] = (int) $_POST['n-once-year'];
             $frequency['n-once-hour'] = (int) $_POST['n-once-hour'];
             $frequency['n-once-minutes'] = (int) $_POST['n-once-minutes'];
             break;
     }
     $sid = (int) $_POST['sid'];
     $serversList = new JsonDB(__serversdb);
     $newTask = array();
     $newTask['added'] = time();
     $newTask['type'] = 'mysql_backup';
     $newTask['title'] = $_POST['title'];
     $newTask['status'] = $_POST['status'];
     $newTask['execStatus'] = 0;
     $newTask['lastExec'] = time();
     $newTask['deep'] = (int) $_POST['deep'];
     $newTask['frequency'] = $frequency;
     $newTask['mysql-backup-address'] = $_POST['mysql-backup-address'];
     $newTask['mysql-backup-name'] = $_POST['mysql-backup-name'];
     $newTask['mysql-backup-user'] = $_POST['mysql-backup-user'];
     $newTask['mysql-backup-password'] = $_POST['mysql-backup-password'];
     $query = new ApiQuery($serversList->data[$sid]['address'], $serversList->data[$sid]['apiKey']);
     $result = $query->addTask($newTask, true);
     if ($result['responseStatus'] == 'success') {
         $id = (int) $result['id'];
         $serversList->data[$sid]['tasks'][$id] = $result['task'];
         $serversList->saveToFile(__serversdb);
     }
     $this->redirect('?r=servers/server_tasks_list&id=' . $sid);
 }
Example #4
0
 /**
  * сохраняем данные записи
  * @param $data
  */
 public function save($data)
 {
     foreach ($data as $key => $value) {
         $data[$key] = $this->db->real_escape_string($value);
     }
     $stmt = $this->db->prepare("INSERT INTO users (name, surname, password, email,  profile_image) VALUES (?, ?, ?, ?, ?);");
     $stmt->bind_param('sssss', $data['exampleInputName'], $data['exampleInputSurname'], md5($data['exampleInputPassword1']), $data['exampleInputEmail1'], end(explode('/user_registration', $data['profile_image'])));
     $stmt->execute();
     $stmt->close();
     addNotification($this->db->error, 'success');
 }
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $frequency = array();
     $frequency['type'] = $_POST['n-start'];
     switch ($_POST['n-start']) {
         case 'n-minutes':
             $frequency['n-minutes-minute'] = (int) $_POST['n-minutes-minute'];
             break;
         case 'n-every-hour':
             $frequency['n-every-hour-minute'] = (int) $_POST['n-every-hour-minute'];
             break;
         case 'n-day':
             $frequency['n-day-hour'] = (int) $_POST['n-day-hour'];
             $frequency['n-day-minute'] = (int) $_POST['n-day-minute'];
             break;
         case 'n-month':
             $frequency['n-month-day'] = (int) $_POST['n-month-day'];
             $frequency['n-month-hour'] = (int) $_POST['n-month-hour'];
             $frequency['n-month-minutes'] = (int) $_POST['n-month-minutes'];
             break;
         case 'n-once':
             $frequency['n-once-month'] = (int) $_POST['n-once-month'];
             $frequency['n-once-day'] = (int) $_POST['n-once-day'];
             $frequency['n-once-year'] = (int) $_POST['n-once-year'];
             $frequency['n-once-hour'] = (int) $_POST['n-once-hour'];
             $frequency['n-once-minutes'] = (int) $_POST['n-once-minutes'];
             break;
     }
     $id = time();
     $newTask = array();
     $newTask['id'] = $id;
     $newTask['added'] = time();
     $newTask['type'] = 'mysql_backup';
     $newTask['title'] = $_POST['title'];
     $newTask['status'] = $_POST['status'];
     $newTask['execStatus'] = 0;
     $newTask['lastExec'] = time();
     $newTask['deep'] = (int) $_POST['deep'];
     $newTask['frequency'] = $frequency;
     $newTask['mysql-backup-address'] = $_POST['mysql-backup-address'];
     $newTask['mysql-backup-name'] = $_POST['mysql-backup-name'];
     $newTask['mysql-backup-user'] = $_POST['mysql-backup-user'];
     $newTask['mysql-backup-password'] = $_POST['mysql-backup-password'];
     $tasksDB = new JsonDB(__taskdb);
     $tasksDB->data[$id] = $newTask;
     $tasksDB->saveToFile(__taskdb);
     $this->redirect('?r=tasks/list');
 }
Example #6
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $usersDB = new JsonDB(__userdb);
     unset($usersDB->data[$id]);
     $usersDB->saveToFile(__userdb);
     $this->redirect('?r=users/list');
 }
Example #7
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $serversDB = new JsonDB(__serversdb);
     $server = $serversDB->data[$id];
     $serversDB->deleteById($id);
     $serversDB->saveToFile(__serversdb);
     deleteDir(__archiveDIR . 'servers/' . $server['id']);
     $this->redirect('?r=servers/servers');
 }
Example #8
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $settingsDB = new JsonDB(__settingsdb);
     $settingsDB->data['serverName'] = $_POST['serverName'];
     $settingsDB->data['shortName'] = $_POST['shortName'];
     $settingsDB->data['apiKey'] = $_POST['apiKey'];
     $settingsDB->data['lang'] = $_POST['lang'];
     $settingsDB->saveToFile(__settingsdb);
     $this->redirect('?r=settings/main');
 }
Example #9
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $tasksDB = new JsonDB(__taskdb);
     unset($tasksDB->data[$id]);
     $tasksDB->saveToFile(__taskdb);
     $dir = __archiveDIR . "local/{$id}";
     deleteDir($dir);
     $this->redirect('?r=tasks/list');
 }
Example #10
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $serversDB = new JsonDB(__serversdb);
     $id = (int) $_POST['id'];
     $serversDB->data[$id]['address'] = $_POST['address'];
     $serversDB->data[$id]['apiKey'] = $_POST['apiKey'];
     $serversDB->data[$id]['archSync'] = $_POST['archSync'];
     $serversDB->data[$id]['archDepth'] = $_POST['depth'];
     $serversDB->saveToFile(__serversdb);
     $this->redirect('?r=servers/servers');
 }
Example #11
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('administrator')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $id = (int) $_POST['id'];
     $sid = (int) $_POST['sid'];
     $serversList = new JsonDB(__serversdb);
     $query = new ApiQuery($serversList->data[$sid]['address'], $serversList->data[$sid]['apiKey']);
     $result = $query->deleteTask($id, true);
     if ($result['responseStatus'] == 'success') {
         $id = (int) $result['id'];
         unset($serversList->data[$sid]['tasks'][$id]);
         $serversList->saveToFile(__serversdb);
         $dir = __archiveDIR . "servers/{$sid}/{$id}";
         deleteDir($dir);
     }
     $this->redirect('?r=servers/server_tasks_list&id=' . $sid);
 }
Example #12
0
function beforeInstall()
{
    $res = 0;
    if (!file_exists(__workfolder . 'conf.php')) {
        $res = 1;
        addNotification('conf.php not found. Please rename install_conf.php to conf.php', 'danger');
    } else {
        if (!is_writable(__workfolder . 'conf.php')) {
            $res = 1;
            addNotification('conf.php is not writable.', 'danger');
        }
    }
    if (!is_writable(__archiveDIR)) {
        $res = 1;
        addNotification('"archive" folder is not writable.', 'danger');
    }
    if (!is_writable(__corePath . 'data')) {
        $res = 1;
        addNotification('"core/data" folder is not writable.', 'danger');
    }
    return $res;
}
Example #13
0
 public function execute()
 {
     $user = new User(1);
     if (!$user->checkRights('manager')) {
         addNotification($this->_LANG['misc']["You don't have permissions"], 'warning');
         return 0;
     }
     $taskId = (int) $_POST['taskId'];
     $fileName = str_replace('/', '', $_POST['fileName']);
     $folder = $_POST['folder'];
     $server = (int) $_POST['server'];
     switch ($folder) {
         case 'local':
             $path = __archiveDIR . "local/{$taskId}/{$fileName}";
             unlink($path);
             $this->redirect("?r=store/local/folder&id={$taskId}");
             break;
         case 'remote':
             $path = __archiveDIR . "servers/{$server}/{$taskId}/{$fileName}";
             unlink($path);
             $this->redirect("?r=store/remote/folder&fid={$taskId}&sid={$server}");
             break;
     }
 }
Example #14
0
     require_once DIR_APP . 'projects.php';
     $id = AddRaterToProject($_POST['project_id'], $_SESSION['uid'], $_POST['sent_to']);
     if (!empty($id)) {
         if ($id == 'limit') {
             $responce['result'] = 'LIMIT';
         } else {
             $responce['result'] = 'OK';
             $responce['id'] = $id;
             $responce['user_id'] = $_POST['sent_to'];
             $responce['user'] = getUserNameById($_POST['sent_to']);
             //            addSuggestion($_POST['project_id'], $_POST['sent_to'], $_SESSION['uid']);
             $project_title = getProjectTitle($_POST['project_id']);
             $author = getUserNameById($_SESSION['uid']);
             $url = SITE_URL . '/project_details.php?pid=' . $_POST['project_id'];
             $text = $author . ' assigned to rate project ' . $project_title;
             addNotification($_POST['sent_to'], $text, $_SESSION['uid'], $url);
         }
     } else {
         $responce['result'] = 'FALSE';
     }
     echo json_encode($responce);
     break;
 case 'register-profiled':
     require_once DIR_APP . 'users.php';
     require_once DIR_APP . 'projects.php';
     $id = registerProfile($_POST);
     if ($id == true) {
         $responce['result'] = 'OK';
     } else {
         $responce['result'] = 'FALSE';
     }
Example #15
0
function sendMail($from, $fromName, $to, $toName, $subject, $message, $options = array())
{
    require_once APP_ROOT . '/lib/phpmailer.php';
    require_once APP_ROOT . '/lib/class.smtp.php';
    //smtp mail
    $mail = new PHPMailer();
    // defaults to using php "mail()"
    if (!empty($options['emailSettings'])) {
        $emailSettings = $options['emailSettings'];
    }
    if (!empty($emailSettings['smtpSettings'])) {
        $smtpSettings = $emailSettings['smtpSettings'];
    }
    //if(true){
    if (!empty($smtpSettings) && !empty($smtpSettings['useSmtp'])) {
        $mail->IsSMTP();
        $mail->Host = $smtpSettings['smtpHost'];
        // sets the SMTP server
        $mail->Port = $smtpSettings['smtpPort'];
        if ($smtpSettings['smtpAuth'] == 1 && !empty($smtpSettings['smtpAuthUsername']) && !empty($smtpSettings['smtpAuthPassword'])) {
            $mail->SMTPAuth = true;
            //enable SMTP authentication
            $mail->Username = $smtpSettings['smtpAuthUsername'];
            // SMTP account username
            $mail->Password = $smtpSettings['smtpAuthPassword'];
        }
        $mail->SMTPSecure = $smtpSettings['smtpEncryption'];
        $mail->From = $from;
        $mail->FromName = $fromName;
        $mail->AddAddress($to);
        $mail->IsHTML(true);
        $mail->Subject = $subject;
        $mail->MsgHTML($message);
        //$mail->Debugoutput = function($str, $level) { /* place any code for debugging here. */ };
    } else {
        $body = $message;
        $mail->SetFrom($from, $fromName);
        $mail->AddAddress($to, $toName);
        $mail->Subject = $subject;
        $mail->MsgHTML($body);
    }
    if (!$mail->Send()) {
        addNotification($type = 'E', $title = 'Mail Error', $message = $mail->ErrorInfo, $state = 'U');
        return false;
    } else {
        //echo "Message sent!";
        return true;
    }
}
Example #16
0
                if ($dahp < $tempdef) {
                    destroyFleet($sid, $dfid);
                } else {
                    while ($tempdef > 1) {
                        for ($x = 1; $x < sizeof($dshiparray) + 1; $x++) {
                            if ($dshiparray[$x] > 0) {
                                $tempdef = $tempdef - getShipStat(hp, $x);
                                if ($tempdef > 0) {
                                    $dshiparray[$x]--;
                                } else {
                                    break;
                                }
                            }
                        }
                        if ($count == sizeof($ashiparray)) {
                            break;
                        }
                    }
                    for ($x = 1; $x < sizeof($dshiparray) + 1; $x++) {
                        $str = "ship" . $x;
                        setFleetStat($str, $dshiparray[$x], $sid, $dfid);
                    }
                }
            }
            addNotification($endstr1, $sid, $aplayerid);
            addNotification($endstr2, $sid, $dplayerid);
        }
    }
}
?>
      
Example #17
0
/**
 * @param $id
 * @return mixed
 * @todo delete unused tags?
 */
function deleteTask($id)
{
    check_write_access();
    $db = DBConnection::instance();
    $title = $db->sq("SELECT title FROM {$db->prefix}todolist WHERE id={$id}");
    $list_id = $db->sq("SELECT list_id FROM {$db->prefix}todolist WHERE id={$id}");
    $db->ex("BEGIN");
    $db->ex("DELETE FROM {$db->prefix}tag2task WHERE task_id={$id}");
    $db->dq("DELETE FROM {$db->prefix}todolist WHERE id={$id}");
    $affected = $db->affected();
    $db->ex("COMMIT");
    addNotification(_r('n_task_deleted', $title), Notification::NOTIFICATION_TYPE_TASK_CHANGED, $list_id, $id);
    return $affected;
}
Example #18
0
 public static function testSendMail()
 {
     $isSent = sendAppMail(array('userID' => $GLOBALS['userID']), '/templates/email/testEmail.tpl.php', array('isTest' => 1));
     if (!empty($isSent)) {
         addNotification($type = 'N', $title = 'Test Mail', $message = 'E-Mail Sent Successfully.', $state = 'U', $callbackOnClose = '', $callbackReference = '');
     }
 }
Example #19
0
    $response = $ipn->handleIpn($_POST);
    if (empty($response)) {
        ipnLog("empty response");
        die;
    }
    if (isset($response['error'])) {
        ipnLog("error");
        ipnLog(json_encode($response));
        die;
    }
    $notification = $response['notification'];
    $customer = $response['customer'];
    $trasaction = $response['transaction'];
    //ipnLog("....");
    //ipnLog(json_encode($notification));
    addNotification($notification);
    addCustomer($customer);
    addTransaction($trasaction);
}
/**
 * @param String $data
 */
function ipnLog($data)
{
    //Check log.log file permissions
    $date = date('Y-m-d H:i');
    file_put_contents("log.log", "[" . $date . "]" . $data . " \n", FILE_APPEND);
}
function addNotification($notification)
{
    $params = array('id' => null, 'txn_id' => $notification->getTxnId(), 'txn_type' => $notification->getTxnType(), 'receiver_email' => $notification->getReceiverEmail(), 'payment_status' => $notification->getPaymentStatus(), 'pending_reason' => $notification->getPendingReason(), 'reason_code' => $notification->getReasonCode(), 'custom' => $notification->getCustom(), 'invoice' => $notification->getInvoice());
Example #20
0
<?php

/**
 * если значения $_GET['controller'] и $_GET['action'] не проинициализированны - присваиваем дефолтные значения
 */
if (!isset($_GET['controller'])) {
    $_GET['controller'] = 'index';
    $_GET['action'] = 'index';
}
/**
 * переменная используется для отслеживания возможности обработать запрос
 */
$canProcessRequest = false;
if (isset($_GET['controller']) && $_GET['action']) {
    $controllerName = ucfirst($_GET['controller']) . 'Controller';
    if (file_exists('controllers/' . $controllerName . '.php')) {
        $controller = new $controllerName();
        if (method_exists($controller, $_GET['action'])) {
            $controller->{$_GET}["action"]();
            $canProcessRequest = true;
        }
    }
}
if (!$canProcessRequest) {
    addNotification('Please provide valid parameters', 'error');
    header('Location: /?controller=index&action=index');
}
Example #21
0
 public static function backupProcessor($siteIDs, $params)
 {
     $accountInfo = array('account_info' => $params['accountInfo']);
     if (!empty($accountInfo['account_info']['iwp_gdrive'])) {
         //$accountInfo['account_info']['iwp_gdrive']['gDriveEmail'] = unserialize(getOption('googleDriveAccessToken'));
         $repoID = $accountInfo['account_info']['iwp_gdrive']['gDriveEmail'];
         if (function_exists('backupRepositorySetGoogleDriveArgs')) {
             $accountInfo['account_info']['iwp_gdrive'] = backupRepositorySetGoogleDriveArgs($accountInfo['account_info']['iwp_gdrive']);
         } else {
             addNotification($type = 'E', $title = 'Cloud backup Addon Missing', $message = "Check if cloud backup addon exists and is active", $state = 'U', $callbackOnClose = '', $callbackReference = '');
             return false;
         }
     }
     $config = $params['config'];
     $timeout = 20 * 60;
     //20 mins
     $type = "backup";
     $action = $config['mechanism'] == 'multiCall' ? "multiCallNow" : "now";
     $requestAction = "scheduled_backup";
     if (empty($config['taskName'])) {
         $config['taskName'] = 'Backup Now';
     }
     $exclude = explode(',', $config['exclude']);
     $include = explode(',', $config['include']);
     array_walk($exclude, 'trimValue');
     array_walk($include, 'trimValue');
     $requestParams = array('task_name' => $config['taskName'], 'mechanism' => $config['mechanism'], 'args' => array('type' => $type, 'action' => $action, 'what' => $config['what'], 'optimize_tables' => $config['optimizeDB'], 'exclude' => $exclude, 'exclude_file_size' => (int) $config['excludeFileSize'], 'exclude_extensions' => $config['excludeExtensions'], 'include' => $include, 'del_host_file' => $config['delHostFile'], 'disable_comp' => $config['disableCompression'], 'fail_safe_db' => $config['failSafeDB'], 'fail_safe_files' => $config['failSafeFiles'], 'limit' => $config['limit'], 'backup_name' => $config['backupName']), 'secure' => $accountInfo);
     if ($action == "multiCallNow") {
         //this function set the multicall options value from config.php if available
         setMultiCallOptions($requestParams);
     }
     $historyAdditionalData = array();
     $historyAdditionalData[] = array('uniqueName' => $config['taskName'], 'detailedAction' => $type);
     $incTime = 20 * 60;
     //20 mins
     $i = 0;
     $lastHistoryID = '';
     if (empty($params['timeScheduled'])) {
         $params['timeScheduled'] = time();
     }
     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['status'] = 'pending';
         $PRP['timeScheduled'] = $params['timeScheduled'];
         if ($lastHistoryID) {
             $runCondition = array();
             $runCondition['satisfyType'] = 'OR';
             $runCondition['query'] = array('table' => "history_additional_data", 'select' => 'historyID', 'where' => "historyID = " . $lastHistoryID . " AND status IN('success', 'error', 'netError')");
             //$runCondition['maxWaitTime'] = $params['timeScheduled'] + $incTime * $i;
             $PRP['runCondition'] = serialize($runCondition);
             $PRP['status'] = 'scheduled';
         }
         $lastHistoryID = prepareRequestAndAddHistory($PRP);
         $i++;
     }
 }
Example #22
0
function cronCheck()
{
    if ($_GET['type'] == 'manage') {
        //easyCron triggered
        define('CRON_MODE', 'easyCronManage');
        $getNextTaskScheduleTime = getNextTaskScheduleTime();
        if (!empty($getNextTaskScheduleTime) && $getNextTaskScheduleTime < time() + 30 * 60) {
            //if manageCron trigger at 00:00. say a cron task scheduled at 00:10, it will be accepted by this if which checks less then 00:30, cronTask which will disable it self, it will keep triggering for every minutue even it doesnt have any task to execute
            $result = manageEasyCron::taskCronEnable();
            if ($result['status'] == 'error') {
                addNotification($type = 'E', $title = 'Easy Cron API Error', $result['error']['message'], $state = 'U');
            }
        }
        die;
    } elseif ($_GET['type'] == 'task') {
        //easyCron triggered
        define('CRON_MODE', 'easyCronTask');
        define('CRON_TIMEOUT', 30);
    } else {
        $freq = getSystemCronRunningFrequency();
        if ($freq == 5) {
            //5 min system cron
            define('CRON_MODE', 'systemCronShortTime');
            define('CRON_TIMEOUT', 310);
        } else {
            //should be 20 min system cron
            define('CRON_MODE', 'systemCronDefault');
            define('CRON_TIMEOUT', 1210);
        }
    }
}
 /**
  * отображение формы логина и проверка данных
  */
 public function login()
 {
     if (isset($_SESSION['logged_user'])) {
         header('Location: /');
     }
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!isset($_POST['exampleInputEmail1']) || empty($_POST['exampleInputEmail1'])) {
             $errors['exampleInputEmail1'] = "This field is required";
         }
         if (!isset($_POST['exampleInputPassword1']) || empty($_POST['exampleInputPassword1'])) {
             $errors['exampleInputPassword1'] = "This field is required";
         }
         if (!$errors) {
             $usersModel = new UsersModel();
             $status = $usersModel->checUserExist($_POST);
             if ($status) {
                 $_SESSION['logged_user'] = $status;
                 addNotification('Welcome!');
                 header('Location: /');
             } else {
                 $errors['exampleInputEmail1'] = "Please verify you credentials";
             }
         }
     }
     include 'views/login.php';
 }
Example #24
0
    $seedrating = calculate_mr($project['project_id']);
    if ($seedrating == 'N/A') {
        continue;
    }
    if ($project['status'] == '1') {
        continue;
    }
    $user = '******';
    //automatically published need to define user
    $query = "UPDATE `projects` SET `status`='1',`accepted_by`=" . $user . " WHERE `project_id`=" . $project['project_id'];
    $db_con->query($query);
    $project_title = getProjectTitle($project['project_id']);
    $url = SITE_URL . '/home.php?pid=' . $project['project_id'];
    $sent_to = getProjectAuthor($project['project_id']);
    $text = 'Your Project  "' . $project_title . '" has been Published.';
    addNotification($sent_to, $text, 168, $url);
    //automatically published need to define user
}
$projects = getAllRecentProjects();
foreach ($projects as $project) {
    $seedrating = calculate_mr($project['project_id']);
    if ($seedrating == 'N/A') {
        continue;
    }
    $likes = getLikesCount($project_id);
    $comments = getCommentsCount($project_id);
    $query = 'SELECT `routed_by` FROM `routed_projects` WHERE `project_id` = ' . $project_id;
    $users1 = count($db_con->sql2array($query));
    $query = 'SELECT DISTINCT(`sent_to`) FROM `suggestions` WHERE `project_id` = ' . $project_id;
    $routers1 = count($db_con->sql2array($query));
    $routers = $users1 + $routers1;
Example #25
0
<?php

session_start();
require "pdo.php";
$senderID = $_SESSION["userID"];
$receiverID = $_POST["receiverID"];
$daySlot = $_POST["dayslot"];
$action = $_POST["action"];
$status = addNotification($senderID, $receiverID, $action, $daySlot);
echo $status;
Example #26
0
function landFleet($sid, $fid)
{
    //Check the time to see if can land
    $destination = getFleetStat(destination, $sid, $fid);
    if (timeLeft(getFleetStat(destinationtime, $sid, $fid)) < 0) {
        //$did is the owner id of the destination
        $did = getPlanetStat(ownerid, $sid, $destination);
        if (getFleetStat(combatid, $sid, $fid) > 0) {
            //Check to make sure the combat is still valid
            if ($did == getFleetStat(ownerid, $sid, $fid) || $did == 0) {
                setFleetStat(combatid, 0, $sid, $fid);
            } else {
                return false;
            }
        }
        //Check and see if it has a settler landing on an uninhabited planet
        if ($did != getFleetStat(ownerid, $sid, $fid) && $did > 0) {
            //Check to see if someone else owns the planet
            setFleetStat(combatid, 1, $sid, $fid);
            return false;
        }
        setFleetStat(destination, 0, $sid, $fid);
        setFleetStat(loc, $destination, $sid, $fid);
        if (getPlanetStat(ownerid, $sid, $destination) == 0) {
            $settlers = getFleetStat(ship5, $sid, $fid);
            if ($settlers > 0) {
                $settlers--;
                setFleetStat(ship5, $settlers, $sid, $fid);
                setPlanetStat(ownerid, getFleetStat(ownerid, $sid, $fid), $sid, $destination);
                addNotification('You have succesfully colonized <a href="planetdetails.php?id=' . $destination . '">' . getPlanetStat(name, $sid, $destination) . '</a>.', $sid, getFleetStat(ownerid, $sid, $fid));
            }
        }
        return true;
    }
    return false;
}
Example #27
0
function declineRoute($routed_by, $user_id, $notify_id)
{
    global $db_con;
    $q = 'DELETE FROM `routers` WHERE `user_id` = ' . $user_id . ' AND `routed_by` = ' . $routed_by;
    $db_con->query($q);
    $q = 'DELETE FROM `notifications` WHERE `notify_id` = ' . $notify_id;
    $db_con->query($q);
    $author = getUserNameById($user_id);
    $text = $author . ' declined your route';
    addNotification($routed_by, $text, $user_id);
}
    $wfield3 = $_GET['wfield3'];
    $wfield4 = $_GET['wfield4'];
    $id = $_GET['id'];
}
/*
$dsn = 'mysql:dbname=movert;host=127.0.0.1';
$user = '******';
$password = '******';
$dbh = new PDO($dsn, $user, $password);*/
$dsn = 'mysql:dbname=school;host=localhost';
$user = '******';
$password = '';
$dbh = new PDO($dsn, $user, $password);
switch ($action) {
    case 1:
        addNotification();
        break;
    case 2:
        findNotification();
        break;
    default:
        break;
}
function findCount($sql)
{
    global $dbh;
    $total = 0;
    foreach ($dbh->query($sql) as $row) {
        $total = $total + 1;
    }
    return $total;
Example #29
0
                } else {
                    if ($probe > $sentry + 40) {
                        $rand = rand(9, 11) / 10;
                        $def = floor(calcDef($sid, $pid) * $rand);
                        $report = 'Your probe report came back very positive. They report the estimated defensive capabilities are ' . $def . '. The estimated land remaining is ' . $land . '. This report is very accurate.';
                    } else {
                        if ($probe > $sentry + 25) {
                            $rand = rand(8, 12) / 10;
                            $def = floor(calcDef($sid, $pid) * $rand);
                            $report = 'Your probe report came back positive. They report the estimated defensive capabilities are ' . $def . '.';
                        } else {
                            if ($probe > $sentry + 10) {
                                $rand = rand(7, 13) / 10;
                                $def = floor(calcDef($sid, $pid) * $rand);
                                $report = 'Your probe report came back neutral. They report the estimated defensive capabilities are ' . $def . '. This report is somewhat uncertain.';
                            } else {
                                $rand = rand(5, 15) / 10;
                                $def = floor(calcDef($sid, $pid) * $rand);
                                $report = 'Your probe report came back very vague. They report the estimated defensive capabilities are ' . $def . '. This report is very uncertain.';
                            }
                        }
                    }
                }
                echo $report;
                setFleetStat(report, $report, $sid, $fid);
                setFleetStat(probetime, -1, $sid, $fid);
                addNotification('Your scan of planet <a href="./planetdetails.php?id=' . $pid . '">' . getPlanetStat(name, $sid, $pid) . '</a> is complete. The results are <a href="./report.php?id=' . $fid . '">here</a>', $sid, getFleetStat(ownerid, $sid, $fid));
            }
        }
    }
}
Example #30
0
     $user_id = mysql_real_escape_string($_POST['user_id']);
     $status_value = mysql_real_escape_string($_POST['status_value']);
     $createdby = mysql_real_escape_string($_POST['user_id']);
     $updatedby = mysql_real_escape_string($_POST['user_id']);
     addjournal($finao_id, $finao_journal, $journal_status, $user_id, $status_value, $createdby, $updatedby);
     break;
 case "addNotification":
     $tracker_userid = $_POST['tracker_userid'];
     $user_id = $_POST['user_id'];
     $tile_id = $_POST['tile_id'];
     $finao_id = $_POST['finao_id'];
     $journal_id = $_POST['journal_id'];
     $notification_action = $_POST['notification_action'];
     $updatedby = $user_id;
     $createdby = $user_id;
     addNotification($tracker_userid, $user_id, $tile_id, $finao_id, $journal_id, $notification_action, $updatedby, $createdby);
     break;
 case "addTracker":
     $tracker_userid = $_POST['tracker_userid'];
     $tracked_userid = $_POST['tracked_userid'];
     $tracked_tileid = $_POST['tracked_tileid'];
     $status = $_POST['status'];
     addTracker($tracker_userid, $tracked_userid, $tracked_tileid, $status);
     break;
 case "updateTracker":
     $tracker_userid = $_POST['tracker_userid'];
     $tracked_userid = $_POST['tracked_userid'];
     $tracked_tileid = $_POST['tracked_tileid'];
     $tracking_id = $_POST['tracking_id'];
     $status = $_POST['status'];
     updateTracker($tracker_userid, $tracked_userid, $tracked_tileid, $tracking_id, $status);