mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
- Store and Download is now takes advantage of on-the-fly stuff correctly
- Download and deletion of stored backups now allowed git-svn-id: file:///svn/phpbb/trunk@5789 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
b0aa0e6050
commit
8c2f02ca00
4 changed files with 84 additions and 40 deletions
|
@ -16,7 +16,8 @@
|
|||
</fieldset>
|
||||
<fieldset class="submit-buttons">
|
||||
<input class="button1" type="submit" id="submit" name="submit" value="{L_START_RESTORE}" />
|
||||
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
|
||||
<input class="button2" type="submit" id="delete" name="delete" value="{L_DELETE_BACKUP}" />
|
||||
<input class="button2" type="submit" id="download" name="download" value="{L_DOWNLOAD_BACKUP}" />
|
||||
</fieldset>
|
||||
</form>
|
||||
<!-- ELSE -->
|
||||
|
|
|
@ -44,10 +44,21 @@ class acp_database
|
|||
$format = request_var('method', '');
|
||||
$where = request_var('where', '');
|
||||
|
||||
$store = $download = false;
|
||||
|
||||
if ($where == 'store_and_download' || $where == 'store')
|
||||
{
|
||||
$store = true;
|
||||
}
|
||||
|
||||
if ($where == 'store_and_download' || $where == 'download')
|
||||
{
|
||||
$download = true;
|
||||
}
|
||||
|
||||
@set_time_limit(1200);
|
||||
|
||||
$filename = time();
|
||||
//$time_start = microtime(true);
|
||||
|
||||
// We set up the info needed for our on-the-fly creation :D
|
||||
switch ($format)
|
||||
|
@ -82,7 +93,7 @@ class acp_database
|
|||
// memory. The server process can be easily killed by storing too much data at once.
|
||||
|
||||
|
||||
if ($where == 'store')
|
||||
if ($store == true)
|
||||
{
|
||||
$file = $phpbb_root_path . 'store/' . $filename . $ext;
|
||||
|
||||
|
@ -93,7 +104,8 @@ class acp_database
|
|||
trigger_error('Unable to write temporary file to storage folder');
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ($download == true)
|
||||
{
|
||||
$name = $filename . $ext;
|
||||
header('Pragma: no-cache');
|
||||
|
@ -107,7 +119,6 @@ class acp_database
|
|||
$sql_data .= "# phpBB Backup Script\n";
|
||||
$sql_data .= "# Dump of tables for $table_prefix\n";
|
||||
$sql_data .= "# DATE : " . gmdate("d-m-Y H:i:s", $filename) . " GMT\n";
|
||||
//$sql_data .= "# START : $time_start\n";
|
||||
$sql_data .= "#\n";
|
||||
|
||||
switch (SQL_LAYER)
|
||||
|
@ -144,11 +155,12 @@ class acp_database
|
|||
$sql_data .= $this->get_table_structure($table_name);
|
||||
}
|
||||
// Now write the data for the first time. :)
|
||||
if ($where !== 'download')
|
||||
if ($store == true)
|
||||
{
|
||||
$write($fp, $sql_data);
|
||||
}
|
||||
else
|
||||
|
||||
if ($download == true)
|
||||
{
|
||||
if (!empty($oper))
|
||||
{
|
||||
|
@ -209,11 +221,12 @@ class acp_database
|
|||
}
|
||||
$sql_data .= $schema_insert . implode(', ', $values) . ");\n";
|
||||
|
||||
if ($where !== 'download')
|
||||
if ($store == true)
|
||||
{
|
||||
$write($fp, $sql_data);
|
||||
}
|
||||
else
|
||||
|
||||
if ($download == true)
|
||||
{
|
||||
if (!empty($oper))
|
||||
{
|
||||
|
@ -226,6 +239,7 @@ class acp_database
|
|||
}
|
||||
$sql_data = '';
|
||||
|
||||
$values = array();
|
||||
}
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
|
@ -254,12 +268,15 @@ class acp_database
|
|||
$field_set[$j] = $field[$j]->name;
|
||||
}
|
||||
|
||||
$search = array('\\', "'", "\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
|
||||
$replace = array('\\\\\\\\', "''", '\0', '\n', '\r', '\Z');
|
||||
$fields = implode(', ', $field_set);
|
||||
$values = array();
|
||||
$schema_insert = 'INSERT INTO ' . $table_name . ' (' . $fields . ') VALUES (';
|
||||
|
||||
while ($row = mysql_fetch_row($result))
|
||||
{
|
||||
$values = array();
|
||||
|
||||
for ($j = 0; $j < $fields_cnt; $j++)
|
||||
{
|
||||
if (!isset($row[$j]) || is_null($row[$j]))
|
||||
|
@ -272,16 +289,17 @@ class acp_database
|
|||
}
|
||||
else
|
||||
{
|
||||
$values[] = "'" . $row[$j] . "'";
|
||||
$values[] = "'" . str_replace($search, $replace, $row[$j]) . "'";
|
||||
}
|
||||
}
|
||||
$sql_data .= $schema_insert . implode(', ', $values) . ");\n";
|
||||
|
||||
if ($where !== 'download')
|
||||
if ($store == true)
|
||||
{
|
||||
$write($fp, $sql_data);
|
||||
}
|
||||
else
|
||||
|
||||
if ($download == true)
|
||||
{
|
||||
if (!empty($oper))
|
||||
{
|
||||
|
@ -293,8 +311,6 @@ class acp_database
|
|||
}
|
||||
}
|
||||
$sql_data = '';
|
||||
|
||||
$values = array();
|
||||
}
|
||||
mysql_free_result($result);
|
||||
}
|
||||
|
@ -331,11 +347,12 @@ class acp_database
|
|||
}
|
||||
$sql_data .= 'INSERT INTO ' . $table_name . ' (' . implode(', ', $names) . ') VALUES ('. implode(', ', $data) .");\n";
|
||||
|
||||
if ($where !== 'download')
|
||||
if ($store == true)
|
||||
{
|
||||
$write($fp, $sql_data);
|
||||
}
|
||||
else
|
||||
|
||||
if ($download == true)
|
||||
{
|
||||
if (!empty($oper))
|
||||
{
|
||||
|
@ -413,11 +430,12 @@ class acp_database
|
|||
// into a valid sql statement to recreate that field in the data.
|
||||
$sql_data .= "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES(' . implode(', ', $schema_vals) . ");\n";
|
||||
|
||||
if ($where !== 'download')
|
||||
if ($store == true)
|
||||
{
|
||||
$write($fp, $sql_data);
|
||||
}
|
||||
else
|
||||
|
||||
if ($download == true)
|
||||
{
|
||||
if (!empty($oper))
|
||||
{
|
||||
|
@ -428,6 +446,7 @@ class acp_database
|
|||
echo $sql_data;
|
||||
}
|
||||
}
|
||||
|
||||
$sql_data = '';
|
||||
|
||||
}
|
||||
|
@ -447,16 +466,13 @@ class acp_database
|
|||
break;
|
||||
}
|
||||
|
||||
/*$time_stop = microtime(true);
|
||||
$sql_data .= "# END : $time_stop\n";
|
||||
$sql_data .= "# DIFF : ".($time_stop-$time_start);*/
|
||||
|
||||
if ($where !== 'download')
|
||||
if ($store == true)
|
||||
{
|
||||
$write($fp, $sql_data);
|
||||
$close($fp);
|
||||
}
|
||||
else
|
||||
|
||||
if ($download == true)
|
||||
{
|
||||
if (!empty($oper))
|
||||
{
|
||||
|
@ -471,18 +487,6 @@ class acp_database
|
|||
|
||||
unset($sql_data);
|
||||
|
||||
if ($where == 'store_and_download')
|
||||
{
|
||||
$name = $filename . $ext;
|
||||
|
||||
$fp = fopen("{$phpbb_root_path}store/$name", 'rb');
|
||||
while ($buffer = fread($fp, 1024))
|
||||
{
|
||||
echo $buffer;
|
||||
}
|
||||
fclose($fp);
|
||||
exit;
|
||||
}
|
||||
add_log('admin', 'LOG_DB_BACKUP');
|
||||
trigger_error($user->lang['BACKUP_SUCCESS']);
|
||||
break;
|
||||
|
@ -570,6 +574,15 @@ class acp_database
|
|||
switch ($action)
|
||||
{
|
||||
case 'submit':
|
||||
$delete = request_var('delete', '');
|
||||
|
||||
if ($delete)
|
||||
{
|
||||
$file = request_var('file', '');
|
||||
unlink($phpbb_root_path . 'store/' . $file);
|
||||
trigger_error($user->lang['BACKUP_SUCCESS']);
|
||||
}
|
||||
|
||||
$file = request_var('file', '');
|
||||
$data = '';
|
||||
|
||||
|
@ -588,6 +601,32 @@ class acp_database
|
|||
break;
|
||||
}
|
||||
|
||||
$download = request_var('download', '');
|
||||
|
||||
if ($download)
|
||||
{
|
||||
$name = $matches[0];
|
||||
|
||||
switch ($matches[2])
|
||||
{
|
||||
case 'sql':
|
||||
$mimetype = 'text/x-sql';
|
||||
break;
|
||||
case 'sql.bz2':
|
||||
$mimetype = 'application/x-bzip2';
|
||||
break;
|
||||
case 'sql.gz':
|
||||
$mimetype = 'application/x-gzip';
|
||||
break;
|
||||
}
|
||||
|
||||
header('Pragma: no-cache');
|
||||
header("Content-Type: $mimetype; name=\"$name\"");
|
||||
header("Content-disposition: attachment; filename=$name");
|
||||
echo $data;
|
||||
die;
|
||||
}
|
||||
|
||||
if (!empty($data))
|
||||
{
|
||||
// Strip out sql comments...
|
||||
|
|
|
@ -252,7 +252,7 @@ $lang = array_merge($lang, array(
|
|||
'ALLOW_AUTOLOGIN_EXPLAIN' => 'Determines whether users can autologin when they visit the board.',
|
||||
'AUTOLOGIN_LENGTH' => 'Persistent login key expiry days',
|
||||
'AUTOLOGIN_LENGTH_EXPLAIN' => 'Number of days after which persistent login keys are removed or zero to disable.',
|
||||
'VISUAL_CONFIRM_REG' => 'Enable visual confirmation',
|
||||
'VISUAL_CONFIRM_REG' => 'Enable visual confirmation for registrations',
|
||||
'VISUAL_CONFIRM_REG_EXPLAIN'=> 'Requires new users to enter a random code matching an image to help prevent mass registrations.',
|
||||
'VISUAL_CONFIRM_POST' => 'Enable visual confirmation for guest postings',
|
||||
'VISUAL_CONFIRM_POST_EXPLAIN'=> 'Requires anonymous users to enter a random code matching an image to help prevent mass postings.',
|
||||
|
|
|
@ -47,10 +47,14 @@ $lang = array_merge($lang, array(
|
|||
|
||||
'STORE_AND_DOWNLOAD' => 'Store and Download',
|
||||
'ACP_RESTORE' => 'Restore',
|
||||
'ACP_RESTORE_EXPLAIN' => 'This will perform a full restore of all phpBB tables from a saved file. You can <u>either</u> upload the backup file via this form or upload it manually to a location on the server. If your server supports it you may use a gzip compressed text file and it will automatically be decompressed. <b>WARNING</b> This will overwrite any existing data. The restore may take a long time to process please do not move from this page till it is complete.',
|
||||
'ACP_RESTORE_EXPLAIN' => 'This will perform a full restore of all phpBB tables from a saved file. You can <u>either</u> upload the backup file via this form or upload it manually to a location on the server. If your server supports it you may use a gzip or bzip2 compressed text file and it will automatically be decompressed. <b>WARNING</b> This will overwrite any existing data. The restore may take a long time to process please do not move from this page till it is complete.',
|
||||
'SELECT_FILE' => 'Select a file',
|
||||
'RESTORE_OPTIONS' => 'Restore options',
|
||||
'START_RESTORE' => 'Start Restore',
|
||||
'DELETE_BACKUP' => 'Delete Backup',
|
||||
'DOWNLOAD_BACKUP' => 'Download Backup',
|
||||
'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.',
|
||||
'BACKUP_SUCCESS' => 'The backup has been successfully deleted.',
|
||||
));
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue