📄 sql.php
字号:
<?
function split_sql_file ($sql, $delimiter = ';')
{
$sql = trim ($sql);
$char = '';
$last_char = '';
$ret = array ();
$string_start = '';
$in_string = FALSE;
$escaped_backslash = FALSE;
for ($i = 0; ($i < strlen ($sql)); ++$i)
{
$char = $sql[$i];
if ((($char == $delimiter) AND !$in_string))
{
$ret[] = substr ($sql, 0, $i);
$sql = substr ($sql, ($i + 1));
$i = 0;
$last_char = '';
}
if ($in_string)
{
if (($char == '\\'))
{
if (($last_char != '\\'))
{
$escaped_backslash = FALSE;
}
else
{
$escaped_backslash = !$escaped_backslash;
}
}
if ((($char == $string_start) AND (($char == '`') OR !(($last_char == '\\') AND !$escaped_backslash))))
{
$in_string = FALSE;
$string_start = '';
}
}
else
{
if (((($char == '"') OR ($char == '\'')) OR ($char == '`')))
{
$in_string = TRUE;
$string_start = $char;
}
}
$last_char = $char;
}
if (!empty ($sql))
{
$ret[] = $sql;
}
return $ret;
}
include_once 'inc/auth.php';
ob_implicit_flush ();
echo str_repeat (' ', 512);
echo '
<html>
<head>
<title>代码恢复</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body class="bodycolor" topmargin="5">
<table border="0" width="100%" cellspacing="0" cellpadding="3" class="small">
<tr>
<td class="Big"><img src="/images/menu/system.gif" align="absmiddle">';
echo '<s';
echo 'pan class="big3"> 代码恢复</span><br>
</td>
</tr>
</table>
<br>
';
$tables = fread ($fp = fopen ($sql_file, 'r'), filesize ($sql_file));
fclose ($fp);
if (!$tables)
{
message ('', (((''.'对不起,无法读取代码恢复导入文件 ').$sql_file).' 。'));
exit ();
}
if ((stristr ($tables, 'CREATE TABLE `address`') OR stristr ($tables, 'CREATE TABLE `user`')))
{
message ('提示', '您要导入的可能不是代码文件。');
button_back ();
exit ();
}
$querys = split_sql_file ($tables);
$ERROR_COUNT = 0;
foreach ($querys as $query)
{
preg_match ('/CREATE TABLE `([a-z0-9_]+)`/i', $query, $tmp);
$tableName = $tmp[1];
if (exequery ($connection, $query))
{
if ($tableName)
{
message ('', ((''.'成功建立表格 ').$tableName));
continue;
}
continue;
}
message ('代码恢复出现错误', (('错误原因:'.mysql_error ()).((''.'<br><br>错误语句:').$query)));
++$ERROR_COUNT;
}
$STR = '代码恢复完成!';
if ((0 < $ERROR_COUNT))
{
($STR .= (('<br>共发生'.$ERROR_COUNT).'次错误!'));
}
else
{
($STR .= '<br>全部代码恢复成功!');
}
message ('', $STR);
button_back ();
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -