-
Notifications
You must be signed in to change notification settings - Fork 3
/
mok_bduss_show.php
178 lines (175 loc) · 6.96 KB
/
mok_bduss_show.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
if (!defined('SYSTEM_ROOT')) { die('Insufficient Permissions'); }
global $i,$m;
loadhead();
?>
<style type="text/css">
.panel-heading{ cursor: pointer;}
button{ outline:none !important}
/*tbody td:last-child{ text-align: center}*/
#mok_me td{ transition:color .5s ease-in-out;}
.ok{color: #08ac10}
.no{color: #f00;}
</style>
<script>
$(function(){
//判断当前用户的IDs是否有效
for (var i = 0; i < $("#mok_me tbody tr").length; i++) {
$.get("plugins/mok_bduss/mok_bduss_bg.php",{"do":"tr","bduss":$("#mok_me tbody tr:eq("+i+") td:eq(2) input").val(),"eq":i},function(data){
var tr=$("#mok_me tbody tr:eq("+data['eq']+")").children();
if(data['valid'] == '0'){
tr.eq(1).addClass("no").text(decodeURI(data['name']));
} else {
tr.eq(1).addClass("ok").text(decodeURI(data['name']));
}
},"json");
};
});
function mail(id){
window.event.stopPropagation();
var label = $('#tab_'+id+' .label');
if(label.hasClass('label-success')) return;
label.text('正在发送...');
$.get('plugins/mok_bduss/mok_bduss_bg.php',{"do":"mail","id":id},function(data){
if(data['status'] == 'true'){
label.text('已发送').removeClass('label-warning').addClass('label-success');
} else {
label.text('发送邮件提醒他');
alert(data['msg']);
}
},"json");
}
function tab(id){
$("#tab_"+id+"~.panel-body").slideToggle("fast",function(){
if($("#tab_"+id+" .badge").hasClass('glyphicon-chevron-down')){
$("#tab_"+id+" .badge").removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
$.get("plugins/mok_bduss/mok_bduss_bg.php",{"do":"table","uid":id},function(data){
var tar=$("#tab_"+id+"~.panel-body");
tar.slideUp("fast",function(){
if(data["Empty"]){//如果该账号下没有绑定百度账号
tar.html("这个账号还没有绑定任何一个百度账号。你可以 -> <button type='button' class='btn btn-danger' onclick='delUser("+id+",$(this))'>删掉这坑货</button>");
} else {
tar.text("").append('<table class="table" style="margin-bottom:0"><thead><tr><th style="width:10%">ID</th><th style="width:20%">用户名</th><th style="width:60%">BDUSS</th><th style="width:10%">操作</th></tr></thead><tbody></tbody></table>');
for (var i in data) {
var tmp = $.parseJSON(data[i][0]);
if(tmp['valid'] == '0'){
var user = ' class="no">'+decodeURI(tmp['name']);
if($('#tab_'+id+' .label').length == 0){//判断是否已经有此按钮
$('#tab_'+id).append('<span class="label label-warning" onclick="mail('+id+')">发送邮件提醒他</span>');
}
} else {
var user = ' class="ok">'+decodeURI(tmp['name']);
}
tar.children("table").children("tbody").append('<tr id="'+i+'_tr"><td>'+i+'</td><td id="'+i+'_id"'+user+'</td><td><div class="input-group"><input type="text" id="'+i+'_bduss" class="form-control" value="'+data[i][1]+'"><span class="input-group-btn"><button id="'+i+'_save" class="btn btn-default" type="button" onclick="save('+i+')">保存</button></span></div></td><td><button type="button" id="'+i+'_del" class="btn btn-danger" onclick="del('+i+')">删除</button></td></tr>');
};
}
tar.slideDown("fast");
});
},"json");
} else {
$("#tab_"+id+" .badge").removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
$(this).text("加载中...");
}
});
}
function save(id){
var btn=$("#"+id+"_save");
var bduss=$("#"+id+"_bduss").val();
btn.text("保存中").attr("disabled","true");
if(bduss==""){
alert("请输入有效的BDUSS");
btn.removeAttr("disabled").text("保存");
} else {
$.get("plugins/mok_bduss/mok_bduss_bg.php",{"do":"save","id":id,"bduss":bduss},function(data){
if(data["valid"]=="0"){
alert(data["msg"]);
btn.removeAttr("disabled").text("保存");
} else {
btn.text("已保存");
$("#"+id+"_id").removeAttr("class").addClass("ok").text(decodeURI(data["name"]));
}
},"json");
}
}
function del(id){
var btn=$("#"+id+"_del");
var bduss=$("#"+id+"_bduss").val();
if(confirm("真的要删除ID为 "+id+" 的这条账号信息吗?")){
btn.text("删除中").attr("disabled","true");
$.get("plugins/mok_bduss/mok_bduss_bg.php",{"do":"del","id":id},function(data){
if(data["status"]=="false"){
alert(data["msg"]);
btn.removeAttr("disabled").text("删除");
} else {
$("#"+id+"_tr").fadeOut("fast");
}
},"json");
}
}
function delUser(uid,btn){
var user=$("#tab_"+uid+' .user').text();
if(confirm("真的要删除 "+user+" 这个签到账号吗?")){
btn.text("删除中").attr("disabled","true");
$.get("plugins/mok_bduss/mok_bduss_bg.php",{"do":"delUser","uid":uid},function(data){
if(data["status"]=="false"){
alert(data["msg"]);
btn.removeAttr("disabled").text("删掉这坑货");
} else {
$("#tab_"+uid).parent().slideUp("fast");
}
},"json");
}
}
function tabAll(){
var tabs=$(".panel-default");
if(tabs.length==0){ return; }
var i=0;
var jsq = setInterval(function(){
tabs.eq(i).children().click();
if(i==tabs.length){
clearInterval(jsq);
jsq=null;
}
i++;
},500);
}
</script>
<h2>Bduss有效性检测<button type="button" class="btn btn-default pull-right" onclick="tabAll()">全部展开</button></h2>
<div class="alert alert-info" role="alert">如果出现红字则表示该BDUSS已失效,请及时更新,否则将会断签</div>
<div id="mok_me" class="panel panel-primary">
<div class="panel-heading"><?php echo NAME; ?></div>
<div class="panel-body">
<table class="table" style="margin-bottom:0">
<thead>
<tr>
<th style="width:10%">ID</th>
<th style="width:20%">用户名</th>
<th style="width:60%">BDUSS</th>
<th style="width:10%">操作</th>
</tr>
</thead>
<tbody>
<?php /*获取当前用户绑定的ID列表*/ ?>
<?php foreach ($i['user']['bduss'] as $id => $bduss) { ?>
<tr id="<?php echo $id; ?>_tr"><td><?php echo $id; ?></td><td id="<?php echo $id; ?>_id">读取中...</td>
<td><div class="input-group"><input type="text" id="<?php echo $id; ?>_bduss" class="form-control" value="<?php echo $bduss; ?>"><span class="input-group-btn"><button id="<?php echo $id; ?>_save" class="btn btn-default" type="button" onclick="save(<?php echo $id; ?>)">保存</button></span></div></td>
<td><button type="button" id="<?php echo $id; ?>_del" class="btn btn-danger" onclick="del(<?php echo $id; ?>)">删除</button></td></tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<?php
/*如果当前用户为管理员,则显示其他用户的ID*/
if($i['user']['role']==="admin"){
$q=$m->query("Select id,name From ".DB_PREFIX."users Where id!=".$i['user']['uid']);
while ($row=$q->fetch_row()) {
?>
<div class="panel panel-default">
<div id="tab_<?php echo $row[0]; ?>" class="panel-heading" onclick="tab(<?php echo $row[0]; ?>)">
<span class='user'><?php echo $row[1]; ?></span><span class="badge glyphicon glyphicon-chevron-down pull-right"> </span>
</div>
<div class="panel-body" style="display:none">读取中...</div>
</div>
<?php }} ?>
<?php loadfoot(); ?>