Vergleich admin/modules/tools/system_health.php - 1.6.11 - 1.6.18

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 180Zeile 180

if($mybb->request_method == "post" || ($mybb->input['do'] == "all" && !empty($mybb->input['table'])))
{


if($mybb->request_method == "post" || ($mybb->input['do'] == "all" && !empty($mybb->input['table'])))
{

 
		if(!empty($mybb->input['mb4']) && version_compare($db->get_version(), '5.5.3', '<'))
{
flash_message($lang->error_utf8mb4_version, 'error');
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");
}

		@set_time_limit(0);

		@set_time_limit(0);


$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');



$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');


		if(!$db->table_exists($db->escape_string($mybb->input['table'])))
{

		if(!$db->table_exists($db->escape_string($mybb->input['table'])))
{

 
			$db->set_table_prefix($old_table_prefix);

			flash_message($lang->error_invalid_table, 'error');
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");

			flash_message($lang->error_invalid_table, 'error');
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");

		}


		}


		$db->set_table_prefix($old_table_prefix);

$page->add_breadcrumb_item($lang->utf8_conversion, "index.php?module=tools-system_health&amp;action=utf8_conversion");

		$db->set_table_prefix($old_table_prefix);

$page->add_breadcrumb_item($lang->utf8_conversion, "index.php?module=tools-system_health&amp;action=utf8_conversion");





		$page->output_header($lang->system_health." - ".$lang->utf8_conversion);

$sub_tabs['system_health'] = array(

		$page->output_header($lang->system_health." - ".$lang->utf8_conversion);

$sub_tabs['system_health'] = array(

Zeile 220Zeile 226
        preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table1, $matches);
$charset = $matches[1];


        preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table1, $matches);
$charset = $matches[1];


		$table->construct_cell("<strong>".$lang->sprintf($lang->converting_to_utf8, $mybb->input['table'], $charset)."</strong>");








		if(!empty($mybb->input['mb4']))
{
$table->construct_cell("<strong>".$lang->sprintf($lang->converting_to_utf8mb4, $mybb->input['table'], $charset)."</strong>");
}
else
{
$table->construct_cell("<strong>".$lang->sprintf($lang->converting_to_utf8, $mybb->input['table'], $charset)."</strong>");
}

		$table->construct_row();

$table->construct_cell($lang->please_wait);

		$table->construct_row();

$table->construct_cell($lang->please_wait);

Zeile 252Zeile 265
		$convert_to_binary = '';
$convert_to_utf8 = '';
$comma = '';

		$convert_to_binary = '';
$convert_to_utf8 = '';
$comma = '';

 

if(!empty($mybb->input['mb4']))
{
$character_set = 'utf8mb4';
$collation = 'utf8mb4_general_ci';
}
else
{
$character_set = 'utf8';
$collation = 'utf8_general_ci';
}


// Set table default charset


// Set table default charset

		$db->write_query("ALTER TABLE {$mybb->input['table']} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");

		$db->write_query("ALTER TABLE {$mybb->input['table']} DEFAULT CHARACTER SET {$character_set} COLLATE {$collation}");


// Fetch any fulltext keys
if($db->supports_fulltext($mybb->input['table']))


// Fetch any fulltext keys
if($db->supports_fulltext($mybb->input['table']))

Zeile 320Zeile 344
				}

$convert_to_binary .= $comma.$names.preg_replace('/'.$type.'/i', $types[$type], $column['Type']).' '.$attributes;

				}

$convert_to_binary .= $comma.$names.preg_replace('/'.$type.'/i', $types[$type], $column['Type']).' '.$attributes;

				$convert_to_utf8 .= "{$comma}{$names}{$column['Type']} CHARACTER SET utf8 COLLATE utf8_general_ci {$attributes}";

				$convert_to_utf8 .= "{$comma}{$names}{$column['Type']} CHARACTER SET {$character_set} COLLATE {$collation} {$attributes}";


