added operation of deleting textures on manage page
This commit is contained in:
parent
711a744304
commit
07e699f64e
@ -2,8 +2,8 @@
|
||||
/**
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-04 13:53:55
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-08 22:06:43
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-03-06 15:34:29
|
||||
*/
|
||||
require "../includes/session.inc.php";
|
||||
|
||||
@ -38,10 +38,24 @@ if (isset($_GET['action'])) {
|
||||
$json['errno'] = 0;
|
||||
$json['msg'] = "成功更改了 ".$_GET['uname']." 的密码。";
|
||||
} // Will raise exception if password invalid
|
||||
} else if ($action == "delete") {
|
||||
} else if ($action == "deleteAccount") {
|
||||
$user->unRegister();
|
||||
$json['errno'] = 0;
|
||||
$json['msg'] = "成功删除了该用户。";
|
||||
} else if ($action == "deleteTexture") {
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
switch($i) {
|
||||
case 1: $type = "steve"; break;
|
||||
case 2: $type = "alex"; break;
|
||||
case 3: $type = "cape"; break;
|
||||
}
|
||||
if ($_POST[$type] == "true" && $user->getTexture($type) != "") {
|
||||
Utils::remove("./textures/".$user->getTexture($type));
|
||||
$user->db->update($user->uname, 'hash_'.$type, '');
|
||||
}
|
||||
}
|
||||
$json['errno'] = 0;
|
||||
$json['msg'] = "成功地删除了该用户的所选材质。";
|
||||
} else if ($action == "model") {
|
||||
if (isset($_POST['model']) && $_POST['model'] == 'slim' || $_POST['model'] == 'default') {
|
||||
$user->setPreference($_POST['model']);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-03-06 14:19:20
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-03-06 14:44:26
|
||||
* @Last Modified time: 2016-03-06 15:32:20
|
||||
*/
|
||||
require "../includes/session.inc.php";
|
||||
if (!$user->is_admin) header('Location: ../index.php?msg=看起来你并不是管理员');
|
||||
@ -76,6 +76,7 @@ if (!$user->is_admin) header('Location: ../index.php?msg=看起来你并不是
|
||||
<span>(<?php echo $row['preference']; ?>)</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:deleteTexture('<?php echo $row['username'] ?>');" class="pure-button pure-button-warning">删除材质</a>
|
||||
<a href="javascript:changePasswd('<?php echo $row['username'] ?>');" class="pure-button pure-button-default">更改密码</a>
|
||||
<a href="javascript:deleteAccount('<?php echo $row['username'] ?>');" class="pure-button pure-button-error">删除用户</a>
|
||||
</td>
|
||||
@ -90,7 +91,7 @@ if (!$user->is_admin) header('Location: ../index.php?msg=看起来你并不是
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a href="index.php?page=<?php echo $page_now-1; ?>" aria-label="Previous">
|
||||
<a href="manage.php?page=<?php echo $page_now-1; ?>" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
@ -100,7 +101,7 @@ if (!$user->is_admin) header('Location: ../index.php?msg=看起来你并不是
|
||||
if ($i == $page_now) {
|
||||
echo '<li class="active"><a href="#">'.(string)$i.'</a></li>';
|
||||
} else {
|
||||
echo '<li><a href="index.php?page='.$i.'">'.(string)$i.'</a></li>';
|
||||
echo '<li><a href="manage.php?page='.$i.'">'.(string)$i.'</a></li>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ if (!$user->is_admin) header('Location: ../index.php?msg=看起来你并不是
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a href="index.php?page=<?php echo $page_now+1; ?>" aria-label="Next">
|
||||
<a href="manage.php?page=<?php echo $page_now+1; ?>" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
|
@ -2,8 +2,13 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-04 16:47:54
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-03-06 14:19:55
|
||||
* @Last Modified time: 2016-03-06 15:33:44
|
||||
*/
|
||||
@media screen and (min-width: 48em) {
|
||||
.container {
|
||||
width: 90%;
|
||||
}
|
||||
}
|
||||
.overview {
|
||||
margin: 80px auto 0;
|
||||
width: 100%;
|
||||
@ -25,6 +30,15 @@ input {
|
||||
width: 100%;
|
||||
margin: 10px 0 20px;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
width: initial;
|
||||
margin: 0;
|
||||
margin: 0 5px 0 5px;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
margin: 6px 0;
|
||||
}
|
||||
.fw {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @Author: prpr
|
||||
* @Date: 2016-02-04 16:48:42
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-05 22:01:44
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-03-06 15:23:40
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@ -53,6 +53,43 @@ function uploadTexture(uname, type) {
|
||||
ply.open();
|
||||
}
|
||||
|
||||
function deleteTexture(uname) {
|
||||
var ply = new Ply({
|
||||
el: '<h2>选择要删除的 '+uname+' 的当前材质:</h2>'+
|
||||
'<label><input id="steve" type="checkbox" checked="">Steve 模型</label>'+
|
||||
'<label><input id="alex" type="checkbox" checked="">Alex 模型</label>'+
|
||||
'<label><input id="cape" type="checkbox" checked="">披风</label>'+
|
||||
'<label style="margin: 6px 0 12px;"><input id="all" type="checkbox" checked="">全部</label>'+
|
||||
'<button id="confirm" class="pure-button pure-button-primary fw">确定</button>',
|
||||
effect: "fade",
|
||||
onaction: function() {
|
||||
var steve = $('#steve').prop('checked');
|
||||
var alex = $('#alex').prop('checked');
|
||||
var cape = $('#cape').prop('checked');
|
||||
if ($('#all').prop('checked')) {
|
||||
steve = alex = cape = true;
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "admin_ajax.php?action=deleteTexture&uname="+uname,
|
||||
dataType: "json",
|
||||
data: {
|
||||
"steve" : steve,
|
||||
"alex" : alex,
|
||||
"cape" : cape
|
||||
},
|
||||
success: function(json) {
|
||||
if (json.errno == 0) {
|
||||
showAlert(json.msg);
|
||||
} else {
|
||||
showAlert(json.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
ply.open();
|
||||
}
|
||||
|
||||
function changePasswd(uname) {
|
||||
Ply.dialog("prompt", {
|
||||
@ -82,7 +119,7 @@ function deleteAccount(uname) {
|
||||
}).done(function(ui){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "admin_ajax.php?action=delete&uname="+uname,
|
||||
url: "admin_ajax.php?action=deleteAccount&uname="+uname,
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
if (json.errno == 0) {
|
||||
|
@ -2,13 +2,13 @@
|
||||
/**
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-16 23:01:33
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-02-14 16:21:53
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-03-06 15:27:00
|
||||
*/
|
||||
|
||||
class User
|
||||
{
|
||||
private $uname = "";
|
||||
public $uname = "";
|
||||
private $passwd = "";
|
||||
private $token = "";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user