forked from laksa19/mikhmonv3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
509 lines (413 loc) · 14.6 KB
/
index.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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
<?php
/*
* Copyright (C) 2018 Laksamadi Guko.
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
// hide all error
error_reporting(0);
// check url
ob_start("ob_gzhandler");
$url = $_SERVER['REQUEST_URI'];
// load session MikroTik
$session = $_GET['session'];
if (!isset($_SESSION["mikhmon"])) {
header("Location:./admin.php?id=login");
} elseif (empty($session)) {
echo "<script>window.location='./admin.php?id=sessions'</script>";
} else {
$_SESSION["$session"] = $session;
$setsession = $_SESSION["$session"];
$_SESSION["connect"] = "";
$trff = "trff" . $session;
$_SESSION[$trff] = "";
// load config
include('./include/config.php');
include('./include/readcfg.php');
// routeros api
include_once('./lib/routeros_api.class.php');
include_once('./lib/formatbytesbites.php');
$API = new RouterosAPI();
$API->debug = false;
$API->connect($iphost, $userhost, decrypt($passwdhost));
$getidentity = $API->comm("/system/identity/print");
$identity = $getidentity[0]['name'];
// get variable
$hotspot = $_GET['hotspot'];
$hotspotuser = $_GET['hotspot-user'];
$userbyname = $_GET['hotspot-user'];
$removeuseractive = $_GET['remove-user-active'];
$removehost = $_GET['remove-host'];
$removecookie = $_GET['remove-cookie'];
$removeipbinding = $_GET['remove-ip-binding'];
$removehotspotuser = $_GET['remove-hotspot-user'];
$removehotspotusers = $_GET['remove-hotspot-users'];
$removeuserprofile = $_GET['remove-user-profile'];
$resethotspotuser = $_GET['reset-hotspot-user'];
$removehotspotuserbycomment = $_GET['remove-hotspot-user-by-comment'];
$enablehotspotuser = $_GET['enable-hotspot-user'];
$disablehotspotuser = $_GET['disable-hotspot-user'];
$enableipbinding = $_GET['enable-ip-binding'];
$disableipbinding = $_GET['disable-ip-binding'];
$userprofile = $_GET['user-profile'];
$userprofilebyname = $_GET['user-profile'];
$sys = $_GET['system'];
$enablesch = $_GET['enable-scheduler'];
$disablesch = $_GET['disable-scheduler'];
$removesch = $_GET['remove-scheduler'];
$macbinding = $_GET['mac'];
$ipbinding = $_GET['addr'];
$ppp = $_GET['ppp'];
$secretbyname = $_GET['secret'];
$enablesecr = $_GET['enable-pppsecret'];
$disablesecr = $_GET['disable-pppsecret'];
$removesecr = $_GET['remove-pppsecret'];
$removepprofile = $_GET['remove-pprofile'];
$removepactive = $_GET['remove-pactive'];
$srv = $_GET['srv'];
$prof = $_GET['profile'];
$comm = $_GET['comment'];
$serveractive = $_GET['server'];
$report = $_GET['report'];
include_once('./include/headhtml.php');
include_once('./include/menu.php');
$disable_sci = '<script>
document.getElementById("comment").onkeypress = function(e) {
var chr = String.fromCharCode(e.which);
if (" _!@#$%^&*()+=;|?,.~".indexOf(chr) >= 0)
return false;
};
</script>';
// logout
if ($hotspot == "logout") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Logout...</b>";
session_destroy();
echo "<script>sessionStorage.clear();</script>";
echo "<script>window.location='./admin.php?id=login'</script>";
}
// redirect to home
elseif (substr(end(explode("/", $url)), 0, 8) == "?session") {
include_once('./dashboard/home.php');
$_SESSION['ubn'] = "";
}
// redirect to home
elseif ($hotspot == "dashboard") {
include_once('./dashboard/home.php');
$_SESSION['ubn'] = "";
}
// hotspot log
elseif ($hotspot == "log") {
include_once('./hotspot/log.php');
}
// hotspot log
elseif ($report == "userlog") {
include_once('./report/userlog.php');
}
// about
elseif ($hotspot == "about") {
include_once('./include/about.php');
}
// bad request
elseif (substr($url, -1) == "=") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Bad request! redirect to Home......</b>";
echo "<script>window.location='./'</script>";
}
// hotspot add users
elseif ($hotspot == "add-user") {
$_SESSION['hua'] = "";
include_once('./hotspot/adduser.php');
}
// hotspot users
elseif ($hotspot == "users" && $prof == "all") {
$_SESSION['ubp'] = "";
$_SESSION['hua'] = "";
$_SESSION['ubc'] = "";
$_SESSION['vcr'] = "";
include_once('./hotspot/users.php');
}
// hotspot users filter by profile
elseif ($hotspot == "users" && $prof != "") {
$_SESSION['ubp'] = $prof;
$_SESSION['hua'] = "";
$_SESSION['ubc'] = "";
$_SESSION['vcr'] = "";
include_once('./hotspot/users.php');
}
// hotspot users filter by comment
elseif ($hotspot == "users" && $comm != "") {
$_SESSION['ubc'] = $comm;
$_SESSION['hua'] = "";
$_SESSION['ubp'] = "";
$_SESSION['vcr'] = "";
include_once('./hotspot/users.php');
}
// hotspot by profile
elseif ($hotspot == "users-by-profile") {
$_SESSION['ubp'] = "";
$_SESSION['hua'] = "";
$_SESSION['ubc'] = "";
$_SESSION['vcr'] = "active";
include_once('./hotspot/userbyprofile.php');
}
// export hotspot users
elseif ($hotspot == "export-users") {
include_once('./hotspot/exportusers.php');
}
// add hotspot user
elseif ($hotspotuser == "add") {
include_once('./hotspot/adduser.php');
echo $disable_sci;
}
// add hotspot user
elseif ($hotspotuser == "generate") {
include_once('./hotspot/generateuser.php');
echo $disable_sci;
}
// hotspot users filter by name
elseif (substr($hotspotuser, 0, 1) == "*") {
$_SESSION['ubn'] = $hotspotuser;
$_SESSION['hua'] = "";
include_once('./hotspot/userbyname.php');
} elseif ($hotspotuser != "") {
$_SESSION['ubn'] = $hotspotuser;
include_once('./hotspot/userbyname.php');
}
// remove hotspot user
elseif ($removehotspotuser != "" || $removehotspotusers != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removehotspotuser.php');
}
// remove hotspot user by comment
elseif ($removehotspotuserbycomment != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removehotspotuserbycomment.php');
}
// reset hotspot user
elseif ($resethotspotuser != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/resethotspotuser.php');
}
// enable hotspot user
elseif ($enablehotspotuser != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/enablehotspotuser.php');
}
// disable hotspot user
elseif ($disablehotspotuser != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/disablehotspotuser.php');
}
// user profile
elseif ($hotspot == "user-profiles") {
include_once('./hotspot/userprofile.php');
}
// add user profile
elseif ($userprofile == "add") {
include_once('./hotspot/adduserprofile.php');
}
// User profile by name
elseif (substr($userprofile, 0, 1) == "*") {
include_once('./hotspot/userprofilebyname.php');
} elseif ($userprofile != "") {
include_once('./hotspot/userprofilebyname.php');
}
// remove user profile
elseif ($removeuserprofile != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removeuserprofile.php');
}
// hotspot active
elseif ($hotspot == "active") {
$_SESSION['ubp'] = "";
$_SESSION['hua'] = "hotspotactive";
$_SESSION['ubc'] = "";
include_once('./hotspot/hotspotactive.php');
}
// hotspot hosts
elseif ($hotspot == "dhcp-leases") {
include_once('./dhcp/dhcpleases.php');
}
// hotspot hosts
elseif ($hotspot == "hosts" || $hotspot == "hostp" || $hotspot == "hosta") {
include_once('./hotspot/hosts.php');
}
// hotspot bindings
elseif ($hotspot == "binding") {
include_once('./hotspot/binding.php');
}
// template editor
elseif ($hotspot == "template-editor") {
include_once('./settings/vouchereditor.php');
}
// upload logo
elseif ($hotspot == "uplogo") {
include_once('./settings/uplogo.php');
}
// hotspot Cookies
elseif ($hotspot == "cookies") {
include_once('./hotspot/cookies.php');
}
// remove hotspot Cookies
elseif ($removecookie != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removecookie.php');
}
// hotspot Ip Bindings
elseif ($hotspot == "ipbinding") {
include_once('./hotspot/ipbinding.php');
}
// remove enable disable ipbinding
elseif ($removeipbinding != "" || $enableipbinding != "" || $disableipbinding != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/pipbinding.php');
}
// remove user active
elseif ($removeuseractive != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removeuseractive.php');
}
// remove host
elseif ($removehost != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removehost.php');
}
// makebinding
elseif ($macbinding != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/makebinding.php');
}
// selling
elseif ($report == "selling") {
include_once('./report/selling.php');
}
// ppp secret
elseif ($ppp == "secrets") {
include_once('./ppp/pppsecrets.php');
}
// ppp addsecret
elseif ($ppp == "addsecret") {
include_once('./ppp/addsecret.php');
}
// ppp secretbyname
elseif ($secretbyname != "") {
include_once('./ppp/secretbyname.php');
}
// remove enable disable secret
elseif ($removesecr != "" || $enablesecr != "" || $disablesecr != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/psecret.php');
}
// ppp profile
elseif ($ppp == "profiles") {
include_once('./ppp/pppprofile.php');
}
// remove enable disable profile
elseif ($removepprofile != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removepprofile.php');
}
// ppp active connection
elseif ($ppp == "active") {
include_once('./ppp/pppactive.php');
}
// remove ppp active connection
elseif ($removepactive != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/removepactive.php');
}
// sys scheduler
elseif ($sys == "scheduler") {
include_once('./system/scheduler.php');
}
// remove enable disable scheduler
elseif ($removesch != "" || $enablesch != "" || $disablesch != "") {
echo "<b class='cl-w'><i class='fa fa-circle-o-notch fa-spin' style='font-size:24px'></i> Processing...</b>";
include_once('./process/pscheduler.php');
}
?>
</div>
</div>
</div>
<script src="js/mikhmon-ui.min.js"></script>
<script src="js/mikhmon.js"></script>
<script>
$(document).ready(function(){
$("#filterTable").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#dataTable tbody tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
<?php
if ($hotspot == "dashboard" || substr(end(explode("/", $url)), 0, 8) == "?session") {
echo '<script>
$(document).ready(function(){
var interval= "' . ($areload * 1000) . '";
setInterval(function() {
$("#reloadHome").load("./dashboard/home.php?session=' . $session . '"); }, interval);
})
</script>';
} elseif ($hotspot == "active" && $serveractive != "") {
echo '<script>
$(document).ready(function(){
var interval = "' . ($areload * 1000) . '";
setInterval(function() {
$("#reloadHotspotActive").load("./hotspot/hotspotactive.php?server=' . $serveractive . '&session=' . $session . '"); }, interval);})
</script>
';
} elseif ($hotspot == "active" && $serveractive == "") {
echo '<script>
$(document).ready(function(){
var interval = "' . ($areload * 1000) . '";
setInterval(function() {
$("#reloadHotspotActive").load("./hotspot/hotspotactive.php?session=' . $session . '"); }, interval);})
</script>
';
} elseif ($userprofile == "add" || substr($userprofile, 0, 1) == "*" || $userprofile != "") {
echo "<script>
//enable disable input on ready
$(document).ready(function(){
var exp = document.getElementById('expmode').value;
var val = document.getElementById('validity').style;
var grp = document.getElementById('graceperiod').style;
var vali = document.getElementById('validi');
var grpi = document.getElementById('gracepi');
if (exp === 'rem' || exp === 'remc') {
val.display= 'table-row';
vali.type = 'text';
$('#validi').focus();
grp.display = 'table-row';
grpi.type = 'text';
} else if (exp === 'ntf' || exp === 'ntfc') {
val.display = 'table-row';
vali.type = 'text';
$('#validi').focus();
grp.display = 'none';
grpi.type = 'hidden';
} else {
val.display = 'none';
grp.display = 'none';
vali.type = 'hidden';
grpi.type = 'hidden';
}
});
</script>";
}
}
?>
</body>
</html>