1
0
mirror of https://github.com/ZeroDream-CN/PHPMC7 synced 2024-11-24 04:52:54 +08:00

修复安装程序 bug

修复安装程序的一些问题
This commit is contained in:
Akkariin Meiko 2018-09-15 02:45:23 +08:00
parent a88302456a
commit 9aac12cfc8
4 changed files with 41 additions and 18 deletions

View File

@ -5,7 +5,7 @@ $pathinfo = pathinfo($_SERVER['PHP_SELF']);
$path = str_replace("/" . $pathinfo['basename'], "", $_SERVER['PHP_SELF']);
define("ROOT", str_replace("\\", "/", __DIR__));
define("DOCROOT", $path);
if(!file_exists(ROOT . "/include/data/config.php")) {
if(!file_exists(ROOT . "/include/data/config.php") && !isset($_GET['installed'])) {
echo "<script>location='install/';</script>";
exit;
}

View File

@ -1,17 +1,11 @@
<?php
if(file_exists("install.lock")) {
echo file_get_contents("template/locked.html");
exit;
}
if($_GET['step'] == '') {
echo file_get_contents("template/1.html");
exit;
}
if($_GET['step'] == '2') {
echo file_get_contents("template/2.html");
exit;
}
if($_GET['step'] == '3') {
/**
*
* PHPMC 7 Install
*
*/
error_reporting(E_ALL);
function install() {
$db_host = $_POST['db_host'];
$db_port = $_POST['db_port'];
$db_user = $_POST['db_user'];
@ -145,6 +139,34 @@ class Config {
}
}');
@file_put_contents("install.lock", "");
echo file_get_contents("template/3.html");
}
if(file_exists("install.lock")) {
echo @file_get_contents("template/locked.html");
exit;
}
if(isset($_GET['step'])) {
switch($_GET['step']) {
case '1':
echo @file_get_contents("template/1.html");
break;
case '2':
echo @file_get_contents("template/2.html");
break;
case '3':
install();
$type = $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$self = str_replace("index.php", "?installed=true", str_replace("install/", "", $_SERVER['PHP_SELF']));
$connect = "{$type}{$_SERVER['HTTP_HOST']}{$self}";
echo str_replace("{HOME}", $connect, @file_get_contents("template/3.html"));
break;
default:
echo @file_get_contents("template/1.html");
break;
}
exit;
} else {
echo @file_get_contents("template/1.html");
exit;
}

View File

@ -35,9 +35,7 @@
<div class="text-center">
<br>
<p>安装完成,立即使用。</p>
<a href="/">
<button class="btn btn-success"><i class="fa fa-send"></i> 进入后台</button>
</a>
<button class="btn btn-success" onclick="location='{HOME}'"><i class="fa fa-send"></i> 进入后台</button>
</div>
</form>
</div>

View File

@ -28,6 +28,9 @@
<p>PHPMC 7 官方网站:<a href="https://www.phpmc.cn/" target="_blank">https://www.phpmc.cn/</a></p>
<hr>
<p>PHPMC 7 已经安装过了,重新安装请删除 install 目录下的 install.lock</p>
<center>
<button class="btn btn-success" onclick="location='/'"><i class="fa fa-send"></i> 进入后台</button>
</center>
</div>
</div>
</div>