aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2006-12-13 00:56:56 +0000
committerDavid M <davidmj@users.sourceforge.net>2006-12-13 00:56:56 +0000
commita2e512b2181c333ff7f8d86e9e210d9d674b3ccd (patch)
treeb01d344aa957f140ece63625a9192bbf0b6bb13a
parent515993f5aead7b10584956fbf6d9dffe8705ecd4 (diff)
downloadforums-a2e512b2181c333ff7f8d86e9e210d9d674b3ccd.tar
forums-a2e512b2181c333ff7f8d86e9e210d9d674b3ccd.tar.gz
forums-a2e512b2181c333ff7f8d86e9e210d9d674b3ccd.tar.bz2
forums-a2e512b2181c333ff7f8d86e9e210d9d674b3ccd.tar.xz
forums-a2e512b2181c333ff7f8d86e9e210d9d674b3ccd.zip
#6192
- i wanted to do this using streams but found myself unable to do so. if one could figure out how to do so, i would like to find out :D git-svn-id: file:///svn/phpbb/trunk@6752 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/includes/acp/acp_database.php131
1 files changed, 41 insertions, 90 deletions
diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php
index 1059d4940d..7da2044471 100644
--- a/phpBB/includes/acp/acp_database.php
+++ b/phpBB/includes/acp/acp_database.php
@@ -90,7 +90,6 @@ class acp_database
$open = 'bzopen';
$write = 'bzwrite';
$close = 'bzclose';
- $oper = 'bzcompress';
$mimetype = 'application/x-bzip2';
break;
case 'gzip':
@@ -98,7 +97,6 @@ class acp_database
$open = 'gzopen';
$write = 'gzwrite';
$close = 'gzclose';
- $oper = 'gzencode';
$mimetype = 'application/x-gzip';
break;
}
@@ -106,6 +104,25 @@ class acp_database
// We write the file to "store" first (and then compress the file) to not use too much
// memory. The server process can be easily killed by storing too much data at once.
+ if ($download == true)
+ {
+ $fh = fopen('php://output', 'wb');
+
+ switch ($format)
+ {
+ case 'bzip2':
+ ob_start('ob_bz2handler');
+ break;
+ case 'gzip':
+ ob_start('ob_gzhandler');
+ break;
+ }
+
+ $name = $filename . $ext;
+ header('Pragma: no-cache');
+ header("Content-Type: $mimetype; name=\"$name\"");
+ header("Content-disposition: attachment; filename=$name");
+ }
if ($store == true)
{
@@ -119,14 +136,6 @@ class acp_database
}
}
- if ($download == true)
- {
- $name = $filename . $ext;
- header('Pragma: no-cache');
- header("Content-Type: $mimetype; name=\"$name\"");
- header("Content-disposition: attachment; filename=$name");
- }
-
// All of the generated queries go here
$sql_data = '';
$sql_data .= "#\n";
@@ -215,14 +224,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -284,14 +286,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -358,14 +353,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
}
@@ -447,14 +435,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -548,14 +529,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -669,14 +643,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -780,14 +747,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -875,14 +835,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -959,14 +912,7 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
}
$sql_data = '';
@@ -999,14 +945,8 @@ class acp_database
if ($download == true)
{
- if (!empty($oper))
- {
- echo $oper($sql_data);
- }
- else
- {
- echo $sql_data;
- }
+ fwrite($fh, $sql_data);
+ fclose($fh);
exit;
}
@@ -2025,4 +1965,15 @@ class acp_database
}
}
+// Internal handler for BZip2
+function ob_bz2handler($data, $mode)
+{
+ static $internal = '';
+ $internal .= $data;
+ if ($mode & PHP_OUTPUT_HANDLER_END)
+ {
+ return bzcompress($internal);
+ }
+}
+
?> \ No newline at end of file