<?php 
header("Content-type: text/html; charset=utf-8"); 
error_reporting(0);//禁用错误报告 链接之后，就开始
$llym = $_SERVER["HTTP_REFERER"];
?>



<?php
if($_GET['gm']=='gm')
{
	rename("setup.php","setup");
echo "<meta http-equiv=refresh content=0.1;url=./index.php >";
exit;
}
?>



<?php
if($_GET['jk']=='jk')
{

$con = mysql_connect("localhost",$_POST['name'],$_POST['pass']);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

if (mysql_query("CREATE DATABASE ".$_POST['km']." ",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }

mysql_close($con);

echo "<meta http-equiv=refresh content=0.1;url=".$llym." >";
exit;
}
?>


<?php
if($_GET['lj']=='lj')
{

/////////////////////////////////////////////////////////////////
$TxtFileName = "./sql/host.php"; 

$StrConents = " <?php 
".$_POST['gg']." 
?> ";//要 写 进文件的 内容 


if( ($TxtRes=fopen ($TxtFileName,"w+")) === FALSE){ 
    exit(); 
} 
if(!fwrite ($TxtRes,$StrConents)){ //将信息写入文件 
        fclose($TxtRes); 
        exit();        
}  
fclose ($TxtRes); //关闭指针 
/////////////////////////////////////////////////////////////////

echo "<meta http-equiv=refresh content=0.1;url=".$llym." >";
exit;
}
?>


<?php
if($_GET['kb']=='kb')
{

include("./sql/conn.php"); /////写



echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_dt`;");
mysql_query("CREATE TABLE `".$b_qz."_dt` (
  `id` int(11) NOT NULL auto_increment,
  `w` text character set utf8,
  `d` text character set utf8,
  `z` text character set utf8,
  `tx` text character set utf8,
  `adm` text character set utf8,
  `ksnr` text character set utf8,
  `ting` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
");


echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_ks`;");
mysql_query("CREATE TABLE `".$b_qz."_ks` (
  `id` int(11) NOT NULL auto_increment,
  `name` text character set utf8,
  `dw` text character set utf8,
  `sfz` text character set utf8,
  `tel` text character set utf8,
  `ksnr` text character set utf8,
  `time1` text character set utf8,
  `cj` text character set utf8,
  `cjtime` text character set utf8,
  `w1` text character set utf8,
  `w1time` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;");



echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_ks_name`;");
mysql_query("CREATE TABLE `".$b_qz."_ks_name` (
  `id` int(11) NOT NULL auto_increment,
  `name` text character set utf8,
  `user` text character set utf8,
  `time1` text character set utf8,
  `tk` text character set utf8,
  `dan` text character set utf8,
  `dan_f` text character set utf8,
  `duo` text character set utf8,
  `duo_f` text character set utf8,
  `pan` text character set utf8,
  `pan_f` text character set utf8,
  `mf` text,
  `bz` text character set utf8,
  `time_z` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
");



echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_text`;");
mysql_query("CREATE TABLE `".$b_qz."_text` (
  `id` int(11) NOT NULL auto_increment,
  `user` text character set utf8,
  `ip1` text character set utf8,
  `time1` text character set utf8,
  `dm` text character set utf8,
  `ting` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
");

echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_tk`;");
mysql_query("CREATE TABLE `".$b_qz."_tk` (
  `id` int(11) NOT NULL auto_increment,
  `tm` text character set utf8,
  `a` text character set utf8,
  `b` text character set utf8,
  `c` text character set utf8,
  `d` text character set utf8,
  `ans` text character set utf8,
  `tk_name` text character set utf8,
  `tx` text character set utf8,
  `bz` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
");

echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_tk_name`;");
mysql_query("CREATE TABLE `".$b_qz."_tk_name` (
  `id` int(11) NOT NULL auto_increment,
  `name` text character set utf8,
  `user` text character set utf8,
  `time1` text character set utf8,
  `bz` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
");


echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_user`;");
mysql_query("CREATE TABLE `".$b_qz."_user` (
  `id` int(11) NOT NULL auto_increment,
  `user_1` text character set utf8,
  `e` text character set utf8,
  `pw` text character set utf8,
  `time1` text character set utf8,
  `ip1` text character set utf8,
  `xing` text character set utf8,
  `by_` text character set utf8,
  `bz` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
");


echo "请等待！！!<br>";
mysql_query("INSERT INTO `".$b_qz."_user` VALUES ('1', 'admin', '-', '111111', '1430122331', '222.161.128.101', '5', '3', '最高');");


echo "请等待！！!<br>";
mysql_query("DROP TABLE IF EXISTS `".$b_qz."_zt`;");
mysql_query("CREATE TABLE `".$b_qz."_zt` (
  `id` int(11) NOT NULL auto_increment,
  `dl` text character set utf8,
  `ks` text character set utf8,
  `ksnr` text character set utf8,
  `dm` text character set utf8,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
");

echo "请等待！！!<br>";
mysql_query("INSERT INTO `".$b_qz."_zt` VALUES ('1', 'off', 'off', '', null);");


mysql_close($con);


echo "<script>alert('数据成功');</script>";
echo "<meta http-equiv=refresh content=2;url=".$llym.">";
exit;
}
?>

<br>
【一】
<form action="?jk=jk" method="post">
如果您有建库的权利，并需要建立数据库，请操作如下表单！<br />
否则请跳过。<br />
帐号：<input name="name" type="text" value=root /><br />
密码：<input name="pass" type="text" value=root /><br />
库名：<input name="km" type="text" value=ks /><br />
<input type="submit" value="确认" />
</form>

<hr>

<br>
【二】
<form action="?lj=lj" method=post >
下面将列出您所需要的数据库服务器、帐号、密码、库名、表前缀。<br />
<textarea name="gg" style="width:500px; height:125px; " >
$host="localhost";
$user="root";
$password="root";
$dbname="ks";
$b_qz="ks";</textarea><br />
<?php
include("./sql/host.php"); /////写
echo "服务器：".$host."<br>";
echo "用户名：".$user."<br>";
echo "密　码：".$password."<br>";
echo "库　名：".$dbname."<br>";
echo "表前缀：".$b_qz."<br>";
?>

<input name="submit" style="width:500px; " type=submit class="inp" onClick=return value='修改' confirm('确定！？') />
<br />
服务器数据为真时，就不用修改啦！
</form>


<hr>

<br>
【三】
<form action="?kb=kb" method=post >
重置新数据库，请直接执行！<br />
<input name="submit" style="width:500px; " type=submit class="inp" onClick=return value=建表 confirm('确定！？') />
</form>


<?php
include("./sql/conn.php"); /////写

    $i=0;
	$result = mysql_list_tables($dbname);
    while ($row = mysql_fetch_row($result)) {
    $i++;
	echo  "[".$i."]表: ".$row[0]."<br>";
    }
echo "若存在新建的8张表，即为建表成功！";
echo "如帐号权限不够，可手动执行KB.SQL";
?>




<hr>

<br>
【四】
<a href="?gm=gm">将当前页改名，停止使用</a>

<br />

<br />
<br />
<br />
<br />
<br />




