PHP Method User::checkRights, codiad Code Examples

This page contains top rated real world PHP examples of method User::checkRights from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: update.php Project: openweb-tech/hotbackup
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');
 }
Example #2
Show file File: download.php Project: openweb-tech/hotbackup
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 #3
Show file File: add_mysql_backup.php Project: openweb-tech/hotbackup
0
 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
Show file File: add_mysql_backup.php Project: openweb-tech/hotbackup
0
 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 #5
Show file File: delete.php Project: openweb-tech/hotbackup
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 #6
Show file File: update_main.php Project: openweb-tech/hotbackup
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 #7
Show file File: delete.php Project: openweb-tech/hotbackup
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 #8
Show file File: delete_server.php Project: openweb-tech/hotbackup
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 #9
Show file File: update_server.php Project: openweb-tech/hotbackup
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 #10
Show file File: delete.php Project: openweb-tech/hotbackup
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 #11
Show file File: deleteFile.php Project: openweb-tech/hotbackup
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;
     }
 }