diff --git a/README.md b/README.md index c69a9b88..08715990 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Blessing Skin Server -Just a simple open-source Minecraft skin server write in PHP. [Live demo](https://work.prinzeugen.net/blessing-skin-server/) +优雅的开源 PHP Minecraft 皮肤站。[Live demo](https://work.prinzeugen.net/blessing-skin-server/) ![screenshot](https://img.prinzeugen.net/image.php?di=FIQD) diff --git a/README_en-US.md b/README_en-US.md new file mode 100644 index 00000000..c69a9b88 --- /dev/null +++ b/README_en-US.md @@ -0,0 +1,109 @@ +# Blessing Skin Server + +Just a simple open-source Minecraft skin server write in PHP. [Live demo](https://work.prinzeugen.net/blessing-skin-server/) + +![screenshot](https://img.prinzeugen.net/image.php?di=FIQD) + +Features: +----------- + +- Support latest [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/blob/master/doc/UniSkinAPI_zh-CN.md) +- Support CustomSkinLoader API +- Also support legacy link to access image directly +- Nothing else... + +Installation: +----------- + +1. Configure your database information in config.php +2. Run `./admin/install.php` +3. Configure your rewrite rules in your `nginx.conf` +3. Register or login with `admin/123456` +4. Upload your skin/cape +5. Configure your url in `UniSkinMod.cfg` of Minecraft client +6. Enjoy~ + +Server configure: +------------ + +Add rewrite rules to your nginx.conf: + +``` +rewrite ^/([^/]*).json$ /get.php?type=json&uname=$1 last; +rewrite ^/(skin|cape)/([^/-]*)(|-)(|alex|steve).png$ /get.php?type=$1&model=$4&uname=$2 last; +# Optional +rewrite ^/(usm|csl)/([^/]*).json$ /get.php?type=json&uname=$2&api=$1 last; +rewrite ^/(usm|csl)/textures/(.*)$ /textures/$2 last; +``` +You can also use optional rewrite rules to support both CustomSkinLoader API & UniSkinAPI. + +If you installed the skin server to subdirectory, you should configure the rules as this: + +``` +rewrite ^/subdir/([^/]*).json$ /subdir/get.php?type=json&uname=$1 last; +``` + +Now you can access `http://example.com/username.json` to get your json profile of your preferred API. Another API is also available `http://example.com/(usm|csl)/username.json`. + +After uploading skins, you can also access `http://example.com/skin/username.png` for prefered model's skin image or `http://example.com/cape/username.png` for cape. Secondary model's texture is available on `http://example.com/skin/username-(alex|steve).png`. + +Client configure: +------------ + +#### For UniSkinMod version >= 1.3 + +Put your root directory of skin server( like `/path/to/root` above ) into your `/config/UniSkinMod.cfg` of Minecraft client + +Sample: + +``` +# Line starts with '#' is a commit line +# Line starts with 'Root: ' indicates a server +# All servers will be queried in that order. +# Server in front has higher priority +# Official server has the lowest priority +# No more legacy style link support! + +# SkinMe Default +Root: http://www.skinme.cc/uniskin +# Your Server +Root: http://example.com +``` + +#### For UniSkinMod version < 1.3 or other + +Also put your url into `/config/UniSkinMod.cfg`, but you need to fill 2 urls for skin and cape + +Sample: + +``` +Version: 1 +# Do not edit the line above + +Skin: http://skins.minecraft.net/MinecraftSkins/%s.png +Cape: http://skins.minecraft.net/MinecraftCloaks/%s.png +# Your Server +Skin: http://example.com/skin/%s.png +Cape: http://example.com/cape/%s.png +``` + +FAQ +------------ + +If everything works well, you will get an awesome skin in game: + +![screenshot2](https://img.prinzeugen.net/image.php?di=EV1E) + +And the log will be like this: + +``` +[16:23:56] [launcher/INFO] [UniSkinMod]: Loading configuration ... @D:\Minecraft\1.8\.minecraft\config\UniSkinMod.cfg +[16:23:56] [launcher/INFO] [UniSkinMod]: Root Url Added: http://127.0.0.1/blessing-skin-server + +[16:24:23] [Client thread/INFO] [UniSkinMod]: Filling profile for player: 621sama +[16:24:23] [Client thread/INFO] [UniSkinMod]: Fetching URL: http://127.0.0.1/blessing-skin-server/621sama.json +[16:24:23] [Client thread/INFO] [UniSkinMod]: Player Skin Selected: 621sama default 3f14a21723023642b9e8d2bc008b443780698aaedbb7d4e29960e8a2c754a771 +[16:24:23] [Client thread/INFO] [UniSkinMod]: Player Cape Selected: 621sama aed8c3fc67aae4906b72fa74c27e15866c89752f0838f6b2a1c44bb4d59cec1e +``` + +If not, please check your log to locate where error occured. diff --git a/admin/admin_ajax.php b/admin/admin_ajax.php index 070cdc5c..fb710cf2 100644 --- a/admin/admin_ajax.php +++ b/admin/admin_ajax.php @@ -3,7 +3,7 @@ * @Author: prpr * @Date: 2016-02-04 13:53:55 * @Last Modified by: prpr - * @Last Modified time: 2016-02-04 18:42:22 + * @Last Modified time: 2016-02-05 21:43:29 */ session_start(); $dir = dirname(dirname(__FILE__)); @@ -20,12 +20,12 @@ if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) { if (isset($_SESSION['uname'])) { $admin = new user($_SESSION['uname']); if ($_SESSION['token'] != $admin->getToken()) { - header('Location: ../index.php?msg=Invalid token. Please login.'); + header('Location: ../index.php?msg=无效的 token,请重新登录。'); } else if (!$admin->is_admin) { - header('Location: ../index.php?msg=Looks like that you are not administrator :('); + header('Location: ../index.php?msg=看起来你并不是管理员'); } } else { - header('Location: ../index.php?msg=Illegal access. Please login.'); + header('Location: ../index.php?msg=非法访问,请先登录。'); } /* @@ -42,34 +42,34 @@ if (isset($_GET['action'])) { if (!is_null($file)) { if ($user->setTexture($type, $file)) { $json['errno'] = 0; - $json['msg'] = "Skin uploaded successfully."; + $json['msg'] = "皮肤上传成功。"; } else { $json['errno'] = 1; - $json['msg'] = "Uncaught error."; + $json['msg'] = "出现了奇怪的错误。。请联系作者"; } } else { - utils::raise(1, 'No input file selected'); + utils::raise(1, '你没有选择任何文件哦'); } } else if ($action == "change") { if (user::checkValidPwd($_POST['passwd'])) { $user->changePasswd($_POST['passwd']); $json['errno'] = 0; - $json['msg'] = "Password of ".$_GET['uname']." changed successfully."; + $json['msg'] = "成功更改了 ".$_GET['uname']." 的密码。"; } // Will raise exception if password invalid } else if ($action == "delete") { $user->unRegister(); $json['errno'] = 0; - $json['msg'] = "Account successfully deleted."; + $json['msg'] = "成功删除了该用户。"; } else if ($action == "model") { if (isset($_POST['model']) && $_POST['model'] == 'slim' || $_POST['model'] == 'default') { $user->setPreference($_POST['model']); $json['errno'] = 0; - $json['msg'] = "Model preference of ".$_GET['uname']." changed to ".$_POST['model']." successfully."; + $json['msg'] = "成功地将用户 ".$_GET['uname']." 的优先皮肤模型更改为 ".$_POST['model']." 。"; } else { - utils::raise(1, 'Illegal parameters'); + utils::raise(1, '非法参数。'); } } else { - utils::raise(1, 'Illegal parameters'); + utils::raise(1, '非法参数。'); } } diff --git a/admin/index.php b/admin/index.php index 2b62a500..85f1ece7 100644 --- a/admin/index.php +++ b/admin/index.php @@ -3,7 +3,7 @@ * @Author: prpr * @Date: 2016-02-03 14:39:50 * @Last Modified by: prpr - * @Last Modified time: 2016-02-05 16:05:42 + * @Last Modified time: 2016-02-05 21:44:08 */ session_start(); @@ -18,12 +18,12 @@ if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) { if (isset($_SESSION['uname'])) { $admin = new user($_SESSION['uname']); if ($_SESSION['token'] != $admin->getToken()) { - header('Location: ../index.php?msg=Invalid token. Please login.'); + header('Location: ../index.php?msg=无效的 token,请重新登录。'); } else if (!$admin->is_admin) { - header('Location: ../index.php?msg=Looks like that you are not administrator :('); + header('Location: ../index.php?msg=看起来你并不是管理员'); } } else { - header('Location: ../index.php?msg=Illegal access. Please login.'); + header('Location: ../index.php?msg=非法访问,请先登录。'); } ?> @@ -32,7 +32,7 @@ if (isset($_SESSION['uname'])) { - Console - <?php echo SITE_TITLE; ?> + 仪表盘 - <?php echo SITE_TITLE; ?> @@ -48,10 +48,10 @@ if (isset($_SESSION['uname'])) {
@@ -67,10 +67,10 @@ if (isset($_SESSION['uname'])) { # - Username - Preview Textures - Change Textures - Opreation + 用户名 + 预览材质 + 更改材质 + 操作 @@ -88,14 +88,14 @@ if (isset($_SESSION['uname'])) { '; ?> - Skin - Cape - Model + 皮肤 + 披风 + 优先模型 () - Password - Delete + 更改密码 + 删除用户 diff --git a/admin/install.php b/admin/install.php index d361065c..40920b41 100644 --- a/admin/install.php +++ b/admin/install.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-16 23:01:33 * @Last Modified by: prpr - * @Last Modified time: 2016-02-05 12:36:34 + * @Last Modified time: 2016-02-05 21:41:55 * * Create tables automatically */ @@ -11,20 +11,20 @@ $dir = dirname(dirname(__FILE__)); require "$dir/includes/autoload.inc.php"; -echo ""; +echo ""; if (!file_exists("./install.lock")) { $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWD, DB_NAME); - echo "

Blessing Skin Server Install

"; + echo "

Blessing Skin Server 安装程序

"; if ($conn->connect_error) { - utils::raise(-1, "Can not connect to mysql, check if database info correct in config.php. ".$conn->connect_error); + utils::raise(-1, "无法连接至 MySQL 服务器,确定你在 config.php 填写的数据库信息正确吗?".$conn->connect_error); } else { - echo "Succesfully connected to database ".DB_USER."@".DB_HOST.".

"; + echo "成功连接至 MySQL 服务器 ".DB_USER."@".DB_HOST."。

"; } - echo "Start creating tables...

"; + echo "开始创建数据表。。

"; $sql = "CREATE TABLE IF NOT EXISTS `users` ( `uid` int(11) NOT NULL AUTO_INCREMENT, @@ -40,7 +40,7 @@ if (!file_exists("./install.lock")) { ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15;"; if(!$conn->query($sql)) { - die("Creating tables failed.

".$conn->error); + die("数据表创建失败了。。请带上错误信息联系作者

".$conn->error); } /** @@ -49,7 +49,7 @@ if (!file_exists("./install.lock")) { */ $conn->query("INSERT INTO `users` (`uid`, `username`, `password`, `ip`, `preference`) VALUES(1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '127.0.0.1', 'default')"); - echo "Creating tables successfully

"; + echo "数据表创建成功!

"; echo "
@@ -62,22 +62,22 @@ if (!file_exists("./install.lock")) {
 	";
 
 	if (!is_dir("../textures/")) {
-		echo mkdir("../textures/") ? "Creating textures directory...

" : - "Creating textures directory failed. Check permissons.

"; + echo mkdir("../textures/") ? "正在创建 textures 文件夹。。

" : + "文件夹创建失败。确定你的目录权限正确吗?

"; } - echo "Successfully installed. Index"; + echo "安装成功辣~ 首页"; if ($lock = fopen("./install.lock", 'w')) { fwrite($lock, time()); fclose($lock); } else { - die("Unable to write `install.lock`. Please check the permisson and create a `install.lock` file manually."); + die("无法创建自动 `install.lock`。请人工新建一个 `install.lock` 置于 `admin` 目录下。"); } } else { echo "
"; - echo "It seems that you have already installed. Index

"; - echo "May you should delete the file `install.lock` in ./admin to unlock installing."; + echo "看起来你已经安装过一次了哦? 首页

"; + echo "或许你需要删除 `admin` 文件夹下的 `install.lock` 开解锁安装程序。"; } ?> diff --git a/ajax.php b/ajax.php index bcc4f497..3d48abd2 100644 --- a/ajax.php +++ b/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 15:35:31 + * @Last Modified time: 2016-02-05 21:23:27 * * - login, register, logout * - upload, change, delete @@ -24,10 +24,10 @@ if (isset($_POST['uname'])) { if (user::checkValidUname($uname)) { $user = new user($_POST['uname']); } else { - utils::raise(1, 'Invalid username. Only letters, numbers and _ is allowed.'); + utils::raise(1, '无效的用户名。用户名只能包含数字,字母以及下划线。'); } } else { - utils::raise('1', 'Empty username.'); + utils::raise('1', '空用户名。'); } $action = isset($_GET['action']) ? $_GET['action'] : null; $json = null; @@ -39,16 +39,16 @@ if ($action == "login") { if (checkPost()) { if (!$user->is_registered) { $json['errno'] = 1; - $json['msg'] = "Non-existent user."; + $json['msg'] = "用户不存在哦"; } else { if ($user->checkPasswd($_POST['passwd'])) { $json['errno'] = 0; - $json['msg'] = 'Logging in succeed!'; + $json['msg'] = '登录成功,欢迎回来~'; $json['token'] = $user->getToken(); $_SESSION['token'] = $user->getToken(); } else { $json['errno'] = 1; - $json['msg'] = "Incorrect usename or password."; + $json['msg'] = "用户名或密码不对哦"; } } } @@ -69,19 +69,19 @@ if ($action == "login") { // use once md5 to encrypt password if ($user->register(md5($_POST['passwd']), $ip)) { $json['errno'] = 0; - $json['msg'] = "Registered successfully."; + $json['msg'] = "注册成功~"; } else { $json['errno'] = 1; - $json['msg'] = "Uncaught error."; + $json['msg'] = "出现了奇怪的错误。。请联系作者 :("; } } else { $json['errno'] = 1; - $json['msg'] = "You can't create more than ".REGS_PER_IP." accounts with this IP."; + $json['msg'] = "你最多只能注册 ".REGS_PER_IP." 个账户哦"; } } } else { $json['errno'] = 1; - $json['msg'] = "User already registered."; + $json['msg'] = "这个用户名已经被人注册辣,换一个吧"; } } } @@ -90,7 +90,7 @@ function checkPost() { global $json; if (!isset($_POST['passwd'])) { $json['errno'] = 1; - $json['msg'] = "Empty password!"; + $json['msg'] = "空密码。"; return false; } return true; @@ -106,35 +106,35 @@ if ($action == "upload") { $model = (isset($_GET['model']) && $_GET['model'] == "steve") ? "steve" : "alex"; if ($user->setTexture($model, $file)) { $json['skin']['errno'] = 0; - $json['skin']['msg'] = "Skin uploaded successfully."; + $json['skin']['msg'] = "皮肤上传成功!"; } else { $json['skin']['errno'] = 1; - $json['skin']['msg'] = "Uncaught error."; + $json['skin']['msg'] = "出现了奇怪的错误。。请联系作者 :("; } } if ($file = utils::getValue('cape_file', $_FILES)) { if ($user->setTexture('cape', $file)) { $json['cape']['errno'] = 0; - $json['cape']['msg'] = "Cape uploaded successfully."; + $json['cape']['msg'] = "披风上传成功!"; } else { $json['cape']['errno'] = 1; - $json['cape']['msg'] = "Uncaught error."; + $json['cape']['msg'] = "出现了奇怪的错误。。请联系作者 :("; } } } } else { $json['errno'] = 1; - $json['msg'] = "Invalid token."; + $json['msg'] = "无效的 token,请先登录。"; } } else if ($action == "model") { if (utils::getValue('token', $_SESSION) == $user->getToken()) { $new_model = ($user->getPreference() == "default") ? "slim" : "default"; $user->setPreference($new_model); $json['errno'] = 0; - $json['msg'] = "Preferred model successfully changed to ".$user->getPreference()."."; + $json['msg'] = "优先模型已经更改为 ".$user->getPreference()."。"; } else { $json['errno'] = 1; - $json['msg'] = "Invalid token."; + $json['msg'] = "无效的 token,请先登录。"; } } @@ -143,7 +143,7 @@ function checkFile() { if (!(utils::getValue('skin_file', $_FILES) || utils::getValue('cape_file', $_FILES))) { $json['errno'] = 1; - $json['msg'] = "No input file selected."; + $json['msg'] = "什么文件都没有诶?"; return false; } /** @@ -159,11 +159,11 @@ function checkFile() { } else { if (utils::getValue('skin_file', $_FILES)) { $json['errno'] = 1; - $json['msg'] = 'Skin file type error.'; + $json['msg'] = '错误的皮肤文件类型。'; return false; } else { $json['skin']['errno'] = 0; - $json['skin']['msg'] = 'No skin file selected.'; + $json['skin']['msg'] = '什么文件都没有诶?'; } } @@ -180,11 +180,11 @@ function checkFile() { } else { if (utils::getValue('cape_file', $_FILES)) { $json['errno'] = 1; - $json['msg'] = 'Cape file type error.'; + $json['msg'] = '错误的披风文件类型。'; return false; } else { $json['cape']['errno'] = 0; - $json['cape']['msg'] = 'No cape file selected.'; + $json['cape']['msg'] = '什么文件都没有诶?'; } } @@ -200,14 +200,14 @@ if ($action == "change") { if ($user->checkPasswd($_POST['passwd'])) { $user->changePasswd($_POST['new_passwd']); $json['errno'] = 0; - $json['msg'] = "Password updated successfully."; + $json['msg'] = "密码更改成功。请重新登录。"; } else { $json['errno'] = 1; - $json['msg'] = "Incorrect usename or password."; + $json['msg'] = "原密码不对哦?"; } } else { $json['errno'] = 1; - $json['msg'] = "New password required."; + $json['msg'] = "新密码呢?"; } } } else if ($action == "delete") { @@ -217,30 +217,30 @@ if ($action == "change") { session_destroy(); $user->unRegister(); $json['errno'] = 0; - $json['msg'] = "Account successfully deleted."; + $json['msg'] = "账号已经成功删除,再见~"; } else { $json['errno'] = 1; - $json['msg'] = "Incorrect password."; + $json['msg'] = "错误的密码。"; } } } else { $json['errno'] = 1; - $json['msg'] = "Invalid token."; + $json['msg'] = "无效的 token,请先登录。"; } } else if ($action == "logout") { if (utils::getValue('token', $_SESSION)) { session_destroy(); $json['errno'] = 0; - $json['msg'] = 'Session destroyed.'; + $json['msg'] = 'Session 成功销毁。'; } else { $json['errno'] = 1; - $json['msg'] = 'No available session.'; + $json['msg'] = '并没有任何有效的 session。'; } } if (!$action) { $json['errno'] = 1; - $json['msg'] = "Invalid parameters."; + $json['msg'] = "无效的参数。不要乱 POST 玩哦。"; } echo json_encode($json); diff --git a/assets/css/style.css b/assets/css/style.css index 07cc93ce..a50f3003 100755 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-01-21 07:57:38 * @Last Modified by: prpr -* @Last Modified time: 2016-02-04 23:15:08 +* @Last Modified time: 2016-02-05 21:13:54 */ @import url(https://fonts.googleapis.com/css?family=Ubuntu); @@ -21,7 +21,7 @@ html { line-height: 1.7em; color: #fff; font-size: 13px; - font-family: Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; + font-family: Ubuntu, 'Segoe UI', 'Microsoft Yahei', 'Microsoft Jhenghei', sans-serif; } p { @@ -164,3 +164,6 @@ p { margin-top: 100px; } } +.ply-layer { + font-family: Ubuntu, 'Segoe UI', 'Microsoft Yahei', 'Microsoft Jhenghei', sans-serif!important; +} diff --git a/assets/js/admin.utils.js b/assets/js/admin.utils.js index 386bd619..22350c09 100644 --- a/assets/js/admin.utils.js +++ b/assets/js/admin.utils.js @@ -2,14 +2,14 @@ * @Author: prpr * @Date: 2016-02-04 16:48:42 * @Last Modified by: prpr -* @Last Modified time: 2016-02-05 15:52:32 +* @Last Modified time: 2016-02-05 22:01:44 */ 'use strict'; function uploadSkin(uname) { Ply.dialog("confirm", { - text: "Which model do you want to change?", + text: "更改该用户对应哪个模型的皮肤?", ok: "Steve", cancel: "Alex" }).done(function(){ @@ -21,9 +21,9 @@ function uploadSkin(uname) { function uploadTexture(uname, type) { var ply = new Ply({ - el: '

Upload new '+type+':

'+ + el: '

为该用户上传新的 '+type+':

'+ ''+ - '', + '', effect: "fade", onaction: function(){ var form_data = new FormData(); @@ -39,11 +39,11 @@ function uploadTexture(uname, type) { processData: false, success: function(json) { if (json.errno == 0) { - showAlert("Successfully uploaded.", function(){ + showAlert("上传成功。", function(){ location.reload(); }); } else { - showAlert("Error when uploading texture:\n" + json.msg); + showAlert("上传材质的时候出错啦:\n" + json.msg); } } }); @@ -56,8 +56,8 @@ function uploadTexture(uname, type) { function changePasswd(uname) { Ply.dialog("prompt", { - title: "Type in "+uname+"'s new password", - form: { passwd: "New Password" } + title: "修改 "+uname+" 的登录密码:", + form: { passwd: "新的密码" } }).done(function(ui){ var passwd = ui.data.passwd; $.ajax({ @@ -78,7 +78,7 @@ function changePasswd(uname) { function deleteAccount(uname) { Ply.dialog("prompt", { - title: "Are you sure to delete "+uname+"?", + title: "确定要删除 "+uname+"?此操作不可恢复。", }).done(function(ui){ $.ajax({ type: "POST", @@ -99,8 +99,8 @@ function deleteAccount(uname) { function changeModel(uname) { Ply.dialog("prompt", { - title: "Change "+uname+"'s model prefrence:", - form: { text: "Type in `slim` or `default`" } + title: "修改 "+uname+" 的优先皮肤模型:", + form: { text: "输入 `slim` 或者 `default`" } }).done(function(ui){ var model = ui.data.text; if (model == 'slim'| model == 'default') { @@ -120,7 +120,7 @@ function changeModel(uname) { } }); } else { - showAlert('Only `slim` or `default` is valid.'); + showAlert('只能输入 `slim` 或者 `default` 哦'); } }); } diff --git a/assets/js/index.utils.js b/assets/js/index.utils.js index 111bacd6..f06ff2fa 100644 --- a/assets/js/index.utils.js +++ b/assets/js/index.utils.js @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-01-21 13:55:44 * @Last Modified by: prpr -* @Last Modified time: 2016-02-04 12:34:37 +* @Last Modified time: 2016-02-05 21:11:56 */ 'use strict'; @@ -17,22 +17,22 @@ var login = function() { dataType: "json", data: { "uname": uname, "passwd": passwd }, beforeSend: function() { - showMsg("alert-info", "Logging in..."); + showMsg('alert-info', '登录中。。'); }, success: function(json) { if (json.errno == 0) { - docCookies.setItem("uname", uname, null, '/'); - docCookies.setItem("token", json.token, null, '/'); - if ($("#keep").prop("checked")) { - docCookies.setItem("uname", uname, 604800, '/'); + docCookies.setItem('uname', uname, null, '/'); + docCookies.setItem('token', json.token, null, '/'); + if ($('#keep').prop('checked')) { + docCookies.setItem('uname', uname, 604800, '/'); // 设置长效 token (7天) - docCookies.setItem("token", json.token, 604800, '/'); + docCookies.setItem('token', json.token, 604800, '/'); } - showAlert("Logging succeed!"); - window.setTimeout("window.location = './user/index.php'", 1000); + showAlert(json.msg); + window.setTimeout('window.location = "./user/index.php"', 1000); } else { showAlert(json.msg); - showMsg('hide', ""); + showMsg('hide', ''); } } }); @@ -40,25 +40,25 @@ var login = function() { } var register = function() { - var uname = $("#reg-uname").val(); - var passwd = $("#reg-passwd").val(); - if (checkForm("register", uname, passwd, $("#reg-passwd2").val())) { + var uname = $('#reg-uname').val(); + var passwd = $('#reg-passwd').val(); + if (checkForm('register', uname, passwd, $('#reg-passwd2').val())) { $.ajax({ type: "POST", url: "ajax.php?action=register", dataType: "json", - data: {"uname":uname, "passwd":passwd}, + data: {'uname':uname, 'passwd':passwd}, beforeSend: function() { - showMsg("alert-info", "Registering..."); + showMsg('alert-info', 'Registering...'); }, success: function(json) { if (json.errno == 0) { showAlert(json.msg, function(){ - showMsg('hide', ""); + showMsg('hide', ''); $('[data-remodal-id=register-modal]').remodal().close(); // Automatically login after registeration - $("#uname").val(uname); - $("#passwd").val(passwd); + $('#uname').val(uname); + $('#passwd').val(passwd); login(); }); } else { @@ -74,12 +74,12 @@ function checkForm(type, uname, passwd, passwd2) { switch(type) { case "login": if (uname == "") { - showMsg("alert-warning", "Empty Username!"); + showMsg('alert-warning', '用户名不能为空哦'); $("#uname").focus(); return false; } else if (passwd == ""){ - showMsg("alert-warning", "Empty Password!"); - $("#passwd").focus(); + showMsg('alert-warning', '密码不能为空哦'); + $('#passwd').focus(); return false; } else { return true; @@ -87,20 +87,20 @@ function checkForm(type, uname, passwd, passwd2) { break; case "register": if (uname == "") { - showMsg("alert-warning", "Empty Username!"); - $("#uname").focus(); + showMsg('alert-warning', '用户名不能为空哦'); + $('#uname').focus(); return false; } else if (passwd == ""){ - showMsg("alert-warning", "Empty Password!"); - $("#passwd").focus(); + showMsg('alert-warning', '密码不能为空哦'); + $('#passwd').focus(); return false; } else if (passwd2 == ""){ - showMsg("alert-warning", "Empty Confirming Password!"); - $("#cpasswd").focus(); + showMsg('alert-warning', '确认密码不能为空'); + $('#cpasswd').focus(); return false; } else if (passwd != passwd2){ - showMsg("alert-warning", "Non-equal password confirming!"); - $("#cpasswd").focus(); + showMsg('alert-warning', '注册密码和确认密码不一样诶'); + $('#cpasswd').focus(); return false; } else { return true; @@ -120,12 +120,12 @@ $('#register').click(function(){ }) // Register Event -$("body").on("keypress", "[data-remodal-id=register-modal]", function(event){ +$('body').on('keypress', '[data-remodal-id=register-modal]', function(event){ if (event.which == 13) register(); -}).on("click", "#register-button", register); +}).on('click', '#register-button', register); // Login Event -$("body").on("keypress", "[data-remodal-id=login-modal]", function(event){ +$('body').on('keypress', '[data-remodal-id=login-modal]', function(event){ if (event.which == 13) login(); -}).on("click", "#login-button", login); +}).on('click', '#login-button', login); diff --git a/assets/js/profile.utils.js b/assets/js/profile.utils.js index 8889b96c..a8ff12e0 100644 --- a/assets/js/profile.utils.js +++ b/assets/js/profile.utils.js @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-02-03 17:21:46 * @Last Modified by: prpr -* @Last Modified time: 2016-02-03 20:25:52 +* @Last Modified time: 2016-02-05 21:23:08 */ 'use strict'; @@ -19,7 +19,7 @@ $('#change').click(function(){ success: function(json) { if (json.errno == 0) { logout(function(){ - showAlert(json.msg + " Please log in again.", function(){ + showAlert(json.msg, function(){ window.location = "../index.php"; }); }); @@ -33,20 +33,20 @@ $('#change').click(function(){ function checkForm(passwd, new_passwd, confirm_pwd) { if (passwd == ""){ - showAlert("Empty Password!"); - //$("#passwd").focus(); + showAlert("原密码不能为空"); + $("#passwd").focus(); return false; } else if (new_passwd == ""){ - showAlert("Empty New Password!"); + showAlert("新密码要好好填哦"); $("#new_passwd").focus(); return false; } else if (confirm_pwd == ""){ - showAlert("Empty Confirming Password!"); + showAlert("确认密码不能为空"); $("#confirm_pwd").focus(); return false; } else if (new_passwd != confirm_pwd){ console.log(new_passwd, confirm_pwd) - showAlert("Non-equal password confirming!"); + showAlert("新密码和确认的密码不一样诶?"); $("#confirm_pwd").focus(); return false; } else { @@ -56,7 +56,7 @@ function checkForm(passwd, new_passwd, confirm_pwd) { $('#delete').click(function(){ Ply.dialog("prompt", { - title: "Type in your password to confirm:", + title: "这是危险操作!输入密码来确认:", form: { passwd: "Password" } }).done(function(ui){ var passwd = ui.data.passwd; @@ -69,7 +69,7 @@ $('#delete').click(function(){ if (json.errno == 0) { docCookies.removeItem("uname", "/"); docCookies.removeItem("token", "/"); - showAlert(json.msg + " Bye~", function(){ + showAlert(json.msg, function(){ window.location = "../index.php"; }); } else { diff --git a/assets/js/user.utils.js b/assets/js/user.utils.js index ceda2f16..f343b64d 100644 --- a/assets/js/user.utils.js +++ b/assets/js/user.utils.js @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-01-21 13:56:40 * @Last Modified by: prpr -* @Last Modified time: 2016-02-05 18:54:38 +* @Last Modified time: 2016-02-05 21:20:30 */ 'use strict'; @@ -33,13 +33,13 @@ function handleFiles(files, type) { } }; img.onerror = function () { - showMsg("alert-danger", "Error: Not an image or unknown file format"); + showMsg("alert-danger", "错误:这张图片编码不对哦"); }; img.src = this.result; }; fr.readAsDataURL(file); } else { - showMsg("alert-danger", "Error: This is not a PNG image!"); + showMsg("alert-danger", "错误:皮肤文件必须为 PNG 格式"); } } }; @@ -71,9 +71,9 @@ $("[title='Rotation']").click(function(){ function show2dPreview() { $('#canvas3d').remove(); $('.operations').hide(); - $("#skinpreview").html($('

Skin for Steve model:

').append($('').addClass('skin2d').attr('src', '../skin/'+docCookies.getItem('uname')+'-steve.png?v='+Math.random()))); - $("#skinpreview").append($('

Skin for Alex model:

').append($('').addClass('skin2d').attr('src', '../skin/'+docCookies.getItem('uname')+'-alex.png?v='+Math.random()))); - $("#skinpreview").append($('

Cape:

').append($('').addClass('skin2d').attr('src', '../cape/'+docCookies.getItem('uname')+'.png?v='+Math.random()))); + $("#skinpreview").html($('

Steve 模型的皮肤:

').append($('').addClass('skin2d').attr('src', '../skin/'+docCookies.getItem('uname')+'-steve.png?v='+Math.random()))); + $("#skinpreview").append($('

Alex 模型的皮肤:

').append($('').addClass('skin2d').attr('src', '../skin/'+docCookies.getItem('uname')+'-alex.png?v='+Math.random()))); + $("#skinpreview").append($('

披风:

').append($('').addClass('skin2d').attr('src', '../cape/'+docCookies.getItem('uname')+'.png?v='+Math.random()))); $('#preview').html('3D Preview').attr('href', 'javascript:show3dPreview();'); } @@ -102,28 +102,28 @@ $("#upload").click(function(){ data: form_data, processData: false, beforeSend: function() { - showMsg('alert-info', 'Uploading...'); + showMsg('alert-info', '正在上传。。'); }, success: function(json) { console.log(json); if (json.skin.errno == 0 && json.cape.errno == 0) { - showMsg('alert-success', 'Successfully uploaded.'); + showMsg('alert-success', '上传成功!'); } if (json.skin.errno != 0) { - showMsg('alert-danger', 'Error when uploading skin:\n'+json.skin.msg); + showMsg('alert-danger', '上传皮肤的时候出错了:\n'+json.skin.msg); } if (json.cape.errno != 0) { - showMsg('alert-danger', 'Error when uploading cape:\n'+json.cape.msg); + showMsg('alert-danger', '上传披风的时候出错了:\n'+json.cape.msg); } } }); } else { - showMsg('alert-warning', 'No input file selected'); + showMsg('alert-warning', '你还没有选择任何文件哦'); } }); function changeModel(uname) { - showAlert("Sure to change?", function(){ + showAlert('确定要更改优先皮肤模型吗?', function(){ $.ajax({ type: "POST", url: "../ajax.php?action=model", diff --git a/assets/js/utils.js b/assets/js/utils.js index b666010a..a3593247 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-02-03 18:23:21 * @Last Modified by: prpr -* @Last Modified time: 2016-02-04 23:02:46 +* @Last Modified time: 2016-02-05 21:12:29 */ 'use strict'; @@ -33,7 +33,7 @@ function logout(callback) { $("#logout").click(function(){ logout(function(json){ - showAlert(json.msg + " Successfully logged out.", function(){ + showAlert(json.msg, function(){ window.location = "../index.php"; }); }); diff --git a/config.php b/config.php index 6c4978b7..1dddb726 100644 --- a/config.php +++ b/config.php @@ -1,24 +1,24 @@ 16 || strlen($passwd) < 5) { - utils::raise(1, 'Illegal password. Password length should be in 5~16.'); + utils::raise(1, '无效的密码。密码长度应该大于 6 并小于 15。'); } else if (utils::convertString($passwd) != $passwd) { - utils::raise(1, 'Illegal password. Password contains unsupported characters.'); + utils::raise(1, '无效的密码。密码中包含了奇怪的字符。'); } return true; } @@ -146,7 +146,7 @@ class user $json['skins'][$sec_model] = $this->getTexture($sec_model == "default" ? "steve" : "alex"); $json['cape'] = $this->getTexture('cape'); } else { - utils::raise(-1, 'Configuration error. Non-supported API_TYPE.'); + utils::raise(-1, '配置文件错误:不支持的 API_TYPE。'); } } else { $json['errno'] = 1; diff --git a/includes/utils.class.php b/includes/utils.class.php index a842508c..d358b5ac 100644 --- a/includes/utils.class.php +++ b/includes/utils.class.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-16 23:01:33 * @Last Modified by: prpr - * @Last Modified time: 2016-02-05 13:27:43 + * @Last Modified time: 2016-02-05 21:59:56 */ class utils @@ -55,7 +55,7 @@ class utils public static function remove($filename) { if(file_exists($filename)) { if (!unlink($filename)) { - self::raise(-1, "Uncaught error when deleting $filename"); + self::raise(-1, "删除 $filename 的时候出现了奇怪的问题。。请联系作者"); } else { return true; } diff --git a/index.php b/index.php index e50b59a1..d00fc479 100755 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-17 13:55:20 * @Last Modified by: prpr - * @Last Modified time: 2016-02-05 16:04:20 + * @Last Modified time: 2016-02-05 21:13:05 */ session_start(); $dir = dirname(__FILE__); @@ -42,9 +42,9 @@ if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) { @@ -60,11 +60,11 @@ if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {

- Just a simple open-source Minecraft skin server + 开源的 PHP Minecraft 皮肤站

- Sign Up + 现在注册

@@ -76,28 +76,28 @@ if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
-

Sign In

+

登录

- - + +
- +
-

Sign Up

+

注册

- - - + + +
- +
diff --git a/user/index.php b/user/index.php index 9402ebfd..f4348cdd 100644 --- a/user/index.php +++ b/user/index.php @@ -19,10 +19,10 @@ if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) { if (isset($_SESSION['uname'])) { $user = new user($_SESSION['uname']); if ($_SESSION['token'] != $user->getToken()) { - header('Location: ../index.php?msg=Invalid token. Please login.'); + header('Location: ../index.php?msg=无效的 token,请重新登录。'); } } else { - header('Location: ../index.php?msg=Illegal access. Please login.'); + header('Location: ../index.php?msg=非法访问,请先登录。'); } ?> @@ -30,7 +30,7 @@ if (isset($_SESSION['uname'])) { - Upload - <?php echo SITE_TITLE; ?> + 上传皮肤 - <?php echo SITE_TITLE; ?> @@ -45,10 +45,10 @@ if (isset($_SESSION['uname'])) {
@@ -62,35 +62,35 @@ if (isset($_SESSION['uname'])) {
-
Upload
+
上传
-

Select a skin:

+

选择皮肤:


-

Select a cape:

+

选择皮肤:


- +
- +

- - 2D Preview + + 2D 皮肤预览
-
Change Preferred Model
+
修改优先皮肤模型
-

Your preference model is getPreference(); ?>. Change?

+

你现在的优先皮肤模型是 getPreference(); ?>更改

-
Preview +
皮肤预览
@@ -112,7 +112,7 @@ if (isset($_SESSION['uname'])) { getTexture('alex') && ($user->getTexture('steve') == "")) {?> diff --git a/user/profile.php b/user/profile.php index 0874a17f..8d7c5a33 100644 --- a/user/profile.php +++ b/user/profile.php @@ -3,7 +3,7 @@ * @Author: prpr * @Date: 2016-02-03 16:12:45 * @Last Modified by: prpr - * @Last Modified time: 2016-02-05 16:05:18 + * @Last Modified time: 2016-02-05 21:56:16 */ session_start(); @@ -18,10 +18,10 @@ if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) { if (isset($_SESSION['uname'])) { $user = new user($_SESSION['uname']); if ($_SESSION['token'] != $user->getToken()) { - header('Location: ../index.php?msg=Invalid token. Please login.'); + header('Location: ../index.php?msg=无效的 token,请重新登录。'); } } else { - header('Location: ../index.php?msg=Illegal access. Please login.'); + header('Location: ../index.php?msg=非法访问,请先登录。'); } ?> @@ -29,7 +29,7 @@ if (isset($_SESSION['uname'])) { - Profile - <?php echo SITE_TITLE; ?> + 个人设置 - <?php echo SITE_TITLE; ?> @@ -49,7 +49,7 @@ if (isset($_SESSION['uname'])) { Upload
  • - Welcome, ! | Log out? + 欢迎, | 登出?
  • @@ -64,26 +64,25 @@ if (isset($_SESSION['uname'])) {
    -
    Change Password
    +
    更改密码
    - - - - + + + +
    -
    Delete Account
    +
    删除账号
    -

    Are you sure you want to delete your account?

    -

    You're about to delete your account on Blessing Skin Server.

    -

    This is permanent! No backups, no restores, no magic undo button.

    -

    We warned you, ok?

    - +

    确定要删除你在 上的账号吗?

    +

    此操作不可恢复!我们不提供任何备份,或者神奇的撤销按钮。

    +

    我们警告过你了,确定要这样做吗?

    +
    @@ -91,7 +90,7 @@ if (isset($_SESSION['uname'])) {
    -
    How To Use?
    +
    如何使用?
    @@ -100,9 +99,9 @@ if (isset($_SESSION['uname'])) { is_admin) { ?>
    -
    Welcome, administrator.
    +
    欢迎,尊敬的管理员
    -

    Here manage your site: Console

    +

    在这里管理你的皮肤站: 仪表盘