public function backup() { if (!$this->accessAdminPage(3)) { return new ActionResult($this, '/admin/modules/', 1, 'You are not allowed to do that', B_T_FAIL); } $backups = WebApp::post('backups') === NULL ? array() : strgetcsv(WebApp::post('backups')); if (count($backups) == 0) { $backups = WebApp::get('m') === NULL ? array() : array(WebApp::get('m')); } if (count($backups) == 0) { return new ActionResult($this, '/admin/modules/backup', 0, 'No module(s) were selected!', B_T_FAIL); } foreach ($backups as $backup) { $validated = GUMP::is_valid(array('bk' => $backup), array('bk' => 'integer')); if ($validated !== true) { return new ActionResult($this, '/admin/modules/backup', 0, 'No module(s) were selected!', B_T_FAIL); } } $location = __BACKUP__ . DIRECTORY_SEPARATOR . date(DATET_BKUP) . DIRECTORY_SEPARATOR; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'backup.php'; $result = array(); foreach ($backups as $module) { $backup = new Backup($this->parent); if (!$backup->setLocation($location)) { return new CronResult($this, false, 'Failed to create backup dir: ' . DIRECTORY_SEPARATOR . 'backup' . str_replace(__BACKUP__, '', $location . $module)); } if (!$backup->setID($module)) { return new CronResult($this, false, 'Failed to setID for ' . $module); } $results[$module] = $backup->backup(); unset($backup); } $msg = ''; $status = true; foreach ($results as $ns => $data) { $msg .= '"' . $ns . '": ' . $data['msg'] . PHP_EOL; if (!$data['s']) { $status = false; } } if ($status) { $msg = 'Backup was completed for selected module(s)!'; $type = B_T_SUCCESS; } else { $msg = 'Backup was completed but failed for some/all module(s). Details as follows:' . PHP_EOL . $msg; $type = B_T_WARNING; } $this->parent->parent->logEvent($this::name_space, 'Back up modules: ' . csvgetstr($backups)); return new ActionResult($this, '/admin/modules/backup', 1, $msg, $type); }