-
Notifications
You must be signed in to change notification settings - Fork 82
/
ajax.php
329 lines (224 loc) · 14.4 KB
/
ajax.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
<?php
/**
* File: ajax.php.
* Author: Ulrich Block
* Date: 03.10.12
* Time: 17:09
* Contact: <[email protected]>
*
* This file is part of Easy-WI.
*
* Easy-WI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Easy-WI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
*
* Diese Datei ist Teil von Easy-WI.
*
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License fuer weitere Details.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
define('EASYWIDIR', dirname(__FILE__));
define('AJAXINCLUDED', true);
if (is_dir(EASYWIDIR . '/install')) {
die('Please remove the "install" folder');
}
include(EASYWIDIR . '/stuff/config.php');
include(EASYWIDIR . '/stuff/keyphrasefile.php');
include(EASYWIDIR . '/stuff/methods/functions.php');
include(EASYWIDIR . '/stuff/methods/class_validator.php');
include(EASYWIDIR . '/stuff/methods/class_ftp.php');
include(EASYWIDIR . '/stuff/methods/class_app.php');
include(EASYWIDIR . '/stuff/methods/class_ts3.php');
include(EASYWIDIR . '/stuff/methods/functions_ts3.php');
include(EASYWIDIR . '/stuff/methods/vorlage.php');
include(EASYWIDIR . '/stuff/settings.php');
if (!isset($admin_id) and !isset($user_id)) {
redirect('login.php');
} else if (isset($admin_id)) {
$pa = User_Permissions($admin_id);
} else if (isset($user_id)) {
$pa = User_Permissions($user_id);
}
if ($ui->smallletters('w', 9, 'get') == 'datatable') {
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 1 Jan 1900 00:00:00 GMT');
header('Content-type: application/json');
$array = array('iTotalRecords' => 0, 'iTotalDisplayRecords' => 0, 'aaData' => array());
$iDisplayStart = ($ui->isinteger('iDisplayStart', 'get')) ? $ui->isinteger('iDisplayStart', 'get') : 0;
$iDisplayLength = ($ui->isinteger('iDisplayLength', 'get')) ? $ui->isinteger('iDisplayLength', 'get') : 10;
$iSortCol = ($ui->isinteger('iSortCol_0', 'get')) ? $ui->isinteger('iSortCol_0', 'get') : 0;
$sSortDir = ($ui->smallletters('sSortDir_0', 4, 'get') == 'desc') ? 'DESC' : 'ASC';
$sSearch = (strlen($ui->escaped('sSearch', 'get')) > 0) ? $ui->escaped('sSearch', 'get') : false;
// Userlog
if (($ui->smallletters('d', 7, 'get') == 'userlog' and isset($user_id)) or ($ui->smallletters('d', 12, 'get') == 'adminuserlog' and isset($admin_id)) and $pa['log']) {
$adminLookup = ($ui->smallletters('d', 12, 'get') == 'adminuserlog' and isset($admin_id)) ? true : false;
require_once(EASYWIDIR . '/stuff/ajax/datatable_userlog.php');
// Mail log
} else if ($ui->smallletters('d', 7, 'get') == 'maillog' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['jobs']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_maillog.php');
// Job log
} else if ($ui->smallletters('d', 6, 'get') == 'joblog' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['jobs']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_joblog.php');
// IP bans
} else if ($ui->smallletters('d', 6, 'get') == 'ipbans' and isset($admin_id) and isset($reseller_id) and $reseller_id == 0 and $pa['ipBans']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_ipbans.php');
// custom module
} else if ($ui->smallletters('d', 12, 'get') == 'custommodule' and isset($admin_id) and isset($reseller_id) and $reseller_id == 0 and $pa['root']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_custommodule.php');
// List of imported news feeds
} else if ($ui->smallletters('d', 16, 'get') == 'feedsnewsentries' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_feedsnewsentries.php');
// List of feeds
} else if ($ui->smallletters('d', 5, 'get') == 'feeds' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_feeds.php');
// App (GS + Tools) masterserver
} else if ($ui->smallletters('d', 15, 'get') == 'appmasterserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['masterServer']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_appmasterserver.php');
// GS images
} else if ($ui->smallletters('d', 10, 'get') == 'gameimages' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['gimages']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_gameimages.php');
// GS addons
} else if ($ui->smallletters('d', 16, 'get') == 'gameserveraddons' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['addons']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_gameaddons.php');
// App server
} else if ($ui->smallletters('d', 9, 'get') == 'appserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['roots']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_appserver.php');
// Admins, reseller and user
} else if ($ui->smallletters('d', 4, 'get') == 'user' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and ($pa['user'] or $pa['user_users'] or $pa['userPassword'])) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_user.php');
// Voice master
} else if ($ui->smallletters('d', 17, 'get') == 'voicemasterserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['voicemasterserver']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_voicemasterserver.php');
// TSDNS master
} else if ($ui->smallletters('d', 17, 'get') == 'tsdnsmasterserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['voicemasterserver']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_tsdnsmasterserver.php');
// MySQL server
} else if ($ui->smallletters('d', 11, 'get') == 'mysqlserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['mysql_settings']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_mysqlserver.php');
// Web master
} else if ($ui->smallletters('d', 15, 'get') == 'webmasterserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['webmaster']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_webmasterserver.php');
// Page comments
} else if ($ui->smallletters('d', 12, 'get') == 'pagecomments' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['cms_pages']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_pagecomments.php');
// Code wise it seems odd, but this way we can get plausible userIDs for following queries up front without having to repeat ourselves
} else {
// When searching a table combination that should provide a server and user´s loginname, firstname, lastname. First do a search at usertable and get IDs.
// This IDs should be used for doing a `ID` IN (implode(',', $foundIDs)) as it will be faster.
if ($sSearch) {
$userIDs = array();
$query = $sql->prepare("SELECT `id`,`cname`,CONCAT(`vname`,' ',`name`) AS `full_name` FROM `userdata` WHERE `resellerid`=:reseller_id HAVING (`cname` LIKE :search OR `full_name` LIKE :search)");
$query->execute(array(':search' => '%' . $sSearch . '%',':reseller_id' => $resellerLockupID));
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
$userIDs[] = $row['id'];
}
}
if ($ui->smallletters('d', 10, 'get') == 'gameserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['gserver']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_gameserver.php');
} else if ($ui->smallletters('d', 11, 'get') == 'voiceserver' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['voiceserver']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_voiceserver.php');
} else if ($ui->smallletters('d', 5, 'get') == 'tsdns' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['voiceserver']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_tsdns.php');
} else if ($ui->smallletters('d', 7, 'get') == 'mysqldb' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['mysql']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_mysqldb.php');
} else if ($ui->smallletters('d', 8, 'get') == 'webvhost' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['webmaster']) {
require_once(EASYWIDIR . '/stuff/ajax/datatable_webvhost.php');
}
}
die(json_encode($array));
// App master server updates. Triggered asyncronous with ajax to avoid 5xx errors
} else if ($ui->smallletters('d', 21, 'get') == 'masterappserverupdate' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and $pa['masterServer']) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_update.php');
die;
} else if (isset($admin_id) and $pa['gserver'] and $ui->smallletters('d', 14, 'get') == 'appmasterusage') {
if ($ui->id('id', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_usage.php');
}
die;
} else if ($ui->smallletters('d', 18, 'get') == 'appmasterportusage' and isset($admin_id) and $pa['gserver']) {
if ($ui->ip4('ip', 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_port_usage.php');
}
die;
} else if ($ui->smallletters('d', 17, 'get') == 'appmasterportbest' and isset($admin_id) and $pa['gserver']) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_port_best.php');
die;
} else if ($ui->smallletters('d', 19, 'get') == 'appmasterappdetails' and isset($admin_id) and $pa['gserver']) {
require_once(EASYWIDIR . '/stuff/ajax/app_master_app_details.php');
die;
} else if (isset($admin_id) and $pa['voiceserver'] and $ui->smallletters('d', 16, 'get') == 'voicemasterusage') {
if ($ui->id('id', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/voice_master_usage.php');
}
die;
} else if ($ui->smallletters('d', 20, 'get') == 'voicemasterportusage' and isset($admin_id) and $pa['voiceserver']) {
if ($ui->ip4('ip', 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/voice_master_port_usage.php');
}
die;
} else if ($ui->smallletters('d', 16, 'get') == 'tsdnsmasterusage' and isset($admin_id) and $pa['voiceserver']) {
require_once(EASYWIDIR . '/stuff/ajax/tsdns_master_usage.php');
die;
} else if (isset($admin_id) and $ui->smallletters('d', 16, 'get') == 'mysqlmasterusage' and $pa['mysql']) {
if ($ui->id('id', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/mysql_master_usage.php');
}
die;
} else if (isset($admin_id) and $pa['dedicatedServer'] and $ui->smallletters('d', 7, 'get') == 'freeips' and $reseller_id == 0) {
if ($ui->id('userID', 10, 'get')) {
$query = $sql->prepare("SELECT `resellerid` FROM `userdata` WHERE `id`=? LIMIT 1");
$query->execute(array($ui->id('userID', 10, 'get')));
$ipsAvailable = freeips(($query->fetchColumn()));
} else {
$ipsAvailable = array();
}
require_once IncludeTemplate($template_to_use, 'ajax_admin_roots_ips.tpl', 'ajax');
die;
} else if (isset($admin_id) and $pa['fastdl'] and $ui->smallletters('d', 9, 'get') == 'webmaster' and $ui->id('id', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/web_master_usage.php');
die;
} else if (isset($user_id) and $pa['usertickets'] and $ui->w('d', 20, 'get') == 'userTicketCategories' and $ui->id('topicName', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/userpanel_ticket_category.php');
die;
} else if (isset($user_id) and $pa['usertickets'] and $ui->w('d', 24, 'get') == 'resellerTicketCategories' and $ui->id('topicName', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/reseller_ticket_category.php');
die;
} else if (isset($admin_id) and $pa['voiceserverStats'] and $ui->w('d', 15, 'get') == 'adminVoiceStats' and $ui->st('w', 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/admin_voice_stats.php');
die;
} else if (isset($user_id) and $pa['voiceserverStats'] and $ui->smallletters('d', 14, 'get') == 'uservoicestats' and $ui->st('w', 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/userpanel_voice_stats.php');
die;
} else if ($pa['voiceserverStats'] and ((isset($user_id) and $ui->w('d', 14, 'get') == 'voiceUserStats') or (isset($admin_id) and $ui->w('d', 15, 'get') == 'voiceAdminStats'))) {
require_once(EASYWIDIR . '/stuff/ajax/stats_voicestats.php');
die;
} else if (($pa['gserver'] or $pa['restart']) and isset($user_id) and $ui->w('d', 9, 'get') == 'serverLog' and $ui->id('id', 10, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/server_log.php');
die;
} else if (isset($user_id) and ($pa['gserver'] or $pa['restart']) and $ui->username('mapgroup', 50, 'get')) {
require_once(EASYWIDIR . '/stuff/ajax/userpanel_mapgroup.php');
die;
} else if (isset($admin_id) and $pa['settings'] and $ui->w('d', 8, 'get') == 'smtptest' and $ui->id('email_settings_port', 5, 'post')) {
require_once(EASYWIDIR . '/stuff/ajax/email_smtp_test.php');
die;
}
die('No Access:' . $ui->smallletters('d', 200, 'get'));