init: workspace opencode sync

This commit is contained in:
2026-08-15 00:28:06 +07:00
commit eb71c40fc1
170 changed files with 23352 additions and 0 deletions
+201
View File
@@ -0,0 +1,201 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
$getprofile = $API->comm("/ip/hotspot/user/profile/print");
$srvlist = $API->comm("/ip/hotspot/print");
if (isset($_POST['name'])) {
$server = ($_POST['server']);
$name = ($_POST['name']);
$password = ($_POST['pass']);
$profile = ($_POST['profile']);
$disabled = ($_POST['disabled']);
$timelimit = ($_POST['timelimit']);
$datalimit = ($_POST['datalimit']);
$comment = ($_POST['comment']);
$chkvalid = ($_POST['valid']);
$mbgb = ($_POST['mbgb']);
if ($timelimit == "") {
$timelimit = "0";
} else {
$timelimit = $timelimit;
}
if ($datalimit == "") {
$datalimit = "0";
} else {
$datalimit = $datalimit * $mbgb;
}
if ($name == $password) {
$usermode = "vc-";
}else{
$usermode = "up-";
}
$comment = $usermode.$comment;
$API->comm("/ip/hotspot/user/add", array(
"server" => "$server",
"name" => "$name",
"password" => "$password",
"profile" => "$profile",
"disabled" => "no",
"limit-uptime" => "$timelimit",
"limit-bytes-total" => "$datalimit",
"comment" => "$comment",
));
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?name" => "$name",
));
$uid = $getuser[0]['.id'];
echo "<script>window.location='./?hotspot-user=" . $uid . "&session=" . $session . "'</script>";
}
}
?>
<script>
function PassUser(){
var x = document.getElementById('passUser');
if (x.type === 'password') {
x.type = 'text';
} else {
x.type = 'password';
}}
</script>
<div class="row">
<div class="col-8">
<div class="card box-bordered">
<div class="card-header">
<h3><i class="fa fa-user-plus"></i> <?= $_add_user ?> <small id="loader" style="display: none;" ><i><i class='fa fa-circle-o-notch fa-spin'></i> <?= $_processing ?> </i></small></h3>
</div>
<div class="card-body">
<form autocomplete="off" method="post" action="">
<div>
<?php if ($_SESSION['ubp'] != "") {
echo " <a class='btn bg-warning' href='./?hotspot=users&profile=" . $_SESSION['ubp'] . "&session=" . $session . "'> <i class='fa fa-close'></i> ".$_close."</a>";
} else {
echo " <a class='btn bg-warning' href='./?hotspot=users&profile=all&session=" . $session . "'> <i class='fa fa-close'></i> ".$_close."</a>";
}
?>
<button type="submit" onclick="loader()" class="btn bg-primary" name="save"><i class="fa fa-save"></i> <?= $_save ?></button>
</div>
<table class="table">
<tr>
<td class="align-middle" >Server</td>
<td>
<select class="form-control" name="server" required="1">
<option>all</option>
<?php $TotalReg = count($srvlist);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $srvlist[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_name ?></td><td><input class="form-control" type="text" autocomplete="off" name="name" value="" required="1" autofocus></td>
</tr>
<tr>
<td class="align-middle"><?= $_password ?></td><td>
<div class="input-group">
<div class="input-group-11 col-box-10">
<input class="group-item group-item-l" id="passUser" type="password" name="pass" autocomplete="new-password" value="" required="1">
</div>
<div class="input-group-1 col-box-2">
<div class="group-item group-item-r pd-2p5 text-center">
<input title="Show/Hide Password" type="checkbox" onclick="PassUser()">
</div>
</div>
</div>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_profile ?></td><td>
<select class="form-control" onchange="GetVP();" id="uprof" name="profile" required="1">
<?php $TotalReg = count($getprofile);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getprofile[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_time_limit ?></td><td><input class="form-control" type="text" autocomplete="off" name="timelimit" value=""></td>
</tr>
<tr>
<td class="align-middle"><?= $_data_limit ?></td><td>
<div class="input-group">
<div class="input-group-10 col-box-9">
<input class="group-item group-item-l" type="number" min="0" max="9999" name="datalimit" value="<?= $udatalimit; ?>">
</div>
<div class="input-group-2 col-box-3">
<select style="padding:4.2px;" class="group-item group-item-r" name="mbgb" required="1">
<option value=1048576>MB</option>
<option value=1073741824>GB</option>
</select>
</div>
</div>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_comment ?></td><td><input class="form-control" type="text" title="No special characters" id="comment" autocomplete="off" name="comment" value=""></td>
</tr>
<tr >
<td colspan="4" class="align-middle" id="GetValidPrice"></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-book"></i> <?= $_readme ?></h3>
</div>
<div class="card-body">
<table>
<tr>
<td colspan="2">
<p style="padding:0px 5px;">
<?= $_format_time_limit ?>
</p>
<p style="padding:0px 5px;">
<?= $_details_add_user ?>
</p>
</td>
</tr>
</table>
</div>
</div>
</div>
<script>
// get valid $ price
function GetVP(){
var prof = document.getElementById('uprof').value;
$("#GetValidPrice").load("./process/getvalidprice.php?name="+prof+"&session=<?= $session; ?> #getdata");
}
</script>
</div>
+254
View File
@@ -0,0 +1,254 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
$getallqueue = $API->comm("/queue/simple/print", array(
"?dynamic" => "false",
));
$getpool = $API->comm("/ip/pool/print");
if (isset($_POST['name'])) {
$name = (preg_replace('/\s+/', '-',$_POST['name']));
$sharedusers = ($_POST['sharedusers']);
$ratelimit = ($_POST['ratelimit']);
$expmode = ($_POST['expmode']);
$validity = ($_POST['validity']);
$graceperiod = ($_POST['graceperiod']);
$getprice = ($_POST['price']);
$getsprice = ($_POST['sprice']);
$addrpool = ($_POST['ppool']);
if ($getprice == "") {
$price = "0";
} else {
$price = $getprice;
}
if ($getsprice == "") {
$sprice = "0";
} else {
$sprice = $getsprice;
}
$getlock = ($_POST['lockunlock']);
if ($getlock == "Enable") {
$lock = '; [:local mac $"mac-address"; /ip hotspot user set mac-address=$mac [find where name=$user]]';
} else {
$lock = "";
}
$randstarttime = "0".rand(1,5).":".rand(10,59).":".rand(10,59);
$randinterval = "00:02:".rand(10,59);
$parent = ($_POST['parent']);
$record = '; :local mac $"mac-address"; :local time [/system clock get time ]; /system script add name="$date-|-$time-|-$user-|-'.$price.'-|-$address-|-$mac-|-' . $validity . '-|-'.$name.'-|-$comment" owner="$month$year" source=$date comment=mikhmon';
$onlogin = ':put (",'.$expmode.',' . $price . ',' . $validity . ','.$sprice.',,' . $getlock . ',"); {:local date [ /system clock get date ];:local year [ :pick $date 7 11 ];:local month [ :pick $date 0 3 ];:local comment [ /ip hotspot user get [/ip hotspot user find where name="$user"] comment]; :local ucode [:pic $comment 0 2]; :if ($ucode = "vc" or $ucode = "up" or $comment = "") do={ /sys sch add name="$user" disable=no start-date=$date interval="' . $validity . '"; :delay 2s; :local exp [ /sys sch get [ /sys sch find where name="$user" ] next-run]; :local getxp [len $exp]; :if ($getxp = 15) do={ :local d [:pic $exp 0 6]; :local t [:pic $exp 7 16]; :local s ("/"); :local exp ("$d$s$year $t"); /ip hotspot user set comment=$exp [find where name="$user"];}; :if ($getxp = 8) do={ /ip hotspot user set comment="$date $exp" [find where name="$user"];}; :if ($getxp > 15) do={ /ip hotspot user set comment=$exp [find where name="$user"];}; /sys sch remove [find where name="$user"]';
if ($expmode == "rem") {
$onlogin = $onlogin . $lock . "}}";
$mode = "remove";
} elseif ($expmode == "ntf") {
$onlogin = $onlogin . $lock . "}}";
$mode = "set limit-uptime=1s";
} elseif ($expmode == "remc") {
$onlogin = $onlogin . $record . $lock . "}}";
$mode = "remove";
} elseif ($expmode == "ntfc") {
$onlogin = $onlogin . $record . $lock . "}}";
$mode = "set limit-uptime=1s";
} elseif ($expmode == "0" && $price != "") {
$onlogin = ':put (",,' . $price . ',,,noexp,' . $getlock . ',")' . $lock;
} else {
$onlogin = "";
}
$bgservice = ':local dateint do={:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" );:local days [ :pick $d 4 6 ];:local month [ :pick $d 0 3 ];:local year [ :pick $d 7 11 ];:local monthint ([ :find $montharray $month]);:local month ($monthint + 1);:if ( [len $month] = 1) do={:local zero ("0");:return [:tonum ("$year$zero$month$days")];} else={:return [:tonum ("$year$month$days")];}}; :local timeint do={ :local hours [ :pick $t 0 2 ]; :local minutes [ :pick $t 3 5 ]; :return ($hours * 60 + $minutes) ; }; :local date [ /system clock get date ]; :local time [ /system clock get time ]; :local today [$dateint d=$date] ; :local curtime [$timeint t=$time] ; :foreach i in [ /ip hotspot user find where profile="'.$name.'" ] do={ :local comment [ /ip hotspot user get $i comment]; :local name [ /ip hotspot user get $i name]; :local gettime [:pic $comment 12 20]; :if ([:pic $comment 3] = "/" and [:pic $comment 6] = "/") do={:local expd [$dateint d=$comment] ; :local expt [$timeint t=$gettime] ; :if (($expd < $today and $expt < $curtime) or ($expd < $today and $expt > $curtime) or ($expd = $today and $expt < $curtime)) do={ [ /ip hotspot user '.$mode.' $i ]; [ /ip hotspot active remove [find where user=$name] ];}}}';
$API->comm("/ip/hotspot/user/profile/add", array(
/*"add-mac-cookie" => "yes",*/
"name" => "$name",
"address-pool" => "$addrpool",
"rate-limit" => "$ratelimit",
"shared-users" => "$sharedusers",
"status-autorefresh" => "1m",
//"transparent-proxy" => "yes",
"on-login" => "$onlogin",
"parent-queue" => "$parent",
));
if($expmode != "0"){
if (empty($monid)){
$API->comm("/system/scheduler/add", array(
"name" => "$name",
"start-time" => "$randstarttime",
"interval" => "$randinterval",
"on-event" => "$bgservice",
"disabled" => "no",
"comment" => "Monitor Profile $name",
));
}else{
$API->comm("/system/scheduler/set", array(
".id" => "$monid",
"name" => "$name",
"start-time" => "$randstarttime",
"interval" => "$randinterval",
"on-event" => "$bgservice",
"disabled" => "no",
"comment" => "Monitor Profile $name",
));
}}else{
$API->comm("/system/scheduler/remove", array(
".id" => "$monid"));
}
$getprofile = $API->comm("/ip/hotspot/user/profile/print", array(
"?name" => "$name",
));
$pid = $getprofile[0]['.id'];
echo "<script>window.location='./?user-profile=" . $pid . "&session=" . $session . "'</script>";
}
}
?>
<div class="row">
<div class="col-8">
<div class="card box-bordered">
<div class="card-header">
<h3><i class="fa fa-plus"></i> <?= $_add.' '.$_user_profile ?> <small id="loader" style="display: none;" ><i><i class='fa fa-circle-o-notch fa-spin'></i> Processing... </i></small></h3>
</div>
<div class="card-body">
<form autocomplete="off" method="post" action="">
<div>
<a class="btn bg-warning" href="./?hotspot=user-profiles&session=<?= $session; ?>"> <i class="fa fa-close btn-mrg"></i> <?= $_close ?></a>
<button type="submit" name="save" class="btn bg-primary btn-mrg" ><i class="fa fa-save btn-mrg"></i> <?= $_save ?></button>
</div>
<table class="table">
<tr>
<td class="align-middle"><?= $_name ?></td><td><input class="form-control" type="text" onchange="remSpace();" autocomplete="off" name="name" value="" required="1" autofocus></td>
</tr>
<tr>
<td class="align-middle">Address Pool</td>
<td>
<select class="form-control " name="ppool">
<option>none</option>
<?php $TotalReg = count($getpool);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getpool[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle">Shared Users</td><td><input class="form-control" type="text" size="4" autocomplete="off" name="sharedusers" value="1" required="1"></td>
</tr>
<tr>
<td class="align-middle">Rate limit [up/down]</td><td><input class="form-control" type="text" name="ratelimit" autocomplete="off" value="" placeholder="Example : 512k/1M" ></td>
</tr>
<tr>
<td class="align-middle"><?= $_expired_mode ?></td><td>
<select class="form-control" onchange="RequiredV();" id="expmode" name="expmode" required="1">
<option value="">Select...</option>
<option value="0">None</option>
<option value="rem">Remove</option>
<option value="ntf">Notice</option>
<option value="remc">Remove & Record</option>
<option value="ntfc">Notice & Record</option>
</select>
</td>
</tr>
<tr id="validity" style="display:none;">
<td class="align-middle"><?= $_validity ?></td><td><input class="form-control" type="text" id="validi" size="4" autocomplete="off" name="validity" value="" required="1"></td>
</tr>
<tr id="graceperiod" style="display:none;">
<td class="align-middle"><?= $_grace_period ?></td><td><input class="form-control" type="text" id="gracepi" size="4" autocomplete="off" name="graceperiod" placeholder="5m" value="5m" required="1"></td>
</tr>
<tr>
<td class="align-middle"><?= $_price.' '.$currency; ?></td><td><input class="form-control" type="text" size="10" min="0" name="price" value="" ></td>
</tr>
<tr>
<td class="align-middle"><?= $_selling_price.' '.$currency; ?></td><td><input class="form-control" type="text" size="10" min="0" name="sprice" value="" ></td>
</tr>
<tr>
<td><?= $_lock_user ?></td><td>
<select class="form-control" id="lockunlock" name="lockunlock" required="1">
<option value="Disable">Disable</option>
<option value="Enable">Enable</option>
</select>
</td>
</tr>
<tr>
<td class="align-middle">Parent Queue</td>
<td>
<select class="form-control " name="parent">
<option>none</option>
<?php $TotalReg = count($getallqueue);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getallqueue[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-book"></i> <?= $_readme ?></h3>
</div>
<div class="card-body">
<table class="table">
<tr>
<td colspan="2">
<p style="padding:0px 5px;">
<?= $_details_user_profile ?>
</p>
<p style="padding:0px 5px;">
<?= $_format_validity ?>
</p>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function remSpace() {
var upName = document.getElementsByName("name")[0];
var newUpName = upName.value.replace(/\s/g, "-");
//alert("<?php if ($currency == in_array($currency, $cekindo['indo'])) {
echo "Nama Profile tidak boleh berisi spasi";
} else {
echo "Profile name can't containing white space!";
} ?>");
upName.value = newUpName;
upName.focus();
}
</script>
+93
View File
@@ -0,0 +1,93 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
$getcookies = $API->comm("/ip/hotspot/cookie/print");
$TotalReg = count($getcookies);
$countcookies = $API->comm("/ip/hotspot/cookie/print", array(
"count-only" => "",
));
}
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class=" fa fa-sitemap"></i> Hotspot Cookies
<?php
if ($countcookies < 2) {
echo "$countcookies item";
} elseif ($countcookies > 1) {
echo "$countcookies items";
};
echo "</th>";
?>
&nbsp;&nbsp; | &nbsp;&nbsp;<i onclick="location.reload();" class="fa fa-refresh pointer" title="Reload data"></i>
</h3>
</div>
<div class="card-body">
<div class="w-6">
<input id="filterTable" type="text" class="form-control" placeholder="Search..">
</div>
<div class="overflow box-bordered mr-t-10" style="max-height: 75vh">
<table id="dataTable" class="table table-bordered table-hover text-nowrap">
<thead>
<tr>
<th></th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> User</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> MAC Address</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Domain</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Expires In</th>
</tr>
</thead>
<tbody>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$cookies = $getcookies[$i];
$id = $cookies['.id'];
$user = $cookies['user'];
$maca = $cookies['mac-address'];
$domain = $cookies['domain'];
$exp = formatDTM($cookies['expires-in']);
$uriprocess = "'./?remove-cookie=" . $id . "&session=" . $session . "'";
echo "<tr>";
echo "<td style='text-align:center;'><span class='pointer' title='Remove " . $user . "' onclick=loadpage(".$uriprocess.")><i class='fa fa-minus-square text-danger'></i></span></td>";
echo "<td>" . $user . "</td>";
echo "<td>" . $maca . "</td>";
echo "<td>" . $domain . "</td>";
echo "<td>" . $exp . "</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
+205
View File
@@ -0,0 +1,205 @@
<?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/>.
*/
// hide all error
error_reporting(0);
ini_set('max_execution_time', 300);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
if ($prof == "all") {
$getuser = $API->comm("/ip/hotspot/user/print");
$TotalReg = count($getuser);
$counttuser = $API->comm("/ip/hotspot/user/print", array(
"count-only" => ""
));
} elseif ($prof != "all") {
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?profile" => "$prof",
));
$TotalReg = count($getuser);
$counttuser = $API->comm("/ip/hotspot/user/print", array(
"count-only" => "",
"?profile" => "$prof",
));
}
if ($comm != "") {
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?comment" => "$comm",
//"?uptime" => "00:00:00"
));
$TotalReg = count($getuser);
$counttuser = $API->comm("/ip/hotspot/user/print", array(
"count-only" => "",
"?comment" => "$comm",
));
}
}
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-users"></i> Export Hotspot Users | <strong class="pointer" onclick="exportTableToCSV('export-user-hotspot-mikhmon-<?= date("Y-m-d"); ?>.<?php if ($_GET['export'] == "csv") {
echo "csv";
} else {
echo "txt";
} ?>')" title="Download User List"><i class="fa fa-download"></i> Download</strong>
</h3>
</div>
<div class="card-body overflow">
<table id="export" class="text-nowrap <?php if ($_GET['export'] == "csv") {
echo "table table-bordered";
} ?>">
<?php if ($_GET['export'] == "script") { ?>
<tr>
<td>/ip hotspot user</td>
</tr>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$userdetails = $getuser[$i];
$uid = $userdetails['.id'];
$userver = $userdetails['server'];
$uname = $userdetails['name'];
$upass = $userdetails['password'];
$uprofile = $userdetails['profile'];
$uuptime = formatDTM($userdetails['uptime']);
$ubyteso = formatBytes($userdetails['bytes-out'], 2);
if ($ubyteso == 0) {
$ubyteso = "";
} else {
$ubyteso = $ubyteso;
}
$ucomment = $userdetails['comment'];
$udisabled = $userdetails['disabled'];
$utimelimit = $userdetails['limit-uptime'];
$udatalimit = $userdetails['limit-bytes-total'];
if ($utimelimit == "") {
$timelimit = "";
} else {
$timelimit = 'limit-uptime="' . $utimelimit . '"';
}
if ($udatalimit == "") {
$datalimit = "";
} else {
$datalimit = 'limit-bytes-total="' . $udatalimit . '"';
}
if ($ucomment == "") {
$comment = "";
} else {
$comment = 'comment="' . $ucomment . '"';
}
echo '
<tr>
<td>add name="' . $uname . '" password="' . $upass . '" profile="' . $uprofile . '" ' . $comment . ' ' . $timelimit . ' ' . $datalimit . '</td>
</tr>
';
}
} else if ($_GET['export'] == "csv") { ?>
<tr>
<th>Username</th>
<th>Password</th>
<th>Profile</th>
<th>Time Limit</th>
<th>Data Limit</th>
<th>Comment</th>
</tr>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$userdetails = $getuser[$i];
$uid = $userdetails['.id'];
$userver = $userdetails['server'];
$uname = $userdetails['name'];
$upass = $userdetails['password'];
$uprofile = $userdetails['profile'];
$uuptime = formatDTM($userdetails['uptime']);
$ubyteso = formatBytes($userdetails['bytes-out'], 2);
if ($ubyteso == 0) {
$ubyteso = "";
} else {
$ubyteso = $ubyteso;
}
$ucomment = $userdetails['comment'];
$udisabled = $userdetails['disabled'];
$utimelimit = $userdetails['limit-uptime'];
$udatalimit = $userdetails['limit-bytes-total'];
echo '
<tr>
<td>' . $uname . '</td>
<td>' . $upass . '</td>
<td>' . $uprofile . '</td>
<td>' . $utimelimit . '</td>
<td>' . $udatalimit . '</td>
<td>' . $ucomment . '</td>
</tr>
';
}
}
?>
</table>
</div>
</div>
</div>
</div>
<script>
function downloadCSV(csv, filename) {
var csvFile;
var downloadLink;
// CSV file
csvFile = new Blob([csv], {type: "text/csv"});
// Download link
downloadLink = document.createElement("a");
// File name
downloadLink.download = filename;
// Create a link to the file
downloadLink.href = window.URL.createObjectURL(csvFile);
// Hide download link
downloadLink.style.display = "none";
// Add the link to DOM
document.body.appendChild(downloadLink);
// Click download link
downloadLink.click();
}
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("#export tr");
for (var i = 0; i < rows.length; i++) {
var row = [], cols = rows[i].querySelectorAll("td, th");
for (var j = 0; j < cols.length; j++)
row.push(cols[j].innerText);
csv.push(row.join(","));
}
// Download CSV file
downloadCSV(csv.join("\n"), filename);
}
</script>
+481
View File
@@ -0,0 +1,481 @@
<?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);
ini_set('max_execution_time', 300);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
// time zone
date_default_timezone_set($_SESSION['timezone']);
$genprof = $_GET['genprof'];
if ($genprof != "") {
$getprofile = $API->comm("/ip/hotspot/user/profile/print", array(
"?name" => "$genprof",
));
$ponlogin = $getprofile[0]['on-login'];
$getprice = explode(",", $ponlogin)[2];
if ($getprice == "0") {
$getprice = "";
} else {
$getprice = $getprice;
}
$getvalid = explode(",", $ponlogin)[3];
$getlocku = explode(",", $ponlogin)[6];
if ($getlocku == "") {
$getprice = "Disable";
} else {
$getlocku = $getlocku;
}
if ($currency == in_array($currency, $cekindo['indo'])) {
$getprice = $currency . " " . number_format((float)$getprice, 0, ",", ".");
} else {
$getprice = $currency . " " . number_format((float)$getprice);
}
$ValidPrice = "<b>Validity : " . $getvalid . " | Price : " . $getprice . " | Lock User : " . $getlocku . "</b>";
} else {
}
$srvlist = $API->comm("/ip/hotspot/print");
if (isset($_POST['qty'])) {
$qty = ($_POST['qty']);
$server = ($_POST['server']);
$user = ($_POST['user']);
$userl = ($_POST['userl']);
$prefix = ($_POST['prefix']);
$char = ($_POST['char']);
$profile = ($_POST['profile']);
$timelimit = ($_POST['timelimit']);
$datalimit = ($_POST['datalimit']);
$adcomment = ($_POST['adcomment']);
$mbgb = ($_POST['mbgb']);
if ($timelimit == "") {
$timelimit = "0";
} else {
$timelimit = $timelimit;
}
if ($datalimit == "") {
$datalimit = "0";
} else {
$datalimit = $datalimit * $mbgb;
}
if ($adcomment == "") {
$adcomment = "";
} else {
$adcomment = $adcomment;
}
$getprofile = $API->comm("/ip/hotspot/user/profile/print", array("?name" => "$profile"));
$ponlogin = $getprofile[0]['on-login'];
$getvalid = explode(",", $ponlogin)[3];
$getprice = explode(",", $ponlogin)[2];
$getsprice = explode(",", $ponlogin)[4];
$getlock = explode(",", $ponlogin)[6];
$_SESSION['ubp'] = $profile;
$commt = $user . "-" . rand(100, 999) . "-" . date("m.d.y") . "-" . $adcomment;
$gentemp = $commt . "|~" . $profile . "~" . $getvalid . "~" . $getprice . "!".$getsprice."~" . $timelimit . "~" . $datalimit . "~" . $getlock;
$gen = '<?php $genu="'.encrypt($gentemp).'";?>';
$temp = './voucher/temp.php';
$handle = fopen($temp, 'w') or die('Cannot open file: ' . $temp);
$data = $gen;
fwrite($handle, $data);
$a = array("1" => "", "", 1, 2, 2, 3, 3, 4);
if ($user == "up") {
for ($i = 1; $i <= $qty; $i++) {
if ($char == "lower") {
$u[$i] = randLC($userl);
} elseif ($char == "upper") {
$u[$i] = randUC($userl);
} elseif ($char == "upplow") {
$u[$i] = randULC($userl);
} elseif ($char == "mix") {
$u[$i] = randNLC($userl);
} elseif ($char == "mix1") {
$u[$i] = randNUC($userl);
} elseif ($char == "mix2") {
$u[$i] = randNULC($userl);
}
if ($userl == 3) {
$p[$i] = randN(3);
} elseif ($userl == 4) {
$p[$i] = randN(4);
} elseif ($userl == 5) {
$p[$i] = randN(5);
} elseif ($userl == 6) {
$p[$i] = randN(6);
} elseif ($userl == 7) {
$p[$i] = randN(7);
} elseif ($userl == 8) {
$p[$i] = randN(8);
}
$u[$i] = "$prefix$u[$i]";
}
for ($i = 1; $i <= $qty; $i++) {
$API->comm("/ip/hotspot/user/add", array(
"server" => "$server",
"name" => "$u[$i]",
"password" => "$p[$i]",
"profile" => "$profile",
"limit-uptime" => "$timelimit",
"limit-bytes-total" => "$datalimit",
"comment" => "$commt",
));
}
}
if ($user == "vc") {
$shuf = ($userl - $a[$userl]);
for ($i = 1; $i <= $qty; $i++) {
if ($char == "lower") {
$u[$i] = randLC($shuf);
} elseif ($char == "upper") {
$u[$i] = randUC($shuf);
} elseif ($char == "upplow") {
$u[$i] = randULC($shuf);
}
if ($userl == 3) {
$p[$i] = randN(1);
} elseif ($userl == 4 || $userl == 5) {
$p[$i] = randN(2);
} elseif ($userl == 6 || $userl == 7) {
$p[$i] = randN(3);
} elseif ($userl == 8) {
$p[$i] = randN(4);
}
$u[$i] = "$prefix$u[$i]$p[$i]";
if ($char == "num") {
if ($userl == 3) {
$p[$i] = randN(3);
} elseif ($userl == 4) {
$p[$i] = randN(4);
} elseif ($userl == 5) {
$p[$i] = randN(5);
} elseif ($userl == 6) {
$p[$i] = randN(6);
} elseif ($userl == 7) {
$p[$i] = randN(7);
} elseif ($userl == 8) {
$p[$i] = randN(8);
}
$u[$i] = "$prefix$p[$i]";
}
if ($char == "mix") {
$p[$i] = randNLC($userl);
$u[$i] = "$prefix$p[$i]";
}
if ($char == "mix1") {
$p[$i] = randNUC($userl);
$u[$i] = "$prefix$p[$i]";
}
if ($char == "mix2") {
$p[$i] = randNULC($userl);
$u[$i] = "$prefix$p[$i]";
}
}
for ($i = 1; $i <= $qty; $i++) {
$API->comm("/ip/hotspot/user/add", array(
"server" => "$server",
"name" => "$u[$i]",
"password" => "$u[$i]",
"profile" => "$profile",
"limit-uptime" => "$timelimit",
"limit-bytes-total" => "$datalimit",
"comment" => "$commt",
));
}
}
if ($qty < 2) {
echo "<script>window.location='./?hotspot-user=" . $u[1] . "&session=" . $session . "'</script>";
} else {
echo "<script>window.location='./?hotspot-user=generate&session=" . $session . "'</script>";
}
}
$getprofile = $API->comm("/ip/hotspot/user/profile/print");
include_once('./voucher/temp.php');
$genuser = explode("-", decrypt($genu));
$genuser1 = explode("~", decrypt($genu));
$umode = $genuser[0];
$ucode = $genuser[1];
$udate = $genuser[2];
$uprofile = $genuser1[1];
$uvalid = $genuser1[2];
$ucommt = $genuser[3];
if ($uvalid == "") {
$uvalid = "-";
} else {
$uvalid = $uvalid;
}
$uprice = explode("!",$genuser1[3])[0];
if ($uprice == "0") {
$uprice = "-";
} else {
$uprice = $uprice;
}
$suprice = explode("!",$genuser1[3])[1];
if ($suprice == "0") {
$suprice = "-";
} else {
$suprice = $suprice;
}
$utlimit = $genuser1[4];
if ($utlimit == "0") {
$utlimit = "-";
} else {
$utlimit = $utlimit;
}
$udlimit = $genuser1[5];
if ($udlimit == "0") {
$udlimit = "-";
} else {
$udlimit = formatBytes($udlimit, 2);
}
$ulock = $genuser1[6];
//$urlprint = "$umode-$ucode-$udate-$ucommt";
$urlprint = explode("|", decrypt($genu))[0];
if ($currency == in_array($currency, $cekindo['indo'])) {
$uprice = $currency . " " . number_format((float)$uprice, 0, ",", ".");
$suprice = $currency . " " . number_format((float)$suprice, 0, ",", ".");
} else {
$uprice = $currency . " " . number_format((float)$uprice);
$suprice = $currency . " " . number_format((float)$suprice);
}
}
?>
<div class="row">
<div class="col-8">
<div class="card box-bordered">
<div class="card-header">
<h3><i class="fa fa-user-plus"></i> <?= $_generate_user ?> <small id="loader" style="display: none;" ><i><i class='fa fa-circle-o-notch fa-spin'></i> <?= $_processing ?> </i></small></h3>
</div>
<div class="card-body">
<form autocomplete="off" method="post" action="">
<div>
<?php if ($_SESSION['ubp'] != "") {
echo " <a class='btn bg-warning' href='./?hotspot=users&profile=" . $_SESSION['ubp'] . "&session=" . $session . "'> <i class='fa fa-close'></i> ".$_close."</a>";
} elseif ($_SESSION['vcr'] = "active") {
echo " <a class='btn bg-warning' href='./?hotspot=users-by-profile&session=" . $session . "'> <i class='fa fa-close'></i> ".$_close."</a>";
} else {
echo " <a class='btn bg-warning' href='./?hotspot=users&profile=all&session=" . $session . "'> <i class='fa fa-close'></i> ".$_close."</a>";
}
?>
<a class="btn bg-pink" title="Open User List by Profile
<?php if ($_SESSION['ubp'] == "") {
echo "all";
} else {
echo $uprofile;
} ?>" href="./?hotspot=users&profile=
<?php if ($_SESSION['ubp'] == "") {
echo "all";
} else {
echo $uprofile;
} ?>&session=<?= $session; ?>"> <i class="fa fa-users"></i> <?= $_user_list ?></a>
<button type="submit" name="save" onclick="loader()" class="btn bg-primary" title="Generate User"> <i class="fa fa-save"></i> <?= $_generate ?></button>
<a class="btn bg-secondary" title="Print Default" href="./voucher/print.php?id=<?= $urlprint; ?>&qr=no&session=<?= $session; ?>" target="_blank"> <i class="fa fa-print"></i> <?= $_print ?></a>
<a class="btn bg-danger" title="Print QR" href="./voucher/print.php?id=<?= $urlprint; ?>&qr=yes&session=<?= $session; ?>" target="_blank"> <i class="fa fa-qrcode"></i> <?= $_print_qr ?></a>
<a class="btn bg-info" title="Print Small" href="./voucher/print.php?id=<?= $urlprint; ?>&small=yes&session=<?= $session; ?>" target="_blank"> <i class="fa fa-print"></i> <?= $_print_small ?></a>
</div>
<table class="table">
<tr>
<td class="align-middle"><?= $_qty ?></td><td><div><input class="form-control " type="number" name="qty" min="1" max="500" value="1" required="1"></div></td>
</tr>
<tr>
<td class="align-middle">Server</td>
<td>
<select class="form-control " name="server" required="1">
<option>all</option>
<?php $TotalReg = count($srvlist);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $srvlist[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_user_mode ?></td><td>
<select class="form-control " onchange="defUserl();" id="user" name="user" required="1">
<option value="up"><?= $_user_pass ?></option>
<option value="vc"><?= $_user_user ?></option>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_user_length ?></td><td>
<select class="form-control " id="userl" name="userl" required="1">
<option>4</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_prefix ?></td><td><input class="form-control " type="text" size="6" maxlength="6" autocomplete="off" name="prefix" value=""></td>
</tr>
<tr>
<td class="align-middle"><?= $_character ?></td><td>
<select class="form-control " name="char" required="1">
<option id="lower" style="display:block;" value="lower"><?= $_random ?> abcd</option>
<option id="upper" style="display:block;" value="upper"><?= $_random ?> ABCD</option>
<option id="upplow" style="display:block;" value="upplow"><?= $_random ?> aBcD</option>
<option id="lower1" style="display:none;" value="lower"><?= $_random ?> abcd2345</option>
<option id="upper1" style="display:none;" value="upper"><?= $_random ?> ABCD2345</option>
<option id="upplow1" style="display:none;" value="upplow"><?= $_random ?> aBcD2345</option>
<option id="mix" style="display:block;" value="mix"><?= $_random ?> 5ab2c34d</option>
<option id="mix1" style="display:block;" value="mix1"><?= $_random ?> 5AB2C34D</option>
<option id="mix2" style="display:block;" value="mix2"><?= $_random ?> 5aB2c34D</option>
<option id="num" style="display:none;" value="num"><?= $_random ?> 1234</option>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_profile ?></td><td>
<select class="form-control " onchange="GetVP();" id="uprof" name="profile" required="1">
<?php if ($genprof != "") {
echo "<option>" . $genprof . "</option>";
} else {
}
$TotalReg = count($getprofile);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getprofile[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_time_limit ?></td><td><input class="form-control " type="text" size="4" autocomplete="off" name="timelimit" value=""></td>
</tr>
<tr>
<td class="align-middle"><?= $_data_limit ?></td><td>
<div class="input-group">
<div class="input-group-10 col-box-9">
<input class="group-item group-item-l" type="number" min="0" max="9999" name="datalimit" value="<?= $udatalimit; ?>">
</div>
<div class="input-group-2 col-box-3">
<select style="padding:4.2px;" class="group-item group-item-r" name="mbgb" required="1">
<option value=1048576>MB</option>
<option value=1073741824>GB</option>
</select>
</div>
</div>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_comment ?></td><td><input class="form-control " type="text" title="No special characters" id="comment" autocomplete="off" name="adcomment" value=""></td>
</tr>
<tr >
<td colspan="4" class="align-middle w-12" id="GetValidPrice">
<?php if ($genprof != "") {
echo $ValidPrice;
} ?>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-ticket"></i> <?= $_last_generate ?></h3>
</div>
<div class="card-body">
<table class="table table-bordered">
<tr>
<td><?= $_generate_code ?></td><td><?= $ucode ?></td>
</tr>
<tr>
<td><?= $_date ?></td><td><?= $udate ?></td>
</tr>
<tr>
<td><?= $_profile ?></td><td><?= $uprofile ?></td>
</tr>
<tr>
<td><?= $_validity ?></td><td><?= $uvalid ?></td>
<tr>
<td><?= $_time_limit ?></td><td><?= $utlimit ?></td>
</tr>
<tr>
<td><?= $_data_limit ?></td><td><?= $udlimit ?></td>
</tr>
<tr>
<td><?= $_price ?></td><td><?= $uprice ?></td>
</tr>
<tr>
<td><?= $_selling_price ?></td><td><?= $suprice ?></td>
</tr>
<tr>
<td><?= $_lock_user ?></td><td><?= $ulock ?></td>
</tr>
<tr>
<td colspan="2">
<p style="padding:0px 5px;">
<?= $_format_time_limit ?>
</p>
<p style="padding:0px 5px;">
<?= $_details_add_user ?>
</p>
</td>
</tr>
</table>
</div>
</div>
</div>
<script>
// get valid $ price
function GetVP(){
var prof = document.getElementById('uprof').value;
$("#GetValidPrice").load("./process/getvalidprice.php?name="+prof+"&session=<?= $session; ?> #getdata");
}
</script>
</div>
+138
View File
@@ -0,0 +1,138 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
if ($hotspot == "hostp") {
$gethosts = $API->comm("/ip/hotspot/host/print", array(
"?bypassed" => "yes",
));
$TotalReg = count($gethosts);
$counthosts = $API->comm("/ip/hotspot/host/print", array(
"?bypassed" => "yes",
"count-only" => "",
));
} elseif ($hotspot == "hosta") {
$gethosts = $API->comm("/ip/hotspot/host/print", array(
"?authorized" => "yes",
));
$TotalReg = count($gethosts);
$counthosts = $API->comm("/ip/hotspot/host/print", array(
"?authorized" => "yes",
"count-only" => "",
));
} else {
$gethosts = $API->comm("/ip/hotspot/host/print");
$TotalReg = count($gethosts);
$counthosts = $API->comm("/ip/hotspot/host/print", array(
"count-only" => "",
));
}
}
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header align-middle">
<h3><i class="fa fa-laptop"></i> Hosts
<?php
if ($counthosts < 2) {
echo "$counthosts item";
} elseif ($counthosts > 1) {
echo "$counthosts items ";
};
?>&nbsp;
| <a class="text-info" title="All" href="./?hotspot=hosts&session=<?= $session; ?>">&nbsp;&nbsp;All&nbsp;&nbsp;</a>
| <a class="text-success" title="Authorized" href="./?hotspot=hosta&session=<?= $session; ?>">&nbsp;&nbsp;A&nbsp;&nbsp;</a>
| <a class="text-primary" title="Bypassed" href="./?hotspot=hostp&session=<?= $session; ?>">&nbsp;&nbsp;P&nbsp;&nbsp;</a>
| &nbsp;&nbsp;<i onclick="location.reload();" class="fa fa-refresh pointer " title="Reload data"></i>
</h3>
</div>
<!-- /.card-header -->
<div class="card-body">
<div class="w-6">
<input id="filterTable" type="text" class="form-control" placeholder="Search..">
</div>
<div class="overflow box-bordered mr-t-10" style="max-height: 75vh">
<table id="dataTable" class="table table-bordered table-hover text-nowrap">
<thead>
<tr>
<th></th>
<th></th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> MAC Address</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Address</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> To Address</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Server</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> <?= $_comment ?></th>
</thead>
<tbody>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$hosts = $gethosts[$i];
$id = $hosts['.id'];
$maca = $hosts['mac-address'];
$addr = $hosts['address'];
$toaddr = $hosts['to-address'];
$server = $hosts['server'];
$commt = $hosts['comment'];
$uriprocess = "'./?remove-host=" . $id . "&session=" . $session . "'";
echo "<tr>";
echo "<td style='text-align:center;'><span class='pointer' title='Remove " . $maca . "' onclick=loadpage(".$uriprocess.")><i class='fa fa-minus-square text-danger'></i></span></td>";
echo "<td style='text-align:center;'>";
if ($hosts['authorized'] == "true" && $hosts['DHCP'] == "true") {
echo "<b class='text-success' title='A - authorized, H - DHCP'>A H</b>";
} elseif ($hosts['authorized'] == "true" && $hosts['dynamic'] == "true") {
echo "<b class='text-success' title='A - Authorized, D - dynamic'>A D</b>";
} elseif ($hosts['authorized'] == "true") {
echo "<b class='text-success' title='A - authorized'>A</b>";
} elseif ($hosts['DHCP'] == "true") {
echo "<b class='text-success' title='H - DHCP'>H</b>";
} elseif ($hosts['dynamic'] == "true") {
echo "<b class='text-success' title='D - dynamic'>D</b>";
} elseif ($hosts['bypassed'] == "true") {
echo "<b class='text-primary' title='P - Bypassed'>P</b>";
} else {
}
echo "</td>";
echo "<td>" . $maca . "</td>";
echo "<td>" . $addr . "</td>";
echo "<td>" . $toaddr . "</td>";
echo "<td>" . $server . "</td>";
echo "<td>" . $commt . "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</tr>
</div>
</div>
+137
View File
@@ -0,0 +1,137 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
// load session MikroTik
$session = $_GET['session'];
$serveractive = $_GET['server'];
// load config
include('../include/config.php');
include('../include/readcfg.php');
// lang
include('../include/lang.php');
include('../lang/'.$langid.'.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));
if ($serveractive != "") {
$gethotspotactive = $API->comm("/ip/hotspot/active/print", array("?server" => "" . $serveractive . ""));
$TotalReg = count($gethotspotactive);
$counthotspotactive = $API->comm("/ip/hotspot/active/print", array(
"count-only" => "", "?server" => "" . $serveractive . ""
));
} else {
$gethotspotactive = $API->comm("/ip/hotspot/active/print");
$TotalReg = count($gethotspotactive);
$counthotspotactive = $API->comm("/ip/hotspot/active/print", array(
"count-only" => "",
));
}
}
?>
<div class="row">
<div id="reloadHotspotActive">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-wifi"></i> <?= $_hotspot_active ?> <?php
if ($serveractive == "") {
} else {
echo $serveractive . " ";
}
if ($counthotspotactive < 2) {
echo "$counthotspotactive item";
} elseif ($counthotspotactive > 1) {
echo "$counthotspotactive items";
};
if ($serveractive == "") {
} else {
echo " | <a href='./?hotspot=active&session=" . $session . "'> <i class='fa fa-search'></i> Show all</a>";
}
?> </h3>
</div>
<div class="card-body overflow">
<table id="tFilter" class="table table-bordered table-hover text-nowrap">
<thead>
<tr>
<th></th>
<th>Server</th>
<th>User</th>
<th>Address</th>
<th>Mac Address</th>
<th class="text-right">Uptime</th>
<th class="text-right">Bytes In</th>
<th class="text-right">Bytes Out</th>
<th class="text-right">Time Left</th>
<th>Login By</th>
<th><?= $_comment ?></th>
</tr>
</thead>
<tbody>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$hotspotactive = $gethotspotactive[$i];
$id = $hotspotactive['.id'];
$server = $hotspotactive['server'];
$user = $hotspotactive['user'];
$address = $hotspotactive['address'];
$mac = $hotspotactive['mac-address'];
$uptime = formatDTM($hotspotactive['uptime']);
$usesstime = formatDTM($hotspotactive['session-time-left']);
$bytesi = formatBytes($hotspotactive['bytes-in'], 2);
$byteso = formatBytes($hotspotactive['bytes-out'], 2);
$loginby = $hotspotactive['login-by'];
$comment = $hotspotactive['comment'];
$uriprocess = "'./?remove-user-active=" . $id . "&session=" . $session . "'";
echo "<tr>";
echo "<td style='text-align:center;'><span class='pointer' title='Remove " . $user . "' onclick=loadpage(".$uriprocess.")><i class='fa fa-minus-square text-danger'></i></span></td>";
echo "<td><a title='filter " . $server . "' href='./?hotspot=active&server=" . $server . "&session=" . $session . "'><i class='fa fa-server'></i> " . $server . "</a></td>";
echo "<td><a title='Open User " . $user . "' href=./?hotspot-user=" . $user . "&session=" . $session . "><i class='fa fa-edit'></i> " . $user . "</a></td>";
echo "<td>" . $address . "</td>";
echo "<td>" . $mac . "</td>";
echo "<td style='text-align:right;'>" . $uptime . "</td>";
echo "<td style='text-align:right;'>" . $bytesi . "</td>";
echo "<td style='text-align:right;'>" . $byteso . "</td>";
echo "<td style='text-align:right;'>" . $usesstime . "</td>";
echo "<td>" . $loginby . "</td>";
echo "<td>" . $comment . "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
+20
View File
@@ -0,0 +1,20 @@
<?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/>.
*/
echo "<meta http-equiv='refresh' content='0;url=../' />";
?>
+133
View File
@@ -0,0 +1,133 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
$getbinding = $API->comm("/ip/hotspot/ip-binding/print");
$TotalReg = count($getbinding);
$countbinding = $API->comm("/ip/hotspot/ip-binding/print", array(
"count-only" => "",
));
}
?>
<div class="row">
<div id="reloadbinding">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class=" fa fa-address-book"></i> <?= $_ip_bindings ?>
<?php
if ($countbinding < 2) {
echo "$countbinding item";
} elseif ($countbinding > 1) {
echo "$countbinding items";
};
?>
</h3>
</div>
<div class="card-body">
<div class="w-6">
<input id="filterTable" type="text" class="form-control" placeholder="Search..">
</div>
<div class="overflow box-bordered mr-t-10" style="max-height: 75vh">
<table id="dataTable" class="table table-bordered table-hover text-nowrap">
<thead>
<tr>
<th></th>
<th></th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> <?= $_name ?></th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> MAC Address</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Address</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> To Address</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Server</th>
</tr>
</thead>
<tbody>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$binding = $getbinding[$i];
$id = $binding['.id'];
$maca = $binding['mac-address'];
$addr = $binding['address'];
$toaddr = $binding['to-address'];
$server = $binding['server'];
$commt = $binding['comment'];
$bdisabled = $binding['disabled'];
echo "<tr>";
?>
<td style='text-align:center;'><i class='fa fa-minus-square text-danger pointer' onclick="if(confirm('Are you sure to delete (<?= $maca; ?>)?')){loadpage('./?remove-ip-binding=<?= $id . '&mac=' . $maca . '&addr=' . $addr; ?>&session=<?= $session; ?>')}else{}" title='Remove <?= $maca; ?>'></i>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<?php
if ($bdisabled == "true") {
$uriprocess = "'./?enable-ip-binding=" . $id . "&session=" . $session . "'";
echo "<span class='text-warning btnsmall pointer' title='Enable Binding " . $addr . "' onclick=loadpage(".$uriprocess.")><i class='fa fa-lock'></span></td>";
} else {
$uriprocess = "'./?disable-ip-binding=" . $id . "&session=" . $session . "'";
echo "<span title='Disable Binding " . $addr . "' class='btnsmall pointer' onclick=loadpage(".$uriprocess.")><i class='fa fa-unlock '></span></td>";
}
echo "<td style='text-align:center;'>";
if ($binding['bypassed'] == "true") {
echo "<b style='color:#0091EA;'>P</b>";
} else {
}
echo "</td>";
echo "<td>" . $commt . "</td>";
echo "<td>" . $maca . "</td>";
echo "<td>" . $addr . "</a></td>";
echo "<td>" . $toaddr . "</td>";
echo "<td>" . $server . "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal-window" id="help" aria-hidden="true">
<div>
<header><h1>Help</h1></header>
<a style="font-weight:bold;" href="#" title="Close" class="modal-close">X</a>
<p>
<?php if ($currency == in_array($currency, $cekindo['indo'])) { ?>
<ul>
<li>Masuk ke menu Hosts.</li>
<li>Klik IP Address yang ingin di binding.</li>
</ul>
<?php
} else { ?>
<ul>
<li>Go to Hosts menu.</li>
<li>Click the IP Address that you want to binding.</li>
</ul>
<?php
} ?>
</p>
</div>
</div>
</div>
</div>
+373
View File
@@ -0,0 +1,373 @@
<?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);
ini_set('max_execution_time', 300);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
$qpid = $_GET['qpid'];
$rem = $_GET['remove'];
$charup = array(
"lower" => "abcd",
"upper" => " ABCD",
"upplow" => " aBcD",
"mix" => " 5ab2c34d",
"mix1" => " 5AB2C34D",
"mix2" => "5aB2c34D",
);
$charvc = array(
"lower" => " abcd2345",
"upper" => " ABCD2345",
"upplow" => " aBcD2345",
"num" => " 1234",
);
if(isset($qpid) && isset($rem)){
$API->comm("/system/script/remove", array(
".id" => "$qpid",
));
echo '<script>window.location.reload()</script>';
}
// get quick print
$getquickprint = $API->comm("/system/script/print", array("?.id" => "$qpid"));
$quickprintdetails = $getquickprint[0];
$qpid = $quickprintdetails['.id'];
$quickprintsource = explode("#",$quickprintdetails['source']);
$package = $quickprintsource[1];
$server = $quickprintsource[2];
$usermode = $quickprintsource[3];
$userlength = $quickprintsource[4];
$prefix = $quickprintsource[5];
$char = $quickprintsource[6];
$profile = $quickprintsource[7];
$timelimit = $quickprintsource[8];
$datalimit = $quickprintsource[9];
$comment = $quickprintsource[10];
if($usermode == "up"){
$tusermode = $_user_pass;
$tchar = $charup[$char];
}elseif($usermode == "vc"){
$tusermode = $_user_user;
$tchar = $charvc[$char];
}
if (substr(formatBytes2($datalimit, 2), -2) == "MB") {
$udatalimit = $datalimit / 1048576;
$xdatalimit = 1048576;
$MG = "MB";
} elseif (substr(formatBytes2($datalimit, 2), -2) == "GB") {
$udatalimit = $datalimit / 1073741824;
$xdatalimit = 1073741824;
$MG = "GB";
} else{
$udatalimit = "";
$xdatalimit = 1048576;
$MG = "MB";
}
// array color
$color = array('1' => 'bg-blue', 'bg-indigo', 'bg-purple', 'bg-pink', 'bg-red', 'bg-yellow', 'bg-green', 'bg-teal', 'bg-cyan', 'bg-grey', 'bg-light-blue');
$srvlist = $API->comm("/ip/hotspot/print");
$getprofile = $API->comm("/ip/hotspot/user/profile/print");
if (isset($_POST['name'])) {
$name = ($_POST['name']);
$sname = "Quick_Print_".(preg_replace('/\s+/', '-', $_POST['name']));
$server = ($_POST['server']);
$user = ($_POST['user']);
$userl = ($_POST['userl']);
$prefix = ($_POST['prefix']);
$char = ($_POST['char']);
$profile = ($_POST['profile']);
$timelimit = ($_POST['timelimit']);
$datalimit = ($_POST['datalimit']);
$adcomment = ($_POST['adcomment']);
$mbgb = ($_POST['mbgb']);
if ($timelimit == "") {
$timelimit = "0";
} else {
$timelimit = $timelimit;
}
if ($datalimit == "") {
$datalimit = "0";
} else {
$datalimit = $datalimit * $mbgb;
}
if ($adcomment == "") {
$adcomment = "";
} else {
$adcomment = $adcomment;
}
$getprofile = $API->comm("/ip/hotspot/user/profile/print", array("?name" => "$profile"));
$ponlogin = $getprofile[0]['on-login'];
$getvalid = explode(",", $ponlogin)[3];
$getprice = explode(",", $ponlogin)[2];
$getsprice = explode(",", $ponlogin)[4];
$getlock = explode(",", $ponlogin)[6];
$source = '#'.$name.'#'.$server.'#'.$user.'#'.$userl.'#'.$prefix.'#'.$char.'#'.$profile.'#'.$timelimit.'#'.$datalimit.'#'.$adcomment.'#'.$getvalid.'#'.$getprice.'_'.$getsprice.'#'.$getlock;
if (isset($qpid)){
$API->comm("/system/script/set", array(
".id" => "$qpid",
"name" => "$sname",
"source" => "$source",
"comment" => "QuickPrintMikhmon",
));
}else{
$API->comm("/system/script/add", array(
"name" => "$sname",
"source" => "$source",
"comment" => "QuickPrintMikhmon",
));
}
echo "<script>window.location='./?hotspot=list-quick-print&session=" . $session . "'</script>";
}
}
?>
<div class="row">
<div class="col-4">
<div class="card box-bordered">
<div class="card-header">
<h3><i class="fa fa-ticket"></i> <?php if(isset($qpid)){echo $_edit;}else{echo $_add;} echo ' '. $_quick_print ?> <small id="loader" style="display: none;" ><i><i class='fa fa-circle-o-notch fa-spin'></i> <?= $_processing ?> </i></small></h3>
</div>
<div class="card-body">
<form autocomplete="off" method="post" action="">
<div>
<?php if(isset($qpid)){echo "
<a class='btn bg-warning' href='./?hotspot=list-quick-print&session=".$session."'> <i class='fa fa-close'></i> ".$_cancel."</a>";
}else{
echo "<a class='btn bg-warning' href='./?hotspot=quick-print&session=".$session."'> <i class='fa fa-close'></i> ".$_close."</a>";
} ?>
<button type="submit" name="save" onclick="loader()" class="btn bg-primary" title="Generate User"> <i class="fa fa-save"></i> <?= $_save ?></button>
</div>
<table class="table">
<tr>
<td class="align-middle"><?= $_name ?></td><td><div><input class="form-control " type="text" name="name" value="<?= $package ?>" required="1"></div></td>
</tr>
<tr>
<td class="align-middle">Server</td>
<td>
<select class="form-control " name="server" required="1">
<?php if(isset($qid)){echo '<option>'. $server .'</option>';}else{echo '<option>all</option>';} ?>
<?php $TotalReg = count($srvlist);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $srvlist[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_user_mode ?></td><td>
<select class="form-control " onchange="defUserl();" id="user" name="user" required="1">
<?php if(isset($qpid)){echo '<option value="'.$usermode.'">'.$tusermode.'</option>';}?>
<option value="up"><?= $_user_pass ?></option>
<option value="vc"><?= $_user_user ?></option>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_user_length ?></td><td>
<select class="form-control " id="userl" name="userl" required="1">
<?php if(isset($qpid)){echo '<option>'.$userlength.'</option>';}?>
<option>4</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_prefix ?></td><td><input class="form-control " type="text" size="4" maxlength="4" autocomplete="off" name="prefix" value="<?= $prefix ?>"></td>
</tr>
<tr>
<td class="align-middle"><?= $_character ?></td><td>
<select class="form-control " name="char" required="1">
<?php if(isset($qpid)){echo '<option value="'.$char.'">'.$_random.' '.$tchar.'</option>';}?>
<option id="lower" style="display:block;" value="lower"><?= $_random ?> abcd</option>
<option id="upper" style="display:block;" value="upper"><?= $_random ?> ABCD</option>
<option id="upplow" style="display:block;" value="upplow"><?= $_random ?> aBcD</option>
<option id="lower1" style="display:none;" value="lower"><?= $_random ?> abcd2345</option>
<option id="upper1" style="display:none;" value="upper"><?= $_random ?> ABCD2345</option>
<option id="upplow1" style="display:none;" value="upplow"><?= $_random ?> aBcD2345</option>
<option id="mix" style="display:block;" value="mix"><?= $_random ?> 5ab2c34d</option>
<option id="mix1" style="display:block;" value="mix1"><?= $_random ?> 5AB2C34D</option>
<option id="mix2" style="display:block;" value="mix2"><?= $_random ?> 5aB2c34D</option>
<option id="num" style="display:none;" value="num"><?= $_random ?> 1234</option>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_profile ?></td><td>
<select class="form-control " onchange="GetVP();" id="uprof" name="profile" required="1">
<?php if (isset($qpid)) {
echo "<option>" . $profile . "</option>";
} else {
}
$TotalReg = count($getprofile);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getprofile[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_time_limit ?></td><td><input class="form-control " type="text" size="4" autocomplete="off" name="timelimit" value="<?= $timelimit ?>"></td>
</tr>
<tr>
<td class="align-middle"><?= $_data_limit ?></td><td>
<div class="input-group">
<div class="input-group-8 col-box-9">
<input class="group-item group-item-l" type="number" min="0" max="9999" name="datalimit" value="<?= $udatalimit; ?>">
</div>
<div class="input-group-4 col-box-3">
<select style="padding:4.2px;" class="group-item group-item-r" name="mbgb" required="1">
<?php if(isset($qpid)){echo '<option value="'.$xdatalimit.'">'.$MG.'</option>';}?>
<option value=1048576>MB</option>
<option value=1073741824>GB</option>
</select>
</div>
</div>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_comment ?></td><td><input class="form-control " type="text" title="No special characters" id="comment" autocomplete="off" name="adcomment" value="<?= $comment ?>"></td>
</tr>
<tr >
<td colspan="4" class="align-middle w-12" id="GetValidPrice">
<?php if ($genprof != "") {
echo $ValidPrice;
} ?>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div class="col-8">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-ticket"></i> <?= $_package.' '. $_quick_print ?></h3>
</div>
<div class="card-body">
<div class="row">
<div class="overflow box-bordered">
<table class="table table-bordered table-hover text-nowrap">
<tr>
<th></th>
<th><?= $_package ?></th>
<th>Server</th>
<th><?= $_user_mode ?></th>
<th><?= $_user_length ?></th>
<th><?= $_prefix ?></th>
<th><?= $_profile ?></th>
<th><?= $_time_limit ?></th>
<th><?= $_data_limit ?></th>
<th><?= $_validity ?></th>
<th><?= $_price ?></th>
<th><?= $_selling_price ?></th>
<th><?= $_lock_user ?></th>
<th><?= $_comment ?></th>
</tr>
<?php
// get quick print
$getquickprint = $API->comm("/system/script/print", array("?comment" => "QuickPrintMikhmon"));
$TotalReg = count($getquickprint);
for ($i = 0; $i < $TotalReg; $i++) {
$quickprintdetails = $getquickprint[$i];
$qpid = $quickprintdetails['.id'];
$quickprintsource = explode("#",$quickprintdetails['source']);
$package = $quickprintsource[1];
$server = $quickprintsource[2];
$usermode = $quickprintsource[3];
$userlength = $quickprintsource[4];
$prefix = $quickprintsource[5];
$char = $quickprintsource[6];
$profile = $quickprintsource[7];
$timelimit = $quickprintsource[8];
$datalimit = $quickprintsource[9];
$comment = $quickprintsource[10];
$validity = $quickprintsource[11];
$getprice = explode("_",$quickprintsource[12])[0];
$getsprice = explode("_",$quickprintsource[12])[1];
$userlock = $quickprintsource[13];
if ($currency == in_array($currency, $cekindo['indo'])) {
$price = $currency . " " . number_format($getprice, 0, ",", ".");
$sprice = $currency . " " . number_format($getsprice, 0, ",", ".");
} else {
$price = $currency . " " . number_format($getprice);
$sprice = $currency . " " . number_format($getsprice);
}
?>
<tr>
<td><i class='fa fa-minus-square text-danger pointer' onclick="if(confirm('Are you sure to delete (<?= $package; ?>)?')){loadpage('./?hotspot=list-quick-print&remove&qpid=<?= $qpid; ?>&session=<?= $session; ?>')}else{}" title='Remove <?= $package; ?>'></i>&nbsp</td>
<td><a title="Edit <?= $_package.' '. $package; ?>" href="./?hotspot=list-quick-print&qpid=<?= $qpid; ?>&session=<?= $session; ?>"><i class="fa fa-edit"></i> <?= $package; ?></a></td>
<td><?= $server ?></td>
<td><?= $usermode ?></td>
<td><?= $userlength ?></td>
<td><?= $prefix ?></td>
<td><?= $profile ?></td>
<td><?= $timelimit ?></td>
<td><?= formatBytes($datalimit, 2) ?></td>
<td><?= $validity ?></td>
<td><?= $price ?></td>
<td><?= $sprice ?></td>
<td><?= $userlock ?></td>
<td><?= $comment ?></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
// get valid $ price
function GetVP(){
var prof = document.getElementById('uprof').value;
var url = "./process/getvalidprice.php?name=";
var session = "&session=<?= $session; ?>"
var getvalidprice = url+prof+session
$("#GetValidPrice").load(getvalidprice);
}
</script>
</div>
+86
View File
@@ -0,0 +1,86 @@
<?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/>.
*/
// hide all error
error_reporting(0);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
$getlog = $API->comm("/log/print", array(
"?topics" => "hotspot,info,debug"
));
$log = array_reverse($getlog);
$TotalReg = count($getlog);
}
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class=" fa fa-align-justify"></i> <?= $_hotspot_log ?> &nbsp; | &nbsp;&nbsp;<i onclick="location.reload();" class="fa fa-refresh pointer " title="Reload data"></i></h3>
</div>
<div class="card-body">
<div style="max-width: 350px;">
<input id="filterTable" type="text" class="form-control" placeholder="Search..">
</div>
<div style="padding: 5px; max-height: 75vh;" class="mr-t-10 overflow">
<table class="table table-sm table-bordered table-hover" id="dataTable" >
<thead>
<tr>
<th><?= $_time ?></th>
<th><?= $_users ?> (IP)</th>
<th><?= $_messages ?></th>
</tr>
</thead>
<tbody>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$mess = explode(":", $log[$i]['message']);
$time = $log[$i]['time'];
echo "<tr>";
if (substr($log[$i]['message'], 0, 2) == "->") {
echo "<td>" . $time . "</td>";
//echo substr($mess[1], 0,2);
echo "<td>";
if (count($mess) > 6) {
echo $mess[1] . ":" . $mess[2] . ":" . $mess[3] . ":" . $mess[4] . ":" . $mess[5] . ":" . $mess[6];
} else {
echo $mess[1];
}
echo "</td>";
echo "<td>";
if (count($mess) > 6) {
echo str_replace("trying to", "", $mess[7] . " " . $mess[8] . " " . $mess[9] . " " . $mess[10]);
} else {
echo str_replace("trying to", "", $mess[2] . " " . $mess[3] . " " . $mess[4] . " " . $mess[5]);
}
echo "</td>";
} else {
}
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
+102
View File
@@ -0,0 +1,102 @@
<?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/>.
*/
// hide all error
error_reporting(0);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
// array color
$color = array('1' => 'bg-blue', 'bg-indigo', 'bg-purple', 'bg-pink', 'bg-red', 'bg-yellow', 'bg-green', 'bg-teal', 'bg-cyan', 'bg-grey', 'bg-light-blue');
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class=" fa fa-print"></i> <?= $_quick_print ?> &nbsp;&nbsp; | &nbsp;&nbsp;<a class="pointer" onclick="location.href='./?hotspot=list-quick-print&session=<?= $session ?>';" title="Quick Print List"><i class="fa fa-list"></i> List</a></h3>
</div>
<div class="card-body">
<div class="overflow" style="max-height: 80vh">
<div class="row">
<?php
// get quick print
$getquickprint = $API->comm("/system/script/print", array("?comment" => "QuickPrintMikhmon"));
$TotalReg = count($getquickprint);
for ($i = 0; $i < $TotalReg; $i++) {
$quickprintdetails = $getquickprint[$i];
$qpname = $quickprintdetails['name'];
$qpid = $quickprintdetails['.id'];
$quickprintsource = explode("#",$quickprintdetails['source']);
$package = $quickprintsource[1];
$server = $quickprintsource[2];
$usermode = $quickprintsource[3];
$userlength = $quickprintsource[4];
$prefix = $quickprintsource[5];
$char = $quickprintsource[6];
$profile = $quickprintsource[7];
$timelimit = $quickprintsource[8];
$datalimit = $quickprintsource[9];
$comment = $quickprintsource[10];
$validity = $quickprintsource[11];
$getprice = explode("_",$quickprintsource[12])[0];
$getsprice = explode("_",$quickprintsource[12])[1];
$userlock = $quickprintsource[13];
if ($currency == in_array($currency, $cekindo['indo'])) {
$price = $currency . " " . number_format((float)$getprice, 0, ",", ".");
$sprice = $currency . " " . number_format((float)$getsprice, 0, ",", ".");
} else {
$price = $currency . " " . number_format((float)$getprice);
$sprice = $currency . " " . number_format((float)$getsprice);
}
?>
<div class="col-4">
<div id='./hotspot/quickuser.php?quickprint=<?= $qpname ?>&session=<?= $session; ?>' class="quick pointer box bmh-75 box-bordered <?= $color[rand(1, 11)]; ?>" title='<?= $_print.' '.$_package.' '. $package; ?>'>
<div class="box-group">
<div class="box-group-icon">
<i class="fa fa-print"></i>
</div>
<div class="box-group-area">
<h3 ><?= $_package ?> : <?= $package; ?> <br></h3>
<span><?= $_time_limit ?> : <?= $timelimit ?> | <?= $_data_limit ?> : <?= formatBytes($datalimit, 2) ?> <br> <?= $_validity ?> : <?= $validity ?> | <?= $_price ?> : <?= $price ?> | <?= $_selling_price ?> : <?= $sprice ?></span>
</div>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$(".quick").click(function(){
loadpage(this.id);
});
});
</script>
+268
View File
@@ -0,0 +1,268 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
// time zone
date_default_timezone_set($_SESSION['timezone']);
// load session MikroTik
$session = $_GET['session'];
$quickprint = $_GET['quickprint'];
$qty = 1;
// lang
include('../include/lang.php');
include('../lang/'.$langid.'.php');
// quick bt
include('../include/quickbt.php');
// 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));
// get quick print
$getquickprint = $API->comm("/system/script/print", array("?name" => "$quickprint"));
$quickprintdetails = $getquickprint[0];
$qpid = $quickprintdetails['.id'];
$quickprintsource = explode("#",$quickprintdetails['source']);
$package = $quickprintsource[1];
$server = $quickprintsource[2];
$usermode = $quickprintsource[3];
$userl = $quickprintsource[4];
$prefix = $quickprintsource[5];
$char = $quickprintsource[6];
$profile = $quickprintsource[7];
$timelimit = $quickprintsource[8];
$datalimit = $quickprintsource[9];
$comment = $quickprintsource[10];
$getvalid = $quickprintsource[11];
$getprice = explode("_",$quickprintsource[12])[0];
$getsprice = explode("_",$quickprintsource[12])[1];
$userlock = $quickprintsource[13];
if($getsprice == "" && $getprice != ""){
$price = $getprice;
}else if($getsprice != ""){
$price = $getsprice;
}else if ($getsprice == "") {
$price = "";
}
$commt = $usermode . "-" . rand(100, 999) . "-" . date("m.d.y") . "-" . $comment;
$a = array("1" => "", "", 1, 2, 2, 3, 3, 4);
if ($usermode == "up") {
for ($i = 1; $i <= $qty; $i++) {
if ($char == "lower") {
$u[$i] = randLC($userl);
} elseif ($char == "upper") {
$u[$i] = randUC($userl);
} elseif ($char == "upplow") {
$u[$i] = randULC($userl);
} elseif ($char == "mix") {
$u[$i] = randNLC($userl);
} elseif ($char == "mix1") {
$u[$i] = randNUC($userl);
} elseif ($char == "mix2") {
$u[$i] = randNULC($userl);
}
if ($userl == 3) {
$p[$i] = randN(3);
} elseif ($userl == 4) {
$p[$i] = randN(4);
} elseif ($userl == 5) {
$p[$i] = randN(5);
} elseif ($userl == 6) {
$p[$i] = randN(6);
} elseif ($userl == 7) {
$p[$i] = randN(7);
} elseif ($userl == 8) {
$p[$i] = randN(8);
}
$u[$i] = "$prefix$u[$i]";
}
for ($i = 1; $i <= $qty; $i++) {
$API->comm("/ip/hotspot/user/add", array(
"server" => "$server",
"name" => "$u[$i]",
"password" => "$p[$i]",
"profile" => "$profile",
"limit-uptime" => "$timelimit",
"limit-bytes-total" => "$datalimit",
"comment" => "$commt",
));
}
}
if ($usermode == "vc") {
$shuf = ($userl - $a[$userl]);
for ($i = 1; $i <= $qty; $i++) {
if ($char == "lower") {
$u[$i] = randLC($shuf);
} elseif ($char == "upper") {
$u[$i] = randUC($shuf);
} elseif ($char == "upplow") {
$u[$i] = randULC($shuf);
}
if ($userl == 3) {
$p[$i] = randN(1);
} elseif ($userl == 4 || $userl == 5) {
$p[$i] = randN(2);
} elseif ($userl == 6 || $userl == 7) {
$p[$i] = randN(3);
} elseif ($userl == 8) {
$p[$i] = randN(4);
}
$u[$i] = "$prefix$u[$i]$p[$i]";
if ($char == "num") {
if ($userl == 3) {
$p[$i] = randN(3);
} elseif ($userl == 4) {
$p[$i] = randN(4);
} elseif ($userl == 5) {
$p[$i] = randN(5);
} elseif ($userl == 6) {
$p[$i] = randN(6);
} elseif ($userl == 7) {
$p[$i] = randN(7);
} elseif ($userl == 8) {
$p[$i] = randN(8);
}
$u[$i] = "$prefix$p[$i]";
}
if ($char == "mix") {
$p[$i] = randNLC($userl);
$u[$i] = "$prefix$p[$i]";
}
if ($char == "mix1") {
$p[$i] = randNUC($userl);
$u[$i] = "$prefix$p[$i]";
}
if ($char == "mix2") {
$p[$i] = randNULC($userl);
$u[$i] = "$prefix$p[$i]";
}
}
for ($i = 1; $i <= $qty; $i++) {
$API->comm("/ip/hotspot/user/add", array(
"server" => "$server",
"name" => "$u[$i]",
"password" => "$u[$i]",
"profile" => "$profile",
"limit-uptime" => "$timelimit",
"limit-bytes-total" => "$datalimit",
"comment" => "$commt",
));
}
}
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?name" => "$u[1]",
));
$userdetails = $getuser[0];
$uid = $userdetails['.id'];
$uname = $userdetails['name'];
$upass = $userdetails['password'];
$uprofile = $userdetails['profile'];
$uuptime = formatDTM($userdetails['uptime']);
$utimelimit = $userdetails['limit-uptime'];
$udatalimit = $userdetails['limit-bytes-total'];
$ucomment = $userdetails['comment'];
if (substr(formatBytes2($udatalimit, 2), -2) == "MB") {
$udatalimit = $udatalimit / 1048576;
$MG = "MB";
} elseif (substr(formatBytes2($udatalimit, 2), -2) == "GB") {
$udatalimit = $udatalimit / 1073741824;
$MG = "GB";
} elseif ($udatalimit == "") {
$udatalimit = "";
$MG = "MB";
}
$_SESSION['sss'] = $uname;
// Print BT
$chl = urlencode("http://$dnsname/login?username=$uname&password=$upass");
$qrcode = 'https://chart.googleapis.com/chart?cht=qr&chs=100x100&chld=L|0&chl=' . $chl . '&choe=utf-8';
//$qrcode = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data='.$chl;
if ($currency == in_array($currency, $cekindo['indo'])) {
$pricebt = $currency . " " . number_format($price, 0, ",", ".");
if (substr($getvalid, -1) == "d") {
$validity = substr($getvalid, 0, -1) . "Hari";
} else if (substr($getvalid, -1) == "h") {
$validity = substr($getvalid, 0, -1) . "Jam";
}
if (substr($utimelimit, -1) == "d" & strlen($utimelimit) > 3) {
$timelimit = ((substr($utimelimit, 0, -1) * 7) + substr($utimelimit, 2, 1)) . "Hari";
} else if (substr($utimelimit, -1) == "d") {
$timelimit = substr($utimelimit, 0, -1) . "Hari";
} else if (substr($utimelimit, -1) == "h") {
$timelimit = substr($utimelimit, 0, -1) . "Jam";
} else if (substr($utimelimit, -1) == "w") {
$timelimit = (substr($utimelimit, 0, -1) * 7) . "Hari";
}
} else {
$pricebt = $currency . " " . number_format($price);
$timelimit = $utimelimit;
$validity = $getvalid;
}
if($qrbt == "enable"){$qr = "yes";}
include('../voucher/printbt.php');
?>
<script>
$(document).ready(function(){
var w = window.innerWidth;
if (w < 800) {
sendToQuickPrinterChrome();
} else if (w > 800) {
window.open('./voucher/print.php?user=<?= $usermode ?>-<?= $uname ?>&qr=<?= $qr ?>&session=<?= $session ?>','_blank','width=310,height=450').print();
//window.location.href="./?hotspot-user=<?= $u[1] ?>&session=<?= $session ?>";
}
//sendToQuickPrinterChrome();
});
</script>
<?php } ?>
+462
View File
@@ -0,0 +1,462 @@
<?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/>.
*/
// hide all error
error_reporting(0);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
date_default_timezone_set($_SESSION['timezone']);
$getprofile = $API->comm("/ip/hotspot/user/profile/print");
$srvlist = $API->comm("/ip/hotspot/print");
if (substr($hotspotuser, 0, 1) == "*") {
$hotspotuser = $hotspotuser;
} elseif (substr($hotspotuser, 0, 1) != "") {
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?name" => "$hotspotuser",
));
$hotspotuser = $getuser[0]['.id'];
//if($hotspotuser == ""){echo "<b>Hotspot User not found</b>";}
}
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?.id" => "$hotspotuser",
));
$userdetails = $getuser[0];
$uid = $userdetails['.id'];
$userver = $userdetails['server'];
$uname = $userdetails['name'];
$upass = $userdetails['password'];
$umac = $userdetails['mac-address'];
$uprofile = $userdetails['profile'];
$uuptime = formatDTM($userdetails['uptime']);
$ueduser = $userdetails['disabled'];
$utimelimit = $userdetails['limit-uptime'];
$udatalimit = $userdetails['limit-bytes-total'];
$ubytesout = $userdetails['bytes-out'];
$ubytesin = $userdetails['bytes-in'];
$ucomment = $userdetails['comment'];
if (substr(formatBytes2($udatalimit, 2), -2) == "MB") {
$udatalimit = $udatalimit / 1048576;
$MG = "MB";
} elseif (substr(formatBytes2($udatalimit, 2), -2) == "GB") {
$udatalimit = $udatalimit / 1073741824;
$MG = "GB";
} elseif ($udatalimit == "") {
$udatalimit = "";
$MG = "MB";
}
if ($uname == $upass) {
$usermode = "vc";
} else {
$usermode = "up";
}
if ($uname == "") {
echo "<b>User not found redirect to user list...</b>";
echo "<script>window.location='./?hotspot=users&profile=all&session=" . $session . "'</script>";
}
if((substr($ucomment,3,1) == "/" && substr($ucomment,6,1) == "/")){
$commt = 'disabled';
$comment2t = 'text';
$_tcomment = $_expired;
$_tcomment2 = $_comment;
$ucomment2 = substr($ucomment,21, (strlen($ucomment)-21));
$ucomment = substr($ucomment,0,20);
}else{
$comment2t = 'hidden';
$_tcomment = $_comment;
$_tcomment2 = "";
$display = 'style="display:none"';
}
$getprofilebyuser = $API->comm("/ip/hotspot/user/profile/print", array(
"?name" => "$uprofile"
));
$profiledetalis = $getprofilebyuser[0];
$ponlogin = $profiledetalis['on-login'];
$getvalid = explode(",", $ponlogin)[3];
$getprice = explode(",", $ponlogin)[2];
$getsprice = explode(",", $ponlogin)[4];
$getsch = $API->comm("/system/scheduler/print", array(
"?name" => "$uname",
));
$schdetails = $getsch[0];
$start = $schdetails['start-date'] . " " . $schdetails['start-time'];
$end = $schdetails['next-run'];
//$valy = $schdetails['interval'];
// share WhatsApp
if ($getvalid != "") {
$wavalid = $_validity." : *" . $getvalid . "* %0A";
} else {
$wavalid = "";
}
if ($utimelimit != "") {
$watlimit = $_time_limit." : *" . $utimelimit . "* %0A";
} else {
$watlimit = "";
$bMB = "";
}
if ($udatalimit != "") {
$wadlimit = $_data_limit." : *" . $udatalimit . "" . $MG . "* %0A";
$bMG = $MG;
} else {
$wadlimit = "";
}
if($getsprice == "" && $getprice != ""){
if ($currency == in_array($currency, $cekindo['indo'])) {
$waprice = $_price." : *" . $currency . " " . number_format((float)$getprice, 0, ",", ".") . "* %0A";
} else {
$waprice = $_price . " : *" . $currency . " " . number_format((float)$getprice) . "* %0A";
}
$btprice = $getprice;
}else if($getsprice != ""){
if ($currency == in_array($currency, $cekindo['indo'])) {
$waprice = $_price." : *" . $currency . " " . number_format((float)$getsprice, 0, ",", ".") . "* %0A";
} else {
$waprice = $_price . " : *" . $currency . " " . number_format((float)$getsprice) . "* %0A";
}
$btprice = $getsprice;
}else if ($getsprice == "") {
$waprice = "";
$btprice = "";
}
$shareWAUP = "
%0A---------%0A
*" . $hotspotname . "*
%0A%0A
Username : *" . $uname . "* %0A
Password : *" . $upass . "* %0A
" . $wavalid . "
" . $watlimit . "
" . $wadlimit . "
" . $waprice . " %0A
Login : *http://" . $dnsname . "* %0A
---------
";
$shareWAVC = "
%0A---------%0A
*" . $hotspotname . "*
%0A%0A
Voucher : *" . $uname . "* %0A
" . $wavalid . "
" . $watlimit . "
" . $wadlimit . "
" . $waprice . " %0A
Login : *http://" . $dnsname . "* %0A
---------
";
if ($uname == $upass) {
$shareWA = $shareWAVC;
} else {
$shareWA = $shareWAUP;
}
// quick bt
include('./include/quickbt.php');
// Print BT
$chl = urlencode("http://$dnsname/login?username=$uname&password=$upass");
$qrcode = 'https://chart.googleapis.com/chart?cht=qr&chs=100x100&chld=L|0&chl=' . $chl . '&choe=utf-8';
//$qrcode = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data='.$chl;
if ($currency == in_array($currency, $cekindo['indo'])) {
$pricebt = $currency . " " . number_format((float)$btprice, 0, ",", ".");
if (substr($getvalid, -1) == "d") {
$validity = substr($getvalid, 0, -1) . "Hari";
} else if (substr($getvalid, -1) == "h") {
$validity = substr($getvalid, 0, -1) . "Jam";
} else if (substr($getvalid, -1) == "m") {
$validity = substr($getvalid, 0, -1) . "Menit";
}
if (substr($utimelimit, -1) == "d" & strlen($utimelimit) > 3) {
$timelimit = ((substr($utimelimit, 0, -1) * 7) + substr($utimelimit, 2, 1)) . "Hari";
} else if (substr($utimelimit, -1) == "d") {
$timelimit = substr($utimelimit, 0, -1) . "Hari";
} else if (substr($utimelimit, -1) == "h") {
$timelimit = substr($utimelimit, 0, -1) . "Jam";
} else if (substr($utimelimit, -1) == "w") {
$timelimit = (substr($utimelimit, 0, -1) * 7) . "Hari";
}
} else {
$pricebt = $currency . " " . number_format((float)$btprice);
$timelimit = $utimelimit;
$validity = $getvalid;
}
if (isset($_POST['name'])) {
$server = ($_POST['server']);
$name = ($_POST['name']);
$password = ($_POST['pass']);
$profile = ($_POST['profile']);
$disabled = ($_POST['disabled']);
$timelimit = ($_POST['timelimit']);
$datalimit = ($_POST['datalimit']);
$comment = ($_POST['comment']);
$comment2 = ($_POST['comment2']);
$hcomment = ($_POST['h_comment']);
$mbgb = ($_POST['mbgb']);
if ($timelimit == "") {
$timelimit = "0";
} else {
$timelimit = $timelimit;
}
if ($datalimit == "") {
$datalimit = "0";
} else {
$datalimit = $datalimit * $mbgb;
}
if ($name == $password) {
$usermode = "vc-";
}else{
$usermode = "up-";
}
if((substr($hcomment,3,1) == "/" && substr($hcomment,6,1) == "/")){
$comment = $hcomment." ".$comment2;
}elseif((substr($comment,3,1) == "/" && substr($comment,6,1) == "/")){
$comment = $comment." ".$comment2;
}elseif(substr($comment,0,3) == "vc-" || substr($comment,0,3) == "up-"){
$comment = $comment;
}else{
$comment = $usermode.$comment;
}
$API->comm("/ip/hotspot/user/set", array(
".id" => "$uid",
"server" => "$server",
"name" => "$name",
"password" => "$password",
"profile" => "$profile",
"disabled" => "$disabled",
"limit-uptime" => "$timelimit",
"limit-bytes-total" => "$datalimit",
"comment" => "$comment",
));
echo "<script>window.location='./?hotspot-user=" . $uid . "&session=" . $session . "'</script>";
}
}
include('./voucher/printbt.php');
?>
<script>
function PassUser(){
var x = document.getElementById('passUser');
if (x.type === 'password') {
x.type = 'text';
} else {
x.type = 'password';
}}
var _0x7baa=["\x63\x6C\x69\x63\x6B","\x2E\x70\x72\x69\x6E\x74\x42\x54","\x72\x65\x61\x64\x79"];$(document)[_0x7baa[2]](function(){$(_0x7baa[1])[_0x7baa[0]](function(){printBT()})})
</script>
<div class="row">
<div class="col-12"></div>
<div class="card">
<div class="card-header">
<h3><i class="fa fa-edit"></i> <?php echo $_edit_user.' '.$uname.' '; if ($utimelimit == "1s") { echo $_expired;}?></h3>
</div>
<div class="card-body">
<form autocomplete="new-password" method="post" action="">
<div>
<?php if ($_SESSION['ubp'] != "") {
echo " <a class='btn bg-warning' href='./?hotspot=users&profile=" . $_SESSION['ubp'] . "&session=" . $session . "'><i class='fa fa-close'></i> ".$_close."</a>";
} elseif ($_SESSION['ubc'] != "") {
echo " <a class='btn bg-warning' href='./?hotspot=users&comment=" . $_SESSION['ubc'] . "&session=" . $session . "'><i class='fa fa-close'></i> ".$_close."</a>";
} elseif ($_SESSION['hua'] != "") {
$_SESSION['ubn'] = "";
echo " <a class='btn bg-warning' href='./?hotspot=active&session=" . $session . "'><i class='fa fa-close'></i> ".$_close."</a>";
$_SESSION['hua'] = "";
} elseif ($_SESSION['ubn'] != "") {
echo " <a class='btn bg-warning' href='./?hotspot=users&profile=all&session=" . $session . "'><i class='fa fa-close'></i> ".$_close."</a>";
$_SESSION['ubn'] = "";
} else {
echo " <a class='btn bg-warning' href='./?hotspot=users&profile=all&session=" . $session . "'><i class='fa fa-close'></i> ".$_close."</a>";
}
?>
<button type="submit" name="save" class="btn bg-primary" > <i class="fa fa-save"></i> <?= $_save ?></button>
<div class="btn bg-danger" onclick="if(confirm('Are you sure to delete username (<?= $uname; ?>)?')){loadpage('./?remove-hotspot-user=<?= $uid; ?>&session=<?= $session; ?>')}else{}" title='Remove <?= $uname; ?>'><i class='fa fa-minus-square'></i> <?= $_remove ?></div>
<a class="btn bg-secondary" title="Print" href="javascript:window.open('./voucher/print.php?user=<?= $usermode . "-" . $uname; ?>&qr=no&session=<?= $session; ?>','_blank','width=310,height=450').print();"> <i class="fa fa-print"></i> <?= $_print ?></a>
<a class="btn bg-info" title="Print QR" href="javascript:window.open('./voucher/print.php?user=<?= $usermode . "-" . $uname; ?>&qr=yes&session=<?= $session; ?>','_blank','width=310,height=450').print();"> <i class="fa fa-qrcode"></i> <?= $_print_qr ?></a>
<?php if ($utimelimit == "1s") {
echo '<a class="btn bg-info" href="./?reset-hotspot-user=' . $uid . '&session=' . $session . '"> <i class="fa fa-retweet"></i> Reset</a>';
} ?>
<a id="shareWA" class="btn bg-green" title="Share WhatsApp" href="whatsapp://send?text=<?= $shareWA; ?>"> <i class="fa fa-whatsapp"></i> <?= $_share ?></a>
<!--<div id="shareWA" class="btn bg-blue printBT" title="Print Bluetooth"><i class="fa fa-bluetooth"></i> <?= $_print ?> BT</div>-->
<div id="shareWA" class="btn bg-blue" onclick="sendToQuickPrinterChrome()" title="Print Bluetooth"><i class="fa fa-bluetooth"></i> <?= $_print ?> BT</div><br>
</div>
<table class="table">
<tr>
<td class="align-middle">Enabled</td>
<td>
<select class="form-control" name="disabled" required="1">
<option value="<?= $ueduser; ?>"><?php if ($ueduser == "true") {
echo "No";
} else {
echo "Yes";
} ?></option>
<option value="no">Yes</option>
<option value="yes">No</option>
</select>
</td>
</tr>
<tr>
<td class="align-middle">Server</td>
<td>
<select class="form-control" name="server" required="1">
<option><?php if ($userver == "") {
echo "all";
} else {
echo $userver;
} ?></option>
<option>all</option>
<?php $TotalReg = count($srvlist);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $srvlist[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_name ?></td><td><input id="name" class="form-control" type="text" autocomplete="off" name="name" value="<?= $uname; ?>"></td>
</tr>
<tr>
<td class="align-middle"><?= $_password ?></td><td>
<div class="input-group">
<div class="input-group-11 col-box-10">
<input class="group-item group-item-l" id="passUser" type="password" name="pass" autocomplete="new-password" value="<?= $upass; ?>">
</div>
<div class="input-group-1 col-box-2">
<div class="group-item group-item-r pd-2p5 text-center">
<input title="Show/Hide Password" type="checkbox" onclick="PassUser()">
</div>
</div>
</div>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_profile ?></td><td>
<select class="form-control" name="profile" required="1">
<option><?= $uprofile; ?></option>
<?php $TotalReg = count($getprofile);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getprofile[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td class="align-middle">Mac Address</td><td><input class="form-control" type="text" value="<?= $umac; ?>"></td>
</tr>
<tr>
<td class="align-middle">Uptime</td><td><input class="form-control" type="text" value="<?php if ($uuptime == 0) {
} else {
echo $uuptime;
} ?>" disabled></td>
</tr>
<tr>
<td class="align-middle">Bytes In / Out</td><td><input class="form-control" type="text" value="<?php if ($ubytesout == 0) {
} else {
echo formatBytes($ubytesin, 2);
} ?> / <?php if ($ubytesout == 0) {
} else {
echo formatBytes($ubytesout, 2);
} ?>" disabled></td>
</tr>
<tr>
<td class="align-middle"><?= $_time_limit ?></td><td><input id="timelimit" class="form-control" type="text" size="4" autocomplete="off" name="timelimit" value="<?php if ($utimelimit == "1s") {echo "";} else {echo $utimelimit;} ?>"></td>
</tr>
<tr>
<td class="align-middle"><?= $_data_limit ?></td><td>
<div class="input-group">
<div class="input-group-10 col-box-9">
<input class="group-item group-item-l" type="number" min="0" max="9999" id="datalimit" name="datalimit" value="<?= $udatalimit; ?>">
</div>
<div class="input-group-2 col-box-3">
<select style="padding: 4.2px;" class="group-item group-item-r" id="mbgb" name="mbgb" required="1">
<option value="<?php if ($MG == "MB") {echo "1048576"; } elseif ($MG == "GB") {echo "1073741824"; } ?>"><?= $MG; ?></option>
<option value="1048576">MB</option>
<option value="1073741824">GB</option>
</select>
</div>
</div>
</td>
</tr>
<tr>
<td class="align-middle"><?= $_tcomment ?></td><td><input class="form-control" type="text" id="comment" autocomplete="off" name="comment" title="No special characters" value="<?= $ucomment; ?>" <?= $commt ?>><input type="hidden" name="h_comment" value="<?= $ucomment ?>"></td>
</tr>
<tr>
<tr <?=$display?>>
<td class="align-middle"><?= $_tcomment2 ?></td><td><input class="form-control" type="<?= $comment2t ;?>" id="comment2" autocomplete="off" name="comment2" title="No special characters" value="<?= $ucomment2; ?>"></td>
</tr>
<tr>
<td class="align-middle"><?= $_price ?></td><td><input class="form-control" id="price" type="text" value="<?php if ($getprice == 0) {
} else {
if ($currency == in_array($currency, $cekindo['indo'])) {
echo $currency . " " . number_format((float)$getprice, 0, ",", ".");
} else {
echo $currency . " " . number_format((float)$getprice);
}
} ?>" disabled></td>
</tr>
<tr>
<td class="align-middle"><?= $_selling_price ?></td><td><input class="form-control" id="price" type="text" value="<?php if ($getprice == 0) {
} else {
if ($currency == in_array($currency, $cekindo['indo'])) {
echo $currency . " " . number_format((float)$getsprice, 0, ",", ".");
} else {
echo $currency . " " . number_format((float)$getsprice);
}
} ?>" disabled></td>
</tr>
<?php if ($getvalid != "") { ?>
<tr>
<td class="align-middle"><?= $_validity ?></td><td><input class="form-control" type="text" id="validity" value="<?= $getvalid; ?>" disabled></td>
</tr>
<?php
} else {
} ?>
<tr>
<td colspan="2">
<p style="padding:0px 5px;">
<?= $_format_time_limit ?>
</p>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
+101
View File
@@ -0,0 +1,101 @@
<?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/>.
*/
// hide all error
error_reporting(0);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
// array color
$color = array('1' => 'bg-blue', 'bg-indigo', 'bg-purple', 'bg-pink', 'bg-red', 'bg-yellow', 'bg-green', 'bg-teal', 'bg-cyan', 'bg-grey', 'bg-light-blue');
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class=" fa fa-users"></i> <?= $_vouchers ?> &nbsp;&nbsp; | &nbsp;&nbsp;<i onclick="location.reload();" class="fa fa-refresh pointer" title="Reload data"></i></h3>
</div>
<div class="card-body">
<div class="overflow" style="max-height: 80vh">
<div class="row">
<div class="col-4">
<div class="box bmh-75 box-bordered <?= $color[rand(1, 11)]; ?>">
<div class="box-group">
<div class="box-group-icon">
<a title='Open User by profile <?= $pname; ?>' href='./?hotspot=users&profile=all&session=<?= $session; ?>'>
<i class="fa fa-ticket"></i></a>
</div>
<div class="box-group-area">
<h3 >Profile : all<br>
<?php $countuser = $API->comm("/ip/hotspot/user/print", array("count-only" => ""));
if ($countuser < 2) {
echo $countuser . " Item";
} elseif ($countuser > 1) {
echo $countuser . " Items";
}
?></h3>
<a title="Open User by profile all" href="./?hotspot=users&profile=all&session=<?= $session; ?>"><i class="fa fa-external-link"></i> <?= $_open ?></a>&nbsp;
<a title="Generate User by profile <?= $pname; ?>" href="./?hotspot-user=generate&session=<?= $session; ?>"><i class="fa fa-users"></i> <?= $_generate ?></a>&nbsp;
</div>
</div>
</div>
</div>
<?php
// get user profile
$getprofile = $API->comm("/ip/hotspot/user/profile/print");
$TotalReg = count($getprofile);
for ($i = 0; $i < $TotalReg; $i++) {
$profiledetalis = $getprofile[$i];
$pname = $profiledetalis['name'];
?>
<div class="col-4">
<div class="box bmh-75 box-bordered <?= $color[rand(1, 11)]; ?>">
<div class="box-group">
<div class="box-group-icon">
<a title='Open User by profile <?= $pname; ?>' href='./?hotspot=users&profile=<?= $pname; ?>&session=<?= $session; ?>'>
<i class="fa fa-ticket"></i></a>
</div>
<div class="box-group-area">
<h3 >Profile : <?= $pname; ?><br>
<?php $countuser = $API->comm("/ip/hotspot/user/print", array("count-only" => "", "?profile" => "$pname", ));
if ($countuser < 2) {
echo $countuser . " Item";
} elseif ($countuser > 1) {
echo $countuser . " Items";
}
?></h3>
<a title="Open User by profile <?= $pname; ?>" href="./?hotspot=users&profile=<?= $pname; ?>&session=<?= $session; ?>"><i class="fa fa-external-link"></i> <?= $_open ?></a>&nbsp;
<a title="Generate User by profile <?= $pname; ?>" href="./?hotspot-user=generate&genprof=<?= $pname; ?>&session=<?= $session; ?>"><i class="fa fa-users"></i> <?= $_generate ?></a>&nbsp;
</div>
</div>
</div>
</div>
<?php
}
} ?>
</div>
</div>
</div>
</div>
</div>
</div>
+173
View File
@@ -0,0 +1,173 @@
<?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/>.
*/
// hide all error
error_reporting(0);
if (!isset($_SESSION["mikhmon"])) {
echo '
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.14.0</center>
</body>
</html>
';
} else {
// get user profile
$getprofile = $API->comm("/ip/hotspot/user/profile/print");
$TotalReg = count($getprofile);
// count user profile
$countprofile = $API->comm("/ip/hotspot/user/profile/print", array(
"count-only" => "",
));
}
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header align-middle">
<h3><i class=" fa fa-pie-chart"></i> User Profile
&nbsp; | &nbsp; <a href="./?user-profile=add&session=<?= $session; ?>" title="Add User"><i class="fa fa-user-plus"></i> Add</a>
</h3>
</div>
<!-- /.card-header -->
<div class="card-body">
<div class="overflow box-bordered" style="max-height: 75vh">
<table id="tFilter" class="table table-bordered table-hover text-nowrap">
<thead>
<tr>
<th style="min-width:50px;" class="text-center" >
<?php
if ($countprofile < 2) {
echo "$countprofile item ";
} elseif ($countprofile > 1) {
echo "$countprofile items ";
}
?></th>
<th class="align-middle"><?= $_name ?></th>
<th class="align-middle">Shared<br>Users</th>
<th class="align-middle">Rate<br>Limit</th>
<th class="align-middle"><?= $_expired_mode ?></th>
<th class="align-middle"><?= $_validity ?></th>
<th class="text-right align-middle" > <?= $_price." ".$currency; ?></th>
<th class="text-right align-middle" > <?= $_selling_price." ".$currency; ?></th>
<th class="align-middle"><?= $_lock_user ?></th>
</tr>
</thead>
<tbody>
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$profiledetalis = $getprofile[$i];
$pid = $profiledetalis['.id'];
$pname = $profiledetalis['name'];
$psharedu = $profiledetalis['shared-users'];
$pratelimit = $profiledetalis['rate-limit'];
$ponlogin = $profiledetalis['on-login'];
$getmonexpired = $API->comm("/system/scheduler/print", array(
"?name" => "$pname",
));
$monexpired = $getmonexpired[0];
$monid = $monexpired['.id'];
$pmon = $monexpired['name'];
$chkpmon = $monexpired['disabled'];
if(empty($pmon) || $chkpmon == "true"){$moncolor = "text-orange";}else{$moncolor = "text-green";}
echo "<tr>";
?>
<td style='text-align:center;'><i class='fa fa-minus-square text-danger pointer' onclick="if(confirm('Are you sure to delete profile (<?= $pname; ?>)?')){loadpage('./?remove-user-profile=<?= $pid; ?>&pname=<?= $pname ?>&session=<?= $session; ?>')}else{}" title='Remove <?= $pname; ?>'></i>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<?php
echo "<a title='Open User by profile " . $pname . "' href='./?hotspot=users&profile=" . $pname . "&session=" . $session . "'><i class='fa fa-users'></i></a></td>";
echo "<td><a title='Open User Profile " . $pname . "' href='./?user-profile=" . $pid . "&session=" . $session . "'><i class='fa fa-edit'></i> <i class='fa fa-ci fa-circle ".$moncolor."'></i> $pname</a></td>";
//$profiledetalis = $ARRAY[$i];echo "<td>" . $profiledetalis['name'];echo "</td>";
echo "<td>" . $psharedu;
echo "</td>";
echo "<td>" . $pratelimit;
echo "</td>";
echo "<td>";
$getexpmode = explode(",", $ponlogin);
// get expired mode
$expmode = $getexpmode[1];
if ($expmode == "rem") {
echo "Remove";
} elseif ($expmode == "ntf") {
echo "Notice";
} elseif ($expmode == "remc") {
echo "Remove & Record";
} elseif ($expmode == "ntfc") {
echo "Notice & Record";
} else {
}
echo "</td>";
echo "<td>";
// get validity
$getvalid = explode(",", $ponlogin);
echo $getvalid[3];
echo "</td>";
echo "<td style='text-align:right;'>";
// get price
$getprice = explode(",", $ponlogin);
$price = trim($getprice[2]);
if ($price == "" || $price == "0") {
echo "";
} else {
if ($currency == in_array($currency, $cekindo['indo'])) {
echo number_format((float)$price, 0, ",", ".");
} else {
echo number_format((float)$price, 2);
}
}
echo "</td>";
echo "<td style='text-align:right;'>";
// get price
$getsprice = explode(",", $ponlogin);
$price = trim($getsprice[4]);
if ($price == "" || $price == "0") {
echo "";
} else {
if ($currency == in_array($currency, $cekindo['indo'])) {
echo number_format((float)$price, 0, ",", ".");
} else {
echo number_format((float)$price, 2);
}
}
echo "</td>";
echo "<td>";
$getgracep = explode(",", $ponlogin);
echo $getgracep[6];
echo "</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
+315
View File
@@ -0,0 +1,315 @@
<?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);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
if (substr($userprofile, 0, 1) == "*") {
$userprofile = $userprofile;
} elseif (substr($userprofile, 0, 1) != "") {
$getprofile = $API->comm("/ip/hotspot/user/profile/print", array(
"?name" => "$userprofile",
));
$userprofile = $getprofile[0]['.id'];
if ($userprofile == "") {
echo "<b>User Profile not found</b>";
}
}
$getpool = $API->comm("/ip/pool/print");
$getprofile = $API->comm("/ip/hotspot/user/profile/print", array(
"?.id" => "$userprofile"
));
$profiledetalis = $getprofile[0];
$pid = $profiledetalis['.id'];
$pname = $profiledetalis['name'];
$psharedu = $profiledetalis['shared-users'];
$pratelimit = $profiledetalis['rate-limit'];
$ponlogin = $profiledetalis['on-login'];
$ppool = $profiledetalis['address-pool'];
$sparent = $profiledetalis['parent-queue'];
if(empty($ppool)){$ppool = "none";}
if(empty($sparent)){$sparent = "none";}
$getexpmode = explode(",", $ponlogin)[1];
if ($getexpmode == "rem") {
$getexpmodet = "Remove";
} elseif ($getexpmode == "ntf") {
$getexpmodet = "Notice";
} elseif ($getexpmode == "remc") {
$getexpmodet = "Remove & Record";
} elseif ($getexpmode == "ntfc") {
$getexpmodet = "Notice & Record";
} else {
$getexpmode = "0";
$getexpmodet = "None";
}
$getprice = explode(",", $ponlogin)[2];
if ($getprice == "0") {
$getprice = "";
} else {
$getprice = $getprice;
}
$getsprice = explode(",", $ponlogin)[4];
if ($getsprice == "0") {
$getsprice = "";
} else {
$getsprice = $getsprice;
}
$getvalid = explode(",", $ponlogin)[3];
$getgracep = explode(",", $ponlogin)[4];
$getlocku = explode(",", $ponlogin)[6];
if ($getlocku == "") {
$getlocku = "Disable";
} else {
$getlocku = $getlocku;
}
$getallqueue = $API->comm("/queue/simple/print", array(
"?dynamic" => "false",
));
$getmonexpired = $API->comm("/system/scheduler/print", array(
"?name" => "$pname",
));
$monexpired = $getmonexpired[0];
$monid = $monexpired['.id'];
$pmon = $monexpired['name'];
$chkpmon = $monexpired['disabled'];
if(empty($pmon) || $chkpmon == "true"){$moncolor = "text-orange";}else{$moncolor = "text-green";}
if (isset($_POST['name'])) {
$name = (preg_replace('/\s+/', '-',$_POST['name']));
$sharedusers = ($_POST['sharedusers']);
$ratelimit = ($_POST['ratelimit']);
$expmode = ($_POST['expmode']);
$validity = ($_POST['validity']);
$graceperiod = ($_POST['graceperiod']);
$getprice = ($_POST['price']);
$getsprice = ($_POST['sprice']);
$addrpool = ($_POST['ppool']);
if ($getprice == "") {
$price = "0";
} else {
$price = $getprice;
}
if ($getsprice == "") {
$sprice = "0";
} else {
$sprice = $getsprice;
}
$getlock = ($_POST['lockunlock']);
if ($getlock == "Enable") {
$lock = '; [:local mac $"mac-address"; /ip hotspot user set mac-address=$mac [find where name=$user]]';
} else {
$lock = "";
}
$randstarttime = "0".rand(1,5).":".rand(10,59).":".rand(10,59);
$randinterval = "00:02:".rand(10,59);
$parent = ($_POST['parent']);
$record = '; :local mac $"mac-address"; :local time [/system clock get time ]; /system script add name="$date-|-$time-|-$user-|-'.$price.'-|-$address-|-$mac-|-' . $validity . '-|-'.$name.'-|-$comment" owner="$month$year" source=$date comment=mikhmon';
$onlogin = ':put (",'.$expmode.',' . $price . ',' . $validity . ','.$sprice.',,' . $getlock . ',"); {:local date [ /system clock get date ];:local year [ :pick $date 7 11 ];:local month [ :pick $date 0 3 ];:local comment [ /ip hotspot user get [/ip hotspot user find where name="$user"] comment]; :local ucode [:pic $comment 0 2]; :if ($ucode = "vc" or $ucode = "up" or $comment = "") do={ /sys sch add name="$user" disable=no start-date=$date interval="' . $validity . '"; :delay 2s; :local exp [ /sys sch get [ /sys sch find where name="$user" ] next-run]; :local getxp [len $exp]; :if ($getxp = 15) do={ :local d [:pic $exp 0 6]; :local t [:pic $exp 7 16]; :local s ("/"); :local exp ("$d$s$year $t"); /ip hotspot user set comment=$exp [find where name="$user"];}; :if ($getxp = 8) do={ /ip hotspot user set comment="$date $exp" [find where name="$user"];}; :if ($getxp > 15) do={ /ip hotspot user set comment=$exp [find where name="$user"];}; /sys sch remove [find where name="$user"]';
if ($expmode == "rem") {
$onlogin = $onlogin . $lock . "}}";
$mode = "remove";
} elseif ($expmode == "ntf") {
$onlogin = $onlogin . $lock . "}}";
$mode = "set limit-uptime=1s";
} elseif ($expmode == "remc") {
$onlogin = $onlogin . $record . $lock . "}}";
$mode = "remove";
} elseif ($expmode == "ntfc") {
$onlogin = $onlogin . $record . $lock . "}}";
$mode = "set limit-uptime=1s";
} elseif ($expmode == "0" && $price != "") {
$onlogin = ':put (",,' . $price . ',,,noexp,' . $getlock . ',")' . $lock;
} else {
$onlogin = "";
}
$bgservice = ':local dateint do={:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" );:local days [ :pick $d 4 6 ];:local month [ :pick $d 0 3 ];:local year [ :pick $d 7 11 ];:local monthint ([ :find $montharray $month]);:local month ($monthint + 1);:if ( [len $month] = 1) do={:local zero ("0");:return [:tonum ("$year$zero$month$days")];} else={:return [:tonum ("$year$month$days")];}}; :local timeint do={ :local hours [ :pick $t 0 2 ]; :local minutes [ :pick $t 3 5 ]; :return ($hours * 60 + $minutes) ; }; :local date [ /system clock get date ]; :local time [ /system clock get time ]; :local today [$dateint d=$date] ; :local curtime [$timeint t=$time] ; :foreach i in [ /ip hotspot user find where profile="'.$name.'" ] do={ :local comment [ /ip hotspot user get $i comment]; :local name [ /ip hotspot user get $i name]; :local gettime [:pic $comment 12 20]; :if ([:pic $comment 3] = "/" and [:pic $comment 6] = "/") do={:local expd [$dateint d=$comment] ; :local expt [$timeint t=$gettime] ; :if (($expd < $today and $expt < $curtime) or ($expd < $today and $expt > $curtime) or ($expd = $today and $expt < $curtime)) do={ [ /ip hotspot user '.$mode.' $i ]; [ /ip hotspot active remove [find where user=$name] ];}}}';
$API->comm("/ip/hotspot/user/profile/set", array(
/*"add-mac-cookie" => "yes",*/
".id" => "$pid",
"name" => "$name",
"address-pool" => "$addrpool",
"rate-limit" => "$ratelimit",
"shared-users" => "$sharedusers",
"status-autorefresh" => "1m",
// "transparent-proxy" => "yes",
"on-login" => "$onlogin",
"parent-queue" => "$parent",
));
if($expmode != "0"){
if (empty($monid)){
$API->comm("/system/scheduler/add", array(
"name" => "$name",
"start-time" => "$randstarttime",
"interval" => "$randinterval",
"on-event" => "$bgservice",
"disabled" => "no",
"comment" => "Monitor Profile $name",
));
}else{
$API->comm("/system/scheduler/set", array(
".id" => "$monid",
"name" => "$name",
"start-time" => "$randstarttime",
"interval" => "$randinterval",
"on-event" => "$bgservice",
"disabled" => "no",
"comment" => "Monitor Profile $name",
));
}}else{
$API->comm("/system/scheduler/remove", array(
".id" => "$monid"));
}
echo "<script>window.location='./?user-profile=" . $pid . "&session=" . $session . "'</script>";
}
}
?>
<div class="row">
<div class="col-8">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-edit"></i> <?= $_edit." ".$_user_profile ?> </h3>
</div>
<div class="card-body">
<form autocomplete="off" method="post" action="">
<div>
<a class="btn bg-warning" href="./?hotspot=user-profiles&session=<?= $session; ?>"> <i class="fa fa-close"></i> <?= $_close?></a>
<button type="submit" name="save" class="btn bg-primary" ><i class="fa fa-save"></i> <?= $_save ?></button>
</div>
<table class="table">
<tr>
<td><?= $_name ?> <i class="fa fa-ci fa-circle <?= $moncolor ?>"></i></td><td><input class="form-control" type="text" onchange="remSpace();" autocomplete="off" name="name" value="<?= $pname; ?>" required="1" autofocus></td>
</tr>
<tr>
<td class="align-middle">Address Pool</td>
<td>
<select class="form-control " name="ppool">
<option><?= $ppool; ?></option>
<option>none</option>
<?php $TotalReg = count($getpool);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getpool[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Shared Users</td><td><input class="form-control" type="text" size="4" autocomplete="off" name="sharedusers" value="<?= $psharedu; ?>" required="1"></td>
</tr>
<tr>
<td>Rate limit [up/down]</td><td><input class="form-control" type="text" name="ratelimit" autocomplete="off" value="<?= $pratelimit; ?>" placeholder="Example : 512k/1M" ></td>
</tr>
<tr>
<td><?= $_expired_mode ?></td><td>
<select class="form-control" onchange="RequiredV();" id="expmode" name="expmode" required="1">
<option value="<?= $getexpmode; ?>"><?= $getexpmodet; ?></option>
<option value="0">None</option>
<option value="rem">Remove</option>
<option value="ntf">Notice</option>
<option value="remc">Remove & Record</option>
<option value="ntfc">Notice & Record</option>
</select>
</td>
</tr>
<tr id="validity" <?php if ($getexpmodet == "None") {echo 'style="display:none;"';}?>>
<td><?= $_validity ?></td><td><input class="form-control" type="text" id="validi" size="4" autocomplete="off" name="validity" value="<?= $getvalid; ?>" required="1"></td>
</tr>
<tr>
<td><?= $_price." ". $currency; ?></td><td><input class="form-control" type="text" min="0" name="price" value="<?= $getprice; ?>" ></td>
</tr>
<tr>
<td class="align-middle"><?= $_selling_price.' '.$currency; ?></td><td><input class="form-control" type="text" size="10" min="0" name="sprice" value="<?= $getsprice; ?>" ></td>
</tr>
<tr>
<td><?= $_lock_user ?></td><td>
<select class="form-control" id="lockunlock" name="lockunlock" required="1">
<option value="<?= $getlocku; ?>"><?= $getlocku; ?></option>
<option value="Enable">Enable</option>
<option value="Disable">Disable</option>
</select>
</td>
</tr>
<tr>
<td class="align-middle">Parent Queue</td>
<td>
<select class="form-control " name="parent">
<option><?= $sparent; ?></option>
<option>none</option>
<?php $TotalReg = count($getallqueue);
for ($i = 0; $i < $TotalReg; $i++) {
echo "<option>" . $getallqueue[$i]['name'] . "</option>";
}
?>
</select>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<div class="col-4">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-book"></i> <?= $_readme ?></h3>
</div>
<div class="card-body">
<table class="table">
<tr>
<td colspan="2">
<p style="padding:0px 5px;">
<?= $_details_user_profile ?>
</p>
<p style="padding:0px 5px;">
<?= $_format_validity ?>
</p>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
+269
View File
@@ -0,0 +1,269 @@
<?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/>.
*/
// hide all error
error_reporting(0);
ini_set('max_execution_time', 300);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
if ($prof == "all") {
$getuser = $API->comm("/ip/hotspot/user/print");
$TotalReg = count($getuser);
$counttuser = $API->comm("/ip/hotspot/user/print", array(
"count-only" => ""
));
} elseif ($prof != "all") {
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?profile" => "$prof",
));
$TotalReg = count($getuser);
$counttuser = $API->comm("/ip/hotspot/user/print", array(
"count-only" => "",
"?profile" => "$prof",
));
}
if ($comm != "") {
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?comment" => "$comm",
//"?uptime" => "00:00:00"
));
$TotalReg = count($getuser);
$counttuser = $API->comm("/ip/hotspot/user/print", array(
"count-only" => "",
"?comment" => "$comm",
));
}
$exp = $_GET['exp'];
if ($exp != "") {
$getuser = $API->comm("/ip/hotspot/user/print", array(
"?limit-uptime" => "1s",
));
$counttuser = $API->comm("/ip/hotspot/user/print", array(
"count-only" => "",
"?limit-uptime" => "1s",
));
}
$getprofile = $API->comm("/ip/hotspot/user/profile/print");
$TotalReg2 = count($getprofile);
}
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3><i class="fa fa-users"></i> <?= $_users ?>
<span style="font-size: 14px">
<?php
if ($counttuser == 0) {
echo "<script>window.location='./?hotspot=users&profile=all&session=" . $session . "</script>";
} ?>
&nbsp; | &nbsp; <a href="./?hotspot-user=add&session=<?= $session; ?>" title="Add User"><i class="fa fa-user-plus"></i> <?= $_add ?></a>
&nbsp; | &nbsp; <a href="./?hotspot-user=generate&session=<?= $session; ?>" title="Generate User"><i class="fa fa-users"></i> <?= $_generate ?></a>
&nbsp; | &nbsp; <a href="<?= str_replace("=users", "=export-users", $url); ?>&export=script" title="Download User List as Mikrotik Script"><i class="fa fa-download"></i> Script</a>&nbsp; | &nbsp; <a href="<?= str_replace("=users", "=export-users", $url); ?>&export=csv" title="Download User List as CSV"><i class="fa fa-download"></i> CSV</a>
</span> &nbsp;
<small id="loader" style="display: none;" ><i><i class='fa fa-circle-o-notch fa-spin'></i> <?= $_processing ?> </i></small>
</h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-6 pd-t-5 pd-b-5">
<div class="input-group">
<div class="input-group-4 col-box-4">
<input id="filterTable" type="text" style="padding:5.8px;" class="group-item group-item-l" placeholder="<?= $_search ?>">
</div>
<div class="input-group-4 col-box-4">
<select style="padding:5px;" class="group-item group-item-m" onchange="location = this.value; loader()" title="Filter by Profile">
<option><?= $_profile ?> </option>
<option value="./?hotspot=users&profile=all&session=<?= $session; ?>"><?= $_show_all ?></option>
<?php
for ($i = 0; $i < $TotalReg2; $i++) {
$profile = $getprofile[$i];
echo "<option value='./?hotspot=users&profile=" . $profile['name'] . "&session=" . $session . "'>" . $profile['name'] . "</option>";
}
?>
</select>
</div>
<div class="input-group-4 col-box-4">
<select style="padding:5px;" class="group-item group-item-r" id="comment" name="comment" onchange="location = './?hotspot=users&comment='+ this.value +'&session=<?= $session;?>';">
<?php
if ($comm != "") {
} else {
echo "<option value=''>".$_comment."</option>";
}
$TotalReg = count($getuser);
for ($i = 0; $i < $TotalReg; $i++) {
$ucomment = $getuser[$i]['comment'];
$uprofile = $getuser[$i]['profile'];
$acomment .= ",".$ucomment."#". $uprofile;
}
$ocomment= explode(",",$acomment);
$comments=array_count_values($ocomment) ;
foreach ($comments as $tcomment=>$value) {
if (is_numeric(substr($tcomment, 3, 3))) {
echo "<option value='" . explode("#",$tcomment)[0] . "' >". explode("#",$tcomment)[0]." ".explode("#",$tcomment)[1]. " [".$value. "]</option>";
}
}
?>
</select>
</div>
</div>
</div>
<div class="col-6">
<?php if ($comm != "") { ?>
<button class="btn bg-red" onclick="if(confirm('Are you sure to delete username by comment (<?= $comm; ?>)?')){loadpage('./?remove-hotspot-user-by-comment=<?= $comm; ?>&session=<?= $session; ?>');loader();}else{}" title="Remove user by comment <?= $comm; ?>"> <i class="fa fa-trash"></i> <?= $_by_comment ?></button>
<?php ; }else if ($exp == "1"){ ?>
<button class="btn bg-red" onclick="if(confirm('Are you sure to delete users?')){loadpage('./?remove-hotspot-user-expired=1&session=<?= $session; ?>');loader();}else{}" title="Remove user expired"> <i class="fa fa-trash"></i> Expired Users</button>
<?php } ?>
<script>
function printV(a,b){
var comm = document.getElementById('comment').value;
var url = "./voucher/print.php?id="+comm+"&"+a+"="+b+"&session=<?= $session; ?>";
if (comm === "" ){
<?php if ($currency == in_array($currency, $cekindo['indo'])) { ?>
alert('Silakan pilih salah satu Comment terlebih dulu!');
<?php
} else { ?>
alert('Please choose one of the Comments first!');
<?php
} ?>
}else{
var win = window.open(url, '_blank');
win.focus();
}}
</script>
<button class="btn bg-primary" title='Print' onclick="printV('qr','no');"><i class="fa fa-print"></i> <?= $_print_default ?></button>
<button class="btn bg-primary" title='Print QR' onclick="printV('qr','yes');"><i class="fa fa-print"></i> <?= $_print_qr ?></button>
<button class="btn bg-primary" title='Print Small'onclick="printV('small','yes');"><i class="fa fa-print"></i> <?= $_print_small ?></button>
</div>
</div>
<div class="overflow mr-t-10 box-bordered" style="max-height: 75vh">
<table id="dataTable" class="table table-bordered table-hover text-nowrap">
<thead>
<tr>
<th style="min-width:50px;" class="align-middle text-center" id="cuser"><?= $counttuser; ?></th>
<th style="min-width:50px;" class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Server</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> <?= $_name ?></th>
<th>Print</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> <?= $_profile ?></th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> Mac Address</th>
<th class="text-right align-middle pointer" title="Click to sort"><i class="fa fa-sort"></i> <?= $_uptime_user ?></th>
<th class="text-right align-middle pointer" title="Click to sort"><i class="fa fa-sort"></i> Bytes In</th>
<th class="text-right align-middle pointer" title="Click to sort"><i class="fa fa-sort"></i> Bytes Out</th>
<th class="pointer" title="Click to sort"><i class="fa fa-sort"></i> <?= $_comment ?></th>
</tr>
</thead>
<tbody id="tbody">
<?php
for ($i = 0; $i < $TotalReg; $i++) {
$userdetails = $getuser[$i];
$uid = $userdetails['.id'];
$userver = $userdetails['server'];
$uname = $userdetails['name'];
$upass = $userdetails['password'];
$uprofile = $userdetails['profile'];
$umacadd = $userdetails['mac-address'];
$uuptime = formatDTM($userdetails['uptime']);
$ubytesi = formatBytes($userdetails['bytes-in'], 2);
$ubyteso = formatBytes($userdetails['bytes-out'], 2);
$ucomment = $userdetails['comment'];
$udisabled = $userdetails['disabled'];
$utimelimit = $userdetails['limit-uptime'];
if ($utimelimit == '1s') {
$utimelimit = ' expired';
} else {
$utimelimit = ' ' . $utimelimit;
}
$udatalimit = $userdetails['limit-bytes-total'];
if ($udatalimit == '') {
$udatalimit = '';
} else {
$udatalimit = ' ' . formatBytes($udatalimit, 2);
}
echo "<tr>";
?>
<td style='text-align:center;'> <i class='fa fa-minus-square text-danger pointer' onclick="if(confirm('Are you sure to delete username (<?= $uname; ?>)?')){loadpage('./?remove-hotspot-user=<?= $uid; ?>&session=<?= $session; ?>')}else{}" title='Remove <?= $uname; ?>'></i>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<?php
if ($udisabled == "true") {
$uriprocess = "'./?enable-hotspot-user=" . $uid . "&session=" . $session."'";
echo '<span class="text-warning pointer" title="Enable User ' . $uname . '" onclick="loadpage('.$uriprocess.')"><i class="fa fa-lock "></i></span></td>';
} else {
$uriprocess = "'./?disable-hotspot-user=" . $uid . "&session=" . $session."'";
echo '<span class="pointer" title="Disable User ' . $uname . '" onclick="loadpage('.$uriprocess.')"><i class="fa fa-unlock "></i></span></td>';
}
echo "<td>" . $userver . "</td>";
if ($uname == $upass) {
$usermode = "vc";
} else {
$usermode = "up";
}
$popup = "javascript:window.open('./voucher/print.php?user=" . $usermode . "-" . $uname . "&qr=no&session=" . $session . "','_blank','width=320,height=550').print();";
$popupQR = "javascript:window.open('./voucher/print.php?user=" . $usermode . "-" . $uname . "&qr=yes&session=" . $session . "','_blank','width=320,height=550').print();";
echo "<td><a title='Open User " . $uname . "' href=./?hotspot-user=" . $uid . "&session=" . $session . "><i class='fa fa-edit'></i> " . $uname . " </a>";
echo '</td><td class"text-center"><a title="Print ' . $uname . '" href="' . $popup . '"><i class="fa fa-print"></i></a> &nbsp <a title="Print ' . $uname . '" href="' . $popupQR . '"><i class="fa fa-qrcode"></i> </a></td>';
echo "<td>" . $uprofile . "</td>";
echo "<td style=' text-align:left'>" . $umacadd . "</td>";
echo "<td style=' text-align:right'>" . $uuptime . "</td>";
echo "<td style=' text-align:right'>" . $ubytesi . "</td>";
echo "<td style=' text-align:right'>" . $ubyteso . "</td>";
echo "<td>";
if ($uname == "default-trial") {
} else if (substr($ucomment,0,3) == "vc-" || substr($ucomment,0,3) == "up-") {
echo "<a href=./?hotspot=users&comment=" . $ucomment . "&session=" . $session . " title='Filter by " . $ucomment . "'><i class='fa fa-search'></i> ". $ucomment." ". $udatalimit ." ".$utimelimit . "</a>";
} else if ($utimelimit == ' expired') {
echo "<a href=./?hotspot=users&profile=all&exp=1&session=" . $session . " title='Filter by expired'><i class='fa fa-search'></i> " . $ucomment." ". $udatalimit ." ".$utimelimit . "</a>";
}else{
echo $ucomment.' ';
}
echo "</td>";
}
?>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>