-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
185 lines (167 loc) · 6.2 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
<?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);
ob_start("ob_gzhandler");
// check url
$url = $_SERVER['REQUEST_URI'];
// load session MikroTik
$session = $_GET['session'];
$id = $_GET['id'];
$c = $_GET['c'];
$router = $_GET['router'];
$logo = $_GET['logo'];
$ids = array(
"editor",
"uplogo",
"settings",
);
// lang
include('./lang/isocodelang.php');
include('./include/lang.php');
include('./lang/'.$langid.'.php');
// quick bt
include('./include/quickbt.php');
// theme
include('./include/theme.php');
include('./settings/settheme.php');
include('./settings/setlang.php');
if ($_SESSION['theme'] == "") {
$theme = $theme;
$themecolor = $themecolor;
} else {
$theme = $_SESSION['theme'];
$themecolor = $_SESSION['themecolor'];
}
// load config
include_once('./include/headhtml.php');
include('./include/config.php');
include('./include/readcfg.php');
include_once('./lib/routeros_api.class.php');
include_once('./lib/formatbytesbites.php');
?>
<?php
if ($id == "login" || substr($url, -1) == "p") {
if (isset($_POST['login'])) {
$user = $_POST['user'];
$pass = $_POST['pass'];
if ($user == $useradm && $pass == decrypt($passadm)) {
$_SESSION["mikhmon"] = $user;
echo "<script>window.location='./admin.php?id=sessions'</script>";
} else {
$error = '<div style="width: 100%; padding:5px 0px 5px 0px; border-radius:5px;" class="bg-danger"><i class="fa fa-ban"></i> Alert!<br>Invalid username or password.</div>';
}
}
include_once('./include/login.php');
} elseif (!isset($_SESSION["mikhmon"])) {
echo "<script>window.location='./admin.php?id=login'</script>";
} elseif (substr($url, -1) == "/" || substr($url, -4) == ".php") {
echo "<script>window.location='./admin.php?id=sessions'</script>";
} elseif ($id == "sessions") {
$_SESSION["connect"] = "";
include_once('./include/menu.php');
include_once('./settings/sessions.php');
/*echo '
<script type="text/javascript">
document.getElementById("sessname").onkeypress = function(e) {
var chr = String.fromCharCode(e.which);
if (" _!@#$%^&*()+=;|?,~".indexOf(chr) >= 0)
return false;
};
</script>';*/
} elseif ($id == "settings" && !empty($session) || $id == "settings" && !empty($router)) {
include_once('./include/menu.php');
include_once('./settings/settings.php');
echo '
<script type="text/javascript">
document.getElementById("sessname").onkeypress = function(e) {
var chr = String.fromCharCode(e.which);
if (" _!@#$%^&*()+=;|?,~".indexOf(chr) >= 0)
return false;
};
</script>';
} elseif ($id == "connect" && !empty($session)) {
ini_set("max_execution_time",5);
include_once('./include/menu.php');
$API = new RouterosAPI();
$API->debug = false;
if ($API->connect($iphost, $userhost, decrypt($passwdhost))){
$_SESSION["connect"] = "<b class='text-green'>Connected</b>";
echo "<script>window.location='./?session=" . $session . "'</script>";
} else {
$_SESSION["connect"] = "<b class='text-red'>Not Connected</b>";
$nl = '\n';
if ($currency == in_array($currency, $cekindo['indo'])) {
echo "<script>alert('Mikhmon not connected!".$nl."Silakan periksa kembali IP, User, Password dan port API harus enable.".$nl."Jika menggunakan koneksi VPN, pastikan VPN tersebut terkoneksi.')</script>";
}else{
echo "<script>alert('Mikhmon not connected!".$nl."Please check the IP, User, Password and port API must be enabled.')</script>";
}
if($c == "settings"){
echo "<script>window.location='./admin.php?id=settings&session=" . $session . "'</script>";
}else{
echo "<script>window.location='./admin.php?id=sessions'</script>";
}
}
} elseif ($id == "uplogo" && !empty($session)) {
include_once('./include/menu.php');
include_once('./settings/uplogo.php');
} elseif ($id == "reboot" && !empty($session)) {
include_once('./process/reboot.php');
} elseif ($id == "shutdown" && !empty($session)) {
include_once('./process/shutdown.php');
} elseif ($id == "remove-session" && $session != "") {
include_once('./include/menu.php');
$fc = file("./include/config.php" );
$f = fopen("./include/config.php", "w");
$q = "'";
$rem = '$data['.$q.$session.$q.']';
foreach ($fc as $line) {
if (!strstr($line, $rem))
fputs($f, $line);
}
fclose($f);
echo "<script>window.location='./admin.php?id=sessions'</script>";
} elseif ($id == "about") {
include_once('./include/menu.php');
include_once('./include/about.php');
} elseif ($id == "logout") {
include_once('./include/menu.php');
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>window.location='./admin.php?id=login'</script>";
} elseif ($id == "remove-logo" && $logo != "" && !empty($session)) {
include_once('./include/menu.php');
$logopath = "./img/";
$remlogo = $logopath . $logo;
unlink("$remlogo");
echo "<script>window.location='./admin.php?id=uplogo&session=" . $session . "'</script>";
} elseif ($id == "editor" && !empty($session)) {
include_once('./include/menu.php');
include_once('./settings/vouchereditor.php');
} elseif (empty($id)) {
echo "<script>window.location='./admin.php?id=sessions'</script>";
} elseif(in_array($id, $ids) && empty($session)){
echo "<script>window.location='./admin.php?id=sessions'</script>";
}
?>
<script src="js/mikhmon-ui.<?= $theme; ?>.min.js"></script>
<script src="js/mikhmon.js?t=<?= str_replace(" ","_",date("Y-m-d H:i:s")); ?>"></script>
<?php include('./include/info.php'); ?>
</body>
</html>