public function zip($dir, $destination) { //Don't forget to remove the trailing slash $the_folder = $dir; $zip_file_name = $destination; $za = new FlxZipArchive(); $res = $za->open($zip_file_name, ZipArchive::CREATE); if ($res === TRUE) { $za->addDir($the_folder, basename($the_folder)); $za->close(); } else { echo 'Could not create a zip archive'; } return $destination; }
if ($file == '.' || $file == '..') { continue; } // Rekursiv, If dir: FlxZipArchive::addDir(), else ::File(); $do = filetype($location . $file) == 'dir' ? 'addDir' : 'addFile'; $this->{$do}($location . $file, $name . $file); } } } //-----------------Class------------------// //------------------Edit------------------// require "../config/connect.php"; require "../engine/logger.php"; $uid = $_POST['uid']; $did = $_POST['did']; $seldir = mysql_query("select dirname,dirpath from directories where dirid='" . $did . "'"); $fetdir = mysql_fetch_array($seldir); $path = "../data/" . $uid . "/files" . $fetdir['dirpath'] . $fetdir['dirname']; $zip_name = "../data/" . $uid . "/zip/" . $fetdir['dirname'] . ".zip"; $zip = new FlxZipArchive(); $res = $zip->open($zip_name, ZipArchive::CREATE); if ($res === TRUE) { $zip->addDir($path, basename($path)); $zip->close(); echo "data/" . $uid . "/zip/" . $fetdir['dirname'] . ".zip"; } else { echo 'ERROR'; exit; } makelogger("Getdir", $uid, "", "", $fetdir['dirname']); //------------------Edit------------------//
if($_POST['argument6'] != "") { $string .= " -where ".'"'.$_POST['argument6']."="; } if($_POST['argument7'] != "") { $string .= "'".$_POST['argument7']."'".'"'." "; } */ $shell = shell_exec($string . " 2>&1"); if (strlen($shell) > 5 && !(strpos(strtolower($shell), 'failure') === FALSE)) { $RESULT['success'] = false; $RESULT['message'] = 'Error while execution query. Please check your optional fields and File Format'; } else { //$downloadFilePath = $folderId.'/'.$fileName.$_TARGET_FILE_FORMATS[$_POST['targetFormat']]; $FilePath = $target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']]; if (is_dir($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']])) { $za = new FlxZipArchive(); $res = $za->open($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']] . '.zip', ZipArchive::CREATE); if ($res === TRUE) { $za->addDir($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']], basename($target_dir . $fileName . $_TARGET_FILE_FORMATS[$_POST['targetFormat']])); $za->close(); //$downloadFilePath .= '.zip'; $FilePath .= '.zip'; } } $RESULT['success'] = true; $RESULT['message'] = file_get_contents($FilePath); //shell_exec("rm -r $FilePath"); //$RESULT['message'] = array($_BASE_URL."download.php?file=".$downloadFilePath, $_BASE_URL."map.php?file=".$downloadFilePath); //echo $string; } } else {
{ $name .= '/'; $location .= '/'; // Read all Files in Dir $dir = opendir($location); while ($file = readdir($dir)) { if ($file == '.' || $file == '..') { continue; } // Rekursiv, If dir: FlxZipArchive::addDir(), else ::File(); $do = filetype($location . $file) == 'dir' ? 'addDir' : 'addFile'; $this->{$do}($location . $file, $name . $file); } } } $za = new FlxZipArchive(); $res = $za->open($zip_file_name, ZipArchive::CREATE); if ($res === TRUE) { $za->addDir($the_folder, basename($the_folder)); $za->close(); } else { echo 'Could not create a zip archive'; } if ($download_file) { ob_get_clean(); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=" . basename($zip_file_name) . ";");
function archiveZip($directory, $file) { $zip = new FlxZipArchive(); $res = $zip->open($file, ZipArchive::CREATE); if ($res === TRUE) { $zip->addDir($directory, basename($directory)); $zip->close(); return true; } else { return false; } }
public function downloadProject() { $path = $_GET['fileDownload']; $project = $_GET['project']; $the_folder = $_SERVER['DOCUMENT_ROOT'] . '/workspaces/' . $project . '/' . $path; $zip_file_name = $path . '_' . time() . '.zip'; $za = new FlxZipArchive(); $res = $za->open($zip_file_name, ZipArchive::CREATE); if ($res === TRUE) { $za->addDir($the_folder, basename($the_folder)); $za->close(); } else { echo 'Could not create a zip archive'; } header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-type: application/zip"); header("Content-Disposition: attachment; filename=\"" . $zip_file_name . "\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($zip_file_name)); readfile($zip_file_name); unlink($zip_file_name); die; }
<?php define('CURRENTDIR', dirname(__FILE__)); chdir(CURRENTDIR); require_once "./flxziparchive.php"; $za = new FlxZipArchive(); $res = $za->open('homebackup_' . date("Y-m-d_H-i-s") . '.zip', ZipArchive::CREATE); // zip all files $files = file('filedef.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if ($res === true) { foreach ($files as $file) { if (substr($file, 0, 1) == '/') { $za->addDir($_SERVER['DOCUMENT_ROOT'] . $file, substr($file, 1)); } else { $za->addFile($_SERVER['DOCUMENT_ROOT'] . '/' . $file, $file); } } // backup sql //$User = "******"; //$Password = "******"; //$DatabaseName = "wordpress"; //echo shell_exec("mysqldump -uroot -papmsetup wordpress");// > blog.sql"); //echo shell_exec("cmd >> blog.sql"); //$Results = shell_exec("mysqldump --allow-keywords --opt -u$User -p$Password $DatabaseName > $DatabaseName.sql"); //$za->addFile('blog' . '.sql'); // Backup Database $files = file('sqldef.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $User = $files[0]; $Password = $files[1]; $Database[0] = $files[2]; //$Database[1] = $files[3];