$comma = $lang->comma;
}


$comma = $lang->comma;
}

Zeile 355Zeile 379
		{
$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');

		{
$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');





			$tables = $db->list_tables($mybb->config['database']['database']);
foreach($tables as $key => $tablename)
{

			$tables = $db->list_tables($mybb->config['database']['database']);
foreach($tables as $key => $tablename)
{

Zeile 363Zeile 387
				{
$table = $db->show_create_table($tablename);
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);

				{
$table = $db->show_create_table($tablename);
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);

					if(fetch_iconv_encoding($matches[1]) == 'utf-8' && $mybb->input['table'] != $tablename)





					if(empty($mybb->input['mb4']) && (fetch_iconv_encoding($matches[1]) == 'utf-8' || $matches[1] == 'utf8mb4') && $mybb->input['table'] != $tablename)
{
continue;
}
elseif(!empty($mybb->input['mb4']) && fetch_iconv_encoding($matches[1]) != 'utf-8' && $mybb->input['table'] != $tablename)

					{
continue;
}

$mybb_tables[$key] = $tablename;

					{
continue;
}

$mybb_tables[$key] = $tablename;

				}

				}

			}

asort($mybb_tables);

			}

asort($mybb_tables);

Zeile 381Zeile 409
			foreach($mybb_tables as $key => $tablename)
{
if($is_next == true)

			foreach($mybb_tables as $key => $tablename)
{
if($is_next == true)

				{

				{

					$nexttable = $tablename;
break;
}
else if($mybb->input['table'] == $tablename)
{
$is_next = true;

					$nexttable = $tablename;
break;
}
else if($mybb->input['table'] == $tablename)
{
$is_next = true;

				}

				}

			}

$db->set_table_prefix($old_table_prefix);

			}

$db->set_table_prefix($old_table_prefix);

Zeile 396Zeile 424
			if($nexttable)
{
$nexttable = $db->escape_string($nexttable);

			if($nexttable)
{
$nexttable = $db->escape_string($nexttable);

				admin_redirect("index.php?module=tools-system_health&action=utf8_conversion&do=all&table={$nexttable}");






				$mb4 = '';
if(!empty($mybb->input['mb4']))
{
$mb4 = "&amp;mb4=1";
}
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion&do=all&table={$nexttable}{$mb4}");

				exit;
}

				exit;
}

		}

admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");


		}

admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");


		exit;
}

		exit;
}





	if($mybb->input['table'] || $mybb->input['do'] == "all")
{

	if($mybb->input['table'] || $mybb->input['do'] == "all")
{

 
		if(!empty($mybb->input['mb4']) && version_compare($db->get_version(), '5.5.3', '<'))
{
flash_message($lang->error_utf8mb4_version, 'error');
admin_redirect("index.php?module=tools-system_health&action=utf8_conversion");
}


		$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');


		$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');


Zeile 427Zeile 466
				{
$table = $db->show_create_table($tablename);
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);

				{
$table = $db->show_create_table($tablename);
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);

					if(fetch_iconv_encoding($matches[1]) == 'utf-8')





					if(empty($mybb->input['mb4']) && (fetch_iconv_encoding($matches[1]) == 'utf-8' || $matches[1] == 'utf8mb4'))
{
continue;
}
elseif(!empty($mybb->input['mb4']) && fetch_iconv_encoding($matches[1]) != 'utf-8')

					{
continue;
}

					{
continue;
}

Zeile 445Zeile 488
			}
else
{

			}
else
{

 
				$db->set_table_prefix($old_table_prefix);

				flash_message($lang->success_all_tables_already_converted, 'success');
admin_redirect("index.php?module=tools-system_health");
}

				flash_message($lang->success_all_tables_already_converted, 'success');
admin_redirect("index.php?module=tools-system_health");
}

Zeile 480Zeile 524
        preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);
$charset = $matches[1];


        preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);
