public static function doFTPBackup($source, $details) { //TODO wirte a cleaner ftp handle ftpBackupFile($source, $details['server'], $details['username'], $details['password']); if (file_exists($source)) { unlink($source); } }
$fileName = '/backup_' . $currenttime . '.zip'; $createZip->addDirectory('user_privileges/'); $createZip->get_files_from_folder('user_privileges/', 'user_privileges/'); $createZip->addDirectory('storage/'); $createZip->get_files_from_folder('storage/', 'storage/'); $backup_DBFileName = "sqlbackup_" . $currenttime . ".sql"; $dbdump = new DatabaseDump(dbserver, dbuser, dbpass); $dumpfile = 'backup/' . $backup_DBFileName; $dbdump->save(dbname, $dumpfile); $filedata = implode("", file('backup/' . $backup_DBFileName)); $createZip->addFile($filedata, $backup_DBFileName); $fd = fopen($fileName, 'wb'); $out = fwrite($fd, $createZip->getZippedfile()); fclose($fd); $source_file = $fileName; ftpBackupFile($source_file, $ftpserver, $ftpuser, $ftppassword); if (file_exists($source_file)) { unlink($source_file); } } } if ($enable_local_backup == 'true' && is_admin($current_user) == true) { define("dbserver", $dbconfig['db_hostname']); define("dbuser", $dbconfig['db_username']); define("dbpass", $dbconfig['db_password']); define("dbname", $dbconfig['db_name']); $path_query = $adb->pquery("SELECT * FROM vtiger_systems WHERE server_type = ?", array('local_backup')); $path = $adb->query_result($path_query, 0, 'server_path'); $currenttime = date("Ymd_His"); if (is_dir($path) && is_writable($path)) { $createZip = new createDirZip();