时间:2021-07-01 10:21:17 帮助过:1人阅读
$files="data/config.php";
if(!is_writable($files)){
echo "不可写!!!";
}else{
echo "可写";
}
if(isset($_POST[install])){
$config_str = "$config_str .= "\n";
$config_str .= '$mysql_host = "' . $_POST[db_host] . '";';
$config_str .= "\n";
$config_str .= '$mysql_user = "' . $_POST[db_user] . '";';
$config_str .= "\n";
$config_str .= '$mysql_pass = "' . $_POST[db_pass] . '";';
$config_str .= "\n";
$config_str .= '$mysql_dbname = "' . $_POST[db_dbname] . '";';
$config_str .= "\n";
$config_str .= '$mysql_tag = "' . $_POST[db_tag] . '";';
$config_str .= "\n";
$config_str .= '?>';
$ff = fopen($files, "w+");
fwrite($ff, $config_str);
//=====================
include_once ("data/config.php"); //嵌入配置文件
if (!@$link = mysql_connect($mysql_host, $mysql_user, $mysql_pass)) { //检查数据库连接情况
echo "数据库连接失败! 请返回上一页检查连接参数 返回修改";
} else {
mysql_query("CREATE DATABASE `$mysql_dbname`");
mysql_select_db($mysql_dbname);
$sql_query[] = "CREATE TABLE `" . $mysql_tag . "admin_log1` (
`id` int(8) unsigned NOT NULL auto_increment,
`username` varchar(40) NOT NULL COMMENT '操作用户名称',
`types` varchar(60) NOT NULL,
PRIMARY KEY (`id`)
) ;";
$sql_query[] = "CREATE TABLE `" . $mysql_tag . "admin_log2` (
`id` int(8) unsigned NOT NULL auto_increment,
`username` varchar(40) NOT NULL COMMENT '操作用户名称',
`types` varchar(60) NOT NULL,
PRIMARY KEY (`id`)
) ;";
$sql_query[] = "CREATE TABLE `" . $mysql_tag . "admin_log3` (
`id` int(8) unsigned NOT NULL auto_increment,
`username` varchar(40) NOT NULL COMMENT '操作用户名称',
`types` varchar(60) NOT NULL,
PRIMARY KEY (`id`)
) ;";
foreach($sql_query as $val){
mysql_query($val);
}
echo "";
rename("install.php","install.lock");
}
}
?>