<?php
/***************************************************************************
* copyright : (C) 2006 The openology Group
* email : hide@address.com
*
* $Id
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
header('Content-Type: text/html; charset=UTF-8');
$script_path = (!empty($HTTP_POST_VARS['script_path'])) ? $HTTP_POST_VARS['script_path'] : str_replace('/install', '', dirname($HTTP_SERVER_VARS['PHP_SELF']));
$hidd_path = $script_path;
$dbhost = (!empty($HTTP_POST_VARS['dbhost'])) ? $HTTP_POST_VARS['dbhost'] : 'localhost';
function ShowMsg($msg,$gotoPage)
{
$msg = str_replace("'","`",trim($msg));
$gotoPage = str_replace("'","`",trim($gotoPage));
echo "<script language='javascript'>\n";
echo "alert('$msg');";
if($gotoPage=="back")
{
echo "history.go(-1);\r\n";
}
else if(ereg("^-",$gotoPage))
{
echo "history.go($gotoPage);\r\n";
}
else if($gotoPage!="")
{
echo "location.href='$gotoPage';\r\n";
}
echo "</script>";
}
$s_isreg = @get_cfg_var("register_globals");
if($s_isreg!=1)
{
if (!empty($_GET)) foreach($_GET AS $key => $value){$$key = $value;}
if (!empty($_POST)) foreach($_POST AS $key => $value){$$key = $value;}
}
function GetConfigFile()
{
$fp = fopen("config_base.php","r") or die("é
ç½®æä»¶æ æ³è¯»åææ æ³è®¿é®,请æå½åç®å½æé设为å¯è¯»åï¼");
$configfile = fread($fp,filesize("config_base.php"));
fclose($fp);
return $configfile;
}
function SaveConfigFile($str)
{
$fp = fopen("config_base.php","w") or die("é
ç½®æä»¶æ æ³åå
¥ï¼è¯·æå½åç®å½æé设为å¯è¯»åï¼");;
fwrite($fp,$str);
fclose($fp);
}
if ($step == 1) {
//if(empty($setuptype))
$setuptype=0;
$conn = @mysql_connect($dbhost,$dbuser,$dbpwd) or die("<script>alert('æ°æ®åºæå¡å¨æç»å½å¯ç æ æï¼\\n\\næ æ³è¿æ¥æ°æ®åºï¼è¯·éæ°è®¾å®ï¼');history.go(-1);</script>");
if($isnew == 1){
mysql_query("CREATE DATABASE ".$dbname,$conn) or die("<script>alert('åå»ºæ°æ®åºå¤±è´¥ï¼å¯è½æéä¸è¶³ï¼');history.go(-1);</script>");;
}
mysql_select_db($dbname) or die("<script>alert('æ°æ®åºä¸åå¨ï¼è¯·éæ°è®¾å®ï¼');history.go(-1);</script>");
//åå§åç³»ç»è¡¨
$sqlfiles[0]="sql.txt";
$sql = "INSERT INTO `bbb_user` (`ID`, `ad_name`, `ad_pass`) VALUES (NULL, '$adminname', md5('$adminpwd'));";
$sqlfile = $sqlfiles[$setuptype];
$fp = fopen($sqlfile,"r");
$query = "";
while($line = fgets($fp,1024))
{
$line = trim($line);
if(ereg(";$",$line))
{
$query.=$line;
mysql_query($query,$conn);
$query="";
}
else if(!ereg("^//",$line))
{
$query.=$line;
}
}
fclose($fp);
if($setuptype==0) mysql_query($sql,$conn);
//
mysql_close($conn);
$basedir = ereg_replace("/$","",$basedir);
$basedir = str_replace("\\","",$basedir);
$basepath = ereg_replace("/$","",trim($basepath));
if($basepath=="/") $basepath="";
if($basepath!=""&&!ereg("^/",$basepath)) $basepath="/".$basepath;
$rbasepath = "";
if($basepath=="") $rbasepath="/";
else $rbasepath = $basepath;
if(!file_exists($basedir.$basepath."/install/install.php"))
{
/* echo "<script>alert('ç½ç«æ ¹ç®å½æç¸å¯¹è·¯å¾æ²¡è®¾ç½®æ£ç¡®ï¼');history.go(-1);</script>";
exit();*/
}
$phpdir = ereg_replace("/$","",$basepath);
$baktruedir = $phpdir;
$baseurl = ereg_replace("/$","",$baseurl);
//$artdir = $basepath.ereg_replace("/$","",$artdir);
//æ´æ¹é
ç½®æä»¶
$configstr = GetConfigFile();
$configstr = str_replace("~dbhost~",$dbhost,$configstr);
$configstr = str_replace("~dbname~",$dbname,$configstr);
$configstr = str_replace("~dbuser~",$dbuser,$configstr);
$configstr = str_replace("~dbpwd~",$dbpwd,$configstr);
$configstr = str_replace("~basedir~",$basedir,$configstr);
$configstr = str_replace("~baseurl~",$baseurl,$configstr);
$configstr = str_replace("~phpdir~",$hidd_path,$configstr);
$configstr = str_replace("~indexurl~",$rbasepath,$configstr);
SaveConfigFile($configstr);
//if ($need == 1){
copy("config_base.php","../backend/config_base.php");
copy("login_data.php","../backend/login.php");
//}
ShowMsg("ç½ç«å®è£
æå,请å°installæä»¶å¤¹å é¤,ç¡®ä¿æ¬ç¨åºæ£å¸¸ï¼","../backend/index.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en-EU" lang="en-EU">
<head><title>install</title>
<link rel="stylesheet" href="../backend/css/style.css" type="text/css" />
</head>
<body>
<form action="install.php" name="form1" method="post">
<h3>妿æå¡å¨ææ°æ®åºï¼è¯·å®æä»¥ä¸æ¥éª¤ï¼å¦ææ²¡ææ°æ®åºè¯·ç¹å»<a href="nodatabase.php">è¿é</a></h3>
<h4>MySqlæ°æ®åºå®è£
ååºæ¬è®¾å®</h4><p />
<div id="lwidth">
<div align="right">
<div class="left">æ°æ®æå¡å¨ï¼</div><input name="dbhost" type="text" id="dbhost" value="<?=$dbhost?>" size="30">
</div>
<div align="right">
<div class="left">æ°æ®åºåç§°ï¼</div><input name="dbname" type="text" id="dbname" size="30">
</div>
<div id="note">(è¦æ°å»ºæ°æ®åºè¯·éæ©åå»ºæ°æ®åºï¼æ°æ®åºåé¦å符å¿
é¡»ä¸ºåæ¯)</div>
<div align="right">
<div class="left">åå»ºæ°æ®åºï¼</div><input name="isnew" type="checkbox" id="isnew" value="1">
</div>
<div id="note">(æ°æ®åºè´¦å·ä¸å¯ç )</div>
<div class="clear"></div>
<div align="right">
<div class="left">æ°æ®åºç»å½ç¨æ·ï¼</div><input name="dbuser" type="text" id="dbuser" size="30">
</div>
<div align="right">
<div class="left">æ°æ®åºç»å½å¯ç ï¼</div><input name="dbpwd" type="password" id="dbpwd" size="30">
</div>
<div align="right">
<div class="left">管çååç§°ï¼</div><input name="adminname" type="text" id="adminname" value="admin">
</div>
<div align="right">
<div class="left">管çåå¯ç ï¼</div><input name="adminpwd" type="text" id="adminpwd" value="admin">
</div>
<div align="right">
<div class="left">平尿å¨ç®å½ï¼</div><input name="bdir" type="text" id="bdir" value="<?=$script_path?>" size="26" readonly>
</div>
<?php
$acpath = @dirname(__FILE__);
$acpath = str_replace("\\","/",$acpath);
$acpath = str_replace("$hidd_path/install", "", $acpath);
?>
<input name="basedir" type="hidden" id="basedir" value="<?=$acpath?>">
<div align="right">
<div class="left">ååï¼</div><input name="baseurl" type="text" id="baseurl" value="<?php if(isset($_SERVER["HTTP_HOST"])) echo $_SERVER["HTTP_HOST"];?>" size="30">
</div>
<!--<div align="right">
<div class="left">使ç¨åå°ï¼</div><input type="radio" name="need" value="1" />éè¦<input type="radio" name="need" value="0" />ä¸éè¦
</div>-->
</div>
<p />
<div align="center"><input name="step" type="submit" value="宿"></div>
<input type="hidden" name="step" value="1" />
</form>
</body>
</html>