- 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
This commit is contained in:
David M 2006-12-13 00:56:56 +00:00
parent 515993f5ae
commit a2e512b218

View file

@ -90,7 +90,6 @@ class acp_database
$open = 'bzopen'; $open = 'bzopen';
$write = 'bzwrite'; $write = 'bzwrite';
$close = 'bzclose'; $close = 'bzclose';
$oper = 'bzcompress';
$mimetype = 'application/x-bzip2'; $mimetype = 'application/x-bzip2';
break; break;
case 'gzip': case 'gzip':
@ -98,7 +97,6 @@ class acp_database
$open = 'gzopen'; $open = 'gzopen';
$write = 'gzwrite'; $write = 'gzwrite';
$close = 'gzclose'; $close = 'gzclose';
$oper = 'gzencode';
$mimetype = 'application/x-gzip'; $mimetype = 'application/x-gzip';
break; 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 // 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. // 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) 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 // All of the generated queries go here
$sql_data = ''; $sql_data = '';
$sql_data .= "#\n"; $sql_data .= "#\n";
@ -215,14 +224,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -284,14 +286,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -358,14 +353,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
} }
@ -447,14 +435,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -548,14 +529,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -669,14 +643,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -780,14 +747,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -875,14 +835,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -959,14 +912,7 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
} }
$sql_data = ''; $sql_data = '';
@ -999,14 +945,8 @@ class acp_database
if ($download == true) if ($download == true)
{ {
if (!empty($oper)) fwrite($fh, $sql_data);
{ fclose($fh);
echo $oper($sql_data);
}
else
{
echo $sql_data;
}
exit; 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);
}
}
?> ?>