diff --git a/ajax.php b/ajax.php index 23a8d573..1b416f8c 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-08 22:11:17 + * @Last Modified time: 2016-02-10 21:00:40 * * - login, register, logout * - upload, change, delete @@ -229,6 +229,22 @@ if ($action == "change") { $json['errno'] = 1; $json['msg'] = "无效的 token,请先登录。"; } +} else if ($action == "reset") { + if (isset($_SESSION['token']) && $_SESSION['token'] == $user->getToken()) { + if (checkPost()) { + if ($user->checkPasswd($_POST['passwd'])) { + $user->reset(); + $json['errno'] = 0; + $json['msg'] = "重置成功。"; + } else { + $json['errno'] = 1; + $json['msg'] = "错误的密码。"; + } + } + } else { + $json['errno'] = 1; + $json['msg'] = "无效的 token,请先登录。"; + } } else if ($action == "logout") { if (Utils::getValue('token', $_SESSION)) { session_destroy(); diff --git a/assets/css/style.css b/assets/css/style.css index 5ac94ca6..ba4cc23b 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-10 14:16:23 +* @Last Modified time: 2016-02-10 20:32:32 */ @import url(https://fonts.googleapis.com/css?family=Ubuntu); @@ -76,6 +76,10 @@ p { background: rgb(202, 60, 60); color: #fff; } +.pure-button-warning { + background: #ec971f; + color: #fff; +} .container { width: 100%; height: 100%; @@ -122,12 +126,6 @@ p { } -.panel-default { - border-color: #ddd!important; -} -.panel-danger { - border-color: #ebccd1!important; -} .panel { background-color: #fff; border: 1px solid transparent; @@ -137,15 +135,31 @@ p { width: 90%; margin: 0 auto 20px; } -.panel-danger>.panel-heading { + +.panel-default { + border-color: #ddd!important; +} +.panel-danger { + border-color: #ebccd1!important; +} +.panel-warning { + border-color: #faebcc; +} + +.panel-default > .panel-heading { + color: #333; + background-color: #f5f5f5; + border-color: #ddd; +} +.panel-danger > .panel-heading { color: #a94442; background-color: #f2dede; border-color: #ebccd1; } -.panel-default>.panel-heading { - color: #333; - background-color: #f5f5f5; - border-color: #ddd; +.panel-warning > .panel-heading { + color: #8a6d3b; + background-color: #fcf8e3; + border-color: #faebcc; } .panel-heading { padding: 10px 15px; diff --git a/assets/js/profile.utils.js b/assets/js/profile.utils.js index a8ff12e0..f1575eb1 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-05 21:23:08 +* @Last Modified time: 2016-02-10 20:53:55 */ 'use strict'; @@ -79,3 +79,25 @@ $('#delete').click(function(){ }); }); }); + +$('#reset').click(function(){ + Ply.dialog("prompt", { + title: "这是危险操作!输入密码来确认:", + form: { passwd: "Password" } + }).done(function(ui){ + var passwd = ui.data.passwd; + $.ajax({ + type: "POST", + url: "../ajax.php?action=reset", + dataType: "json", + data: { "uname": docCookies.getItem('uname'), "passwd": passwd }, + success: function(json) { + if (json.errno == 0) { + showAlert(json.msg); + } else { + showAlert(json.msg); + } + } + }); + }); +}); diff --git a/includes/User.class.php b/includes/User.class.php index f9768f49..25ba8812 100644 --- a/includes/User.class.php +++ b/includes/User.class.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-16 23:01:33 * @Last Modified by: prpr - * @Last Modified time: 2016-02-10 15:07:08 + * @Last Modified time: 2016-02-10 21:04:32 */ class User @@ -76,9 +76,23 @@ class User return $this->db->delete($this->uname); } + public function reset() { + for ($i = 1; $i <= 3; $i++) { + switch($i) { + case 1: $type = "steve"; break; + case 2: $type = "alex"; break; + case 3: $type = "cape"; break; + } + if ($this->getTexture($type) != "") + Utils::remove("./textures/".$this->getTexture($type)); + $this->db->update($this->uname, 'hash_'.$type, ''); + } + $this->db->update($this->uname, 'preference', 'default'); + } + /** * Get textures of user - * @param string $type steve|alex|cape + * @param string $type steve|alex|cape, 'skin' for texture of preferred model * @return string sha256-hash of texture file */ public function getTexture($type) { diff --git a/user/preview.php b/user/preview.php index b5fa197e..4a48e44a 100644 --- a/user/preview.php +++ b/user/preview.php @@ -3,14 +3,14 @@ * @Author: prpr * @Date: 2016-02-04 19:37:21 * @Last Modified by: prpr - * @Last Modified time: 2016-02-10 18:37:35 + * @Last Modified time: 2016-02-10 21:12:26 */ ?>
-

Steve 模型的皮肤:getTexture('skin');?>" />

-

Alex 模型的皮肤:getTexture('alex');?>" />

-

披风:getTexture('cape');?>" />

+

Steve 模型的皮肤:" />

+

Alex 模型的皮肤:" />

+

披风:" />

diff --git a/user/profile.php b/user/profile.php index f6f9c44b..bcc00db9 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-10 14:39:11 + * @Last Modified time: 2016-02-10 20:54:13 */ require "../includes/session.inc.php"; ?> @@ -77,16 +77,23 @@ require "../includes/session.inc.php"; - is_admin): ?>
+
+
重置账号
+
+

这将会删除所有你上传的内容。我们不提供任何备份,确定?

+ +
+
+ is_admin): ?>
欢迎,尊敬的管理员

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

-
+