|
From: Jonathan H. <the...@us...> - 2001-11-19 19:39:03
|
Update of /cvsroot/phpbb/phpBB2/admin
In directory usw-pr-cvs1:/tmp/cvs-serv24735
Modified Files:
admin_db_utilities.php
Log Message:
Change to use a temp file... Hopefully reduce memory usage on backup.
Index: admin_db_utilities.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/admin/admin_db_utilities.php,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** admin_db_utilities.php 2001/11/13 21:17:32 1.28
--- admin_db_utilities.php 2001/11/19 19:39:00 1.29
***************
*** 631,637 ****
function output_table_content($content)
{
! global $backup_sql;
! $backup_sql .= $content . "\n";
return;
--- 631,638 ----
function output_table_content($content)
{
! global $tempfile;
! fwrite($tempfile, $content . "\n");
! //$backup_sql .= $content . "\n";
return;
***************
*** 776,780 ****
$backup_sql = "\n" . pg_get_sequences("\n", $backup_type);
}
!
for($i = 0; $i < count($tables); $i++)
{
--- 777,793 ----
$backup_sql = "\n" . pg_get_sequences("\n", $backup_type);
}
! //
! // Ok to save on some memory we're going to try writing all this stuff
! // to a tmpfile and sending it later...
! //
! $tempfile = tmpfile();
! if(!$tempfile)
! {
! //
! // Temp file creation failed... Do something here..
! //
! exit;
! }
! fwrite($tempfile, $backup_sql);
for($i = 0; $i < count($tables); $i++)
{
***************
*** 785,790 ****
if($backup_type != 'data')
{
! $backup_sql .= "#\n# TABLE: " . $table_prefix . $table_name . "\n#\n";
! $backup_sql .= $table_def_function($table_prefix . $table_name, "\n") . "\n";
}
--- 798,803 ----
if($backup_type != 'data')
{
! fwrite($tempfile, "#\n# TABLE: " . $table_prefix . $table_name . "\n#\n");
! fwrite($tempfile, $table_def_function($table_prefix . $table_name, "\n") . "\n");
}
***************
*** 794,797 ****
--- 807,819 ----
}
}
+
+ //
+ // Flush all output to the temp file and get it's size, then rewind the
+ // pointer to the beginning.
+ //
+
+ fflush($tempfile);
+ $temp_size = ftell($tempfile) + 1;
+ rewind($tempfile);
//
***************
*** 819,823 ****
header("Content-disposition: attachment; filename=phpbb_db_backup.sql.gz");
! echo gzencode($backup_sql);
}
else
--- 841,846 ----
header("Content-disposition: attachment; filename=phpbb_db_backup.sql.gz");
! //echo gzencode($backup_sql);
! echo gzencode(fread($tempfile, $temp_size));
}
else
***************
*** 826,830 ****
header("Content-disposition: attachment; filename=phpbb_db_backup.sql");
! echo $backup_sql;
}
--- 849,854 ----
header("Content-disposition: attachment; filename=phpbb_db_backup.sql");
! //echo $backup_sql;
! echo fread($tempfile, $temp_size);
}
|