创建前文件界面
创建配置文件后界面,会提示不能重复安装
下面就上代码吧,html界面的代码就不上了,直接上php代码吧
复制代码 代码如下:
<?php
/*
file:install.php
author:www.5dkx.com
date:2010-3-29
done:安装配置文件
*/
if($_post[mysubmit])
{
$host = $_post[hostname];
$user = $_post[user];
$passwd = $_post[passwd];
$dbname = $_post[dbname];
$siteurl = "http://".$_post[siteurl];
$sitekeyword = $_post[sitekeyword];
$sitedescription = $_post[sitedescription];
$sitename = $_post[sitename];
if(!file_exists("install_locak.txt"))
{
$fp = fopen("./include/config.func.php","w+");
if(flock($fp,lock_ex))
{
fwrite($fp,"<"."?phprn");
fwrite($fp,"$host="$host";rn");
fwrite($fp,"$user="$user";rn");
fwrite($fp,"$passwd="$passwd";rn");
fwrite($fp,"$dbname="$dbname";rn");
fwrite($fp,"$sitename="$sitename";rn");
fwrite($fp,"$siteurl="$siteurl";rn");
fwrite($fp,"$sitekeyword="$sitekeyword";rn");
fwrite($fp,"$sitedescription="$sitedescription";rn");
$tmp = "$conn = mysql_connect($host,$user,$passwd)or die(mysql_error());rn";
fwrite($fp,$tmp);
$tmp ="mysql_query("set names 'gbk'")or die("设置字符库失败!");rn";
fwrite($fp,$tmp);
$tmp ="mysql_select_db($dbname,$conn)or die("连接数据库失败!");rn";
fwrite($fp,$tmp);
fwrite($fp,"?>rn");
flock($fp,lock_un);
echo "文件配置成功!<br>";
echo "<script language="javascript">window.location.href="install2.php";</script>";
}
else
{
echo "can't lock the file!<br>";
}
fclose($fp);
$fins = fopen("install_lock.txt","w");
fclose($fins);
}
else
{
echo "install_locak.txt已经存在,要想重新安装请删除此文件!<br>";
}
}
?>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!