public function indexAction()
 {
     $cnf = Zend_Registry::get('cnf');
     $this->initCSS();
     $model = new BackupModel();
     $this->view->backups = $model->listBackups();
     $this->view->formaction = $cnf->url->fullurl . "backup/extract/processed/";
 }
 public function indexAction()
 {
     $cnf = Zend_Registry::get('cnf');
     $this->initCSS();
     $this->view->formaction = $cnf->url->fullurl . "backup/make/";
     $model = new BackupModel();
     $this->view->backupname = $model->makeBackupName();
     $this->view->mysqldump = $model->makeMysqlDumpName();
     $this->view->files = $model->getRootDir();
 }
Example #3
0
 function actionCreate($params = '')
 {
     if (!empty($params['dosubmit'])) {
         $objBackup = new BackupModel();
         // backup database
         $created = $objBackup->createBackup();
         if ($created) {
             $this->messages[] = array('type' => 'success', 'message' => 'Database Backup Completed');
         } else {
             $this->messages[] = array('type' => 'error', 'message' => 'Error during backup!');
             $this->messages[] = array('type' => 'error', 'message' => $objBackup->errorMsg);
         }
     }
     $this->actionIndex();
 }
 public function indexAction()
 {
     $cnf = Zend_Registry::get('cnf');
     $this->initCSS();
     $model = new BackupModel();
     $f = $this->_request->getPost('f_backup_submit');
     if (!empty($f)) {
         $mysqldump = $this->_request->getPost('s_mysql_backup');
         if (isset($mysqldump)) {
             $dumpname = $this->_request->getPost('s_mysql_dump_name');
             $model->makeMySQLdump($dumpname) . "<br/><br/>";
         }
         $files = array_keys($this->_request->getPost('s_files'));
         $var .= $model->makeBackup($this->_request->getPost('s_backupname'), $files);
         $this->sendMessage("site backuped successfully: {$var}", "backup", $cnf->url->fullurl . "backup/");
     } else {
         $this->sendMessage("filename required", "backup", $cnf->url->fullurl . "backup/");
     }
 }
Example #5
0
 public function handleDelete($serverId)
 {
     $path = $this->serverRepo->getPath($serverId);
     try {
         $this->serverRepo->removeServer($serverId);
         BackupModel::removeDir($path);
     } catch (Exception $ex) {
         dump($ex);
     }
     $this->presenter->flashMessage("Smazáno.", 'success');
     $this->presenter->redirect('this');
 }
Example #6
0
 /**
  * Enregistre la fonction dans la base si elle n'est pas crée, sinon la met à jour
  * @return boolean true si l'enregistrement s'est bien déroulé, false sinon
  */
 public function record()
 {
     // $date = date('Y-m-d H:i:s', time());
     if ($this->_id == '') {
         $statement = ConnectionModel::getConnection()->query('Insert into function values ("", :name, :ownerId, :content, NOW(), :label, :type)', ['name' => $this->_name, 'content' => $this->_content, 'ownerId' => $this->_ownerId, 'label' => $this->_label, 'type' => $this->_type]);
     } else {
         // Backup déjà crées
         $oldBackups = BackupModel::loadByFunctionId($this->_id);
         // Nouveau backup à enregistrer
         $newBackup = new BackupModel();
         // Chargement de la version courante de l'algorithme
         $currentVersion = AlgorithmModel::loadFunctionById($this->_id);
         $newBackup->setFunctionId($currentVersion->getId());
         $newBackup->setContent($currentVersion->getContent());
         $newBackup->setLabel($currentVersion->getLabel());
         $newBackup->setType($currentVersion->getType());
         if (\sizeof($oldBackups) < 3) {
             if (\sizeof($oldBackups) == 0) {
                 $newBackup->setVersionId(0);
             } else {
                 $newBackup->setVersionId($oldBackups[0]->getVersionId() + 1);
             }
         } else {
             $backup0 = $oldBackups[0];
             $backup1 = $oldBackups[1];
             $backup2 = $oldBackups[2];
             $backup0->setContent($backup1->getContent());
             $backup0->setLabel($backup1->getLabel());
             $backup0->setType($backup1->getType());
             $backup0->update();
             $backup1->setContent($backup2->getContent());
             $backup1->setLabel($backup2->getLabel());
             $backup1->setType($backup2->getType());
             $backup1->update();
             $backup2->setContent($newBackup->getContent());
             $backup2->setLabel($newBackup->getLabel());
             $backup2->setType($newBackup->getType());
             $backup2->update();
         }
         $statement = ConnectionModel::getConnection()->query('Update function set name = :name, content = :content, date = NOW(), label = :label, type = :type where id =:id', ['name' => $this->_name, 'content' => $this->_content, 'label' => $this->_label, 'type' => $this->_type, 'id' => $this->_id]);
     }
     return $statement;
 }
Example #7
0
 public static function loadByKey($functionId, $versionId)
 {
     $result = [];
     $cursor = ConnectionModel::getConnection()->query("Select * From backup where functionId = :functionId and versionId = :versionId", ['functionId' => $functionId, 'versionId' => $versionId]);
     $i = 0;
     while ($i < \sizeof($cursor) && $cursor) {
         $newBackup = new BackupModel();
         $newBackup->hydrate($cursor[$i]);
         array_push($result, $newBackup);
         $i += 1;
     }
     return $result;
 }
Example #8
0
 public function renderDefault()
 {
     $this->template->backups = $this->backupModel->getBackups($this->path);
     $this->template->couldMakeNew = $this->configModel['backup']['number'] >= count($this->template->backups);
     $this->template->foreign = $this->configModel['backup']['foreign'];
 }