forked from firesunCN/BlueLotus_XSSReceiver
-
Notifications
You must be signed in to change notification settings - Fork 26
/
api.php
207 lines (183 loc) · 7.38 KB
/
api.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
<?php
error_reporting(0);
define("IN_XSS_PLATFORM", true);
require_once('auth.php');
require_once("dio.php");
header('Content-Type: application/json');
//与xss记录相关api
if ( isset( $_GET['cmd'] ) ) {
switch ( $_GET['cmd'] ) {
//获取所有记录包括详细信息
case 'list':
echo json_encode( list_xss_record_detail() );
break;
//只获取时间戳(索引id)
case 'id_list':
echo json_encode( list_xss_record_id() );
break;
//根据时间戳(索引id)获得单条信息
case 'get':
if ( isset( $_GET['id'] ) )
echo json_encode( load_xss_record( $_GET['id'] ) );
else
echo json_encode( false );
break;
//根据时间戳(索引id)删除单条信息
case 'del':
if ( isset( $_GET['id'] ) )
echo json_encode( delete_xss_record( $_GET['id'] ) );
else
echo json_encode( false );
break;
//清空记录
case 'clear':
echo json_encode( clear_xss_record() );
break;
default:
echo json_encode( false );
}
}
//与js模板相关api
else if ( isset( $_GET['js_template_cmd'] ) ) {
switch ( $_GET['js_template_cmd'] ) {
//获取所有js模板的名字与描述
case 'list':
echo json_encode( list_js_name_and_desc( JS_TEMPLATE_PATH ) );
break;
//添加js模板
case 'add':
if ( isset( $_POST['name'] ) && isset( $_POST['desc'] ) && isset( $_POST['content'] ) ) {
if (get_magic_quotes_gpc()) {
$_POST['name'] = stripslashes($_POST['name']);
$_POST['desc'] = stripslashes($_POST['desc']);
$_POST['content'] = stripslashes($_POST['content']);
}
$result = save_js_desc( JS_TEMPLATE_PATH, $_POST['desc'], $_POST['name'] )
&& save_js_content( JS_TEMPLATE_PATH, $_POST['content'], $_POST['name'] );
echo json_encode( $result );
}
else
echo json_encode( false );
break;
//修改js模板
case 'modify':
if ( isset( $_POST['old_name'] ) && isset( $_POST['name'] ) && isset( $_POST['desc'] ) && isset( $_POST['content'] ) ) {
if (get_magic_quotes_gpc()) {
$_POST['old_name'] = stripslashes($_POST['old_name']);
$_POST['name'] = stripslashes($_POST['name']);
$_POST['desc'] = stripslashes($_POST['desc']);
$_POST['content'] = stripslashes($_POST['content']);
}
$result = true;
if ( $_POST['old_name'] != $_POST['name'] )
$result = delete_js( JS_TEMPLATE_PATH, $_POST['old_name'] );
if( $result ) {
$result = save_js_desc( JS_TEMPLATE_PATH, $_POST['desc'], $_POST['name'] )
&& save_js_content( JS_TEMPLATE_PATH, $_POST['content'], $_POST['name'] );
}
echo json_encode( $result );
}
else
echo json_encode( false );
break;
//获取某一js模板的内容
case 'get':
if ( isset( $_GET['name'] ) ) {
if (get_magic_quotes_gpc())
$_POST['name'] = stripslashes($_POST['name']);
echo json_encode( load_js_content( JS_TEMPLATE_PATH, $_GET['name'] ) );
}
else
echo json_encode( false );
break;
//删除js模板
case 'del':
if ( isset( $_GET['name'] ) ) {
if (get_magic_quotes_gpc())
$_POST['name'] = stripslashes($_POST['name']);
echo json_encode( delete_js( JS_TEMPLATE_PATH, $_GET['name'] ) );
}
else
echo json_encode( false );
break;
//清空js模板
case 'clear':
echo json_encode( clear_js( JS_TEMPLATE_PATH ) );
break;
default:
echo json_encode( false );
}
}
//与我的js相关api
else if ( isset( $_GET['my_js_cmd'] ) ) {
switch ( $_GET['my_js_cmd'] ) {
//获取所有我的js的名字与描述
case 'list':
echo json_encode( list_js_name_and_desc( MY_JS_PATH ) );
break;
//添加js模板
case 'add':
if ( isset( $_POST['name'] ) && isset( $_POST['desc'] ) && isset( $_POST['content'] ) ) {
if (get_magic_quotes_gpc()) {
$_POST['name'] = stripslashes($_POST['name']);
$_POST['desc'] = stripslashes($_POST['desc']);
$_POST['content'] = stripslashes($_POST['content']);
}
$result = save_js_desc( MY_JS_PATH, $_POST['desc'], $_POST['name'] )
&& save_js_content( MY_JS_PATH, $_POST['content'], $_POST['name'] );
echo json_encode( $result );
}
else
echo json_encode( false );
break;
//修改js模板
case 'modify':
if ( isset( $_POST['old_name'] ) && isset( $_POST['name'] ) && isset( $_POST['desc'] ) && isset( $_POST['content'] ) ) {
if (get_magic_quotes_gpc()) {
$_POST['old_name'] = stripslashes($_POST['old_name']);
$_POST['name'] = stripslashes($_POST['name']);
$_POST['desc'] = stripslashes($_POST['desc']);
$_POST['content'] = stripslashes($_POST['content']);
}
$result = true;
if ( $_POST['old_name'] != $_POST['name'] )
$result = delete_js( MY_JS_PATH, $_POST['old_name'] );
if( $result ) {
$result = save_js_desc( MY_JS_PATH, $_POST['desc'], $_POST['name'] )
&& save_js_content( MY_JS_PATH, $_POST['content'], $_POST['name'] );
}
echo json_encode( $result );
}
else
echo json_encode( false );
break;
//获取某一js模板的内容
case 'get':
if ( isset( $_GET['name'] ) ) {
if (get_magic_quotes_gpc())
$_POST['name'] = stripslashes($_POST['name']);
echo json_encode( load_js_content( MY_JS_PATH, $_GET['name'] ) );
}
else
echo json_encode( false );
break;
//删除js模板
case 'del':
if ( isset( $_GET['name'] ) ) {
if (get_magic_quotes_gpc())
$_POST['name'] = stripslashes($_POST['name']);
echo json_encode( delete_js( MY_JS_PATH, $_GET['name'] ) );
}
else
echo json_encode( false );
break;
//清空js模板
case 'clear':
echo json_encode( clear_js( MY_JS_PATH ) );
break;
default:
echo json_encode( false );
}
}
else
echo json_encode( false );