diff options
author | the_systech <the_systech@users.sourceforge.net> | 2001-11-19 19:39:00 +0000 |
---|---|---|
committer | the_systech <the_systech@users.sourceforge.net> | 2001-11-19 19:39:00 +0000 |
commit | 1598af6afd6d0e0602bb6abbef1979644da49402 (patch) | |
tree | f3daf9140d7e699bd0824b729e2f37790da17ced /phpBB/admin | |
parent | ffe885d4e5e1a3a7d49ddfe79215cd086a42666d (diff) | |
download | forums-1598af6afd6d0e0602bb6abbef1979644da49402.tar forums-1598af6afd6d0e0602bb6abbef1979644da49402.tar.gz forums-1598af6afd6d0e0602bb6abbef1979644da49402.tar.bz2 forums-1598af6afd6d0e0602bb6abbef1979644da49402.tar.xz forums-1598af6afd6d0e0602bb6abbef1979644da49402.zip |
Change to use a temp file... Hopefully reduce memory usage on backup.
git-svn-id: file:///svn/phpbb/trunk@1375 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/admin')
-rw-r--r-- | phpBB/admin/admin_db_utilities.php | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/phpBB/admin/admin_db_utilities.php b/phpBB/admin/admin_db_utilities.php index 9d459e4c92..9d953e6146 100644 --- a/phpBB/admin/admin_db_utilities.php +++ b/phpBB/admin/admin_db_utilities.php @@ -630,9 +630,10 @@ function get_table_content_mysql($table, $handler) function output_table_content($content) { - global $backup_sql; + global $tempfile; - $backup_sql .= $content . "\n"; + fwrite($tempfile, $content . "\n"); + //$backup_sql .= $content . "\n"; return; } @@ -775,7 +776,19 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) { $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++) { $table_name = $tables[$i]; @@ -784,8 +797,8 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) 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"; + fwrite($tempfile, "#\n# TABLE: " . $table_prefix . $table_name . "\n#\n"); + fwrite($tempfile, $table_def_function($table_prefix . $table_name, "\n") . "\n"); } if($backup_type != 'structure') @@ -793,6 +806,15 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) $table_content_function($table_prefix . $table_name, "output_table_content"); } } + + // + // 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); // // move forward with sending the file across... @@ -818,14 +840,16 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql.gz\""); header("Content-disposition: attachment; filename=phpbb_db_backup.sql.gz"); - echo gzencode($backup_sql); + //echo gzencode($backup_sql); + echo gzencode(fread($tempfile, $temp_size)); } else { header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql\""); header("Content-disposition: attachment; filename=phpbb_db_backup.sql"); - echo $backup_sql; + //echo $backup_sql; + echo fread($tempfile, $temp_size); } exit; |