$charset = $matches[1];


		$form = new Form("index.php?module=tools-system_health&amp;action=utf8_conversion", "post", "utf8_conversion");







		$mb4 = '';
if(!empty($mybb->input['mb4']))
{
$mb4 = "&amp;mb4=1";
}

$form = new Form("index.php?module=tools-system_health&amp;action=utf8_conversion{$mb4}", "post", "utf8_conversion");

		echo $form->generate_hidden_field("table", $mybb->input['table']);

if($mybb->input['do'] == "all")
{
echo $form->generate_hidden_field("do", "all");

		echo $form->generate_hidden_field("table", $mybb->input['table']);

if($mybb->input['do'] == "all")
{
echo $form->generate_hidden_field("do", "all");

		}

$table = new Table;

if($mybb->input['do'] == "all")
{
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_all_to_utf, $charset)."</strong>");
}
else
{
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_to_utf8, $mybb->input['table'], $charset)."</strong>");
}

$table->construct_row();









		}

$table = new Table;

if(!empty($mybb->input['mb4']))
{
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_all_to_utf8mb4, $charset)."</strong>");
$lang->notice_process_long_time .= "<br /><br /><strong>{$lang->notice_mb4_warning}</strong>";
}
else
{
if($mybb->input['do'] == "all")
{
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_all_to_utf, $charset)."</strong>");
}
else
{
$table->construct_cell("<strong>".$lang->sprintf($lang->convert_to_utf8, $mybb->input['table'], $charset)."</strong>");
}
}

$table->construct_row();


$table->construct_cell($lang->notice_process_long_time);
$table->construct_row();


$table->construct_cell($lang->notice_process_long_time);
$table->construct_row();





		if($mybb->input['do'] == "all")
{
$table->output($lang->convert_tables);
$buttons[] = $form->generate_submit_button($lang->convert_database_tables);

		if($mybb->input['do'] == "all")
{
$table->output($lang->convert_tables);
$buttons[] = $form->generate_submit_button($lang->convert_database_tables);

		}

		}

		else
{
$table->output($lang->convert_table.": {$mybb->input['table']}");

		else
{
$table->output($lang->convert_table.": {$mybb->input['table']}");

Zeile 518Zeile 576
		$form->output_submit_wrapper($buttons);

$form->end();

		$form->output_submit_wrapper($buttons);

$form->end();





		$db->set_table_prefix($old_table_prefix);

		$db->set_table_prefix($old_table_prefix);





		$page->output_footer();

		$page->output_footer();





		exit;

		exit;

 
	}

if(!$mybb->config['database']['encoding'])
{
flash_message($lang->error_db_encoding_not_set, 'error');
admin_redirect("index.php?module=tools-system_health");

	}

$tables = $db->list_tables($mybb->config['database']['database']);

	}

$tables = $db->list_tables($mybb->config['database']['database']);

Zeile 531Zeile 595
	$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');


	$old_table_prefix = $db->table_prefix;
$db->set_table_prefix('');


	$not_okey_count = 0;
$not_okey = array();
$okey_count = 0;

	$encodings = array();




foreach($tables as $key => $tablename)
{


foreach($tables as $key => $tablename)
{

Zeile 541Zeile 603
		{
$table = $db->show_create_table($tablename);
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);

		{
$table = $db->show_create_table($tablename);
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table, $matches);

			if(fetch_iconv_encoding($matches[1]) != 'utf-8')
{
$not_okey[$key] = $tablename;
++$not_okey_count;
}
else
{
++$okay_count;
}


			$encodings[$key] = fetch_iconv_encoding($matches[1]);










			$mybb_tables[$key] = $tablename;

			$mybb_tables[$key] = $tablename;

		}
}

$db->set_table_prefix($old_table_prefix);

if($okay_count == count($mybb_tables))
{
flash_message($lang->success_all_tables_already_converted, 'success');
admin_redirect("index.php?module=tools-system_health");
}

if(!$mybb->config['database']['encoding'])
{
flash_message($lang->error_db_encoding_not_set, 'error');
admin_redirect("index.php?module=tools-system_health");
}


		}
}

$db->set_table_prefix($old_table_prefix);














	$page->add_breadcrumb_item($lang->utf8_conversion, "index.php?module=tools-system_health&amp;action=utf8_conversion");

$page->output_header($lang->system_health." - ".$lang->utf8_conversion);

	$page->add_breadcrumb_item($lang->utf8_conversion, "index.php?module=tools-system_health&amp;action=utf8_conversion");

$page->output_header($lang->system_health." - ".$lang->utf8_conversion);


$page->output_nav_tabs($sub_tabs, 'utf8_conversion');



$page->output_nav_tabs($sub_tabs, 'utf8_conversion');


	asort($mybb_tables);

	asort($mybb_tables);





























$unique = array_unique($encodings);

$convert_utf8 = $convert_utf8mb4 = false;
foreach($unique as $encoding)
{
if($encoding == 'utf-8')
{
$convert_utf8mb4 = true;
}
elseif($encoding != 'utf8mb4')
{
$convert_utf8 = true;
}
}

if(count($unique) > 1)
{
$page->output_error("<p><em>{$lang->warning_multiple_encodings}</em></p>");
}

if(in_array('utf8mb4', $unique) && $mybb->config['database']['encoding'] != 'utf8mb4')
{
$page->output_error("<p><em>{$lang->warning_utf8mb4_config}</em></p>");
}


	$table = new Table;
$table->construct_header($lang->table);

	$table = new Table;
$table->construct_header($lang->table);

	$table->construct_header($lang->status, array("class" => "align_center"));


















	$table->construct_header($lang->status_utf8, array("class" => "align_center"));
$table->construct_header($lang->status_utf8mb4, array("class" => "align_center"));

$all_utf8 = $all_utf8mb4 = '-';
if($convert_utf8)
{
$all_utf8 = "<strong><a href=\"index.php?module=tools-system_health&amp;action=utf8_conversion&amp;do=all\">{$lang->convert_all}</a></strong>";
}
if($convert_utf8mb4)
{
$all_utf8mb4 = "<strong><a href=\"index.php?module=tools-system_health&amp;action=utf8_conversion&amp;do=all&amp;mb4=1\">{$lang->convert_all}</a></strong>";
}
$table->construct_cell("<strong>{$lang->all_tables}</strong>");
$table->construct_cell($all_utf8, array("class" => "align_center", 'width' => '15%'));
$table->construct_cell($all_utf8mb4, array("class" => "align_center", 'width' => '25%'));
$table->construct_row();

$db_version = $db->get_version();


