From 81d95fa3afbc55efe9c18385231abf7785153d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Sun, 15 Jul 2001 00:31:36 +0000 Subject: [PATCH] Added bzip support for dump files --- ChangeLog | 4 +++ Documentation.html | 13 +++++---- db_details.php3 | 25 +++++++++++++----- functions.js | 31 ++++++++++++++++------ lang/brazilian_portuguese.inc.php3 | 3 ++- lang/bulgarian-win1251.inc.php3 | 1 + lang/catala.inc.php3 | 1 + lang/chinese_big5.inc.php3 | 3 ++- lang/chinese_gb.inc.php3 | 1 + lang/czech-iso.inc.php3 | 1 + lang/czech-win1250.inc.php3 | 1 + lang/danish.inc.php3 | 1 + lang/dutch.inc.php3 | 1 + lang/english.inc.php3 | 1 + lang/french.inc.php3 | 1 + lang/german.inc.php3 | 1 + lang/italian.inc.php3 | 1 + lang/japanese.inc.php3 | 1 + lang/korean.inc.php3 | 1 + lang/norwegian.inc.php3 | 1 + lang/polish.inc.php3 | 1 + lang/portuguese.inc.php3 | 1 + lang/russian-koi8.inc.php3 | 1 + lang/russian-win1251.inc.php3 | 1 + lang/spanish.inc.php3 | 1 + lang/swedish.inc.php3 | 1 + lang/thai.inc.php3 | 1 + tbl_dump.php3 | 42 +++++++++++++++++++++--------- tbl_properties.php3 | 25 +++++++++++++----- 29 files changed, 127 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4b253963..d39a8fda5 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2001-07-14 Loïc Chapeaux + * db_details.php3, tbl_properties.php3, functions.js, tbl_dump.php3, + documentation.html, translations: added bzip support for dump files. + 2001-07-14 Armel Fauveau * Added a warning concerning bookmark feature and advanced auth diff --git a/Documentation.html b/Documentation.html index 07464bd66..53b84f720 100755 --- a/Documentation.html +++ b/Documentation.html @@ -168,8 +168,9 @@ (*)  - phpMyAdmin can compress (GZip format - RFC 1952) dumps and CSV exports - if you use PHP>=4.0.4 with Zlib support (--with-zlib) + phpMyAdmin can compress (GZip format -RFC 1952- or Bzip2) dumps and CSV + exports if you use PHP4 >= 4.0.4 with Zlib support + (--with-zlib) and/or Bzip2 support (--with-bz2). @@ -748,11 +749,13 @@

- How can I GZip a dump or a CSV export. It seem to not work? + How can I GZip or Bzip a dump or a CSV export. It seem to not work?
- This feature is based on gzencode() to be more independent of the platform + These features are based on the gzencode() and + bzcompress() php functions to be more independent of the platform (Unix/Windows, Safe Mode or not, and so on). - So, you must have PHP4 >= 4.0.4 and Zlib support (--with-zlib). + So, you must have PHP4 >= 4.0.4 and Zlib/Bzip2 support + (--with-zlib and --with-bz2).

