  
- UID
- 2031431
- 威望
- 27 点
- 金钱
- 2 金币
- 点卡
- 10 点
|
1#
发表于 2005-11-6 00:18
| 只看该作者
查看数据库的信息,可以删除表等
- <?php
- session_start();
- echo "<style type=text/css>body,td,input {background-color:#eeeeee; font-size:12px; font-family:verdana}</style>";
- if (!IsSet($host) )
- {
- echo "<center><form action=$PHP_SELF method=post>
- 请输入数据库的信息:<P>
- 数据库主机 : <input name=host value=localhost><p>
- 数据库用户名: <input name=user><p>
- 数据库密码 : <input name=pass><p>
- 数据库名字 : <input name=db_name><p>
- <input type=submit>
- </from></center>";
- }
- else
- {
- session_register("host");
- session_register("user");
- session_register("pass");
- session_register("db_name");
-
- $linkid = mysql_connect($host, $user, $pass);
- if ( !IsSet($table_prefix) )
- {
- $result = mysql_list_tables($db_name, $linkid);
- while ($data = mysql_fetch_row($result) )
- {
- list($table) = $data;
- echo "$table<br>";
- }
- $num = mysql_num_rows($result);
- echo "<P><font color=red>在数据库 $db_name 中,共有以上 $num 个表</font><P>";
- mysql_free_result($result);
-
- //以下删除操作没有确认,且不可恢复,请慎重操作!
- echo "<hr><h3><font color=red>请仔细阅读说明,以下删除操作没有确认,且不可恢复,请慎重操作!</font></h3><p>";
- echo "<form action=$PHP_SELF method=post>请输入欲删除表的全名,如想批量删除,请输入欲删除表的前缀。<br>
- 比如,你输入 "phpBB_" ,则所有名字以 "phpBB_" 开头的表将会被删除!<br>
- <font color=red>如想删除所有的表请输入 "/" </font><p>
- <input name=table_prefix style="color:red"><input type=submit></form> ";
- }
- else
- {
- if ( $table_prefix == "" ) die("没有输入表名");
- if ( $table_prefix == "/" ) $table_prefix = "";
- //以下是操作数据库 $db_name 的结果:<P>
- echo "以下是操作数据库 $db_name 的结果:<P>";
- $result = mysql_list_tables($db_name, $linkid);
- while ($data = mysql_fetch_row($result) )
- {
- list($table) = $data;
- if ( IsPrefix($table_prefix, $table) == TRUE )
- {
- //delete table $table
- $sql = "drop table $table";
- if ( mysql_query($sql) )
- echo "$table ------ 删除成功!<P>";
- else
- echo "<font color=red>$table ------ 删除失败!</font><P>";
- }
- }
- mysql_free_result($result);
- echo "<a href=$PHP_SELF><h2><<回首页</h2></a>";
- }
-
- mysql_close($linkid);
- }
- function IsPrefix($table_prefix, $table)
- {
- $len = strlen($table_prefix);
- $prefix = substr($table, 0, $len);
- if ($prefix == $table_prefix)
- return TRUE;
- else
- return FALSE;
- }
- ?>
复制代码 |
哈哈哈!!!!你的IP是不是 ?我都知道了!!! |
|