foreach($mybb_tables as $key => $tablename)
{


foreach($mybb_tables as $key => $tablename)
{

		if(array_key_exists($key, $not_okey))

		if($encodings[$key] != 'utf-8' && $encodings[$key] != 'utf8mb4')

		{
$status = "<a href=\"index.php?module=tools-system_health&amp;action=utf8_conversion&amp;table={$tablename}\" style=\"background: url(styles/{$page->style}/images/icons/cross.gif) no-repeat; padding-left: 20px;\">{$lang->convert_now}</a>";
}
else
{
$status = "<img src=\"styles/{$page->style}/images/icons/tick.gif\" alt=\"{$lang->ok}\" />";

		{
$status = "<a href=\"index.php?module=tools-system_health&amp;action=utf8_conversion&amp;table={$tablename}\" style=\"background: url(styles/{$page->style}/images/icons/cross.gif) no-repeat; padding-left: 20px;\">{$lang->convert_now}</a>";
}
else
{
$status = "<img src=\"styles/{$page->style}/images/icons/tick.gif\" alt=\"{$lang->ok}\" />";

 
		}
if(version_compare($db_version, '5.5.3', '<'))
{
$utf8mb4 = $lang->not_available;
}
elseif($encodings[$key] == 'utf8mb4')
{
$utf8mb4 = "<img src=\"styles/{$page->style}/images/icons/tick.gif\" alt=\"{$lang->ok}\" />";
}
elseif($encodings[$key] == 'utf-8')
{
$utf8mb4 = "<a href=\"index.php?module=tools-system_health&amp;action=utf8_conversion&amp;table={$tablename}&amp;mb4=1\" style=\"background: url(styles/{$page->style}/images/icons/cross.gif) no-repeat; padding-left: 20px;\">{$lang->convert_now}</a>";
}
else
{
$utf8mb4 = "-";

		}
$table->construct_cell("<strong>{$tablename}</strong>");
$table->construct_cell($status, array("class" => "align_center", 'width' => '15%'));

		}
$table->construct_cell("<strong>{$tablename}</strong>");
$table->construct_cell($status, array("class" => "align_center", 'width' => '15%'));

 
		$table->construct_cell($utf8mb4, array("class" => "align_center", 'width' => '25%'));

		$table->construct_row();
}


		$table->construct_row();
}


	$table->output("<div style=\"float: right; text-decoration: underline\"><small><a href=\"index.php?module=tools-system_health&amp;action=utf8_conversion&amp;do=all\">({$lang->convert_all})</a></small></div><div>{$lang->utf8_conversion}</div>");

	$table->output("<div>{$lang->utf8_conversion}</div>");


$page->output_footer();
}


$page->output_footer();
}

Zeile 604Zeile 704
if(!$mybb->input['action'])
{
$plugins->run_hooks("admin_tools_system_health_start");

if(!$mybb->input['action'])
{
$plugins->run_hooks("admin_tools_system_health_start");





	$page->output_header($lang->system_health);

	$page->output_header($lang->system_health);





	$page->output_nav_tabs($sub_tabs, 'system_health');

$table = new Table;
$table->construct_header($lang->totals, array("colspan" => 2));
$table->construct_header($lang->attachments, array("colspan" => 2));

	$page->output_nav_tabs($sub_tabs, 'system_health');

$table = new Table;
$table->construct_header($lang->totals, array("colspan" => 2));
$table->construct_header($lang->attachments, array("colspan" => 2));





	$query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused, SUM(downloads*filesize) as bandwidthused", "visible='1' AND pid > '0'");
$attachs = $db->fetch_array($query);


	$query = $db->simple_select("attachments", "COUNT(*) AS numattachs, SUM(filesize) as spaceused, SUM(downloads*filesize) as bandwidthused", "visible='1' AND pid > '0'");
$attachs = $db->fetch_array($query);


Zeile 626Zeile 726
	{
$attach_average_size = round($attachs['spaceused']/$attachs['numattachs']);
$bandwidth_average_usage = round($attachs['bandwidthused']);

	{
$attach_average_size = round($attachs['spaceused']/$attachs['numattachs']);
$bandwidth_average_usage = round($attachs['bandwidthused']);

	}

	}

	else
{
$attach_average_size = 0;

	else
{
$attach_average_size = 0;

Zeile 647Zeile 747
	$table->construct_row();

$table->output($lang->stats);

	$table->construct_row();

$table->output($lang->stats);





	$table->construct_header($lang->task);
$table->construct_header($lang->run_time, array("width" => 200, "class" => "align_center"));


	$table->construct_header($lang->task);
$table->construct_header($lang->run_time, array("width" => 200, "class" => "align_center"));


Zeile 662Zeile 762
		$table->construct_cell("<strong>{$task['title']}</strong>");
$table->construct_cell($next_run, array("class" => "align_center"));


		$table->construct_cell("<strong>{$task['title']}</strong>");
$table->construct_cell($next_run, array("class" => "align_center"));


 
		$table->construct_row();
}

if($table->num_rows() == 0)
{
$table->construct_cell($lang->no_tasks, array('colspan' => 2));

		$table->construct_row();
}


		$table->construct_row();
}