Added bzip support for dump files

This commit is contained in:
Loïc Chapeaux
2001-07-15 00:31:36 +00:00
parent 997cae5159
commit 81d95fa3af
29 changed files with 127 additions and 40 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2001-07-14 Lo<4C>c Chapeaux <lolo@phpheaven.net>
* 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 <armel.fauveau@globalis-ms.com> 2001-07-14 Armel Fauveau <armel.fauveau@globalis-ms.com>
* Added a warning concerning bookmark feature and advanced auth * Added a warning concerning bookmark feature and advanced auth

View File

@@ -168,8 +168,9 @@
<tr> <tr>
<td valign="top">(*)&nbsp;</td> <td valign="top">(*)&nbsp;</td>
<td> <td>
phpMyAdmin can compress (GZip format - RFC 1952) dumps and CSV exports phpMyAdmin can compress (GZip format -RFC 1952- or Bzip2) dumps and CSV
if you use PHP>=4.0.4 with Zlib support (--with-zlib) exports if you use PHP4&nbsp;>=&nbsp;4.0.4 with Zlib support
(<tt>--with-zlib</tt>) and/or Bzip2 support (<tt>--with-bz2</tt>).
</td> </td>
</tr> </tr>
</table> </table>
@@ -748,11 +749,13 @@
</p> </p>
<p> <p>
<b>How can I GZip a dump or a CSV export. It seem to not work?</b> <b>How can I GZip or Bzip a dump or a CSV export. It seem to not work?</b>
<br /> <br />
This feature is based on gzencode() to be more independent of the platform These features are based on the <tt>gzencode()</tt> and
<tt>bzcompress()</tt> php functions to be more independent of the platform
(Unix/Windows, Safe Mode or not, and so on). (Unix/Windows, Safe Mode or not, and so on).
So, you must have PHP4&nbsp;>=&nbsp;4.0.4 and Zlib support (<tt>--with-zlib</tt>). So, you must have PHP4&nbsp;>=&nbsp;4.0.4 and Zlib/Bzip2 support
(<tt>--with-zlib</tt> and <tt>--with-bz2</tt>).
</p> </p>
<p> <p>

View File

