Пример #1
0
 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $ftpSettings = Settings_BackUp_Module_Model::getFTPSettings();
     if ($ftpSettings != false) {
         $viewer->assign('FTP_SERVER_NAME', $ftpSettings[1]);
         $viewer->assign('FTP_LOGIN', $ftpSettings[2]);
         $viewer->assign('FTP_PASSWORD', $ftpSettings[3]);
         $viewer->assign('FTP_CONNECTION_STATUS', $ftpSettings[4]);
     }
     $backUpInfo = Settings_BackUp_Module_Model::getBackUpInfo();
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $pagination = Settings_BackUp_Pagination_Action::process($request);
     $pagination = json_decode($pagination, true);
     $viewer->assign('PREV_PAGE', $pagination['prevPage']);
     $viewer->assign('NEXT_PAGE', $pagination['nextPage']);
     $viewer->assign('OFFSET', $pagination['offset']);
     $viewer->assign('ALL_PAGES', $pagination['allPages']);
     $viewer->assign('PAGE', $pagination['page']);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('BACKUP_EXIST', $backUpInfo['status']);
     $viewer->assign('BACKUPS', $pagination['backups']);
     $viewer->assign('FTP_SERVER_NAME', $ftpSettings[1]);
     $viewer->assign('FTP_LOGIN', $ftpSettings[2]);
     $viewer->assign('FTP_PASSWORD', $ftpSettings[3]);
     $viewer->assign('FTP_CONNECTION_STATUS', $ftpSettings[4]);
     $viewer->view('Index.tpl', $qualifiedModuleName);
 }
Пример #2
0
 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $ftpSettings = Settings_BackUp_Module_Model::getFTPSettings();
     if ($ftpSettings != false) {
         $viewer->assign('FTP_HOST', $ftpSettings[1]);
         $viewer->assign('FTP_LOGIN', $ftpSettings[2]);
         $password = Settings_BackUp_Module_Model::encrypt_decrypt('decrypt', $ftpSettings[3]);
         $viewer->assign('FTP_PASSWORD', $password);
         $viewer->assign('FTP_CONNECTION_STATUS', $ftpSettings[4]);
         $viewer->assign('FTP_PORT', $ftpSettings[5]);
         $viewer->assign('FTP_ACTIVE', $ftpSettings[6]);
         $viewer->assign('FTP_PATH', $ftpSettings[7]);
     }
     $adminUsers = Users_Module_Model::getAdminUsers();
     $backUpInfo = Settings_BackUp_Module_Model::getBackUpInfo();
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $pagination = Settings_BackUp_Pagination_Action::process($request);
     $pagination = json_decode($pagination, true);
     $viewer->assign('PREV_PAGE', $pagination['prevPage']);
     $viewer->assign('NEXT_PAGE', $pagination['nextPage']);
     $viewer->assign('OFFSET', $pagination['offset']);
     $viewer->assign('ALL_PAGES', $pagination['allPages']);
     $viewer->assign('PAGE', $pagination['page']);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('BACKUP_EXIST', $backUpInfo['status']);
     $viewer->assign('BACKUPS', $pagination['backups']);
     $viewer->assign('QUALIFIED_MODULE_NAME', $qualifiedModuleName);
     $viewer->assign('ADMIN_USERS', $adminUsers);
     $viewer->view('Index.tpl', $qualifiedModuleName);
 }
Пример #3
0
 public function process(Vtiger_Request $request)
 {
     $log = vglobal('log');
     $newBackup = Settings_BackUp_Module_Model::clearBackupFilesTable();
     $log->info('Settings_BackUp_CreateFileBackUp_Action::process - Start files backup');
     $dirsFromConfig = Settings_BackUp_Module_Model::getConfig('folder');
     $dirsDiffConfig = '';
     $dirs = array_filter(array_merge(glob('*'), glob('.htaccess')));
     $dirs = array_diff($dirs, array('cache'));
     if ('true' != $dirsFromConfig['storage_folder']) {
         $dirs = array_diff($dirs, ['storage']);
     }
     if ('true' != $dirsFromConfig['backup_folder']) {
         $dirs = array_diff($dirs, [Settings_BackUp_Module_Model::$destDir]);
     }
     $dbDirs = Settings_BackUp_Module_Model::getDirs();
     $newDirs = array();
     $count = 0;
     $backUpInfo = Settings_BackUp_Module_Model::getBackUpInfo();
     $sqlFileName = $backUpInfo['file_name'];
     $this->fileName = $sqlFileName . '.files';
     if ($request->get('backUpAction') == 'cron') {
         $cron = TRUE;
     } else {
         $cron = FALSE;
     }
     if ($newBackup) {
         $log->info('New files backup');
         foreach ($dirs as $dir) {
             $dir = str_replace('\\', '/', $dir);
             if (!isset($dbDirs[$dir])) {
                 $newDirs[] = $dir;
             }
             if (!isset($dbDirs[$dir]) || $dbDirs[$dir] == 0) {
                 Settings_BackUp_CreateFileBackUp_Action::zipData($dir, Settings_BackUp_Module_Model::$tempDir . '/' . $this->fileName . '.zip', 0, $cron, array(), $this->fileName);
             }
         }
         Settings_BackUp_Module_Model::addBackupDirs($newDirs);
     }
     $dbAccuallyDirs = Settings_BackUp_Module_Model::getDirs();
     foreach ($dirs as $dir) {
         Settings_BackUp_CreateFileBackUp_Action::zipData($dir, Settings_BackUp_Module_Model::$tempDir . '/' . $this->fileName . '.zip', 1, $cron, $dbAccuallyDirs, $this->fileName);
     }
     $zip = new ZipArchive();
     $zip->open(Settings_BackUp_Module_Model::$destDir . '/' . $sqlFileName . '.zip', ZipArchive::CREATE);
     $zip->addFile(Settings_BackUp_Module_Model::$tempDir . '/' . $sqlFileName . '.db.zip', "db.zip");
     $zip->addFile(Settings_BackUp_Module_Model::$tempDir . '/' . $this->fileName . '.zip', "files.zip");
     $zip->close();
     Settings_BackUp_Module_Model::sendBackupToFTP(Settings_BackUp_Module_Model::$destDir . '/', $sqlFileName . '.zip');
     Settings_BackUp_Module_Model::sendNotificationEmail();
     Settings_BackUp_Module_Model::setBackUp();
     Settings_BackUp_Module_Model::deleteTmpBackUpContent();
     Settings_BackUp_Module_Model::deleteFile($sqlFileName . '.db.zip');
     Settings_BackUp_Module_Model::deleteFile($this->fileName . '.zip');
     echo json_encode(array('percentage' => 100));
 }