Vergleich admin/modules/tools/backupdb.php - 1.8.5 - 1.8.38

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 14Zeile 14
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}


	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}


// Allows us to refresh cache to prevent over flowing






/**
* Allows us to refresh cache to prevent over flowing
*
* @param resource $fp
* @param string $contents
*/

function clear_overflow($fp, &$contents)
{
global $mybb;

function clear_overflow($fp, &$contents)
{
global $mybb;

Zeile 72Zeile 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']);

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

 
    $ext = get_extension($file);





	if(!trim($mybb->input['file']) || !file_exists(MYBB_ADMIN_DIR.'backups/'.$file))

    if(!trim($mybb->input['file']) || !file_exists(MYBB_ADMIN_DIR.'backups/'.$file) || filetype(MYBB_ADMIN_DIR.'backups/'.$file) != 'file' || ($ext != 'gz' && $ext != 'sql'))

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

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

	}


	}


	$plugins->run_hooks("admin_tools_backupdb_delete");

if($mybb->request_method == "post")
{
$delete = @unlink(MYBB_ADMIN_DIR.'backups/'.$file);

	$plugins->run_hooks("admin_tools_backupdb_delete");

if($mybb->request_method == "post")
{
$delete = @unlink(MYBB_ADMIN_DIR.'backups/'.$file);





		if($delete)

		if($delete)

		{

		{

			$plugins->run_hooks("admin_tools_backupdb_delete_commit");

// Log admin action

			$plugins->run_hooks("admin_tools_backupdb_delete_commit");

// Log admin action

Zeile 116Zeile 128
		{
flash_message($lang->error_backup_not_deleted, 'error');
admin_redirect("index.php?module=tools-backupdb");

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

		}

		}

	}
else
{

	}
else
{

Zeile 130Zeile 142

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['filetype'] == 'gzip')

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

if($mybb->input['filetype'] == 'gzip')

			{

			{

				if(!function_exists('gzopen')) // check zlib-ness
{
flash_message($lang->error_no_zlib, 'error');

				if(!function_exists('gzopen')) // check zlib-ness
{
flash_message($lang->error_no_zlib, 'error');

Zeile 151Zeile 170
				}

$fp = gzopen($file.'.incomplete.sql.gz', 'w9');

				}

$fp = gzopen($file.'.incomplete.sql.gz', 'w9');

			}

			}

			else
{
$fp = fopen($file.'.incomplete.sql', 'w');
}
}
else

			else
{
$fp = fopen($file.'.incomplete.sql', 'w');
}
}
else

		{

		{

			$file = 'backup_'.substr(md5($mybb->user['uid'].TIME_NOW), 0, 10).random_str(54);
if($mybb->input['filetype'] == 'gzip')
{

			$file = 'backup_'.substr(md5($mybb->user['uid'].TIME_NOW), 0, 10).random_str(54);
if($mybb->input['filetype'] == 'gzip')
{

Zeile 169Zeile 188
				}

// 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 200Zeile 218
			$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 230Zeile 252
					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);
}