建立設定檔 用PHP寫出自己的BLOG系統 2

來源:互聯網
上載者:User

先看看

建立前檔案介面

建立設定檔後介面,會提示不能重複安裝

下面就上代碼吧,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,"<"."?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(\"設定字元庫失敗!\");\r\n";
fwrite($fp,$tmp);
$tmp ="mysql_select_db(\$dbname,\$conn)or die(\"串連資料庫失敗!\");\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已經存在,要想重新安裝請刪除此檔案!<br>";
}
}
?>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.