mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-03-07 15:16:40 +08:00
Merge branch 'master' of https://github.com/printempw/blessing-skin-server
This commit is contained in:
commit
0686829a5e
13
README.md
13
README.md
@ -81,28 +81,33 @@ Cape: http://example.com/cape/%s.png
|
||||
|
||||
这是通过 URL 重写(伪静态)实现的,所以皮肤站目录下没有 `skin` 和 `cape` 目录也不要惊讶哦。
|
||||
|
||||
#### CustomSkinLoader 传统链接:
|
||||
#### CustomSkinLoader 13.1 版以下:
|
||||
|
||||
在 `.minecraft/CustomSkinLoader/skinurls.txt` 中添加如下地址:
|
||||
|
||||
```
|
||||
http://example.com/skin/*.png
|
||||
http://skins.minecraft.net/MinecraftSkins/*.png
|
||||
http://minecrack.fr.nf/mc/skinsminecrackd/*.png
|
||||
http://www.skinme.cc/MinecraftSkins/*.png
|
||||
```
|
||||
|
||||
在 `.minecraft/CustomSkinLoader/capeurls.txt` 中:
|
||||
注意你需要将你的皮肤站地址放在配置文件最上方以优先加载。
|
||||
|
||||
同理在 `.minecraft/CustomSkinLoader/capeurls.txt` 中加入:
|
||||
|
||||
```
|
||||
http://example.com/cape/*.png
|
||||
```
|
||||
|
||||
#### CustomSkinLoader API
|
||||
#### CustomSkinLoader 13.1
|
||||
|
||||
等待作者发布
|
||||
|
||||
常见问题:
|
||||
------------
|
||||
|
||||
####游戏中皮肤不显示?
|
||||
#### 游戏中皮肤不显示?
|
||||
|
||||
请先确认你的皮肤站 URL 重写规则已经配置正确,并且可以正常获取皮肤图片。
|
||||
|
||||
|
@ -3,30 +3,12 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-04 13:53:55
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 21:43:29
|
||||
* @Last Modified time: 2016-02-06 23:29:34
|
||||
*/
|
||||
session_start();
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
require "../includes/session.inc.php";
|
||||
|
||||
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
$_SESSION['uname'] = $_COOKIE['uname'];
|
||||
$_SESSION['token'] = $_COOKIE['token'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check token, won't allow non-admin user to access
|
||||
*/
|
||||
if (isset($_SESSION['uname'])) {
|
||||
$admin = new user($_SESSION['uname']);
|
||||
if ($_SESSION['token'] != $admin->getToken()) {
|
||||
header('Location: ../index.php?msg=无效的 token,请重新登录。');
|
||||
} else if (!$admin->is_admin) {
|
||||
header('Location: ../index.php?msg=看起来你并不是管理员');
|
||||
}
|
||||
} else {
|
||||
header('Location: ../index.php?msg=非法访问,请先登录。');
|
||||
}
|
||||
// Check token, won't allow non-admin user to access
|
||||
if (!$admin->is_admin) header('Location: ../index.php?msg=看起来你并不是管理员');
|
||||
|
||||
/*
|
||||
* No protection here,
|
||||
@ -34,7 +16,7 @@ if (isset($_SESSION['uname'])) {
|
||||
*/
|
||||
if (isset($_GET['action'])) {
|
||||
$action = $_GET['action'];
|
||||
$user = new user($_GET['uname']);
|
||||
$user = new User($_GET['uname']);
|
||||
|
||||
if ($action == "upload") {
|
||||
$type = isset($_GET['type']) ? $_GET['type'] : "skin";
|
||||
@ -48,7 +30,7 @@ if (isset($_GET['action'])) {
|
||||
$json['msg'] = "出现了奇怪的错误。。请联系作者";
|
||||
}
|
||||
} else {
|
||||
utils::raise(1, '你没有选择任何文件哦');
|
||||
Utils::raise(1, '你没有选择任何文件哦');
|
||||
}
|
||||
} else if ($action == "change") {
|
||||
if (user::checkValidPwd($_POST['passwd'])) {
|
||||
@ -66,10 +48,10 @@ if (isset($_GET['action'])) {
|
||||
$json['errno'] = 0;
|
||||
$json['msg'] = "成功地将用户 ".$_GET['uname']." 的优先皮肤模型更改为 ".$_POST['model']." 。";
|
||||
} else {
|
||||
utils::raise(1, '非法参数。');
|
||||
Utils::raise(1, '非法参数。');
|
||||
}
|
||||
} else {
|
||||
utils::raise(1, '非法参数。');
|
||||
Utils::raise(1, '非法参数。');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,30 +3,11 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-03 14:39:50
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 23:15:10
|
||||
* @Last Modified time: 2016-02-06 23:29:33
|
||||
*/
|
||||
|
||||
session_start();
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
|
||||
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
$_SESSION['uname'] = $_COOKIE['uname'];
|
||||
$_SESSION['token'] = $_COOKIE['token'];
|
||||
}
|
||||
|
||||
if (isset($_SESSION['uname'])) {
|
||||
$admin = new user($_SESSION['uname']);
|
||||
if ($_SESSION['token'] != $admin->getToken()) {
|
||||
header('Location: ../index.php?msg=无效的 token,请重新登录。');
|
||||
} else if (!$admin->is_admin) {
|
||||
header('Location: ../index.php?msg=看起来你并不是管理员');
|
||||
}
|
||||
} else {
|
||||
header('Location: ../index.php?msg=非法访问,请先登录。');
|
||||
}
|
||||
require "../includes/session.inc.php";
|
||||
if (!$admin->is_admin) header('Location: ../index.php?msg=看起来你并不是管理员');
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -76,7 +57,7 @@ if (isset($_SESSION['uname'])) {
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$db = new database();
|
||||
$db = new Database();
|
||||
$result = $db->query("SELECT * FROM users");
|
||||
while ($row = $result->fetch_array()) { ?>
|
||||
<tr>
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-16 23:01:33
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 21:41:55
|
||||
* @Last Modified time: 2016-02-06 23:06:23
|
||||
*
|
||||
* Create tables automatically
|
||||
*/
|
||||
@ -19,7 +19,7 @@ if (!file_exists("./install.lock")) {
|
||||
echo "<h2>Blessing Skin Server 安装程序</h2>";
|
||||
|
||||
if ($conn->connect_error) {
|
||||
utils::raise(-1, "无法连接至 MySQL 服务器,确定你在 config.php 填写的数据库信息正确吗?".$conn->connect_error);
|
||||
Utils::raise(-1, "无法连接至 MySQL 服务器,确定你在 config.php 填写的数据库信息正确吗?".$conn->connect_error);
|
||||
} else {
|
||||
echo "成功连接至 MySQL 服务器 ".DB_USER."@".DB_HOST."。 <br /><br />";
|
||||
}
|
||||
|
40
ajax.php
40
ajax.php
@ -3,7 +3,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-16 23:01:33
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 21:23:27
|
||||
* @Last Modified time: 2016-02-06 23:12:17
|
||||
*
|
||||
* - login, register, logout
|
||||
* - upload, change, delete
|
||||
@ -17,17 +17,17 @@ header('Content-type: application/json');
|
||||
|
||||
$dir = dirname(__FILE__);
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
database::checkConfig();
|
||||
Database::checkConfig();
|
||||
|
||||
if (isset($_POST['uname'])) {
|
||||
$uname = $_POST['uname'];
|
||||
if (user::checkValidUname($uname)) {
|
||||
$user = new user($_POST['uname']);
|
||||
$user = new User($_POST['uname']);
|
||||
} else {
|
||||
utils::raise(1, '无效的用户名。用户名只能包含数字,字母以及下划线。');
|
||||
Utils::raise(1, '无效的用户名。用户名只能包含数字,字母以及下划线。');
|
||||
}
|
||||
} else {
|
||||
utils::raise('1', '空用户名。');
|
||||
Utils::raise('1', '空用户名。');
|
||||
}
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : null;
|
||||
$json = null;
|
||||
@ -100,9 +100,9 @@ function checkPost() {
|
||||
* Handle request from user/index.php
|
||||
*/
|
||||
if ($action == "upload") {
|
||||
if (utils::getValue('token', $_SESSION) == $user->getToken()) {
|
||||
if (Utils::getValue('token', $_SESSION) == $user->getToken()) {
|
||||
if (checkFile()) {
|
||||
if ($file = utils::getValue('skin_file', $_FILES)) {
|
||||
if ($file = Utils::getValue('skin_file', $_FILES)) {
|
||||
$model = (isset($_GET['model']) && $_GET['model'] == "steve") ? "steve" : "alex";
|
||||
if ($user->setTexture($model, $file)) {
|
||||
$json['skin']['errno'] = 0;
|
||||
@ -112,7 +112,7 @@ if ($action == "upload") {
|
||||
$json['skin']['msg'] = "出现了奇怪的错误。。请联系作者 :(";
|
||||
}
|
||||
}
|
||||
if ($file = utils::getValue('cape_file', $_FILES)) {
|
||||
if ($file = Utils::getValue('cape_file', $_FILES)) {
|
||||
if ($user->setTexture('cape', $file)) {
|
||||
$json['cape']['errno'] = 0;
|
||||
$json['cape']['msg'] = "披风上传成功!";
|
||||
@ -127,7 +127,7 @@ if ($action == "upload") {
|
||||
$json['msg'] = "无效的 token,请先登录。";
|
||||
}
|
||||
} else if ($action == "model") {
|
||||
if (utils::getValue('token', $_SESSION) == $user->getToken()) {
|
||||
if (Utils::getValue('token', $_SESSION) == $user->getToken()) {
|
||||
$new_model = ($user->getPreference() == "default") ? "slim" : "default";
|
||||
$user->setPreference($new_model);
|
||||
$json['errno'] = 0;
|
||||
@ -141,7 +141,7 @@ if ($action == "upload") {
|
||||
function checkFile() {
|
||||
global $json;
|
||||
|
||||
if (!(utils::getValue('skin_file', $_FILES) || utils::getValue('cape_file', $_FILES))) {
|
||||
if (!(Utils::getValue('skin_file', $_FILES) || Utils::getValue('cape_file', $_FILES))) {
|
||||
$json['errno'] = 1;
|
||||
$json['msg'] = "什么文件都没有诶?";
|
||||
return false;
|
||||
@ -149,15 +149,16 @@ function checkFile() {
|
||||
/**
|
||||
* Check for skin_file
|
||||
*/
|
||||
if ((utils::getValue('skin_file', $_FILES)["type"] == "image/png") || (utils::getValue('skin_file', $_FILES)["type"] == "image/x-png")) {
|
||||
if ((Utils::getValue('skin_file', $_FILES)["type"] == "image/png") ||
|
||||
(Utils::getValue('skin_file', $_FILES)["type"] == "image/x-png")) {
|
||||
// if error occured while uploading file
|
||||
if (utils::getValue('skin_file', $_FILES)["error"] > 0) {
|
||||
if (Utils::getValue('skin_file', $_FILES)["error"] > 0) {
|
||||
$json['errno'] = 1;
|
||||
$json['msg'] = utils::getValue('skin_file', $_FILES)["error"];
|
||||
$json['msg'] = Utils::getValue('skin_file', $_FILES)["error"];
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (utils::getValue('skin_file', $_FILES)) {
|
||||
if (Utils::getValue('skin_file', $_FILES)) {
|
||||
$json['errno'] = 1;
|
||||
$json['msg'] = '错误的皮肤文件类型。';
|
||||
return false;
|
||||
@ -170,15 +171,16 @@ function checkFile() {
|
||||
/**
|
||||
* Check for cape_file
|
||||
*/
|
||||
if ((utils::getValue('cape_file', $_FILES)["type"] == "image/png") || (utils::getValue('cape_file', $_FILES)["type"] == "image/x-png")) {
|
||||
if ((Utils::getValue('cape_file', $_FILES)["type"] == "image/png") ||
|
||||
(Utils::getValue('cape_file', $_FILES)["type"] == "image/x-png")) {
|
||||
// if error occured while uploading file
|
||||
if (utils::getValue('cape_file', $_FILES)["error"] > 0) {
|
||||
if (Utils::getValue('cape_file', $_FILES)["error"] > 0) {
|
||||
$json['errno'] = 1;
|
||||
$json['msg'] = utils::getValue('cape_file', $_FILES)["error"];
|
||||
$json['msg'] = Utils::getValue('cape_file', $_FILES)["error"];
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (utils::getValue('cape_file', $_FILES)) {
|
||||
if (Utils::getValue('cape_file', $_FILES)) {
|
||||
$json['errno'] = 1;
|
||||
$json['msg'] = '错误的披风文件类型。';
|
||||
return false;
|
||||
@ -228,7 +230,7 @@ if ($action == "change") {
|
||||
$json['msg'] = "无效的 token,请先登录。";
|
||||
}
|
||||
} else if ($action == "logout") {
|
||||
if (utils::getValue('token', $_SESSION)) {
|
||||
if (Utils::getValue('token', $_SESSION)) {
|
||||
session_destroy();
|
||||
$json['errno'] = 0;
|
||||
$json['msg'] = 'Session 成功销毁。';
|
||||
|
10
get.php
10
get.php
@ -3,7 +3,7 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-02 20:56:42
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-06 21:51:19
|
||||
* @Last Modified time: 2016-02-06 23:06:26
|
||||
*
|
||||
* All textures requests of legacy link will be handle here.
|
||||
*/
|
||||
@ -12,8 +12,8 @@ $dir = dirname(__FILE__);
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
|
||||
if (isset($_GET['type']) && isset($_GET['uname'])) {
|
||||
$user = new user($_GET['uname']);
|
||||
if (!$user->is_registered) utils::raise(1, 'Non-existent user.');
|
||||
$user = new User($_GET['uname']);
|
||||
if (!$user->is_registered) Utils::raise(1, 'Non-existent user.');
|
||||
// Cache friendly
|
||||
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : null;
|
||||
|
||||
@ -36,8 +36,8 @@ if (isset($_GET['type']) && isset($_GET['uname'])) {
|
||||
echo $user->getJsonProfile(API_TYPE);
|
||||
}
|
||||
} else {
|
||||
utils::raise(1, 'Illegal parameters.');
|
||||
Utils::raise(1, 'Illegal parameters.');
|
||||
}
|
||||
} else {
|
||||
utils::raise(1, 'Illegal parameters.');
|
||||
Utils::raise(1, 'Illegal parameters.');
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-02-02 21:59:06
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-03 15:55:17
|
||||
* @Last Modified time: 2016-02-06 23:06:30
|
||||
*/
|
||||
|
||||
class database
|
||||
class Database
|
||||
{
|
||||
private $connection = null;
|
||||
|
||||
@ -17,16 +17,16 @@ class database
|
||||
public static function checkConfig() {
|
||||
$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWD, DB_NAME);
|
||||
if ($conn->connect_error) {
|
||||
utils::raise(-1, "Can not connect to mysql, check if database info correct in config.php. ".
|
||||
Utils::raise(-1, "Can not connect to mysql, check if database info correct in config.php. ".
|
||||
$conn->connect_error);
|
||||
}
|
||||
if (!self::checkTableExist($conn)) {
|
||||
utils::raise(-1, "Looks like that there is no `users` table in your database. ".
|
||||
Utils::raise(-1, "Looks like that there is no `users` table in your database. ".
|
||||
"Please run `/admin/install.php` first.");
|
||||
}
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
if (!is_dir("$dir/textures/")) {
|
||||
utils::raise(-1, "No `textures` directory exists. Please run `/admin/install.php` ".
|
||||
Utils::raise(-1, "No `textures` directory exists. Please run `/admin/install.php` ".
|
||||
"or put one manually.");
|
||||
}
|
||||
return $conn;
|
||||
@ -44,7 +44,7 @@ class database
|
||||
if (!$this->connection->error) {
|
||||
return $result;
|
||||
}
|
||||
utils::raise(-1, "Database query error: ".$this->connection->error);
|
||||
Utils::raise(-1, "Database query error: ".$this->connection->error);
|
||||
}
|
||||
|
||||
public function fetchArray($sql) {
|
||||
|
24
includes/session.inc.php
Normal file
24
includes/session.inc.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-06 23:18:49
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-06 23:27:48
|
||||
*/
|
||||
session_start();
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
|
||||
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
$_SESSION['uname'] = $_COOKIE['uname'];
|
||||
$_SESSION['token'] = $_COOKIE['token'];
|
||||
}
|
||||
|
||||
if (isset($_SESSION['uname'])) {
|
||||
$user = new User($_SESSION['uname']);
|
||||
if ($_SESSION['token'] != $user->getToken()) {
|
||||
header('Location: ../index.php?msg=无效的 token,请重新登录。');
|
||||
}
|
||||
} else {
|
||||
header('Location: ../index.php?msg=非法访问,请先登录。');
|
||||
}
|
@ -3,10 +3,10 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-16 23:01:33
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-06 21:34:21
|
||||
* @Last Modified time: 2016-02-06 23:32:13
|
||||
*/
|
||||
|
||||
class user
|
||||
class User
|
||||
{
|
||||
private $uname = "";
|
||||
private $passwd = "";
|
||||
@ -17,8 +17,8 @@ class user
|
||||
public $is_admin = false;
|
||||
|
||||
function __construct($uname) {
|
||||
$this->uname = utils::convertString($uname);
|
||||
$this->db = new database();
|
||||
$this->uname = Utils::convertString($uname);
|
||||
$this->db = new Database();
|
||||
if ($this->db->checkRecordExist('username', $this->uname)) {
|
||||
$this->passwd = $this->db->select('username', $this->uname)['password'];
|
||||
$this->token = md5($this->uname . $this->passwd.SALT);
|
||||
@ -43,9 +43,9 @@ class user
|
||||
|
||||
public static function checkValidPwd($passwd) {
|
||||
if (strlen($passwd) > 16 || strlen($passwd) < 5) {
|
||||
utils::raise(1, '无效的密码。密码长度应该大于 6 并小于 15。');
|
||||
} else if (utils::convertString($passwd) != $passwd) {
|
||||
utils::raise(1, '无效的密码。密码中包含了奇怪的字符。');
|
||||
Utils::raise(1, '无效的密码。密码长度应该大于 6 并小于 15。');
|
||||
} else if (Utils::convertString($passwd) != $passwd) {
|
||||
Utils::raise(1, '无效的密码。密码中包含了奇怪的字符。');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -68,11 +68,11 @@ class user
|
||||
|
||||
public function unRegister() {
|
||||
if ($this->getTexture('steve') != "")
|
||||
utils::remove("./textures/".$this->getTexture('steve'));
|
||||
Utils::remove("./textures/".$this->getTexture('steve'));
|
||||
if ($this->getTexture('alex') != "")
|
||||
utils::remove("./textures/".$this->getTexture('alex'));
|
||||
Utils::remove("./textures/".$this->getTexture('alex'));
|
||||
if ($this->getTexture('cape') != "")
|
||||
utils::remove("./textures/".$this->getTexture('cape'));
|
||||
Utils::remove("./textures/".$this->getTexture('cape'));
|
||||
return $this->db->delete($this->uname);
|
||||
}
|
||||
|
||||
@ -96,17 +96,17 @@ class user
|
||||
// Cache friendly
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->getLastModified()).' GMT');
|
||||
header('Content-Length: '.filesize($filename));
|
||||
return utils::fread($filename);
|
||||
return Utils::fread($filename);
|
||||
} else {
|
||||
utils::raise(-1, 'Texture no longer exists.');
|
||||
Utils::raise(-1, 'Texture no longer exists.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setTexture($type, $file) {
|
||||
$hash = utils::upload($file);
|
||||
$hash = Utils::upload($file);
|
||||
// Remove the original texture first
|
||||
if ($this->getTexture($type) != "")
|
||||
utils::remove("./textures/".$this->getTexture($type));
|
||||
Utils::remove("./textures/".$this->getTexture($type));
|
||||
$this->updateLastModified();
|
||||
if ($type == "steve" | $type == "alex" | $type == "cape")
|
||||
return $this->db->update($this->uname, 'hash_'.$type, $hash);
|
||||
@ -147,13 +147,13 @@ class user
|
||||
$json['skins'][$sec_model] = $this->getTexture($sec_model == "default" ? "steve" : "alex");
|
||||
$json['cape'] = $this->getTexture('cape');
|
||||
} else {
|
||||
utils::raise(-1, '配置文件错误:不支持的 API_TYPE。');
|
||||
Utils::raise(-1, '配置文件错误:不支持的 API_TYPE。');
|
||||
}
|
||||
} else {
|
||||
$json['errno'] = 1;
|
||||
$json['msg'] = "Non-existent user.";
|
||||
}
|
||||
return json_encode($json);
|
||||
return json_encode($json, JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
public function updateLastModified() {
|
||||
|
10
index.php
10
index.php
@ -3,16 +3,16 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-17 13:55:20
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 23:14:59
|
||||
* @Last Modified time: 2016-02-06 23:06:24
|
||||
*/
|
||||
session_start();
|
||||
$dir = dirname(__FILE__);
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
|
||||
database::checkConfig();
|
||||
Database::checkConfig();
|
||||
// Auto load cookie value to session
|
||||
if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
$user = new user($_COOKIE['uname']);
|
||||
$user = new User($_COOKIE['uname']);
|
||||
if ($_COOKIE['token'] == $user->getToken()) {
|
||||
$_SESSION['uname'] = $_COOKIE['uname'];
|
||||
$_SESSION['token'] = $user->getToken();
|
||||
@ -62,7 +62,7 @@ if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
<p class="splash-subhead">
|
||||
开源的 PHP Minecraft 皮肤站
|
||||
</p>
|
||||
<?php if (!utils::getValue('uname', $_SESSION)) { ?>
|
||||
<?php if (!Utils::getValue('uname', $_SESSION)) { ?>
|
||||
<p>
|
||||
<a id="register" href="javascript:;" class="pure-button pure-button-primary">现在注册</a>
|
||||
</p>
|
||||
@ -109,7 +109,7 @@ if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
<script type="text/javascript" src="./assets/js/utils.js"></script>
|
||||
<script type="text/javascript" src="./assets/js/index.utils.js"></script>
|
||||
<?php
|
||||
if ($msg = utils::getValue('msg', $_GET)) { ?>
|
||||
if ($msg = Utils::getValue('msg', $_GET)) { ?>
|
||||
<script type="text/javascript"> showAlert("<?php echo $msg; ?>"); </script>
|
||||
<?php } ?>
|
||||
</body>
|
||||
|
@ -5,25 +5,8 @@
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-01-21 20:40:04
|
||||
*/
|
||||
session_start();
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
|
||||
require "../includes/session.inc.php";
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : "";
|
||||
|
||||
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
$_SESSION['uname'] = $_COOKIE['uname'];
|
||||
$_SESSION['token'] = $_COOKIE['token'];
|
||||
}
|
||||
|
||||
if (isset($_SESSION['uname'])) {
|
||||
$user = new user($_SESSION['uname']);
|
||||
if ($_SESSION['token'] != $user->getToken()) {
|
||||
header('Location: ../index.php?msg=无效的 token,请重新登录。');
|
||||
}
|
||||
} else {
|
||||
header('Location: ../index.php?msg=非法访问,请先登录。');
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -3,10 +3,9 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-04 19:37:21
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 15:02:52
|
||||
* @Last Modified time: 2016-02-06 23:24:56
|
||||
*/
|
||||
?>
|
||||
|
||||
<div id="skinpreview"></div>
|
||||
<script type="text/javascript" src="../libs/three.js"></script>
|
||||
<script type="text/javascript" src="../libs/three.msp.js"></script>
|
||||
@ -22,4 +21,4 @@ echo "<script>MSP.changeSkin(dskin);</script>";
|
||||
if ($user->getTexture('cape')) {
|
||||
echo "<script>var dcape ='../textures/".$user->getTexture('cape')."';</script>";
|
||||
echo "<script>MSP.changeCape(dcape);</script>";
|
||||
} ?>
|
||||
}
|
||||
|
@ -3,26 +3,9 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-03 16:12:45
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 23:14:47
|
||||
* @Last Modified time: 2016-02-06 23:29:32
|
||||
*/
|
||||
|
||||
session_start();
|
||||
$dir = dirname(dirname(__FILE__));
|
||||
require "$dir/includes/autoload.inc.php";
|
||||
|
||||
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
|
||||
$_SESSION['uname'] = $_COOKIE['uname'];
|
||||
$_SESSION['token'] = $_COOKIE['token'];
|
||||
}
|
||||
|
||||
if (isset($_SESSION['uname'])) {
|
||||
$user = new user($_SESSION['uname']);
|
||||
if ($_SESSION['token'] != $user->getToken()) {
|
||||
header('Location: ../index.php?msg=无效的 token,请重新登录。');
|
||||
}
|
||||
} else {
|
||||
header('Location: ../index.php?msg=非法访问,请先登录。');
|
||||
}
|
||||
require "../includes/session.inc.php";
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
Loading…
Reference in New Issue
Block a user