@@ -365,12 +365,25 @@ if ($num_tables > 0) {
<input type="checkbox" name="asfile" value="sendit" onclick="return checkTransmitDump(this.form, 'transmit')" /> <input type="checkbox" name="asfile" value="sendit" onclick="return checkTransmitDump(this.form, 'transmit')" />
<?php echo $strSend . "\n"; ?> <?php echo $strSend . "\n"; ?>
<?php <?php
// gzip encode feature // gzip and bzip2 encode features
if (function_exists('gzencode')) { if (PMA_INT_VERSION >= 40004) {
echo "\n"; $is_gzip = @function_exists('gzencode');
?> $is_bzip = @function_exists('bzcompress');
(<input type="checkbox" name="gzip" value="gzip" onclick="return checkTransmitDump(this.form, 'gzip')" /><?php echo $strGzip; ?>) if ($is_gzip || $is_bzip) {
<?php echo "\n" . ' (';
if ($is_gzip) {
?>
<input type="checkbox" name="gzip" value="gzip" onclick="return checkTransmitDump(this.form, 'gzip')" /><?php echo $strGzip . (($is_bzip) ? '&nbsp;' : '') . "\n"; ?>
<?php
}
if ($is_bzip) {
echo "\n"
?>
<input type="checkbox" name="bzip" value="bzip" onclick="return checkTransmitDump(this.form, 'bzip')" /><?php echo $strBzip . "\n"; ?>
<?php
}
echo "\n" . ' )';
}
} }
echo "\n"; echo "\n";
?> ?>

View File

@@ -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 object the form
* @param string a code for the action that causes this function to be run * @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; var formElts = theForm.elements;
// 'gzipped' option has been checked/unchecked // 'gzipped' option has been checked
if (theAction == 'gzip') { if (theAction == 'gzip' && formElts['gzip'].checked) {
if (formElts['gzip'].checked && !formElts['asfile'].checked) { if (!formElts['asfile'].checked) {
theForm.elements['asfile'].checked = true; theForm.elements['asfile'].checked = true;
} }
if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
theForm.elements['bzip'].checked = false;
}
} }
// 'transmit' option has been checked/unchecked // 'bzipped' option has been checked
else if (theAction == 'transmit') { else if (theAction == 'bzip' && formElts['bzip'].checked) {
if (!formElts['asfile'].checked if (!formElts['asfile'].checked) {
&& (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) { theForm.elements['asfile'].checked = true;
}
if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
theForm.elements['gzip'].checked = false; 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; return true;
} // end of the 'checkTransmitDump()' function } // end of the 'checkTransmitDump()' function

View File

@@ -273,8 +273,9 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";
$strRowSize=" Row size "; //to translate $strRowSize=" Row size "; //to translate
?> ?>

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,8 +273,9 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";
$strRowSize=" Row size "; //to translate $strRowSize=" Row size "; //to translate
?> ?>

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -270,6 +270,7 @@ $strWrongUser = "
$strYes = "Ano"; $strYes = "Ano";
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -270,6 +270,7 @@ $strWrongUser = "
$strYes = "Ano"; $strYes = "Ano";
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -45,6 +45,7 @@ $strBookmarkQuery = "Bookmarked SQL-query";
$strBookmarkThis = "Bookmark this SQL-query"; $strBookmarkThis = "Bookmark this SQL-query";
$strBookmarkView = "View only"; $strBookmarkView = "View only";
$strBrowse = "Browse"; $strBrowse = "Browse";
$strBzip = "\"bzipped\"";
$strCantLoadMySQL = "cannot load MySQL extension,<br>please check PHP Configuration."; $strCantLoadMySQL = "cannot load MySQL extension,<br>please check PHP Configuration.";
$strCarriage = "Carriage return: \\r"; $strCarriage = "Carriage return: \\r";

View File

@@ -44,6 +44,7 @@ $strBookmarkQuery = "Requ
$strBookmarkThis = "Bookmarker cette requ<71>te"; $strBookmarkThis = "Bookmarker cette requ<71>te";
$strBookmarkView = "Voir uniquement"; $strBookmarkView = "Voir uniquement";
$strBrowse = "Afficher"; $strBrowse = "Afficher";
$strBzip = "\"bzipp<EFBFBD>\"";
$strCantLoadMySQL = "ne peux charger l'extension MySQL,<br>v<>rifiez la configuration PHP"; $strCantLoadMySQL = "ne peux charger l'extension MySQL,<br>v<>rifiez la configuration PHP";
$strCarriage = "Retour de chariot: \\r"; $strCarriage = "Retour de chariot: \\r";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "Das ist keine Zahl!";
$strNotValidNumber = " ist keine g<>ltige Zeilennummer!"; $strNotValidNumber = " ist keine g<>ltige Zeilennummer!";
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"GZip komprimiert\""; $strGzip = "\"GZip komprimiert\"";
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -270,6 +270,7 @@ $strWrongUser = "Usuario/password equivocado. Acesso denegado.";
$strYes = "Si"; $strYes = "Si";
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -273,6 +273,7 @@ $strNotNumber = "This is not a number!"; //to translate
$strNotValidNumber = " is not a valid row number!"; //to translate $strNotValidNumber = " is not a valid row number!"; //to translate
// export Zip (July 07, 2001, 19:48am) // export Zip (July 07, 2001, 19:48am)
$strBzip = "\"bzipped\"";
$strGzip = "\"gzipped\""; //to translate $strGzip = "\"gzipped\""; //to translate
$strOffSet = "Offset"; $strOffSet = "Offset";
$strNbRecords = "No. Of records"; $strNbRecords = "No. Of records";

View File

@@ -6,7 +6,8 @@ require("./grab_globals.inc.php3");
@set_time_limit(600); @set_time_limit(600);
$crlf="\n"; $crlf="\n";
if (empty($asfile) && !empty($gzip)) { if (empty($asfile)
&& (!empty($gzip) || !empty($bzip))) {
$asfile = 1; $asfile = 1;
} }
@@ -20,11 +21,16 @@ else
if (!isset($table)) $filename=$db; if (!isset($table)) $filename=$db;
else $filename=$table; else $filename=$table;
include("./lib.inc.php3"); include("./lib.inc.php3");
$ext = "sql"; if (isset($bzip) && $bzip == 'bzip') {
if($what == "csv") $ext = "csv"; $ext = 'bz2';
if(isset($gzip)) } else if (isset($gzip) && $gzip == 'bzip') {
if($gzip == "gzip") $ext = "gz"; $ext = 'gz';
} else if ($what == 'csv') {
$ext = 'csv';
} else {
$ext = 'sql';
}
header('Content-Type: application/octetstream'); header('Content-Type: application/octetstream');
header('Content-Disposition: filename="' . $filename . '.' . $ext . '"'); header('Content-Disposition: filename="' . $filename . '.' . $ext . '"');
header('Pragma: no-cache'); header('Pragma: no-cache');
@@ -152,7 +158,10 @@ else
$dump_buffer.= "#$crlf$crlf"; $dump_buffer.= "#$crlf$crlf";
$tmp_buffer=""; $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; $dump_buffer.=$tmp_buffer;
} }
$i++; $i++;
@@ -169,13 +178,20 @@ else
} }
} }
if(isset($gzip)) { if (isset($bzip) && $bzip == 'bzip') {
if($gzip == "gzip" && function_exists("gzencode")) if (function_exists('bzcompress')) {
// without the optional parameter level because it bug echo bzcompress($dump_buffer);
echo gzencode($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)) if(empty($asfile))
{ {

View File

@@ -599,12 +599,25 @@ echo "\n";
<input type="checkbox" name="asfile" value="sendit" onclick="return checkTransmitDump(this.form, 'transmit')" /> <input type="checkbox" name="asfile" value="sendit" onclick="return checkTransmitDump(this.form, 'transmit')" />
<?php echo $strSend . "\n"; ?> <?php echo $strSend . "\n"; ?>
<?php <?php
// gzip encode feature // gzip and bzip2 encode features
if (function_exists('gzencode')) { if (PMA_INT_VERSION >= 40004) {
echo "\n"; $is_gzip = @function_exists('gzencode');
?> $is_bzip = @function_exists('bzcompress');
(<input type="checkbox" name="gzip" value="gzip" onclick="return checkTransmitDump(this.form, 'gzip')" /><?php echo $strGzip; ?>) if ($is_gzip || $is_bzip) {
<?php echo "\n" . ' (';
if ($is_gzip) {
?>
<input type="checkbox" name="gzip" value="gzip" onclick="return checkTransmitDump(this.form, 'gzip')" /><?php echo $strGzip . (($is_bzip) ? '&nbsp;' : '') . "\n"; ?>
<?php
}
if ($is_bzip) {
echo "\n"
?>
<input type="checkbox" name="bzip" value="bzip" onclick="return checkTransmitDump(this.form, 'bzip')" /><?php echo $strBzip . "\n"; ?>
<?php
}
echo "\n" . ' )';
}
} }
echo "\n"; echo "\n";
?> ?>