Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Massage_debug_15_11_2017
:
zip.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php $zip = new ZipArchive(); if($zip->open('Zip.zip', ZipArchive::CREATE) === true) { echo '"Zip.zip" ouvert<br/>'; // Ajout d’un fichier. $zip->addFile('filetxt.txt'); // Ajout direct. $zip->addFromString('Fichier.txt', 'Je suis le contenu de Fichier.txt !'); // Et on referme l'archive. $zip->close(); } else { echo 'Impossible d'ouvrir "Zip.zip<br/>'; // Traitement des erreurs avec un switch(), par exemple. } // https://davidwalsh.name/create-zip-php // https://stackoverflow.com/questions/4914750/how-to-zip-a-whole-folder-using-php // https://www.virendrachandak.com/techtalk/how-to-create-a-zip-file-using-php/ //https://www.tutorialspoint.com/php/perform_mysql_backup_php.htm //http://webcheatsheet.com/php/how_to_create_a_dump_of_mysql_database_in_one_click.php // backup <?php $dump_path = ""; //input location for the backup to be saved $host = ""; //db host e.g.- localhost $user = ""; //user e.g.-root $pass = ""; //password $command=$dump_path.'mysqldump -h '.$host.' -u '.$user.' bank > bank.sql'; system($command); ?> // restore <?php $dump_path = ""; //your backup location $host = ""; //host $user = ""; //username $pass = ""; /passwprd $command=$dump_path.'mysql -h '.$host.' -u '.$user.' bank < bank.sql'; system($command); ?> /* $files_to_zip = array( 'preload-images/1.jpg', 'preload-images/2.jpg', 'preload-images/5.jpg', 'kwicks/ringo.gif', 'rod.jpg', 'reddit.gif' ); //if true, good; if false, zip creation failed $result = create_zip($files_to_zip,'my-archive.zip'); /* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; } //vars $valid_files = array(); //if files were passed in... if(is_array($files)) { //cycle through each file foreach($files as $file) { //make sure the file exists if(file_exists($file)) { $valid_files[] = $file; } } } //if we have good files... if(count($valid_files)) { //create the archive $zip = new ZipArchive(); if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { return false; } //add the files foreach($valid_files as $file) { $zip->addFile($file,$file); } //debug //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; //close the zip -- done! $zip->close(); //check to make sure the file exists return file_exists($destination); } else { return false; } } ?>