Vergleich admin/dbtools.php - 1.2.9 - 1.2.11

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

 * $Id$

 * $Id: dbtools.php 3530 2007-12-01 19:29:47Z Tikitiki $

 */

define("IN_MYBB", 1);

 */

define("IN_MYBB", 1);

Zeile 32Zeile 32
	case 'optimize':
addacpnav($lang->optimize_tables);
break;

	case 'optimize':
addacpnav($lang->optimize_tables);
break;

 
	case 'utf8_conversion':
addacpnav($lang->convert_to_utf8);
break;
}

if($mybb->input['action'] == "utf8_conversion")
{
cpheader();

// The last step where we do the actual conversion process.
if($mybb->request_method == "post" || ($mybb->input['table'] == "all" && isset($mybb->input['table2'])))
{
@set_time_limit(0);

if($mybb->input['table'] == "all")
{
$all = true;
$mybb->input['table'] = $mybb->input['table2'];
}

if(!$db->table_exists($db->escape_string($mybb->input['table'])))
{
cperror($lang->error_invalid_table);
}

starttable();

$table1 = $db->show_create_table($db->escape_string($mybb->input['table']));
preg_match("#CHARSET=([a-zA-Z0-9_]+)\s?#i", $table1, $matches);
$charset = $matches[1];

tableheader($converting_table." {$mybb->input['table']}", 'tablename', 1);

echo "<tr>\n";
echo "<td class=\"subheader\"><strong>".sprintf($lang->converting_to_utf8, $mybb->input['table'], $charset)."</strong></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"altbg1\" align=\"center\">{$lang->please_wait}</td>\n";
echo "</tr>\n";

flush();

$types = array(
'text' => 'blob',
'mediumtext' => 'mediumblob',
'longtext' => 'longblob',
'char' => 'varbinary',
'varchar' => 'varbinary',
'tinytext' => 'tinyblob'
);

// Get next table in list
$convert_to_binary = '';
$convert_to_utf8 = '';
$comma = '';

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

// Fetch any fulltext keys
if($db->supports_fulltext($mybb->input['table']))
{
$table_structure = $db->show_create_table($mybb->input['table']);
preg_match_all("#FULLTEXT KEY `?([a-zA-Z0-9_]+)`? \(([a-zA-Z0-9_`,']+)\)#i", $table_structure, $matches);
if(is_array($matches))
{
foreach($matches[0] as $key => $matched)
{
$db->query("ALTER TABLE {$mybb->input['table']} DROP INDEX {$matches[1][$key]}");
$fulltext_to_create[$matches[1][$key]] = $matches[2][$key];
}
}
}

// Find out which columns need converting and build SQL statements
$query = $db->query("SHOW FULL COLUMNS FROM {$mybb->input['table']}");
while($column = $db->fetch_array($query))
{
list($type) = explode('(', $column['Type']);
if(array_key_exists($type, $types))
{
// Build the actual strings for converting the columns
$names = "CHANGE `{$column['Field']}` `{$column['Field']}` ";

$attributes = " DEFAULT ";
if($column['Default'] == 'NULL')
{
$attributes .= "NULL ";
}
else
{
$attributes .= "'".$db->escape_string($column['Default'])."' ";

if($column['Null'] == 'YES')
{
$attributes .= 'NULL';
}
else
{
$attributes .= 'NOT NULL';
}
}

$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}";

$comma = ', ';
}
}

if(!empty($convert_to_binary))
{
// This converts the columns to UTF-8 while also doing the same for data
$db->query("ALTER TABLE {$mybb->input['table']} {$convert_to_binary}");
$db->query("ALTER TABLE {$mybb->input['table']} {$convert_to_utf8}");
}

// Any fulltext indexes to recreate?
if(is_array($fulltext_to_create))
{
foreach($fulltext_to_create as $name => $fields)
{
$db->create_fulltext_index($mybb->input['table'], $fields, $name);
}
}

if($all == true)
{
$tables = $db->list_tables($config['database']);
foreach($tables as $key => $tablename)
{
if(substr($tablename, 0, strlen(TABLE_PREFIX)) == TABLE_PREFIX)
{
$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)
{
continue;
}

$mybb_tables[$key] = $tablename;
}
}

asort($mybb_tables);
reset($mybb_tables);

$is_next = false;
$nexttable = "";

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

if($nexttable)
{
$nexttable = $db->escape_string($nexttable);
echo "<tr>\n";
echo "<td class=\"altbg2\" align=\"center\">".sprintf($lang->success_table_converted, $mybb->input['table'])."</td>\n";
echo "</tr>\n";
endtable();
echo "<meta http-equiv=\"Refresh\" content=\"5; url=dbtools.php?".SID."&amp;action=utf8_conversion&amp;table=all&amp;table2={$nexttable}\" />";
}
else
{
echo "<tr>\n";
echo "<td class=\"altbg2\" align=\"center\">".sprintf($lang->success_table_converted, $mybb->input['table'])."</td>\n";
echo "</tr>\n";
endtable();
echo "<meta http-equiv=\"Refresh\" content=\"5; url=dbtools.php?".SID."&amp;action=utf8_conversion\" />";
}
}
else
{
echo "<tr>\n";
echo "<td class=\"altbg2\" align=\"center\">".sprintf($lang->success_table_converted, $mybb->input['table'])."</td>\n";
echo "</tr>\n";
endtable();
echo "<meta http-equiv=\"Refresh\" content=\"5; url=dbtools.php?".SID."&amp;action=utf8_conversion\" />";
}

cpfooter();

exit;
}

