<?php
header("content-type:text/html;charset=utf8");
$host = isset($_POST['host'])?$_POST['host']:"";
$user = isset($_POST['user'])?$_POST['user']:"";
$password = isset($_POST['password'])?$_POST['password']:"";
$db_name = isset($_POST['db_name'])?$_POST['db_name']:"";
$db_prefix = isset($_POST['db_prefix'])?$_POST['db_prefix']:"";
$install = isset($_POST['install'])?$_POST['install']:'';
if(!is_writable("./data/config.php")){
echo ("配置文件不可写,请检查配置文件的权限!");
}
$configStr = '<?php $mysql_host='."'{$host}'".';$mysql_user='."'{$user}'".';$mysql_password='."'{$password}'".';
$db_name = '."'{$db_name}'".';$db_prefix = '."'{$db_prefix}'".';?>';
echo $configStr;
$fp = fopen("./data/config.php","w+");
fwrite($fp,$configStr);
//==================================
include_once ("data/config.php");
if(!@$link = mysqli_connect($host,$user,$password)){
echo "数据库连接失败!";
}else{
echo "数据库连接成功!";
$createSql = "create database `$db_name`";
mysqli_query($link, $createSql);
mysqlI_select_db($link,$db_name);
$sql_query[] = "create table `".$db_prefix."_admin_log1`(
`id` int(8) unsigned not null auto_increment key
);";
$sql_query[] = "create table `".$db_prefix."_admin_log2`(
`id` int(8) unsigned not null auto_increment key
);";
foreach($sql_query as $sql){
mysqli_query($link,$sql);
//echo $sql;
echo "导入成功..."."<br>";
}
}
?>
<form action="" method ="post">
<ul style="list-style:none;">
<li>填写主机:<input type="text" name="host" /></li>
<li>用户名:<input type="text" name="user" /></li>
<li>密码:<input type="text" name="password" /></li>
<li>数据库名:<input type="text" name="db_name" /></li>
<li>数据前缀:<input type="text" name="db_prefix" /></li>
<li><button type="submit" name="install">提交</button></li>
</ul>
</form>
php安装包制作
最新推荐文章于 2021-03-09 19:39:46 发布