This repository has been archived by the owner on Oct 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathadmin.php
75 lines (65 loc) · 2.04 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
<?php
/**
* User: WispX
* Date: 2018/1/6 0006
* Time: 9:42
* Link: http://gitee.com/wispx
*/
require __DIR__ . '/init.php';
if ($get_type == 'login') {
$data = Operate::param();
if ($data['username'] == $config['administrator']['username']) {
if ($data['password'] == $config['administrator']['password']) {
$_SESSION['login_status'] = base64_encode(md5(time() . uniqid()));
return Operate::json(1, '登录成功');
}
return Operate::json(0, '密码不正确');
}
return Operate::json(0, '账号不存在');
}
if (!isset($_SESSION['login_status'])) die(require ROOT_PATH . 'view/login.php');
if ($get_type == 'logout') {
$_SESSION['login_status'] = null;
return Operate::json(1, '已注销账号');
}
if ($get_type == 'config') {
$data = Operate::param();
if (!isset($data['fast_delete'])) {
$data['fast_delete'] = '0';
}
if ($db->update('config', $data, "id = 1")) {
return Operate::json(1, '修改成功');
}
return Operate::json(0, '修改失败');
}
if ($get_type == 'blacklist_delete') {
$id = Operate::param('id');
if ($id) {
if ($db->delete('blacklist', "id = {$id}")) {
return Operate::json(1, '删除成功');
}
return Operate::json(0, '删除失败');
}
return Operate::json(0, '数据异常');
}
if ($get_type == 'blacklist_add') {
$name = Operate::param('name');
if ($name) {
if ($db->add(['name' => base64_encode($name)], 'blacklist')) {
return Operate::json(1, '添加成功');
}
return Operate::json(0, '添加失败');
}
return Operate::json(0, '数据异常');
}
if ($get_type == 'article_delete') {
$id = Operate::param('id');
if ($id) {
if ($db->delete('article', "id = {$id}")) {
return Operate::json(1, '删除成功');
}
return Operate::json(0, '删除失败');
}
return Operate::json('数据异常');
}
require ROOT_PATH . "view/". ($action ? "page/{$action}" : "admin") . ".php";