欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

創(chuàng)建配置文件 用PHP寫(xiě)出自己的BLOG系統(tǒng) 2

 更新時(shí)間:2010年04月12日 12:14:04   作者:  
今天做博客安裝程序,首先做的是配置文件的創(chuàng)建。
先看看效果圖

創(chuàng)建前文件界面   

創(chuàng)建配置文件后界面,會(huì)提示不能重復(fù)安裝

下面就上代碼吧,html界面的代碼就不上了,直接上PHP代碼吧

復(fù)制代碼 代碼如下:

<?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,"<"."?php\r\n");
fwrite($fp,"\$host=\"$host\";\r\n");
fwrite($fp,"\$user=\"$user\";\r\n");
fwrite($fp,"\$passwd=\"$passwd\";\r\n");
fwrite($fp,"\$dbname=\"$dbname\";\r\n");
fwrite($fp,"\$sitename=\"$sitename\";\r\n");
fwrite($fp,"\$siteurl=\"$siteurl\";\r\n");
fwrite($fp,"\$sitekeyword=\"$sitekeyword\";\r\n");
fwrite($fp,"\$sitedescription=\"$sitedescription\";\r\n");
$tmp = "\$conn = mysql_connect(\$host,\$user,\$passwd)or die(mysql_error());\r\n";
fwrite($fp,$tmp);
$tmp ="mysql_query(\"set names 'gbk'\")or die(\"設(shè)置字符庫(kù)失敗!\");\r\n";
fwrite($fp,$tmp);
$tmp ="mysql_select_db(\$dbname,\$conn)or die(\"連接數(shù)據(jù)庫(kù)失敗!\");\r\n";
fwrite($fp,$tmp);
fwrite($fp,"?>\r\n");
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已經(jīng)存在,要想重新安裝請(qǐng)刪除此文件!<br>";
}
}
?>

相關(guān)文章

最新評(píng)論