diff --git a/db_details.php3 b/db_details.php3 index 90ce734ef..97d99bdf4 100755 --- a/db_details.php3 +++ b/db_details.php3 @@ -365,12 +365,25 @@ if ($num_tables > 0) { - () - = 40004) { + $is_gzip = @function_exists('gzencode'); + $is_bzip = @function_exists('bzcompress'); + if ($is_gzip || $is_bzip) { + echo "\n" . ' ('; + if ($is_gzip) { + ?> + + + + diff --git a/functions.js b/functions.js index ea5f66612..09f047f55 100755 --- a/functions.js +++ b/functions.js @@ -46,7 +46,8 @@ function checkFormElementInRange(theForm, theFieldName, min, max) /** - * Ensures the choice between 'transmit' and 'gzipped' checkboxes is consistant + * Ensures the choice between 'transmit', 'gzipped' and 'bzipped' checkboxes is + * consistant * * @param object the form * @param string a code for the action that causes this function to be run @@ -57,19 +58,33 @@ function checkTransmitDump(theForm, theAction) { var formElts = theForm.elements; - // 'gzipped' option has been checked/unchecked - if (theAction == 'gzip') { - if (formElts['gzip'].checked && !formElts['asfile'].checked) { + // 'gzipped' option has been checked + if (theAction == 'gzip' && formElts['gzip'].checked) { + if (!formElts['asfile'].checked) { theForm.elements['asfile'].checked = true; } + if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) { + theForm.elements['bzip'].checked = false; + } } - // 'transmit' option has been checked/unchecked - else if (theAction == 'transmit') { - if (!formElts['asfile'].checked - && (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) { + // 'bzipped' option has been checked + else if (theAction == 'bzip' && formElts['bzip'].checked) { + if (!formElts['asfile'].checked) { + theForm.elements['asfile'].checked = true; + } + if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) { theForm.elements['gzip'].checked = false; } } + // 'transmit' option has been unchecked + else if (theAction == 'transmit' && !formElts['asfile'].checked) { + if ((typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) { + theForm.elements['gzip'].checked = false; + } + if ((typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked)) { + theForm.elements['bzip'].checked = false; + } + } return true; } // end of the 'checkTransmitDump()' function diff --git a/lang/brazilian_portuguese.inc.php3 b/lang/brazilian_portuguese.inc.php3 index 4a35c8613..9b4c3b472 100644 --- a/lang/brazilian_portuguese.inc.php3 +++ b/lang/brazilian_portuguese.inc.php3 @@ -273,8 +273,9 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; $strRowSize=" Row size "; //to translate -?> +?> \ No newline at end of file diff --git a/lang/bulgarian-win1251.inc.php3 b/lang/bulgarian-win1251.inc.php3 index 59bcc598b..efb23426a 100644 --- a/lang/bulgarian-win1251.inc.php3 +++ b/lang/bulgarian-win1251.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/catala.inc.php3 b/lang/catala.inc.php3 index 2c3f305df..9f2e0d3ac 100644 --- a/lang/catala.inc.php3 +++ b/lang/catala.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/chinese_big5.inc.php3 b/lang/chinese_big5.inc.php3 index 0d37469ef..2e4ae942a 100644 --- a/lang/chinese_big5.inc.php3 +++ b/lang/chinese_big5.inc.php3 @@ -273,8 +273,9 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; $strRowSize=" Row size "; //to translate -?> +?> \ No newline at end of file diff --git a/lang/chinese_gb.inc.php3 b/lang/chinese_gb.inc.php3 index da3f81606..e05c43328 100644 --- a/lang/chinese_gb.inc.php3 +++ b/lang/chinese_gb.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/czech-iso.inc.php3 b/lang/czech-iso.inc.php3 index 6c246d1c7..afbcf930d 100644 --- a/lang/czech-iso.inc.php3 +++ b/lang/czech-iso.inc.php3 @@ -270,6 +270,7 @@ $strWrongUser = " $strYes = "Ano"; // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/czech-win1250.inc.php3 b/lang/czech-win1250.inc.php3 index d8020096f..a7c8a6b54 100644 --- a/lang/czech-win1250.inc.php3 +++ b/lang/czech-win1250.inc.php3 @@ -270,6 +270,7 @@ $strWrongUser = " $strYes = "Ano"; // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/danish.inc.php3 b/lang/danish.inc.php3 index 329f2a85c..589761c33 100644 --- a/lang/danish.inc.php3 +++ b/lang/danish.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/dutch.inc.php3 b/lang/dutch.inc.php3 index 5201f01e8..881ac8d1f 100644 --- a/lang/dutch.inc.php3 +++ b/lang/dutch.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/english.inc.php3 b/lang/english.inc.php3 index a65d7bab3..64a4141d5 100644 --- a/lang/english.inc.php3 +++ b/lang/english.inc.php3 @@ -45,6 +45,7 @@ $strBookmarkQuery = "Bookmarked SQL-query"; $strBookmarkThis = "Bookmark this SQL-query"; $strBookmarkView = "View only"; $strBrowse = "Browse"; +$strBzip = "\"bzipped\""; $strCantLoadMySQL = "cannot load MySQL extension,
please check PHP Configuration."; $strCarriage = "Carriage return: \\r"; diff --git a/lang/french.inc.php3 b/lang/french.inc.php3 index 0b30d2c5a..2423450fd 100644 --- a/lang/french.inc.php3 +++ b/lang/french.inc.php3 @@ -44,6 +44,7 @@ $strBookmarkQuery = "Requ $strBookmarkThis = "Bookmarker cette requête"; $strBookmarkView = "Voir uniquement"; $strBrowse = "Afficher"; +$strBzip = "\"bzippé\""; $strCantLoadMySQL = "ne peux charger l'extension MySQL,
vérifiez la configuration PHP"; $strCarriage = "Retour de chariot: \\r"; diff --git a/lang/german.inc.php3 b/lang/german.inc.php3 index f95ce2c24..e7c4e7b84 100644 --- a/lang/german.inc.php3 +++ b/lang/german.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "Das ist keine Zahl!"; $strNotValidNumber = " ist keine gültige Zeilennummer!"; // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"GZip komprimiert\""; $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/italian.inc.php3 b/lang/italian.inc.php3 index 2601575bd..a6d474238 100644 --- a/lang/italian.inc.php3 +++ b/lang/italian.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/japanese.inc.php3 b/lang/japanese.inc.php3 index 99b1a930b..e902a6198 100644 --- a/lang/japanese.inc.php3 +++ b/lang/japanese.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/korean.inc.php3 b/lang/korean.inc.php3 index 32a182480..82522177e 100644 --- a/lang/korean.inc.php3 +++ b/lang/korean.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/norwegian.inc.php3 b/lang/norwegian.inc.php3 index 13d502993..aeaea1ad3 100644 --- a/lang/norwegian.inc.php3 +++ b/lang/norwegian.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/polish.inc.php3 b/lang/polish.inc.php3 index 8b59ed977..f01489c78 100644 --- a/lang/polish.inc.php3 +++ b/lang/polish.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/portuguese.inc.php3 b/lang/portuguese.inc.php3 index c3fe12ad8..b8ebee2e4 100644 --- a/lang/portuguese.inc.php3 +++ b/lang/portuguese.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/russian-koi8.inc.php3 b/lang/russian-koi8.inc.php3 index 557a9ca36..d3852a2ae 100644 --- a/lang/russian-koi8.inc.php3 +++ b/lang/russian-koi8.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/russian-win1251.inc.php3 b/lang/russian-win1251.inc.php3 index e7935337c..1718080b3 100644 --- a/lang/russian-win1251.inc.php3 +++ b/lang/russian-win1251.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/spanish.inc.php3 b/lang/spanish.inc.php3 index 1c6a72471..03d17bb70 100644 --- a/lang/spanish.inc.php3 +++ b/lang/spanish.inc.php3 @@ -270,6 +270,7 @@ $strWrongUser = "Usuario/password equivocado. Acesso denegado."; $strYes = "Si"; // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/swedish.inc.php3 b/lang/swedish.inc.php3 index 2404ccc1f..2e94aef65 100644 --- a/lang/swedish.inc.php3 +++ b/lang/swedish.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/lang/thai.inc.php3 b/lang/thai.inc.php3 index 1ed41fe18..749a34df0 100644 --- a/lang/thai.inc.php3 +++ b/lang/thai.inc.php3 @@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate // export Zip (July 07, 2001, 19:48am) +$strBzip = "\"bzipped\""; $strGzip = "\"gzipped\""; //to translate $strOffSet = "Offset"; $strNbRecords = "No. Of records"; diff --git a/tbl_dump.php3 b/tbl_dump.php3 index 6d76b83a7..4c5cf181e 100755 --- a/tbl_dump.php3 +++ b/tbl_dump.php3 @@ -6,7 +6,8 @@ require("./grab_globals.inc.php3"); @set_time_limit(600); $crlf="\n"; -if (empty($asfile) && !empty($gzip)) { +if (empty($asfile) + && (!empty($gzip) || !empty($bzip))) { $asfile = 1; } @@ -20,11 +21,16 @@ else if (!isset($table)) $filename=$db; else $filename=$table; include("./lib.inc.php3"); - $ext = "sql"; - if($what == "csv") $ext = "csv"; - if(isset($gzip)) - if($gzip == "gzip") $ext = "gz"; - + if (isset($bzip) && $bzip == 'bzip') { + $ext = 'bz2'; + } else if (isset($gzip) && $gzip == 'bzip') { + $ext = 'gz'; + } else if ($what == 'csv') { + $ext = 'csv'; + } else { + $ext = 'sql'; + } + header('Content-Type: application/octetstream'); header('Content-Disposition: filename="' . $filename . '.' . $ext . '"'); header('Pragma: no-cache'); @@ -152,7 +158,10 @@ else $dump_buffer.= "#$crlf$crlf"; $tmp_buffer=""; - get_table_content($db, $table, $limit_from, $limit_to, 'my_handler'); + if (!isset($limit_from) || !isset($limit_to)) { + $limit_from = $limit_to = 0; + } + get_table_content($db, $table, $limit_from, $limit_to, 'my_handler'); $dump_buffer.=$tmp_buffer; } $i++; @@ -169,13 +178,20 @@ else } } -if(isset($gzip)) { - if($gzip == "gzip" && function_exists("gzencode")) - // without the optional parameter level because it bug - echo gzencode($dump_buffer); +if (isset($bzip) && $bzip == 'bzip') { + if (function_exists('bzcompress')) { + echo bzcompress($dump_buffer); + } +} +else if (isset($gzip) && $gzip == 'gzip') { + if ($gzip == 'gzip' && function_exists('gzencode')) { + // without the optional parameter level because it bug + echo gzencode($dump_buffer); + } +} +else { + echo $dump_buffer; } -else - echo $dump_buffer; if(empty($asfile)) { diff --git a/tbl_properties.php3 b/tbl_properties.php3 index dc5fc064e..d25c33667 100755 --- a/tbl_properties.php3 +++ b/tbl_properties.php3 @@ -599,12 +599,25 @@ echo "\n"; - () - = 40004) { + $is_gzip = @function_exists('gzencode'); + $is_bzip = @function_exists('bzcompress'); + if ($is_gzip || $is_bzip) { + echo "\n" . ' ('; + if ($is_gzip) { + ?> + + + +