Vergleich admin/modules/tools/backupdb.php - 1.8.6 - 1.8.36

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 77Zeile 77
		header('Content-disposition: attachment; filename='.$file);
header("Content-type: ".$ext);
header("Content-length: ".filesize(MYBB_ADMIN_DIR.'backups/'.$file));

		header('Content-disposition: attachment; filename='.$file);
header("Content-type: ".$ext);
header("Content-length: ".filesize(MYBB_ADMIN_DIR.'backups/'.$file));

		echo file_get_contents(MYBB_ADMIN_DIR.'backups/'.$file);








$handle = fopen(MYBB_ADMIN_DIR.'backups/'.$file, 'rb');
while(!feof($handle))
{
echo fread($handle, 8192);
}
fclose($handle);

	}
else

	}
else

	{

	{

		flash_message($lang->error_invalid_backup, 'error');

		flash_message($lang->error_invalid_backup, 'error');

		admin_redirect("index.php?module=tools-backupdb");
}

		admin_redirect("index.php?module=tools-backupdb");
}

}

}





if($mybb->input['action'] == "delete")
{

if($mybb->input['action'] == "delete")
{

	if($mybb->input['no'])
{

	if($mybb->get_input('no'))
{

		admin_redirect("index.php?module=tools-backupdb");
}

		admin_redirect("index.php?module=tools-backupdb");
}





	$file = basename($mybb->input['file']);

if(!trim($mybb->input['file']) || !file_exists(MYBB_ADMIN_DIR.'backups/'.$file))
{
flash_message($lang->error_backup_doesnt_exist, 'error');
admin_redirect("index.php?module=tools-backupdb");

	$file = basename($mybb->input['file']);

if(!trim($mybb->input['file']) || !file_exists(MYBB_ADMIN_DIR.'backups/'.$file))
{
flash_message($lang->error_backup_doesnt_exist, 'error');
admin_redirect("index.php?module=tools-backupdb");

	}

	}


$plugins->run_hooks("admin_tools_backupdb_delete");



$plugins->run_hooks("admin_tools_backupdb_delete");


Zeile 135Zeile 141

if($mybb->request_method == "post")
{


if($mybb->request_method == "post")
{

		if(!is_array($mybb->input['tables']))

		if(empty($mybb->input['tables']) || !is_array($mybb->input['tables']))

		{
flash_message($lang->error_tables_not_selected, 'error');
admin_redirect("index.php?module=tools-backupdb&action=backup");

		{
flash_message($lang->error_tables_not_selected, 'error');
admin_redirect("index.php?module=tools-backupdb&action=backup");

		}

@set_time_limit(0);









		}

@set_time_limit(0);

// create an array with table prefix appended for checks, as full table names are accepted
$binary_fields_prefixed = array();
foreach($mybb->binary_fields as $table => $fields)
{
$binary_fields_prefixed[TABLE_PREFIX.$table] = $fields;
}


		if($mybb->input['method'] == 'disk')
{
$file = MYBB_ADMIN_DIR.'backups/backup_'.date("_Ymd_His_").random_str(16);

		if($mybb->input['method'] == 'disk')
{
$file = MYBB_ADMIN_DIR.'backups/backup_'.date("_Ymd_His_").random_str(16);

Zeile 174Zeile 187
				}

// Send headers for gzip file

				}

// Send headers for gzip file

				header('Content-Encoding: gzip');

 
				header('Content-Type: application/x-gzip');
header('Content-Disposition: attachment; filename="'.$file.'.sql.gz"');
}

				header('Content-Type: application/x-gzip');
header('Content-Disposition: attachment; filename="'.$file.'.sql.gz"');
}

Zeile 205Zeile 217
			$field_list = array();
$fields_array = $db->show_fields_from($table);
foreach($fields_array as $field)

			$field_list = array();
$fields_array = $db->show_fields_from($table);
foreach($fields_array as $field)

			{

			{

				$field_list[] = $field['Field'];

				$field_list[] = $field['Field'];

			}


			}


			$fields = "`".implode("`,`", $field_list)."`";
if($mybb->input['contents'] != 'data')

			$fields = "`".implode("`,`", $field_list)."`";
if($mybb->input['contents'] != 'data')

			{

			{

				$structure = $db->show_create_table($table).";\n";
$contents .= $structure;

				$structure = $db->show_create_table($table).";\n";
$contents .= $structure;

				clear_overflow($fp, $contents);






if(isset($fp))
{
clear_overflow($fp, $contents);
}

			}

if($mybb->input['contents'] != 'structure')
{
if($db->engine == 'mysqli')

			}

if($mybb->input['contents'] != 'structure')
{
if($db->engine == 'mysqli')

				{

				{

					$query = mysqli_query($db->read_link, "SELECT * FROM {$db->table_prefix}{$table}", MYSQLI_USE_RESULT);

					$query = mysqli_query($db->read_link, "SELECT * FROM {$db->table_prefix}{$table}", MYSQLI_USE_RESULT);

				}

				}

				else
{
$query = $db->simple_select($table);
}

				else
{
$query = $db->simple_select($table);
}





				while($row = $db->fetch_array($query))
{
$insert = "INSERT INTO {$table} ($fields) VALUES (";

				while($row = $db->fetch_array($query))
{
$insert = "INSERT INTO {$table} ($fields) VALUES (";

Zeile 235Zeile 251
					foreach($field_list as $field)
{
if(!isset($row[$field]) || is_null($row[$field]))

					foreach($field_list as $field)
{
if(!isset($row[$field]) || is_null($row[$field]))

						{

						{

							$insert .= $comma."NULL";

							$insert .= $comma."NULL";

						}
else if($db->engine == 'mysqli')
{
$insert .= $comma."'".mysqli_real_escape_string($db->read_link, $row[$field])."'";

 
						}
else
{

						}
else
{

							$insert .= $comma."'".$db->escape_string($row[$field])."'";






















							if($db->engine == 'mysqli')
{
if(!empty($binary_fields_prefixed[$table][$field]))
{
$insert .= $comma."X'".mysqli_real_escape_string($db->read_link, bin2hex($row[$field]))."'";
}
else
{
$insert .= $comma."'".mysqli_real_escape_string($db->read_link, $row[$field])."'";
}
}
else
{
if(!empty($binary_fields_prefixed[$table][$field]))
{
$insert .= $comma.$db->escape_binary($db->unescape_binary($row[$field]));
}
else
{
$insert .= $comma."'".$db->escape_string($row[$field])."'";
}
}

						}
$comma = ',';
}
$insert .= ");\n";
$contents .= $insert;

						}
$comma = ',';
}
$insert .= ");\n";
$contents .= $insert;

					clear_overflow($fp, $contents);






if(isset($fp))
{
clear_overflow($fp, $contents);
}

				}
$db->free_result($query);
}

				}
$db->free_result($query);
}