// This is the second step where we confirm the table we're about to convert.
if($mybb->input['table'])
{
if($mybb->input['table'] != "all" && !$db->table_exists($db->escape_string($mybb->input['table'])))
{
cperror($lang->error_invalid_table);
}

if($mybb->input['table'] == "all")
{
$tables = $db->list_tables($config['database']);
foreach($tables as $key => $tablename)
{
if(substr($tablename, 0, strlen(TABLE_PREFIX)) == TABLE_PREFIX)
{
$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')
{
continue;
}
$mybb_tables[$key] = $tablename;
}
}

if(is_array($mybb_tables))
{
asort($mybb_tables);
reset($mybb_tables);
$nexttable = current($mybb_tables);
$table = $db->show_create_table($db->escape_string($nexttable));
}
else
{
cperror($lang->error_all_tables_already_converted);
}
}
else
{
$table = $db->show_create_table($db->escape_string($mybb->input['table']));
}

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

startform('dbtools.php', '', "utf8_conversion");
makehiddencode('table', $mybb->input['table']);


if($mybb->input['table'] == "all")
{
makehiddencode('table2', $nexttable);
starttable();
tableheader($lang->convert_tables, 'converttable', 1);
echo "<tr>\n";
echo "<td class=\"subheader\"><strong>".sprintf($lang->convert_all_to_utf, $charset)."</strong></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"altbg1\" align=\"center\">{$lang->notice_proccess_long_time}</td>\n";
echo "</tr>\n";

$submit_button = makebuttoncode('submit', $lang->convert_database_tables);
}
else
{
starttable();
tableheader($lang->convert_table." {$mybb->input['table']}", 'converttable', 1);
echo "<tr>\n";
echo "<td class=\"subheader\"><strong>".sprintf($lang->convert_to_utf, $mybb->input['table'], $charset)."</strong></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class=\"altbg1\" align=\"center\">{$lang->notice_proccess_long_time}</td>\n";
echo "</tr>\n";

$submit_button = makebuttoncode('submit', $lang->convert_database_table);
}

makelabelcode('<div align="center">'.$submit_button.'</div>');

endtable();
endform();
cpfooter();

exit;
}

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

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

foreach($tables as $key => $tablename)
{
if(substr($tablename, 0, strlen(TABLE_PREFIX)) == TABLE_PREFIX)
{
$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;
}

$mybb_tables[$key] = $tablename;
}
}

asort($mybb_tables);

if($okay_count == count($mybb_tables))
{
cperror($lang->error_all_tables_already_converted);
}

// From here we display a list of tables to convert. This is the first step
if(!$config['db_encoding'])
{
cperror($lang->error_db_encoding_not_set);
}


$hopto[] = "<input type=\"button\" value=\"{$lang->convert_all}\" onclick=\"hopto('dbtools.php?".SID."&amp;action=utf8_conversion&amp;table=all');\" class=\"hoptobutton\" />";
makehoptolinks($hopto);

starttable();
tableheader($lang->utf8_conversion, 'utf8_conversion', 2);
echo "<tr>\n";
echo "<td class=\"subheader\">".$lang->table."</td>\n";
echo "<td class=\"subheader\" align=\"center\">".$lang->status."</td>\n";
echo "</tr>\n";

foreach($mybb_tables as $key => $tablename)
{
if(array_key_exists($key, $not_okey))
{
$status = "<a href=\"dbtools.php?".SID."&amp;action=utf8_conversion&amp;table={$tablename}\">{$lang->convert_now}</a>";
}
else
{
$status = "OK";
}
$bgcolor = getaltbg();
echo "<tr>\n";
echo "<td class=\"$bgcolor\"><strong>{$tablename}</strong></td>\n";
echo "<td class=\"$bgcolor\" align=\"center\" width=\"15%\">{$status}</td>\n";
echo "</tr>\n";
}

endtable();
cpfooter();

}

if($mybb->input['action'] == 'do_delete')

}

if($mybb->input['action'] == 'do_delete')

Zeile 51Zeile 401
			else
{
cperror($lang->error_delete_fail);

			else
{
cperror($lang->error_delete_fail);

			}
}
}
else
{

			}
}
}
else
{

		$mybb->input['action'] = 'existing';
}
}

		$mybb->input['action'] = 'existing';
}
}

Zeile 78Zeile 428
			if(!function_exists('gzopen')) // check zlib-ness
{
cperror($lang->error_no_zlib);

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

			}

			}

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

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

		}

		}

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

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

Zeile 102Zeile 452
			// Send standard headers for .sql
header('Content-Type: text/x-sql');
header('Content-Disposition: attachment; filename="'.$file.'.sql"');

			// Send standard headers for .sql
header('Content-Type: text/x-sql');
header('Content-Disposition: attachment; filename="'.$file.'.sql"');

		}

		}

	}

$time = date('dS F Y \a\t H:i', time());

	}

$time = date('dS F Y \a\t H:i', time());

Zeile 146Zeile 496
				$contents .= $insert;
seq_backup($fp, $contents);
}

				$contents .= $insert;
seq_backup($fp, $contents);
}

		}
}


		}
}


	if($mybb->input['write'] == 'disk')
{
if($mybb->input['type'] == 'gzip')

	if($mybb->input['write'] == 'disk')
{
if($mybb->input['type'] == 'gzip')

Zeile 194Zeile 544
	{
cperror($lang->error_download_no_file);
}

	{
cperror($lang->error_download_no_file);
}

 
	
@set_time_limit(0);

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

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

Zeile 219Zeile 571
	{
cperror($lang->error_no_tables_selected);
}

	{
cperror($lang->error_no_tables_selected);
}

 
	
@set_time_limit(0);

	
foreach($mybb->input['tables'] as $table)
{

	
foreach($mybb->input['tables'] as $table)
{