diff options
author | the_systech <the_systech@users.sourceforge.net> | 2001-11-20 20:33:15 +0000 |
---|---|---|
committer | the_systech <the_systech@users.sourceforge.net> | 2001-11-20 20:33:15 +0000 |
commit | 038e717c0b0e98391b9d18c2fa7352f2bd989872 (patch) | |
tree | dd2b71a9d548e78118ed1268932d561c7b6e8c9e /phpBB/admin | |
parent | 2cc2ae1eacbdce375be36d9abbe6af37cefabb5d (diff) | |
download | forums-038e717c0b0e98391b9d18c2fa7352f2bd989872.tar forums-038e717c0b0e98391b9d18c2fa7352f2bd989872.tar.gz forums-038e717c0b0e98391b9d18c2fa7352f2bd989872.tar.bz2 forums-038e717c0b0e98391b9d18c2fa7352f2bd989872.tar.xz forums-038e717c0b0e98391b9d18c2fa7352f2bd989872.zip |
Some output buffering to try to decrease time and memory usage.
git-svn-id: file:///svn/phpbb/trunk@1389 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/admin')
-rw-r--r-- | phpBB/admin/admin_db_utilities.php | 119 |
1 files changed, 54 insertions, 65 deletions
diff --git a/phpBB/admin/admin_db_utilities.php b/phpBB/admin/admin_db_utilities.php index 9d953e6146..657d2ae022 100644 --- a/phpBB/admin/admin_db_utilities.php +++ b/phpBB/admin/admin_db_utilities.php @@ -59,6 +59,18 @@ define("VERBOSE", 0); // ----------------------- // The following functions are adapted from phpMyAdmin and upgrade_20.php // +function gzip_PrintFourChars($Val) +{ + for ($i = 0; $i < 4; $i ++) + { + $return .= chr($Val % 256); + $Val = floor($Val / 256); + } + return $return; +} + + + // // This function is used for grabbing the sequences for postgres... // @@ -632,9 +644,9 @@ function output_table_content($content) { global $tempfile; - fwrite($tempfile, $content . "\n"); + //fwrite($tempfile, $content . "\n"); //$backup_sql .= $content . "\n"; - + echo $content ."\n"; return; } // @@ -687,6 +699,7 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) $tables = array('auth_access', 'banlist', 'categories', 'config', 'disallow', 'forums', 'forum_prune', 'groups', 'posts', 'posts_text', 'privmsgs', 'privmsgs_text', 'ranks', 'search_results', 'search_results', 'search_wordlist', 'search_wordmatch', 'sessions', 'smilies', 'themes', 'themes_name', 'topics', 'topics_watch', 'user_group', 'users', 'vote_desc', 'vote_results', 'vote_voters', 'words'); + $additional_tables = (isset($HTTP_POST_VARS['additional_tables'])) ? $HTTP_POST_VARS['additional_tables'] : ( (isset($HTTP_GET_VARS['additional_tables'])) ? $HTTP_GET_VARS['additional_tables'] : "" ); $backup_type = (isset($HTTP_POST_VARS['backup_type'])) ? $HTTP_POST_VARS['backup_type'] : ( (isset($HTTP_GET_VARS['backup_type'])) ? $HTTP_GET_VARS['backup_type'] : "" ); @@ -762,33 +775,46 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) include('page_footer_admin.'.$phpEx); } + header("Pragma: no-cache"); + $do_gzip_compress = FALSE; + if( $gzipcompress ) + { + $phpver = phpversion(); + + if($phpver >= "4.0") + { + if(extension_loaded("zlib")) + { + $do_gzip_compress = TRUE; + } + } + } + if($do_gzip_compress) + { + @ob_start(); + @ob_implicit_flush(0); + header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql.gz\""); + header("Content-disposition: attachment; filename=phpbb_db_backup.sql.gz"); + } + else + { + header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql\""); + header("Content-disposition: attachment; filename=phpbb_db_backup.sql"); + } // // Build the sql script file... // - $backup_sql = "#\n"; - $backup_sql .= "# phpBB Backup Script\n"; - $backup_sql .= "# Dump of tables for $dbname\n"; - $backup_sql .= "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n"; - $backup_sql .= "#\n"; + echo "#\n"; + echo "# phpBB Backup Script\n"; + echo "# Dump of tables for $dbname\n"; + echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n"; + echo "#\n"; if(SQL_LAYER == 'postgres') { - $backup_sql = "\n" . pg_get_sequences("\n", $backup_type); + echo "\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]; @@ -797,8 +823,8 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) 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"); + echo "#\n# TABLE: " . $table_prefix . $table_name . "\n#\n"; + echo $table_def_function($table_prefix . $table_name, "\n") . "\n"; } if($backup_type != 'structure') @@ -807,51 +833,14 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) ) } } - // - // 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... - // - header("Pragma: no-cache"); - - $do_gzip_compress = FALSE; - if( $gzipcompress ) - { - $phpver = phpversion(); - - if($phpver >= "4.0") - { - if(extension_loaded("zlib")) - { - $do_gzip_compress = TRUE; - } - } - } - if($do_gzip_compress) { - 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(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 fread($tempfile, $temp_size); + $Size = ob_get_length(); + $Crc = crc32(ob_get_contents()); + $contents = gzcompress(ob_get_contents()); + ob_end_clean(); + echo "\x1f\x8b\x08\x00\x00\x00\x00\x00".substr($contents, 0, strlen($contents) - 4).gzip_PrintFourChars($Crc).gzip_PrintFourChars($Size); } - exit; break; |