mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Added gzip compression for downloadable file
git-svn-id: file:///svn/phpbb/trunk@805 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
4255736e23
commit
9145937a9f
3 changed files with 90 additions and 39 deletions
|
@ -28,10 +28,6 @@
|
|||
* adapted from the unoficial phpMyAdmin 2.2.0.
|
||||
***************************************************************************/
|
||||
|
||||
//
|
||||
// Do the setmodules stuff for the admin control panel.
|
||||
//
|
||||
|
||||
if($setmodules == 1)
|
||||
{
|
||||
$filename = basename(__FILE__);
|
||||
|
@ -41,12 +37,36 @@ if($setmodules == 1)
|
|||
return;
|
||||
}
|
||||
|
||||
$phpbb_root_path = "./../";
|
||||
include($phpbb_root_path . 'extension.inc');
|
||||
include($phpbb_root_path . 'common.'.$phpEx);
|
||||
|
||||
//
|
||||
// Start session management
|
||||
//
|
||||
$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
|
||||
init_userprefs($userdata);
|
||||
//
|
||||
// End session management
|
||||
//
|
||||
|
||||
//
|
||||
// Is user logged in? If yes are they an admin?
|
||||
//
|
||||
if( !$userdata['session_logged_in'] )
|
||||
{
|
||||
header("Location: ../login.$phpEx?forward_page=admin/");
|
||||
}
|
||||
else if( $userdata['user_level'] != ADMIN )
|
||||
{
|
||||
message_die(GENERAL_MESSAGE, $lang['Not_admin']);
|
||||
}
|
||||
|
||||
//
|
||||
// Set VERBOSE to 1 for debugging info..
|
||||
//
|
||||
define("VERBOSE", 0);
|
||||
|
||||
|
||||
//
|
||||
// Increase maximum execution time, but don't complain about it if it isn't
|
||||
// allowed.
|
||||
|
@ -727,21 +747,6 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
{
|
||||
$perform = (isset($HTTP_POST_VARS['perform'])) ? $HTTP_POST_VARS['perform'] : $HTTP_GET_VARS['perform'];
|
||||
|
||||
if( $perform == 'backup'
|
||||
&& ( isset($HTTP_POST_VARS['backupstart']) || isset($HTTP_GET_VARS['backupstart']) )
|
||||
&& !isset($HTTP_POST_VARS['startdownload']) && !isset($HTTP_GET_VARS['startdownload'])
|
||||
)
|
||||
{
|
||||
// We want to warn the user before the download starts.. This part of the script
|
||||
// needs a META header so we can't include the header yet.
|
||||
$no_page_header = TRUE;
|
||||
}
|
||||
//
|
||||
// Include required files, get $phpEx and check permissions
|
||||
//
|
||||
require('pagestart.inc');
|
||||
|
||||
|
||||
switch($perform)
|
||||
{
|
||||
case 'backup':
|
||||
|
@ -753,7 +758,7 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
case 'oracle':
|
||||
$db_type = "Oracle";
|
||||
break;
|
||||
case 'ofbc':
|
||||
case 'odbc':
|
||||
$db_type = "ODBC";
|
||||
break;
|
||||
case 'mssql':
|
||||
|
@ -761,6 +766,8 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
break;
|
||||
}
|
||||
|
||||
include('page_header_admin.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array(
|
||||
"body" => "admin/admin_message_body.tpl")
|
||||
);
|
||||
|
@ -775,11 +782,14 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
break;
|
||||
}
|
||||
|
||||
$tables = array('auth_access', 'banlist', 'categories', 'config', 'disallow', 'forums', 'groups', 'posts', 'posts_text', 'privmsgs', 'privmsgs_text', 'ranks', 'session', 'smilies', 'themes', 'themes_name', 'topics', 'user_group', 'users', 'words');
|
||||
$tables = array('auth_access', 'banlist', 'categories', 'config', 'disallow', 'forums', 'forum_prune', 'groups', 'posts', 'posts_text', 'privmsgs', 'privmsgs_text', 'ranks', 'session', 'smilies', 'themes', 'themes_name', 'topics', 'user_group', 'users', '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'] : "" );
|
||||
|
||||
$gzipcompress = (!empty($HTTP_POST_VARS['gzipcompress'])) ? $HTTP_POST_VARS['gzipcompress'] : ( (!empty($HTTP_GET_VARS['gzipcompress'])) ? $HTTP_GET_VARS['gzipcompress'] : 0 );
|
||||
|
||||
if(!empty($additional_tables))
|
||||
{
|
||||
if(ereg(",", $additional_tables))
|
||||
|
@ -800,11 +810,13 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
|
||||
if( !isset($HTTP_POST_VARS['backupstart']) && !isset($HTTP_GET_VARS['backupstart']))
|
||||
{
|
||||
include('page_header_admin.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array(
|
||||
"body" => "admin/db_utils_backup_body.tpl")
|
||||
);
|
||||
|
||||
$s_hidden_fields = "<input type=\"hidden\" name=\"perform\" value=\"backup\"><input type=\"hidden\" name=\"drop\" value=\"1\"><input type=\"hidden\" name=\"perform\" value=\"$perform\">";
|
||||
$s_hidden_fields = "<input type=\"hidden\" name=\"perform\" value=\"backup\" /><input type=\"hidden\" name=\"drop\" value=\"1\" /><input type=\"hidden\" name=\"perform\" value=\"$perform\" />";
|
||||
|
||||
$template->assign_vars(array(
|
||||
"L_DATABASE_BACKUP" => $lang['Database_Utilities'] . " : " . $lang['Backup'],
|
||||
|
@ -815,6 +827,9 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
"L_ADDITIONAL_TABLES" => $lang['Additional_tables'],
|
||||
"L_START_BACKUP" => $lang['Start_backup'],
|
||||
"L_BACKUP_OPTIONS" => $lang['Backup_options'],
|
||||
"L_GZIP_COMPRESS" => $lang['Gzip_compress'],
|
||||
"L_NO" => $lang['No'],
|
||||
"L_YES" => $lang['Yes'],
|
||||
|
||||
"S_HIDDEN_FIELDS" => $s_hidden_fields,
|
||||
"S_DBUTILS_ACTION" => append_sid("admin_db_utilities.$phpEx"))
|
||||
|
@ -826,13 +841,12 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
}
|
||||
else if( !isset($HTTP_POST_VARS['startdownload']) && !isset($HTTP_GET_VARS['startdownload']) )
|
||||
{
|
||||
|
||||
$template->set_filenames(array(
|
||||
"body" => "admin/admin_message_body.tpl")
|
||||
);
|
||||
|
||||
$template->assign_vars(array(
|
||||
"META" => "<meta http-equiv=\"refresh\" content=\"0;url=admin_db_utilities.$phpEx?perform=backup&additional_tables=".quotemeta($additional_tables)."&backup_type=$backup_type&drop=1&backupstart=1&startdownload=1\">",
|
||||
"META" => "<meta http-equiv=\"refresh\" content=\"0;url=admin_db_utilities.$phpEx?perform=backup&additional_tables=" . quotemeta($additional_tables) . "&backup_type=$backup_type&drop=1&backupstart=1&gzipcompress=$gzipcompress&startdownload=1\">",
|
||||
|
||||
"MESSAGE_TITLE" => $lang['Database_Utilities'] . " : " . $lang['Backup'],
|
||||
"MESSAGE_TEXT" => $lang['Backup_download'])
|
||||
|
@ -881,11 +895,36 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
//
|
||||
// move forward with sending the file across...
|
||||
//
|
||||
header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql\"");
|
||||
header("Content-disposition: attachment; filename=phpbb_db_backup.sql");
|
||||
header("Pragma: no-cache");
|
||||
|
||||
echo $backup_sql;
|
||||
$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);
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.sql\"");
|
||||
header("Content-disposition: attachment; filename=phpbb_db_backup.sql");
|
||||
|
||||
echo $backup_sql;
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
|
@ -897,6 +936,8 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
//
|
||||
// Define Template files...
|
||||
//
|
||||
include('page_header_admin.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array(
|
||||
"body" => "admin/db_utils_restore_body.tpl")
|
||||
);
|
||||
|
@ -925,6 +966,7 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
//
|
||||
if($backup_file == "none")
|
||||
{
|
||||
include('page_header_admin.'.$phpEx);
|
||||
message_die(GENERAL_ERROR, "Backup file upload failed");
|
||||
}
|
||||
//
|
||||
|
@ -943,6 +985,7 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
}
|
||||
else
|
||||
{
|
||||
include('page_header_admin.'.$phpEx);
|
||||
message_die(GENERAL_ERROR, "Trouble Accessing uploaded file");
|
||||
}
|
||||
|
||||
|
@ -970,12 +1013,15 @@ if( isset($HTTP_GET_VARS['perform']) || isset($HTTP_POST_VARS['perform']) )
|
|||
|
||||
if(!$result && ( !(SQL_LAYER == 'postgres' && eregi("drop table", $sql) ) ) )
|
||||
{
|
||||
include('page_header_admin.'.$phpEx);
|
||||
message_die(GENERAL_ERROR, "Error importing backup file", "", __LINE__, __FILE__, mysql_error() ."<br>". $sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include('page_header_admin.'.$phpEx);
|
||||
|
||||
$template->set_filenames(array(
|
||||
"body" => "admin/admin_message_body.tpl")
|
||||
);
|
||||
|
|
|
@ -679,6 +679,7 @@ $lang['Full_backup'] = "Full backup";
|
|||
$lang['Structure_backup'] = "Structure Only backup";
|
||||
$lang['Data_backup'] = "Data only backup";
|
||||
$lang['Additional_tables'] = "Additional tables";
|
||||
$lang['Gzip_compress'] = "Gzip compress file";
|
||||
$lang['Select_file'] = "Select a file";
|
||||
$lang['Start_Restore'] = "Start Restore";
|
||||
$lang['Restore_success'] = "The Database has been successfully restored.<br /><br />Your board should be back to the state it was when the backup was made.";
|
||||
|
|
|
@ -5,29 +5,33 @@
|
|||
|
||||
<P>{L_BACKUP_EXPLAIN}</p>
|
||||
|
||||
<table cellspacing="1" cellpadding="4" border="0" align="center">
|
||||
<tr><form enctype="multipart/form-data" method="post" action="{S_DBUTILS_ACTION}">
|
||||
<form method="post" action="{S_DBUTILS_ACTION}"><table cellspacing="1" cellpadding="4" border="0" align="center">
|
||||
<tr>
|
||||
<th colspan="2">{L_BACKUP_OPTIONS}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row2">{L_FULL_BACKUP}</td>
|
||||
<td class="row2"><input type="radio" name="backup_type" value="full"></td>
|
||||
<td class="row2"><input type="radio" name="backup_type" value="full" checked="checked" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1">{L_STRUCTURE_BACKUP}</td>
|
||||
<td class="row1"><input type="radio" name="backup_type" value="structure"></td>
|
||||
<td class="row1"><input type="radio" name="backup_type" value="structure" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row2">{L_DATA_BACKUP}</td>
|
||||
<td class="row2"><input type="radio" name="backup_type" value="data"></td>
|
||||
<td class="row2"><input type="radio" name="backup_type" value="data" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="row1">{L_ADDITIONAL_TABLES}</td>
|
||||
<td class="row1"><input type="text" name="additional_tables"></td>
|
||||
<td class="row1"><input type="text" name="additional_tables" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cat" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="backupstart" value="{L_START_BACKUP}"></td>
|
||||
</form></tr>
|
||||
</table></div>
|
||||
<td class="row1">{L_GZIP_COMPRESS}</td>
|
||||
<td class="row1">{L_NO} <input type="radio" name="gzipcompress" value="0" checked="checked" /> {L_YES} <input type="radio" name="gzipcompress" value="1" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="cat" colspan="2" align="center">{S_HIDDEN_FIELDS}<input type="submit" name="backupstart" value="{L_START_BACKUP}" /></td>
|
||||
</tr>
|
||||
</table></form>
|
||||
|
||||
<br clear="all" />
|
||||
|
|
Loading…
Add table
Reference in a new issue