-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathadmin.php
374 lines (372 loc) · 13 KB
/
admin.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<?php
// Load config file start.
if(file_exists("config.php")) {
require "config.php";
} else {
define("password","admin");
define("wpassword","admin");
define("storage",dirname(__FILE__)."/storage/");
define("history",dirname(__FILE__)."/history/");
define("chatfile","chat.log");
define("announcement","announcement.cfg");
define("linkchar1","&");
define("linkchar2","'says'");
define("adminuser","Admin");
};
if(file_exists(storage."version.php")) {
require storage."version.php";
} else {
define("version","Unknown");
};
if(!defined("version")){
define("version","Unknown");
};
if(!defined("adminuser")){
define("adminuser","Admin");
};
if(!defined("wpassword")){
define("wpassword","admin");
};
if(!defined("storage")){
define("storage",dirname(__FILE__)."/storage/");
};
if(!defined("chatfile")){
define("chatfile","chat.log");
};
if(!defined("history")){
define("history",dirname(__FILE__)."/history/");
};
if(!defined("password")){
define("password","admin");
};
if(!defined("linkchar1")){
define("linkchar1","&");
};
if(!defined("linkchar2")){
define("linkchar2","'says'");
};
if(!defined("announcement")){
define("announcement","announcement.cfg");
};
// Load config file end.
// Count message.
if(file_exists(storage.''.chatfile)) {
$file=file(storage.''.chatfile);
$count=count($file);
} else {
$count=0;
};
/**
* Count folder files.
* @param string $url
* @return number
*/
function cff($url)
{
$number=0;
$arr = glob($url);
foreach ($arr as $file)
{
if(is_file($file))
{
$number++;
}
else
{
$number+=cff($v."/*");
}
}
return $number;
};
$hm = cff(history.'*');
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Meow Chat Admin Console</title>
<style type="text/css">
.bodynologin {
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}
.form-signin {
max-width: 300px;
padding: 19px 29px 29px;
margin: 0 auto 20px;
background-color: #fff;
border: 1px solid #e5e5e5;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin input[type="text"],
.form-signin input[type="password"] {
font-size: 16px;
height: auto;
margin-bottom: 15px;
padding: 7px 9px;
}
</style>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/amazeui.flat.css">
<link rel="stylesheet" href="css/buttons.css">
<link rel="stylesheet" href="css/glyphicons.css">
<link rel="stylesheet" href="css/console.css">
<script src="js/bootstrap.min.js"></script>
</head>
<?php if (empty($_GET['password'])) {
echo '<body class="bodynologin">
<div class="container">
<form class="form-signin">
<h3 class="form-signin-heading">喵聊控制台 - 登录</h3>
<div class="row"><span class="glyphicon glyphicon-user"></span> 用户名 *
<input type="text" class="form-control" value="'.adminuser.'" disabled>
</div><div class="row"><span class="glyphicon glyphicon-certificate"></span> 密码 *
<input type="password" class="form-control" name="password" id="password" placeholder="您的管理员密码">
<button class="btn btn-default" type="sumbit">登录</button>
</div>
</form>
</div>
</body>
</html>';
};
if ($_GET['password'] != password && !empty($_GET['password'])) {
echo '<body class="bodynologin">
<div class="container">
<form class="form-signin" action="admin.php">
<h3 class="form-signin-heading">喵聊控制台 - 登录</h3>
<div>
<p>您输入的密码有误,请重新输入!</p>
<button class="btn btn-default" type="sumbit">返回</button>
</div>
</form>
</div>
</body>
</html>';
};
if ($_GET['password'] == password) {
switch ($_GET['mode']) {
case command:
echo '<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Meow Chat</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="admin.php?password='.$_GET['password'].'"><span class="glyphicon glyphicon-scale"></span> 总览<span class="sr-only">(current)</span></a></li>
<li class="active"><a href="admin.php?password='.$_GET['password'].'&mode=command"><span class="glyphicon glyphicon-console"></span> 指令执行</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="index.php?username='.adminuser.'" target="_blank">返回聊天 <span class="glyphicon glyphicon-share-alt"></span></a></li>
<li><a href="http://www.meowcat.org/" target="_blank">小喵工作室</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>';
if (!empty($_GET['consolecmd'])) {
switch ($_GET['consolecmd']) {
case clear:
echo '<div class="panel panel-default">
<div class="panel-body">
执行指令:Clear Message.</br>
输出:<div class="panel panel-default">
<div class="panel-body">
<iframe src="clear.php?password='.$_GET['password'].'" style="height:auto;width:100%;" frameborder="0"/>
</div>
</div>
</div>
</div>
</body>
</html>';
break;
case broadcast:
echo '<div class="panel panel-default">
<div class="panel-body">
执行指令:Add an Announcement.
</br>
输出:<div class="panel panel-default">
<div class="panel-body">
<iframe src="announcement.php?password='.$_GET['password'].'" style="height:auto;width:100%;" frameborder="0"/>
</div>
</div>
</div>
</div>
</body>
</html>';
break;
case send:
if (empty($_GET['msg'])) {
echo '<div class="panel panel-default">
<div class="panel-body">
执行指令 Send a message 时需要以下附加条件:
</br>
<form action="admin.php">
<div class="row">
<input type="password" class="form-control" name="password" id="password" value="'.$_GET['password'].'" style="display:none;">
<input type="text" class="form-control" name="mode" id="mode" value="command" style="display:none;">
<input type="text" class="form-control" name="consolecmd" id="consolecmd" value="send" style="display:none;">
<input type="text" class="form-control" name="msg" id="msg" placeholder="需发送的消息,上限64位,不得含有&等字符">
<button class="btn btn-default" type="sumbit">提交</button>
</div>
</form>
</div>
</div>
</body>
</html>';
} else {
echo '<div class="panel panel-default">
<div class="panel-body">
执行指令:Send a message & message='.$_GET['msg'].'.
</br>
输出:<div class="panel panel-default">
<div class="panel-body">
<iframe src="write.php?password='.wpassword.'&message=<font color=\'5BA783\'>'.$_GET['msg'].'</font>&username=<font color=\'5BA783\'>[管理员]'.adminuser.'</font>&admin='.password.'" style="height:auto;width:100%;" frameborder="0"/>
</div>
</div>
</div>
</div>
</body>
</html>';
};
break;
default:
echo '<div class="panel panel-default">
<div class="panel-body">
执行指令:Unknown.</br>
输出:<div class="panel panel-default">
<div class="panel-body">
Failed.</br>Command Not Specified.</br>
Total time: none.
</div>
</div>
</div>
</div>
</body>
</html>';
};
} else {
echo '<div class="panel panel-default">
<div class="panel-body">
<h1>指令执行 <small>Meow Chat Admin Console</small></h1>
输入指令:
<form action="admin.php">
<div class="row">
<input type="password" class="form-control" name="password" id="password" value="'.$_GET['password'].'" style="display:none;">
<input type="text" class="form-control" name="mode" id="mode" value="command" style="display:none;">
<input type="text" class="form-control" name="consolecmd" id="consolecmd" placeholder="控制台指令">
<button class="btn btn-default" type="sumbit">执行</button>
</div>
</form>
<p>指令提示:</br>broadcast(Add an announcement)插入一条随机公告</br>clear(Clear messages)清空所有消息并保存至历史文件</br>send(Send a message)以管理员身份发送一条消息</p>
</div>
</div>
</div>
</div>
</body>
</html>';
};
break;
default:
echo '<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Meow Chat</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="admin.php?password='.$_GET['password'].'"><span class="glyphicon glyphicon-scale"></span> 总览<span class="sr-only">(current)</span></a></li>
<li><a href="admin.php?password='.$_GET['password'].'&mode=command"><span class="glyphicon glyphicon-console"></span> 指令执行</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="index.php?username='.adminuser.'" target="_blank">返回聊天 <span class="glyphicon glyphicon-share-alt"></span></a></li>
<li><a href="http://www.meowcat.org/" target="_blank">小喵工作室</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="panel-body">
<div class="page-header">
<h1>Meow Chat Admin Console <small>喵聊管理控制台</small></h1>
</div>
<div id="dashboard">
<div class="row-fluid">
<div class="thumbnails">
<div class="responsive span3" style="display:inline;">
<a href="https://github.com/MeowCat-Studio/Meow-Chat" target="_blank" class="ga-event">
<div class="thumbnail purple">
<div class="visual">
<span class="glyphicon glyphicon-record"></span>
</div>
<div class="number">'.version.'</div>
<h4 class="tile-label">程序版本</h4>
<div class="manage">检测更新(Github) <span class="glyphicon glyphicon-new-window"></span></div>
</div>
</a>
</div>
<div class="responsive span3" style="display:inline;">
<a href="index.php?mod=baiduid" class="ga-event">
<div class="thumbnail blue">
<div class="visual">
<span class="glyphicon glyphicon-list"></span>
</div>
<div class="number"><?php
<span id="baiduid_used">'.$count.'</span></div>
<h4 class="tile-label">消息数量/条</h4>
<div class="manage" style="text-transform: uppercase;">发送消息 <span class="glyphicon glyphicon-chevron-right"></span></div>
</div>
</a>
</div>
<div class="responsive span3" style="display:inline;">
<div class="thumbnail green">
<div class="visual">
<span class="glyphicon glyphicon-file"></span>
</div>
<div class="number">'.$hm.'</div>
<h4 class="tile-label">历史文件数量/个</h4>
</div>
</div>
<div class="responsive span3" style="display:inline;">
<div class="thumbnail yellow">
<div class="visual">
<span class="glyphicon glyphicon-list-alt"></span>
</div>
<div class="number">'.date("Y-m-j-l H:i:s.", filemtime(storage.''.chatfile)).'</div>
<h4 class="tile-label">最后发言时间</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>';};
};?>