<?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","../location.bak");
rename("../home.php","../index.php");
$adminsql = "INSERT INTO `dunling_admin` VALUES ('1', 'admin', '90b9aa7e25f80cf4f64e990b78a9fc5ebd6cecad')";
$websql = "INSERT INTO `dunling_web` VALUES ('1', 'URL2398012425', 'http://www.dunling.com', '68', '2040', '10', '2040', '【测试数据】', 'admin', '1468650593')";
$configsql = "INSERT INTO `dunling_config` VALUES ('1', '764', '99', '99', 'www.dunling.com', '1', '100', '1', '1.00', '0.10', '0.50', '0.50', '1', '120', '100', '盾灵多任务推广系统', '<p>福建盾灵网络科技有限公司</p>\n<p>勇于创新 敢于探索 以人为本 精益求精</p>\n<p>Copyright &copy; 2010-2016 Dunling.com All Rights Reserved.</p>\n<p>闽ICP备12024400号 </p>', '<P>广告合作</p>\n<P>咨询QQ:535344220</p>\n<P>会员联系</p>\n<P>咨询QQ:535344220</p>\n<P>财务联系</p>\n<P>咨询QQ:535344220</p>\n<P>工作时间</p>\n<P>周一至周六 09:00-11:30 13:30-18:00</p>', '<p style=height: 30px;>微信咨询</p>\n<img src=images/wx.jpg />', 'QQ: 535344220', '5000')";
mysql_query($configsql,$ok1);
mysql_query($adminsql,$ok1);
mysql_query($websql,$ok1);
    rename("index.php","index.lock");
}else{
    echo "installno";
}
}
?>