require_once('inc.php');
if(!file_exists($l_file)){
echo getstop();
if(!file_exists($c_file)){
if($_SERVER['REQUEST_METHOD']=='POST' && $_POST['hostname']!='' && $_POST['database']!='' && $_POST['username']!=''){
if(@mysql_connect($_POST['hostname'], $_POST['username'], $_POST['password'])){
if(mysql_select_db($_POST['database']) || mysql_query('CREATE DATABASE '.$_POST['database'])){
$c_content="<?phpn$hostname_conn='".$_POST['hostname']."';n$database_conn='".$_POST['database']."';n$username_conn='".$_POST['username']."';n$password_conn='".$_POST['password']."';n$dbprefix='".$_POST['dbprefix']."';n$conn=mysql_connect($hostname_conn, $username_conn, $password_conn) or die('');nmysql_select_db($database_conn, $conn);".(chksqlv()?"nmysql_query("SET NAMES 'gb2312'", $conn);n$charset_conn=1;":'')."n?>";
writeText($c_file,$c_content);
}else{
$e=1;
}
}else{
$e=2;
}
echo '<script type="text/JavaScript">'.(isset($e)?'location.href='?e='.$e:'location.href='mysql.php').'';</script>';
}else{
if(isset($_GET['e']))$msg=$_GET['e']==2?'無法串連資料庫!':'無法建立資料庫!';
if(isset($msg))echo '<div class="msg_v">'.$msg.'</div>';
?>
<div class="title">第1步:配置MySQL</div>
<div class="lcontent">
<form method="post" onsubmit="if(document.form1.hostname.value=='' || document.form1.database.value=='' || document.form1.username.value==''){alert('請輸入主機名稱、資料庫名、使用者名稱。');return false;}" name="form1">
<div class="formline"><label for="formhostname">主機名稱:</label><input name="hostname" id="formhostname" size="32" value="localhost"/></div>
<div class="formline"><label for="formdatabase">資料庫名:</label><input name="database" id="formdatabase" size="32"/></div>
<div class="formline"><label for="formusername">使用者名稱:</label><input name="username" id="formusername" size="32" value="root"/></div>
<div class="formline"><label for="formpassword">密碼:</label><input name="password" id="formpassword" size="32"/></div>
<div class="formline"><label for="formdbprefix">表首碼:</label><input name="dbprefix" id="formdbprefix" size="32" value="alu_"/></div>
<div class="formline"><input type="submit" value="下一步" id="formsubmit" class="button" /> <input type="reset" value="重設" class="button" /></div>
</form>
</div>
<?php
}
}else{
echo '<div class="gcontent">要安裝'.$app_n.',請先刪除“'.$b_file.'”。</div>';
}
echo getsfoot();
}else{
header('Location:../');