From 1bdd2dc6d7fe1ba225e2272542e1ac8887d9ed60 Mon Sep 17 00:00:00 2001
From: printempw
Date: Sun, 27 Mar 2016 15:02:16 +0800
Subject: [PATCH] moved install.php to /setup and added function check
---
assets/css/install.style.css | 32 ++++-
get.php | 5 +-
libraries/Database/Database.class.php | 6 +-
setup/index.php | 187 ++++++++++++++++++++++++++
{admin => setup}/install.php | 73 +++-------
templates/error.tpl.php | 3 +-
6 files changed, 248 insertions(+), 58 deletions(-)
create mode 100644 setup/index.php
rename {admin => setup}/install.php (77%)
diff --git a/assets/css/install.style.css b/assets/css/install.style.css
index ed3bbe67..b11c5192 100644
--- a/assets/css/install.style.css
+++ b/assets/css/install.style.css
@@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-03-12 18:54:09
* @Last Modified by: printempw
-* @Last Modified time: 2016-03-26 18:41:48
+* @Last Modified time: 2016-03-27 14:47:19
*/
@import url(https://fonts.googleapis.com/css?family=Ubuntu);
@@ -41,6 +41,7 @@ p {
}
#logo a {
font-family: Minecraft, sans-serif;
+ transition: all .2s ease-in-out;
font-size: 50px;
color: #666;
height: 84px;
@@ -52,6 +53,9 @@ p {
overflow: hidden;
display: block;
}
+#logo a:hover {
+ color: #42a5f5;
+}
/* Mobile phone */
@media (max-width: 48em) {
#logo a {
@@ -310,3 +314,29 @@ textarea {
background-color: #fcf8e3;
border-color: #faebcc;
}
+.test {
+ margin-bottom: 20px;
+}
+.test-name {
+ display: inline-block;
+ width: 250px;
+ font-size: 16px;
+ /*font-weight: 700;*/
+}
+.result.passed {
+ color: #4caf50;
+}
+.result.failed {
+ color: #f44336;
+}
+.result {
+ float: right;
+ display: inline-block;
+ width: 250px;
+ text-align: right;
+ font-weight: bold;
+}
+.info {
+ margin: 4px 0 0 0;
+ font-size: 14px;
+}
diff --git a/get.php b/get.php
index 4adeb0d3..ef5464c6 100644
--- a/get.php
+++ b/get.php
@@ -3,7 +3,7 @@
* @Author: printempw
* @Date: 2016-02-02 20:56:42
* @Last Modified by: printempw
- * @Last Modified time: 2016-03-27 11:25:36
+ * @Last Modified time: 2016-03-27 14:48:50
*
* All textures requests of legacy link will be handle here.
*/
@@ -12,6 +12,9 @@ $dir = dirname(__FILE__);
require "$dir/libraries/autoloader.php";
if (isset($_GET['type']) && isset($_GET['uname'])) {
+ // Use for checking rewrite rules when install
+ if ($_GET['uname'] == "check_for_rewrite_rules") exit;
+
$user = new User($_GET['uname']);
if (!$user->is_registered) {
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
diff --git a/libraries/Database/Database.class.php b/libraries/Database/Database.class.php
index 5def9fa9..831b6970 100644
--- a/libraries/Database/Database.class.php
+++ b/libraries/Database/Database.class.php
@@ -3,7 +3,7 @@
* @Author: printempw
* @Date: 2016-02-02 21:59:06
* @Last Modified by: printempw
- * @Last Modified time: 2016-03-27 11:32:04
+ * @Last Modified time: 2016-03-27 14:50:39
*/
namespace Database;
@@ -35,9 +35,9 @@ class Database implements EncryptInterface, SyncInterface
if ($conn->connect_error)
throw new E("无法连接至 MySQL 服务器。请确认 config.php 中的配置是否正确:".$conn->connect_error, $conn->connect_errno, true);
if (!self::checkTableExist($conn))
- throw new E("数据库中不存在 ".DB_PREFIX."users 或 ".DB_PREFIX."options 表。请先访问 /admin/install.php 进行安装。", -1, true);
+ throw new E("数据库中不存在 ".DB_PREFIX."users 或 ".DB_PREFIX."options 表。请先访问 /setup 进行安装。", -1, true);
if (!is_dir(BASE_DIR."/textures/"))
- throw new E("textures 文件夹不存在。请先运行 /admin/install.php 进行安装,或者手动放置一个。", -1, true);
+ throw new E("textures 文件夹不存在。请先访问 /setup 进行安装,或者手动放置一个。", -1, true);
$conn->query("SET names 'utf8'");
return $conn;
diff --git a/setup/index.php b/setup/index.php
new file mode 100644
index 00000000..ee9dcb92
--- /dev/null
+++ b/setup/index.php
@@ -0,0 +1,187 @@
+
+
+
+
+
+
+
+出现错误 - Blessing Skin Server 安装程序
+
+
+
+Blessing Skin Server
+错误:PHP 未运行
+Blessing Skin Server 基于 PHP 开发,需要 PHP 运行环境。如果你看到这段话就说明主机的 PHP 未运行。
+你问 PHP 是什么?为什么不问问神奇海螺呢?
+
+
+
+
+
+
+
+
+
+Blessing Skin Server 安装程序
+
+
+
+Blessing Skin Server
+connect_error): ?>
+MySQL 连接错误
+无法连接至 MySQL 服务器,确定你在 config.php 填写的数据库信息正确吗?
+详细信息:connect_error; ?>
+query("SET names 'utf8'");
+
+if (Database\Database::checkTableExist($conn)): ?>
+已安装过
+Blessing Skin Server 看起来已经安装妥当。如果想重新安装,请删除数据库中的旧数据表,或者换一个数据表前缀。
+返回首页
+
+
+欢迎
+欢迎使用 Blessing Skin Server V2!
+成功连接至 MySQL 服务器 ,点击下一步以开始安装。
+下一步
+
+功能检查
+我们需要做一些检查来确保你可以正常使用 Blessing Skin Server。
+
+可用';
+ } else {
+ $fails++;
+ return '不支持';
+ }
+}
+
+function checkClass($classname) {
+ global $fails;
+ if (class_exists($classname)) {
+ return '可用';
+ } else {
+ $fails++;
+ return '不支持';
+ }
+}
+
+function checkRewrite() {
+ global $fails;
+ $uri = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
+ $base_url = explode('setup', $uri)[0];
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $base_url."check_for_rewrite_rules.json");
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ curl_setopt($ch,CURLOPT_NOBODY,true);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ $data = curl_exec($ch);
+ if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200) {
+ return '可用';
+ } else {
+ $fails++;
+ return '不支持';
+ }
+ curl_close($ch);
+}
+
+?>
+
+
+
PHP 版本
+ = 0): ?>
+
+
+
+
+
由于使用了一些新特性,最低需要 PHP 5.4。
+
+
+
+
+
+
重写规则
+
+
伪静态,用于支持传统皮肤获取链接。
+
+
+
+
JSON Encode
+
+
编码 JSON,用于支持 JSON API。
+
+
+
+
写入权限
+
+
可写
+
+
不可写
+
+
目前不支持 SAE 等不可写应用引擎。
+
+
+
+
ZipArchive
+
+
解压缩,用于自动升级。
+
+
+
+
cURL
+
+
抓取网页,用于自动升级。
+
+
+下一步
';
+} else {
+ echo '下一步
';
+}
+?>
+
+
+
+
-
-
-
-
-
-
-出现错误 - Blessing Skin Server 安装程序
-
-
-
-Blessing Skin Server
-错误:PHP 未运行
-Blessing Skin Server 基于 PHP 开发,需要 PHP 运行环境。如果你看到这段话就说明主机的 PHP 未运行。
-你问 PHP 是什么?为什么不问问神奇海螺呢?
-
-
-Blessing Skin Server
-PHP 版本过低
-由于使用了一些新特性,Blessing Skin Server 需要 PHP 版本 >= 5.4。您当前的 PHP 版本为
-
* Stepped installation
*/
switch ($step) {
+
// Step 1
case 1: ?>
-欢迎
-欢迎使用 Blessing Skin Server V2!
-成功连接至 MySQL 服务器 ,点击下一步以开始安装。
-下一步
-
填写信息
您需要填写一些基本信息。无需担心填错,这些信息以后可以再次修改。
-