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); }
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'); }
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'); }
function updateTask($params) { $tasks = new JsonDB($this->taskdb); if (!isset($tasks->data[$params['id']])) { return array('responseStatus' => 'error'); } $receivedTask = json_decode(base64_decode($params['task']), true); foreach ($receivedTask as $key => $val) { $tasks->data[$params['id']][$key] = $val; } $tasks->saveToFile($this->taskdb); return array('responseStatus' => 'success', 'task' => $tasks->data[$params['id']]); }
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'); }
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'); }
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'); }
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'); }
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); }
$i++; if ($i > $server['archDepth']) { unset($files[$key]); } } } $folder = getServersTaskFolder($server['id'], $taskId); echo "folder = {$folder} \n"; foreach ($files as $file) { if (!checkArchFile($folder, $file)) { echo "> file = " . $file['name'] . " \n"; $fileData = $query->downloadFile($taskId, $file['name']); if ($fileData) { file_put_contents($folder . '/' . $file['name'], $fileData); } } } delOldFiles($folder, $server['archDepth']); } // ---------------------------------- } } else { echo "\n status = " . $info['responseStatus'] . "\n"; $serversList->data[$key]['lastCheck'] = time(); $serversList->data[$key]['status'] = 3; } } } $serversList->saveToFile(__serversdb); echo "Servers Service finished [" . date('d.m.Y h:i', time()) . "] \n"; unLock('servers');
public function execute() { $login = $_POST['login']; $pass1 = $_POST['password']; $pass2 = $_POST['confirmation']; $email = $_POST['email']; $folder = $_POST['folder']; $workUrl = $_POST['workUrl']; $beforeInstallError = 0; if (!is_writable('../archive/')) { $beforeInstallError = 1; } if (!is_writable('../core/data')) { $beforeInstallError = 1; } if (!is_writable('../conf.php')) { $beforeInstallError = 1; } if ($beforeInstallError == 0 && $pass2 == $pass1 && $login != '' && $email != '' && is_dir($folder) && $workUrl != '') { $id = time(); $newUser = array('id' => $id, 'login' => $login, 'email' => $email, 'password' => md5($pass1), 'accessGroup' => 'administrator', 'alerts' => 'all'); $usersDB = new JsonDB('../core/data/users.json'); $usersDB->data = array(); $usersDB->data[$id] = $newUser; $usersDB->saveToFile('../core/data/users.json'); $basePath = str_replace('install/index.php', '', $_SERVER['SCRIPT_FILENAME']); $httpPath = 'http://' . $_SERVER['HTTP_HOST'] . str_replace('/install/', '', $_SERVER['REQUEST_URI']); $urlPath = str_replace('/install/', '', $_SERVER['REQUEST_URI']); $salt = md5(rand()); $config = file_get_contents($basePath . 'conf.php'); $config = str_replace('{basePath}', $basePath, $config); $config = str_replace('{httpPath}', $httpPath, $config); $config = str_replace('{urlPath}', $urlPath, $config); $config = str_replace('{salt}', $salt, $config); file_put_contents($basePath . 'conf.php', $config); unset($_SESSION['formSent']); // check settings db $settingsDB = new JsonDB('../core/data/settings.json'); if (!isset($settingsDB->data['shortName'])) { // db have not created, have to create clean $settingsDB->data['serverName'] = 'My new Backup server'; $settingsDB->data['shortName'] = 'BCKP'; $settingsDB->data['apiKey'] = md5(rand()); $settingsDB->data['lang'] = 'en'; $settingsDB->saveToFile('../core/data/settings.json'); } //-- check installation // check usersDB $usersDB = new JsonDB('../core/data/users.json'); if (count($usersDB->data) == 0) { $_SESSION['error'] = 'Unable to access to users db, please check permissions to the /core/data folder.'; header('location: ' . $_SERVER['REQUEST_URI'] . '?r=error'); die; } //-- header('location: ' . $_SERVER['REQUEST_URI'] . '?r=success'); die; } else { $_SESSION['formSent'] = $_POST; if ($beforeInstallError) { $_SESSION['error'] = 'Please check write permissions for work folder.'; } else { $_SESSION['error'] = 'Please check the installation form!'; } header('location: ' . $_SERVER['REQUEST_URI']); die; } }
if ($tasksList->data[$key]['frequency']['type'] == 'n-once') { $tasksList->data[$key]['status'] = 0; } // disable the task } break; case 'mysql_backup': $res = 0; $tasksList->data[$key]['execStatus'] = 0; try { $res = mysqlBackup($task); } catch (Exception $e) { echo $e->getMessage() . "\n"; $tasksList->data[$key]['execStatus'] = 2; } echo "{$res} \n"; if ($res == 'Ok') { $tasksList->data[$key]['lastExec'] = time(); // if task have to execute only once if ($tasksList->data[$key]['frequency']['type'] == 'n-once') { $tasksList->data[$key]['status'] = 0; } // disable the task } break; } } } $tasksList->saveToFile(__taskdb); echo "Service finished [" . date('d.m.Y h:i', time()) . "] \n"; unLock('tasks');