<?php
error_reporting(0);
header("Content-type: text/html; charset=utf-8");
$ip = $_POST['mysqlip'];
$username = $_POST['mysqlusername'];
$userpass = $_POST['mysqluserpass'];
$db = $_POST['mysqldb'];
$ok1 = mysql_connect($ip,$username,$userpass)or die("数据库无法连接,请检查账号或密码填写是否正确!");
$ok2 = mysql_select_db($db)or die("数据库连接异常,请检查数据库名称是否填写正确!");
mysql_query("SET NAMES UTF8");
$install = file_get_contents("dunling.sql");
$install = explode("@dunling@",$install);
foreach($install AS $sqla => $sqlb){
$ok = mysql_query($sqlb,$ok1)or die(mysql_error());
}
if($ok){
$mysqlconfig = $ip.'@dunling@'.$username.'@dunling@'.$userpass.'@dunling@'.$db;
$config_t = file_get_contents("mysql_config.dll");
$config_a = array("@server@","@mysqlname@","@mysqlpass@","@mysqldb@");
$config_b = array($ip,$username,$userpass,$db);
$mysqlconfig = str_replace($config_a,$config_b,$config_t);
$fileok = file_put_contents("../config.php",$mysqlconfig);
if($fileok){
    echo "installok";
    rename("index.php","index.lock");
}else{
    echo "installno";
}
}
?>