moved install.php to /setup and added function check
This commit is contained in:
parent
e1d44e9adf
commit
1bdd2dc6d7
@ -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;
|
||||
}
|
||||
|
5
get.php
5
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");
|
||||
|
@ -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 表。请先访问 <a href='./admin/install.php'>/admin/install.php</a> 进行安装。", -1, true);
|
||||
throw new E("数据库中不存在 ".DB_PREFIX."users 或 ".DB_PREFIX."options 表。请先访问 <a href='./setup'>/setup</a> 进行安装。", -1, true);
|
||||
if (!is_dir(BASE_DIR."/textures/"))
|
||||
throw new E("textures 文件夹不存在。请先运行 /admin/install.php 进行安装,或者手动放置一个。", -1, true);
|
||||
throw new E("textures 文件夹不存在。请先访问 <a href='./setup'>/setup</a> 进行安装,或者手动放置一个。", -1, true);
|
||||
|
||||
$conn->query("SET names 'utf8'");
|
||||
return $conn;
|
||||
|
187
setup/index.php
Normal file
187
setup/index.php
Normal file
@ -0,0 +1,187 @@
|
||||
<?php
|
||||
/**
|
||||
* @Author: printempw
|
||||
* @Date: 2016-03-27 13:30:00
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-03-27 14:46:20
|
||||
*/
|
||||
|
||||
// Sanity check
|
||||
if (false): ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<title>出现错误 - Blessing Skin Server 安装程序</title>
|
||||
<link rel="stylesheet" type="text/css" href="../assets/css/install.style.css">
|
||||
</head>
|
||||
<body class="container">
|
||||
<p id="logo"><a href="https://github.com/printempw/blessing-skin-server" tabindex="-1">Blessing Skin Server</a></p>
|
||||
<h1>错误:PHP 未运行</h1>
|
||||
<p>Blessing Skin Server 基于 PHP 开发,需要 PHP 运行环境。如果你看到这段话就说明主机的 PHP 未运行。</p>
|
||||
<p>你问 PHP 是什么?为什么不问问神奇海螺呢?</p>
|
||||
</body>
|
||||
</html>
|
||||
<?php endif;
|
||||
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
require "$dir/libraries/autoloader.php";
|
||||
$step = isset($_GET['step']) ? $_GET['step'] : 1;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<title>Blessing Skin Server 安装程序</title>
|
||||
<link rel="stylesheet" type="text/css" href="../assets/css/install.style.css">
|
||||
</head>
|
||||
<body class="container">
|
||||
<p id="logo"><a href="https://github.com/printempw/blessing-skin-server" tabindex="-1">Blessing Skin Server</a></p>
|
||||
<?php
|
||||
|
||||
// use error control to hide shitty connect warnings
|
||||
error_reporting(0);
|
||||
$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWD, DB_NAME, DB_PORT);
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
|
||||
if ($conn->connect_error): ?>
|
||||
<h1>MySQL 连接错误</h1>
|
||||
<p>无法连接至 MySQL 服务器,确定你在 config.php 填写的数据库信息正确吗?</p>
|
||||
<p>详细信息:<?php echo $conn->connect_error; ?></p>
|
||||
<?php exit; endif;
|
||||
$conn->query("SET names 'utf8'");
|
||||
|
||||
if (Database\Database::checkTableExist($conn)): ?>
|
||||
<h1>已安装过</h1>
|
||||
<p>Blessing Skin Server 看起来已经安装妥当。如果想重新安装,请删除数据库中的旧数据表,或者换一个数据表前缀。</p>
|
||||
<p class="step"><a href="../index.php" class="button button-large">返回首页</a></p>
|
||||
<?php exit; endif;
|
||||
|
||||
/*
|
||||
* Stepped installation
|
||||
*/
|
||||
switch ($step) {
|
||||
// Step 1
|
||||
case 1: ?>
|
||||
|
||||
<h1>欢迎</h1>
|
||||
<p>欢迎使用 Blessing Skin Server V2!</p>
|
||||
<p>成功连接至 MySQL 服务器 <?php echo DB_USER."@".DB_HOST; ?>,点击下一步以开始安装。</p>
|
||||
<p class="step"><a href="?step=2" class="button button-large">下一步</a></p>
|
||||
<?php break;
|
||||
|
||||
// Step 2
|
||||
case 2: ?>
|
||||
<h1>功能检查</h1>
|
||||
<p>我们需要做一些检查来确保你可以正常使用 Blessing Skin Server。</p>
|
||||
|
||||
<?php
|
||||
$fails = 0;
|
||||
|
||||
function checkFunc($func_name) {
|
||||
global $fails;
|
||||
if (function_exists($func_name)) {
|
||||
return '<span class="result passed">可用</span>';
|
||||
} else {
|
||||
$fails++;
|
||||
return '<span class="result failed">不支持</span>';
|
||||
}
|
||||
}
|
||||
|
||||
function checkClass($classname) {
|
||||
global $fails;
|
||||
if (class_exists($classname)) {
|
||||
return '<span class="result passed">可用</span>';
|
||||
} else {
|
||||
$fails++;
|
||||
return '<span class="result failed">不支持</span>';
|
||||
}
|
||||
}
|
||||
|
||||
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 '<span class="result passed">可用</span>';
|
||||
} else {
|
||||
$fails++;
|
||||
return '<span class="result failed">不支持</span>';
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="test">
|
||||
<span class="test-name">PHP 版本</span>
|
||||
<?php if (strnatcasecmp(phpversion(), '5.4') >= 0): ?>
|
||||
<span class="result passed"><?php echo phpversion(); ?></span>
|
||||
<?php else: ?>
|
||||
<span class="result failed"><?php echo phpversion(); ?></span>
|
||||
<?php $fails++; endif; ?>
|
||||
<div class="info">由于使用了一些新特性,最低需要 PHP 5.4。</div>
|
||||
</div>
|
||||
|
||||
<div class="test">
|
||||
<span class="test-name">MySQLi</span>
|
||||
<?php echo checkClass('mysqli'); ?>
|
||||
<div class="info">数据库操作。</div>
|
||||
</div>
|
||||
|
||||
<div class="test">
|
||||
<span class="test-name">重写规则</span>
|
||||
<?php echo checkRewrite(); ?>
|
||||
<div class="info">伪静态,用于支持传统皮肤获取链接。</div>
|
||||
</div>
|
||||
|
||||
<div class="test">
|
||||
<span class="test-name">JSON Encode</span>
|
||||
<?php echo checkFunc('json_encode'); ?>
|
||||
<div class="info">编码 JSON,用于支持 JSON API。</div>
|
||||
</div>
|
||||
|
||||
<div class="test">
|
||||
<span class="test-name">写入权限</span>
|
||||
<?php if (is_writable(BASE_DIR)): ?>
|
||||
<span class="result passed">可写</span>
|
||||
<?php else: ?>
|
||||
<span class="result failed">不可写</span>
|
||||
<?php $fails++; endif; ?>
|
||||
<div class="info">目前不支持 SAE 等不可写应用引擎。</div>
|
||||
</div>
|
||||
|
||||
<div class="test">
|
||||
<span class="test-name">ZipArchive</span>
|
||||
<?php echo checkClass('ZipArchive'); ?>
|
||||
<div class="info">解压缩,用于自动升级。</div>
|
||||
</div>
|
||||
|
||||
<div class="test">
|
||||
<span class="test-name">cURL</span>
|
||||
<?php echo checkFunc('curl_exec'); ?>
|
||||
<div class="info">抓取网页,用于自动升级。</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($fails == 0) {
|
||||
echo '<p class="step"><a href="install.php" class="button button-large">下一步</a></p>';
|
||||
} else {
|
||||
echo '<p class="step"><a disabled="disabled" class="button button-large">下一步</a></p>';
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php }
|
@ -3,31 +3,11 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-16 23:01:33
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-03-26 19:44:57
|
||||
* @Last Modified time: 2016-03-27 14:59:05
|
||||
*
|
||||
* Blessing Skin Server Installer
|
||||
*/
|
||||
|
||||
// Sanity check
|
||||
if (false): ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<title>出现错误 - Blessing Skin Server 安装程序</title>
|
||||
<link rel="stylesheet" type="text/css" href="../assets/css/install.style.css">
|
||||
</head>
|
||||
<body class="container">
|
||||
<p id="logo"><a href="https://github.com/printempw/blessing-skin-server" tabindex="-1">Blessing Skin Server</a></p>
|
||||
<h1>错误:PHP 未运行</h1>
|
||||
<p>Blessing Skin Server 基于 PHP 开发,需要 PHP 运行环境。如果你看到这段话就说明主机的 PHP 未运行。</p>
|
||||
<p>你问 PHP 是什么?为什么不问问神奇海螺呢?</p>
|
||||
</body>
|
||||
</html>
|
||||
<?php endif;
|
||||
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
require "$dir/libraries/autoloader.php";
|
||||
$step = isset($_GET['step']) ? $_GET['step'] : 1;
|
||||
@ -45,12 +25,6 @@ $step = isset($_GET['step']) ? $_GET['step'] : 1;
|
||||
<p id="logo"><a href="https://github.com/printempw/blessing-skin-server" tabindex="-1">Blessing Skin Server</a></p>
|
||||
<?php
|
||||
|
||||
// if php version < 5.4
|
||||
if (strnatcasecmp(phpversion(), '5.4') < 0): ?>
|
||||
<h1>PHP 版本过低</h1>
|
||||
<p>由于使用了一些新特性,Blessing Skin Server 需要 PHP 版本 >= 5.4。您当前的 PHP 版本为 <?php echo phpversion(); ?></p>
|
||||
<?php exit; endif;
|
||||
|
||||
// use error control to hide shitty connect warnings
|
||||
error_reporting(0);
|
||||
$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWD, DB_NAME, DB_PORT);
|
||||
@ -73,19 +47,12 @@ if (Database\Database::checkTableExist($conn)): ?>
|
||||
* Stepped installation
|
||||
*/
|
||||
switch ($step) {
|
||||
|
||||
// Step 1
|
||||
case 1: ?>
|
||||
<h1>欢迎</h1>
|
||||
<p>欢迎使用 Blessing Skin Server V2!</p>
|
||||
<p>成功连接至 MySQL 服务器 <?php echo DB_USER."@".DB_HOST; ?>,点击下一步以开始安装。</p>
|
||||
<p class="step"><a href="install.php?step=2" class="button button-large">下一步</a></p>
|
||||
<?php break;
|
||||
|
||||
// Step 2
|
||||
case 2: ?>
|
||||
<h1>填写信息</h1>
|
||||
<p>您需要填写一些基本信息。无需担心填错,这些信息以后可以再次修改。</p>
|
||||
<form id="setup" method="post" action="install.php?step=3" novalidate="novalidate">
|
||||
<form id="setup" method="post" action="install.php?step=2" novalidate="novalidate">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label for="username">管理员用户名</label></th>
|
||||
@ -131,8 +98,8 @@ case 2: ?>
|
||||
</form>
|
||||
<?php break;
|
||||
|
||||
// Step 3
|
||||
case 3:
|
||||
// Step 2
|
||||
case 2:
|
||||
// check post
|
||||
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['password2'])) {
|
||||
if ($_POST['password'] != $_POST['password2']) {
|
||||
@ -183,17 +150,18 @@ $sql3 = "INSERT INTO `$table_options` (`option_id`, `option_name`, `option_val
|
||||
(1, 'site_url', ''),
|
||||
(2, 'site_name', '$sitename'),
|
||||
(3, 'site_description', 'Minecraft 皮肤站'),
|
||||
(4, 'user_can_register', '1'),
|
||||
(5, 'regs_per_ip', '2'),
|
||||
(6, 'api_type', '0'),
|
||||
(7, 'announcement', '这是默认的公告~'),
|
||||
(8, 'data_adapter', ''),
|
||||
(9, 'data_table_name', 'authme for example'),
|
||||
(10, 'data_column_uname', 'username'),
|
||||
(11, 'data_column_passwd', 'password'),
|
||||
(12, 'data_column_ip', 'ip'),
|
||||
(13, 'color_scheme', 'skin-blue'),
|
||||
(14, 'home_pic_url', './assets/images/bg.jpg');";
|
||||
(4, 'current_version', '2.3.4'),
|
||||
(5, 'user_can_register', '1'),
|
||||
(6, 'regs_per_ip', '2'),
|
||||
(7, 'api_type', '0'),
|
||||
(8, 'announcement', '这是默认的公告~'),
|
||||
(9, 'data_adapter', ''),
|
||||
(10, 'data_table_name', 'authme for example'),
|
||||
(11, 'data_column_uname', 'username'),
|
||||
(12, 'data_column_passwd', 'password'),
|
||||
(13, 'data_column_ip', 'ip'),
|
||||
(14, 'color_scheme', 'skin-blue'),
|
||||
(15, 'home_pic_url', './assets/images/bg.jpg');";
|
||||
|
||||
if (!$conn->query($sql1) || !$conn->query($sql2) || !$conn->query($sql3)) { ?>
|
||||
<h1>数据表创建失败</h1>
|
||||
@ -226,6 +194,7 @@ if (!is_dir("../textures/")) {
|
||||
</tr>
|
||||
</table>
|
||||
<p class="step"><a href="../index.php" class="button button-large">首页</a></p>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
<?php break;
|
||||
} ?>
|
||||
</body>
|
||||
</html>
|
@ -28,7 +28,8 @@
|
||||
#logo a, p, h1, h2 { font-weight: 400; }
|
||||
#logo, h1, h2 { padding: 0px 0px 7px; }
|
||||
p { padding-bottom: 2px; font-size: 14px; line-height: 1.5; }
|
||||
#logo a { font-family: Minecraft, sans-serif; font-size: 50px; color: #666; height: 84px; line-height: 1.3em; margin: -130px auto 25px; padding: 0; outline: 0; text-decoration: none; overflow: hidden; display: block; }
|
||||
#logo a { font-family: Minecraft, sans-serif; transition: all .2s ease-in-out; font-size: 50px; color: #666; height: 84px; line-height: 1.3em; margin: -130px auto 25px; padding: 0; outline: 0; text-decoration: none; overflow: hidden; display: block; }
|
||||
#logo a:hover { color: #42a5f5; }
|
||||
#logo { margin: 6px 0 14px; border-bottom: none; text-align: center; }
|
||||
/* Mobile phone */
|
||||
@media (max-width: 48em) {
|
||||
|
Loading…
Reference in New Issue
Block a user