diff --git a/ChangeLog b/ChangeLog index b428137e6..9fcf99da8 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ phpMyAdmin - Changelog $Id$ $Source$ +2001-09-23 Armel Fauveau + * add zip dump feature + 2001-09-22 Marc Delisle * lang/romanian.inc.php3 updates, thanks to Valics Lehel. * lang/polish.inc.php3 updates, thanks to Jakub Wilk. diff --git a/Documentation.html b/Documentation.html index 08fea3207..84d927d3c 100755 --- a/Documentation.html +++ b/Documentation.html @@ -1109,6 +1109,7 @@ CREDITS, in chronological order * bookmarks feature * multiple dump feature * gzip dump feature + * zip dump feature [gl] - Geert Lund <glund_at_silversoft.dk> * various fixes diff --git a/Documentation.txt b/Documentation.txt index 2790ccc18..406c1bccf 100644 --- a/Documentation.txt +++ b/Documentation.txt @@ -565,6 +565,7 @@ CREDITS, in chronological order * bookmarks feature * multiple dump feature * gzip dump feature + * zip dump feature [gl] - Geert Lund * various fixes diff --git a/db_details.php3 b/db_details.php3 index 61a76ad3d..da6522817 100755 --- a/db_details.php3 +++ b/db_details.php3 @@ -578,7 +578,8 @@ if ($num_tables > 0) { if (PHP_INT_VERSION >= 40004) { $is_gzip = (isset($cfgGZipDump) && $cfgGZipDump && @function_exists('gzencode')); $is_bzip = (isset($cfgBZipDump) && $cfgBZipDump && @function_exists('bzcompress')); - if ($is_gzip || $is_bzip) { + $is_zip = (isset($cfgGZipDump) && $cfgGZipDump && @function_exists('gzcompress')); + if ($is_gzip || $is_bzip || $is_zip) { echo "\n" . ' ('; if ($is_gzip) { ?> @@ -591,6 +592,12 @@ if ($num_tables > 0) { + + + +$strZip = '"zipped"'; +?> \ No newline at end of file diff --git a/lang/french.inc.php3 b/lang/french.inc.php3 index df2ae40ec..b69bc93b1 100644 --- a/lang/french.inc.php3 +++ b/lang/french.inc.php3 @@ -10,7 +10,7 @@ $byteUnits = array('Octets', 'Ko', 'Mo', 'Go'); $day_of_week = array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'); $month = array('Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'); -// Voir http://www.php.net/manual/en/function.strftime.php pour la variable +// Voir http://www.php3.net/manual/en/function.strftime.php3 pour la variable // ci-dessous $datefmt = '%A %d %B %Y à %H:%M'; @@ -318,4 +318,6 @@ $strWithChecked = 'Pour la s $strWrongUser = 'Erreur d\'utilisateur/mot de passe. Accès refusé'; $strYes = 'Oui'; -?> + +$strZip = '"zippé"'; +?> \ No newline at end of file diff --git a/libraries/zip.lib.php3 b/libraries/zip.lib.php3 new file mode 100755 index 000000000..bc191cb3e --- /dev/null +++ b/libraries/zip.lib.php3 @@ -0,0 +1,123 @@ + datasec[] = $fr; + + $new_offset = strlen(implode("", $this->datasec)); + + // now add to central directory record + + $cdrec = "\x50\x4b\x01\x02"; + $cdrec .="\x00\x00"; // version made by + $cdrec .="\x14\x00"; // version needed to extract + $cdrec .="\x00\x00"; // gen purpose bit flag + $cdrec .="\x08\x00"; // compression method + $cdrec .="\x00\x00\x00\x00"; // last mod time & date + $cdrec .= pack("V",$crc); // crc32 + $cdrec .= pack("V",$c_len); // compressed filesize + $cdrec .= pack("V",$unc_len); // uncompressed filesize + $cdrec .= pack("v", strlen($name) ); // length of filename + $cdrec .= pack("v", 0 ); // extra field length + $cdrec .= pack("v", 0 ); // file comment length + $cdrec .= pack("v", 0 ); // disk number start + $cdrec .= pack("v", 0 ); // internal file attributes + $cdrec .= pack("V", 32 ); // external file attributes - 'archive' bit set + + $cdrec .= pack("V", $this -> old_offset ); // relative offset of local header + $this -> old_offset = $new_offset; + + $cdrec .= $name; + + // optional extra field, file comment goes here + // save to central directory + + $this -> ctrl_dir[] = $cdrec; + } + + function file() { // dump out file + $data = implode("", $this -> datasec); + $ctrldir = implode("", $this -> ctrl_dir); + + return + $data. + $ctrldir. + $this -> eof_ctrl_dir. + pack("v", sizeof($this -> ctrl_dir)). // total # of entries "on this disk" + pack("v", sizeof($this -> ctrl_dir)). // total # of entries overall + pack("V", strlen($ctrldir)). // size of central dir + pack("V", strlen($data)). // offset to start of central dir + "\x00\x00"; // .zip file comment length + } +} +?> \ No newline at end of file diff --git a/tbl_dump.php3 b/tbl_dump.php3 index 1765e30c0..49459001b 100755 --- a/tbl_dump.php3 +++ b/tbl_dump.php3 @@ -63,7 +63,7 @@ function my_csvhandler($sql_insert) require('./libraries/grab_globals.lib.php3'); require('./libraries/common.lib.php3'); require('./libraries/build_dump.lib.php3'); - +require('./libraries/zip.lib.php3'); /** * Increase time limit for script execution and initializes some variables @@ -78,7 +78,7 @@ $crlf = which_crlf(); * Ensure zipped formats are associated with the download feature */ if (empty($asfile) - && (!empty($gzip) || !empty($bzip))) { + && (!empty($gzip) || !empty($bzip) || !empty($zip))) { $asfile = 1; } @@ -111,6 +111,9 @@ else { } else if (isset($gzip) && $gzip == 'gzip') { $ext = 'gz'; $mime_type = 'application/x-gzip'; + } else if (isset($zip) && $zip == 'zip') { + $ext = 'zip'; + $mime_type = 'application/x-zip'; } else if ($what == 'csv' || $what == 'excel') { $ext = 'csv'; $mime_type = 'text/x-csv'; @@ -253,7 +256,19 @@ else if (isset($gzip) && $gzip == 'gzip') { echo gzencode($dump_buffer); } } -// 3. on screen +// 3. as a gzipped file +else if (isset($zip) && $zip == 'zip') { + if (PHP_INT_VERSION >= 40000 && @function_exists('gzcompress')) { + if ($what == 'csv' || $what == 'excel') + $extbis='.csv'; + else + $extbis='.sql'; + $zipfile = new zipfile(); + $zipfile -> add_file($dump_buffer, $filename . $extbis); + echo $zipfile -> file(); + } +} +// 4. on screen else { echo $dump_buffer; } diff --git a/tbl_properties.php3 b/tbl_properties.php3 index bb1610fd2..a64bc4c53 100755 --- a/tbl_properties.php3 +++ b/tbl_properties.php3 @@ -889,6 +889,7 @@ echo "\n"; if (PHP_INT_VERSION >= 40004) { $is_gzip = (isset($cfgGZipDump) && $cfgGZipDump && @function_exists('gzencode')); $is_bzip = (isset($cfgBZipDump) && $cfgBZipDump && @function_exists('bzcompress')); + $is_zip = (isset($cfgGZipDump) && $cfgGZipDump && @function_exists('gzcompress')); if ($is_gzip || $is_bzip) { echo "\n" . ' (' . "\n"; if ($is_gzip) { @@ -902,6 +903,12 @@ if (PHP_INT_VERSION >= 40004) { + +