📄 install.php
字号:
$tablepre = 'cdb_';
@include './config.php';
?>
<tr>
<td align="center">
<br>
<form method="post" action="<?=$PHP_SELF?>">
<table width="500" cellspacing="1" bgcolor="#000000" border="0" align="center">
<tr bgcolor="#3A4273">
<td align="center" width="20%" style="color: #FFFFFF">设置选项</td>
<td align="center" width="35%" style="color: #FFFFFF">当前值</td>
<td align="center" width="45%" style="color: #FFFFFF">注释</td>
</tr>
<tr>
<td bgcolor="#E3E3EA"> 数据库服务器:</td>
<td bgcolor="#EEEEF6" align="center"><input type="text" name="dbhost" value="<?=$dbhost?>" size="30"></td>
<td bgcolor="#E3E3EA"> 数据库服务器地址, 一般为 localhost</td>
</tr>
<tr>
<td bgcolor="#E3E3EA"> 数据库用户名:</td>
<td bgcolor="#EEEEF6" align="center"><input type="text" name="dbuser" value="<?=$dbuser?>" size="30"></td>
<td bgcolor="#E3E3EA"> 数据库账号用户名</td>
</tr>
<tr>
<td bgcolor="#E3E3EA"> 数据库密码:</td>
<td bgcolor="#EEEEF6" align="center"><input type="password" name="dbpw" value="<?=$dbpw?>" size="30"></td>
<td bgcolor="#E3E3EA"> 数据库账号密码</td>
</tr>
<tr>
<td bgcolor="#E3E3EA"> 数据库名:</td>
<td bgcolor="#EEEEF6" align="center"><input type="text" name="dbname" value="<?=$dbname?>" size="30"></td>
<td bgcolor="#E3E3EA"> 数据库名称</td>
</tr>
<tr>
<td bgcolor="#E3E3EA"> 系统 Email:</td>
<td bgcolor="#EEEEF6" align="center"><input type="text" name="adminemail" value="<?=$adminemail?>" size="30"></td>
<td bgcolor="#E3E3EA"> 用于发送程序错误报告</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" style="color: #FF0000"> 表名前缀:</td>
<td bgcolor="#EEEEF6" align="center"><input type="text" name="tablepre" value="<?=$tablepre?>" size="30" onClick="javascript: alert('安装向导提示:\n\n除非您需要在同一数据库安装多个 CDB\n论坛,否则,强烈建议您不要修改表名前缀.');"></td>
<td bgcolor="#E3E3EA"> 同一数据库安装多论坛时使用</td>
</tr>
</table>
<br>
<input type="hidden" name="action" value="environment">
<input type="hidden" name="saveconfig" value="1">
<input type="submit" name="submit" value="保存配置信息" style="height: 25">
<input type="button" name="exit" value="退出安装向导" style="height: 25" onclick="javascript: window.close();">
</form>
</td>
</tr>
<?
} else {
@include './config.php';
?>
<tr>
<td>
<br>
<table width="60%" cellspacing="1" bgcolor="#000000" border="0" align="center">
<tr bgcolor="#3A4273">
<td align="center" style="color: #FFFFFF">变量</td>
<td align="center" style="color: #FFFFFF">当前值</td>
<td align="center" style="color: #FFFFFF">注释</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">$dbhost</td>
<td bgcolor="#EEEEF6" align="center"><?=$dbhost?></td>
<td bgcolor="#E3E3EA" align="center">数据库服务器, 一般为 localhost</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">$dbuser</td>
<td bgcolor="#EEEEF6" align="center"><?=$dbuser?></td>
<td bgcolor="#E3E3EA" align="center">数据库账号(用户名)</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">$dbpw</td>
<td bgcolor="#EEEEF6" align="center"><?=$dbpw?></td>
<td bgcolor="#E3E3EA" align="center">数据库密码</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">$dbname</td>
<td bgcolor="#EEEEF6" align="center"><?=$dbname?></td>
<td bgcolor="#E3E3EA" align="center">数据库名称</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">$adminemail</td>
<td bgcolor="#EEEEF6" align="center"><?=$adminemail?></td>
<td bgcolor="#E3E3EA" align="center">系统 Email</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">$tablepre</td>
<td bgcolor="#EEEEF6" align="center"><?=$tablepre?></td>
<td bgcolor="#E3E3EA" align="center">数据表名前缀</td>
</tr>
</table>
<br>
</td>
</tr>
<tr>
<td align="center">
<form method="post" action="<?=$PHP_SELF?>">
<input type="hidden" name="action" value="environment">
<input type="submit" name="submit" value="上述配置正确" style="height: 25">
<input type="button" name="exit" value="刷新修改结果" style="height: 25" onclick="javascript: window.location=('<?=$PHP_SELF?>?action=config');">
</form>
</td>
</tr>
<?
}
} else {
?>
<tr>
<td align="center">
<br>
<form method="post" action="<?=$PHP_SELF?>">
<input type="hidden" name="action" value="config">
<input type="submit" name="submit" value="重新检查设置" style="height: 25">
<input type="button" name="exit" value="退出安装向导" style="height: 25" onclick="javascript: window.close();">
</form>
</td>
</tr>
<?
}
} elseif($action == 'environment') {
if($HTTP_POST_VARS['saveconfig'] && is_writeable('./config.php')) {
$dbhost = $HTTP_POST_VARS['dbhost'];
$dbuser = $HTTP_POST_VARS['dbuser'];
$dbpw = $HTTP_POST_VARS['dbpw'];
$dbname = $HTTP_POST_VARS['dbname'];
$adminemail = $HTTP_POST_VARS['adminemail'];
$tablepre = $HTTP_POST_VARS['tablepre'];
$fp = fopen('./config.php', 'r');
$configfile = fread($fp, filesize('./config.php'));
fclose($fp);
$configfile = preg_replace("/[$]dbhost\s*\=\s*[\"'].*?[\"']/is", "\$dbhost = '$dbhost'", $configfile);
$configfile = preg_replace("/[$]dbuser\s*\=\s*[\"'].*?[\"']/is", "\$dbuser = '$dbuser'", $configfile);
$configfile = preg_replace("/[$]dbpw\s*\=\s*[\"'].*?[\"']/is", "\$dbpw = '$dbpw'", $configfile);
$configfile = preg_replace("/[$]dbname\s*\=\s*[\"'].*?[\"']/is", "\$dbname = '$dbname'", $configfile);
$configfile = preg_replace("/[$]adminemail\s*\=\s*[\"'].*?[\"']/is", "\$adminemail = '$adminemail'", $configfile);
$configfile = preg_replace("/[$]tablepre\s*\=\s*[\"'].*?[\"']/is", "\$tablepre = '$tablepre'", $configfile);
$fp = fopen('./config.php', 'w');
fwrite($fp, trim($configfile));
fclose($fp);
}
include './config.php';
include './include/db_'.$database.'.php';
$db = new dbstuff;
$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$msg = '';
$quit = FALSE;
$curr_os = PHP_OS;
$curr_php_version = PHP_VERSION;
if($curr_php_version < '4.0.0') {
$msg .= "<font color=\"#FF0000\">您的 PHP 版本小于 4.0.0, 无法使用 Discuz!.</font>\t";
$quit = TRUE;
} elseif($curr_php_version < '4.0.6') {
$msg .= "<font color=\"#FF0000\">您的 PHP 版本小于 4.0.6, 无法使用头像尺寸检查和 gzip 压缩功能.</font>\t";
}
if(@ini_get(file_uploads)) {
$max_size = @ini_get(upload_max_filesize);
$curr_upload_status = "允许/最大 $max_size";
$msg .= "您可以上传尺寸在 $max_size 以下的附件文件.\t";
} else {
$curr_upload_status = '不允许上传附件';
$msg .= "<font color=\"#FF0000\">由于服务器屏蔽, 您无法使用附件功能.</font>\t";
}
$query = $db->query("SELECT VERSION()");
$curr_mysql_version = $db->result($query, 0);
if($curr_mysql_version < '3.23') {
$msg .= "<font color=\"#FF0000\">您的 MySQL 版本低于 3.23, Discuz! 的一些功能可能无法正常使用.</font>\t";
}
$curr_disk_space = intval(diskfreespace('.') / (1024 * 1024)).'M';
if(dir_writeable('./templates')) {
$curr_tpl_writeable = '可写';
} else {
$curr_tpl_writeable = '不可写';
$msg .= "<font color=\"#FF0000\">模板 ./templates 目录属性非 777 或无法写入, 无法使用在线编辑模板和风格导入.</font>\t";
}
if(dir_writeable($attachdir)) {
$curr_attach_writeable = '可写';
} else {
$curr_attach_writeable = '不可写';
$msg .= "<font color=\"#FF0000\">附件 $attachdir 目录属性非 777 或无法写入, 无法使用附件功能.</font>\t";
}
if(dir_writeable('./forumdata/')) {
$curr_data_writeable = '可写';
} else {
$curr_data_writeable = '不可写';
$msg .= "<font color=\"#FF0000\">数据 ./forumdata 目录属性非 777 或无法写入, 无法使用备份到服务器/论坛运行记录等功能.</font>\t";
}
if(dir_writeable('./forumdata/templates/')) {
$curr_template_writeable = '可写';
} else {
$curr_template_writeable = '不可写';
$msg .= "<font color=\"#FF0000\">模板 ./forumdata/templates 目录属性非 777 或无法写入, 无法安装 Discuz!.</font>\t";
$quit = TRUE;
}
if(dir_writeable('./forumdata/cache/')) {
$curr_cache_writeable = '可写';
} else {
$curr_cache_writeable = '不可写';
$msg .= "<font color=\"#FF0000\">缓存 ./forumdata/cache 目录属性非 777 或无法写入, 无法安装 Discuz!.</font>\t";
$quit = TRUE;
}
$db->select_db($dbname);
if($db->error()) {
$db->query("CREATE DATABASE $dbname");
if($db->error()) {
$msg .= "<font color=\"#FF0000\">指定的数据库 $dbname 不存在, 系统也无法自动建立, 无法安装 Discuz!.</font>\t";
$quit = TRUE;
} else {
$db->select_db($dbname);
$msg .= "指定的数据库 $dbname 不存在, 但系统已成功建立, 可以继续安装.\t";
}
}
$query - $db->query("SELECT COUNT(*) FROM $tablepre"."settings", 1);
if(!$db->error()) {
$msg .= "<font color=\"#FF0000\">数据库中已经安装过 Discuz!, 继续安装会清空原有数据.</font>\t";
$alert = " onSubmit=\"return confirm('继续安装会清空全部原有数据,您确定要继续吗?');\"";
} else {
$alert = '';
}
if($quit) {
$msg .= "<font color=\"#FF0000\">由于您目录属性或服务器配置原因, 无法继续安装 Discuz!, 请仔细阅读安装说明.</font>";
} else {
$msg .= "您的服务器可以安装和使用 Discuz!, 请进入下一步安装.";
}
?>
<tr>
<td><b>当前状态:</b><font color="#0000EE">检查当前服务器环境</font></td>
</tr>
<tr>
<td>
<hr noshade align="center" width="100%" size="1">
</td>
</tr>
<tr>
<td><b><font color="#FF0000">></font><font color="#000000"> Discuz! 所需环境和当前服务器配置对比</font></b></td>
</tr>
<tr>
<td>
<br>
<table width="80%" cellspacing="1" bgcolor="#000000" border="0" align="center">
<tr bgcolor="#3A4273">
<td align="center"></td>
<td align="center" style="color: #FFFFFF">Discuz! 所需配置</td>
<td align="center" style="color: #FFFFFF">Discuz! 最佳配置</td>
<td align="center" style="color: #FFFFFF">当前服务器</td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">操作系统</td>
<td bgcolor="#EEEEF6" align="center">不限</td>
<td bgcolor="#E3E3EA" align="center">UNIX/Linux/FreeBSD</td>
<td bgcolor="#E3E3EA" align="center"><?=$curr_os?></td>
</tr>
<tr>
<td bgcolor="#E3E3EA" align="center">PHP 版本</td>
<td bgcolor="#EEEEF6" align="center">4.0.0 以上</td>
<td bgcolor="#E3E3EA" align="center">4.0.6 以上</td>
<td bgcolor="#EEEEF6" align="center"><?=$curr_php_version?></td>
</tr>
<tr>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -