📄 setup.php
字号:
<?
if(isset($_GET['action'])){
switch($_GET['action']){
case "setDB":
$MyHost=$_POST['host'];
$MyUser=$_POST['user'];
$MyPass=$_POST['pass'];
$MyDB=$_POST['dbname'];
if($Mylink=@mysql_connect($MyHost,$MyUser,$MyPass)){
mysql_query("CREATE DATABASE IF NOT EXISTS `".$MyDB."`",$Mylink);
$s_fmt='<?
$MyHost="%s";
$MyUser="%s";
$MyPass="%s";
$MyDB="%s";
$Mylink=@mysql_connect($MyHost,$MyUser,$MyPass) or die("数据库连接出错!<br>Something wrong connecting database server!");
mysql_select_db($MyDB,$Mylink);
$_MYSQL_INC=1;
?>';
$newconf=sprintf($s_fmt,$MyHost,$MyUser,$MyPass,$MyDB);
$fp=fopen("conf_mysql.php","w");
fwrite($fp,$newconf);
fclose($fp);
header("location: setup.php?step=2");
}
else {$error="数据库服务器连接出错,<br>请检查你的输入";include("inc_error.php");}
break;
case "setAD":
if($_POST['pass']!=$_POST['repass']) {$error="两次密码不同";include("inc_error.php");}
elseif($_POST['pass']=="") {$error="注意:密码为空";include("inc_error.php");}
else {
include("conf_mysql.php");
if(@mysql_query("insert into mc_member set id='{$_POST['id']}',pass=password('{$_POST['pass']}'),power=4,jointime=now(),lastlogin=now(),lastIP='{$_SERVER['REMOTE_ADDR']}',logintimes=1",$Mylink)){
session_start();
$_SESSION['id']=$_POST['id'];
$_SESSION['sex']=0;
$_SESSION['power']=4;
$_SESSION['logintimes']=1;
include("conf_class.php");
$trans=array("\n"=>"\\n","\r"=>"","\\'"=>"'");
$class_name=addslashes($class_name);
$alumni_brief=addslashes($alumni_brief);
$album_brief=addslashes($album_brief);
$alumni_initor=$_POST['id'];
$alumni_time=date("Y-m-d H:i");
$class_year=intval($_POST['year']);
$guestbook_url=$_POST['gburl'];
$s_fmt='<?
//--------alumni configure start--------
$class_name="%s";
$alumni_brief="%s";
//--------alumni constant--------
$class_year=%d;
$alumni_initor="%s";
$alumni_time="%s";
$guestbook_url="%s"; //过客友情留言的留言簿URL地址
$words_per_page=%d; //leaveword.php里一页的留言数
$mems_per_page=%d; //addrbook.php里每页显示成员数
//--------alumni configure end--------
//--------album configure start--------
$album_brief="%s";
//--------album constant--------
$album_volumn=%d; //单位为MB
$pix_per_page=%d; //5的倍数
//--------album configure end--------
$_CLASS_CONF=1;
?>';
$newconf=sprintf($s_fmt,strtr($class_name,$trans),strtr($alumni_brief,$trans),$class_year,$alumni_initor,
$alumni_time,$guestbook_url,$words_per_page,$mems_per_page,strtr($album_brief,$trans),
$album_volumn,$pix_per_page);
$fp=fopen("conf_class.php","w");
fwrite($fp,$newconf);
fclose($fp);
header("location: setup.php?step=4");
}
}
break;
default:
header("location: ".$_SERVER['HTTP_REFERER']);
break;
}
}
else {
echo '
<HTML>
<head>
<title>MyChinaren校友录 - 安装</title>
<link type="text/css" href="main.css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body>
';
switch($_GET['step']){
case 2:
include("conf_mysql.php");
$s_flag=array("<font color='#33CC00'>失败</font>","<font color='#CC0000'>成功</font>");
$sql=explode(";",implode("\r\n",file("structure.sql")));
$flag=array(0,0,0);
for($t_count=0;$t_count<3;$t_count++) if(@mysql_query($sql[$t_count],$Mylink)) $flag[$t_count]=1;
echo '
<br><br><br>
创建数据表`mc_member` ........... '.$s_flag[$flag[0]].'<br>
创建数据表`mc_pix` .............. '.$s_flag[$flag[1]].'<br>
创建数据表`mc_word` ............. '.$s_flag[$flag[2]].'<br>
<br><br>
';
if($flag[0] && $flag[1] && $flag[2]) echo '<a href="setup.php?step=3" class="red">继续下一步</a>';
else echo '<a href="setup.php" class="red">返回上一步</a>';
break;
case 3:
echo'
<p style="font-size:14px"><br><br>请填写以下内容</p>
<form action="setup.php?action=setAD" method="post" style="width:300px;text-align:left">
用户名: <input name="id" type="text" maxlength="12" class="input" style="width:120px"> (<12字节)<br>
密码: <input name="pass" type="password" class="input" style="width:120px"><br>
密码确认: <input name="repass" type="password" class="input" style="width:120px"><br><br>
班级年份: <input name="year" type="text" maxlength="4" class="input" style="width:120px"> (班级入学年份)<br>
友情留言: <input name="gburl" type="text" class="input" style="width:120px"> (填留言簿URL地址)
<br><br> <input type="submit" value="确认" class="bt"> <input type="reset" class="bt">
</form>
';
break;
case 4:
echo '
<br><br><br><br>
MyChinaren校友录安装基本完成....
<br><br>
请前往-> <a href="index.php" target="_blank">班级首页</a>
<a href="admin.php" target="_blank">设置班级参数</a>
<a href="personal.php" target="_blank">填写自己的具体信息</a>
<br><br>
另外别忘了 <font color="#CC0000">删除</font> 本文件(setup.php)<br>
具体设置,也可以到 conf_mysql.php 和 conf_class.php 里改
';
break;
case 1:
default:
echo '
<p style="font-size:14px "><br><br>数据库设置:</p>
<form action="setup.php?action=setDB" method="post">
服务器: <input name="host" type="text" value="localhost" class="input" style="width:120px"><br>
用 户: <input name="user" type="text" value="root" class="input" style="width:120px"><br>
密 码: <input name="pass" type="text" value="" class="input" style="width:120px"><br>
数据库: <input name="dbname" type="text" value="test" class="input" style="width:120px"><br>
<br><input type="submit" value="确认" class="bt"> <input type="reset" class="bt">
</form>
';
break;
}
echo '
</body>
</HTML>
';
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -