Bug Fix; Auto expiry of account script +

Bug fixes related to automatic expiry of accounts scripting and such.  Type changes of fields in creating vouchers forms etc
This commit is contained in:
Siby P Varkey 2018-07-15 17:17:58 +05:30 committed by GitHub
parent 07682e6381
commit e8509575a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 135 additions and 63 deletions

View file

@ -22,9 +22,11 @@ if ($_SESSION['user_level'] == 1) {
$lock_user = $_GET['lock_user'];
$rate_limit = $rx_rate_limit.'/'.$tx_rate_limit;
/*
if (empty($session_timeout)) $session_timeout = '3d 00:00:00';
if (empty($mac_cookie_timeout)) $mac_cookie_timeout = '3d 00:00:00';
if (empty($keepalive_timeout)) $keepalive_timeout = '00:02:00';
*/
if ($price == "") {$price = "0";}
if($lock_user == Enable){$mac_bind = ';[:local mac $"mac-address"; /ip hotspot user set mac-address=$mac [find where name=$user]]';} else {$mac_bind = "";}
@ -56,6 +58,16 @@ if ($_SESSION['user_level'] == 1) {
$util->setMenu('/ip hotspot user profile');
if(strtolower($session_timeout) == 'none') $session_timeout = '00:00:00';
$util->add(
array(
'name' => "$profile_name",
'rate-limit' => "$rate_limit",
'shared-users' => "$shared_users",
'status-autorefresh' => "1m",
'transparent-proxy' => "yes",
'on-login' => "$login_script",
)
);
/* Old version
array(
'name' => "$profile_name",
'rate-limit' => "$rate_limit",
@ -67,7 +79,7 @@ if ($_SESSION['user_level'] == 1) {
'transparent-proxy' => "yes",
'on-login' => "$login_script",
)
);
*/
/*
if(strtolower($session_timeout) == 'none') {
$id = $client->sendSync(new Request('/ip/hotspot/user/profile/print .proplist=.id', null, Query::where('name', $profile_name)))->getArgument('.id');

View file

@ -23,9 +23,11 @@ if ((!empty($username)) and (!empty($password)) and (!empty($profile))) {
array(
'name' => "$username",
'password' => "$password",
'disabled' => "no",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
'profile' => "$profile",
'comment' => "Zetozone",
)
);
}
@ -35,8 +37,10 @@ if ((!empty($username)) and (!empty($password)) and (!empty($profile))) {
array(
'name' => "$username",
'password' => "$password",
'disabled' => "no",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
'profile' => "$profile",
'comment' => "Zetozone",
)
);
$limit_bytes = 0; // For Adding it to Local database

View file

@ -21,9 +21,11 @@ if ( !isset($_SESSION) ) session_start();
switch ($pass_type) {
case "s":
$passAlphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
$user_prefix = strtolower($user_prefix);
break;
case "c":
$passAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
$user_prefix = strtoupper($user_prefix);
break;
case "n":
$passAlphabet = "123456789123456789123456789123456789123456789123456789";
@ -33,9 +35,11 @@ switch ($pass_type) {
break;
case "sn":
$passAlphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz123456789123456789123456789";
$user_prefix = strtolower($user_prefix);
break;
case "cn":
$passAlphabet = "123456789123456789123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789123456789123456789";
$user_prefix = strtoupper($user_prefix);
break;
case "scn":
$passAlphabet = "abcdefghijklmnopqrstuvwxyz123456789123456789123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
@ -88,11 +92,13 @@ if($_SESSION['user_level'] >= 1 and $_SESSION['user_level'] <= 3) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$user_name",
'password' => "$pass_word",
'name' => "$username",
'password' => "$password",
'disabled' => "no",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
'profile' => "$profile",
'comment' => "Zetozone",
)
);
}
@ -100,10 +106,12 @@ if($_SESSION['user_level'] >= 1 and $_SESSION['user_level'] <= 3) {
{
$util->add(
array(
'name' => "$user_name",
'password' => "$pass_word",
'name' => "$username",
'password' => "$password",
'disabled' => "no",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
'profile' => "$profile",
'comment' => "Zetozone",
)
);
$limit_bytes = 0; // For Adding it to Local database

View file

@ -24,10 +24,12 @@ if ($_SESSION['user_level'] == 1) {
$rate_limit = $rx_rate_limit.'/'.$tx_rate_limit;
if (empty($rx_rate_limit)) $rx_rate_limit = "256k";
if (empty($tx_rate_limit)) $tx_rate_limit = "128k";
if (empty($session_timeout)) $session_timeout = "1d 00:00:00";
if (empty($shared_users)) $shared_users = 1;
/*
if (empty($session_timeout)) $session_timeout = "1d 00:00:00";
if (empty($mac_cookie_timeout)) $mac_cookie_timeout = "1d 00:00:00";
if (empty($keepalive_timeout)) $keepalive_timeout = "00:02:00";
*/
if ($price == "") {$price = "0";}
if($lock_user == Enable){$mac_bind = ';[:local mac $"mac-address"; /ip hotspot user set mac-address=$mac [find where name=$user]]';} else {$mac_bind = "";}
@ -64,6 +66,7 @@ if ($_SESSION['user_level'] == 1) {
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
$setRequest->setArgument('numbers', $id);
$setRequest->setArgument('rate-limit', $rate_limit);
/*
if(strtolower($session_timeout) != 'none') {
$setRequest->setArgument('session-timeout', $session_timeout);
}
@ -71,10 +74,10 @@ if ($_SESSION['user_level'] == 1) {
{
$setRequest->setArgument('session-timeout', '00:00:00');
}
$setRequest->setArgument('shared-users', $shared_users);
$setRequest->setArgument('mac-cookie-timeout', $mac_cookie_timeout);
$setRequest->setArgument('keepalive-timeout', $keepalive_timeout);
*/
$setRequest->setArgument('shared-users', $shared_users);
$setRequest->setArgument('status-autorefresh', "1m");
$setRequest->setArgument('transparent-proxy', "yes");
$setRequest->setArgument('on-login', "$login_script");

View file

@ -1,5 +1,5 @@
<?php
$host = "192.168.1.200";
$host = "192.168.1.123";
$user = "admin";
$pass = "admin";
?>

View file

@ -918,7 +918,7 @@ function editprofile(oForm) {
//Guest User Profile - End of Updating a User profile;
</script>
<script>
//Guest User Profile - Start of Adding a New User profile;
//Guest User Account - Start of Removing Selected User accounts
function removeSelected(oForm) {
var Removal1 = oForm.elements['removal_list[]'];
var Removal_list = new Array();

View file

@ -136,41 +136,43 @@
<div class="col-sm-4">
<label class="col-sm-6 control-label" >User Name</label>
<div class="col-sm-6">
<input type="text" placeholder="Please enter required username *" name="uname" id="uname" required >
<input type="text" placeholder="Required Username *" name="uname" id="uname" required >
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" >Password</label>
<div class="col-sm-6">
<input type="text" placeholder="Please enter the required password *" name="psw" id="psw" required>
<input type="text" placeholder="required password *" name="psw" id="psw" required>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" >Time Limit (Days)</label>
<label class="col-sm-6 control-label" >Uptime Limit(wdhms format)</label>
<div class="col-sm-6">
<select class="myCombo" id="slimit_uptime" name="slimit_uptime">
<input type="text" placeholder="10m" title="eg.5h30m [w(Weeks) d(days) h(hours) m(minutes) s(seconds) format]" name="slimit_uptime" id="slimit_uptime" >
<!-- <select class="myCombo" id="slimit_uptime" name="slimit_uptime">
<option value="2d">2 Days</option>
<option value="1d">1 Day</option>
<option value="2d">2 Days</option>
<option value="3d">3 Days</option>
<option value="4d">4 Days</option>
<option value="5d">5 Days</option>
</select>
</select> -->
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="limit_bytes">Maximum Usage Limit(GB)</label>
<label class="col-sm-6 control-label" for="slimit_bytes">Maximum Usage Limit(GB), 0 for NO Limit</label>
<div class="col-sm-6">
<select class="myCombo" id="slimit_bytes" name="slimit_bytes">
<input type="number" title="Maximum usable data in GB" name="slimit_bytes" id="slimit_bytes" min="0" value="0" required >
<!--<select class="myCombo" id="slimit_bytes" name="slimit_bytes">
<option value="0">NONE</option>
<option value="1">1 GB</option>
<option value="5">5 GB</option>
<option value="10">10 GB</option>
<option value="20">20 GB</option>
<option value="50">50 GB</option>
</select>
</select> -->
</div>
</div>
<div class="col-sm-4">
@ -249,8 +251,10 @@
</div>
<div class="form-group form-group-sm">
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="limit_uptime">Time Limit (Days)</label>
<label class="col-sm-6 control-label" for="limit_uptime">Uptime Limit(wdhms format)</label>
<div class="col-sm-6">
<input type="text" placeholder="1d1h" title="eg.5h30m [w(Weeks) d(days) h(hours) m(minutes) s(seconds) format]" name="limit_uptime" id="limit_uptime" >
<!--<input type="number" placeholder="No of days" name="limit_uptime" id="limit_uptime" min="1" value="2" required >
<select class="myCombo" id="limit_uptime" name="limit_uptime">
<option value="2d">2 Days</option>
<option value="1d">1 Day</option>
@ -258,7 +262,7 @@
<option value="3d">3 Days</option>
<option value="4d">4 Days</option>
<option value="5d">5 Days</option>
</select>
</select> -->
</div>
</div>
<div class="col-sm-4">
@ -285,7 +289,11 @@
</div>
<div class="form-group form-group-sm">
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="limit_bytes">Maximum Usage Limit(GB)</label>
<label class="col-sm-6 control-label" for="limit_bytes">Maximum Usage Limit(GB), 0 for NO Limit</label>
<div class="col-sm-6">
<input type="number" placeholder="Maximum usable data in GB" name="limit_bytes" id="limit_bytes" min="0" value="0" required >
</div>
<!--<label class="col-sm-6 control-label" for="limit_bytes">Maximum Usage Limit(GB)</label>
<div class="col-sm-6">
<select class="myCombo" id="limit_bytes" name="limit_bytes">
<option value="0">NONE</option>
@ -295,18 +303,18 @@
<option value="20">20 GB</option>
<option value="50">50 GB</option>
</select>
</div>
</div> -->
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="pass_type">Password Type</label>
<div class="col-sm-6">
<select class="myCombo" id="pass_type" name="pass_type" required>
<option value="s">abcd</option>
<option value="c">ABCD</option>
<option value="sc">aBcD</option>
<select class="myCombo" id="pass_type" name="pass_type" value="sn" required>
<option value="sn">abcd1234</option>
<option value="cn">ABCD1234</option>
<option value="scn">aBcD1234</option>
<option value="s">abcd</option>
<option value="c">DCBA</option>
<option value="sc">BaCd</option>
<option value="cn">1342ABCD</option>
<option value="scn">1423aBcD</option>
<option value="n">1234</option>
</select>
</div>
@ -352,7 +360,7 @@
<?php $util->setMenu('/ip hotspot user'); ?>
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered" id="table-01">
<div class="alert alert-info">
<strong><i class="icon-user icon-large"></i><h3 class="text-center">Users inactive at the moment</h3></strong>
<strong><i class="icon-user icon-large"></i><h3 class="text-center">Users Not active at the moment</h3></strong>
</div>
<thead>
<tr>
@ -380,6 +388,7 @@
$limit_uptime = $item->getProperty('limit-uptime');
}
else { $limit_uptime = 'Not Limited'; }
if ($item->getProperty('uptime') == "0s") {
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('name'),'</td>';
@ -390,7 +399,8 @@
echo '<td>', $item->getProperty('uptime'), '</td>';
echo '<td>', $limit_uptime, '</td>';
echo '</tr>';
} ?>
}
}?>
</tbody>
</table>
</div>
@ -477,7 +487,7 @@
<?php $util->setMenu('/ip hotspot user'); ?>
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered" id="table-01">
<div class="alert alert-info">
<strong><i class="icon-user icon-large"></i><h3 class="text-center">List of users accounts which can be removed and not active at the moment</h3></strong>
<strong><i class="icon-user icon-large"></i><h3 class="text-center">List of users accounts</h3></strong>
</div>
<thead>
<tr>
@ -520,8 +530,15 @@
echo '<td>', $limit_uptime, '</td>';
if($_SESSION['user_level'] <= 2) { //Administrator/Unit Head Only
echo '<td>';
$chktrue = "";
if (!empty($item->getProperty('limit-uptime'))) {
if (!($item->getProperty('uptime') < $item->getProperty('limit-uptime'))) {
$chktrue = "checked";
}
}
//if (!($item->getProperty('uptime') < $item->getProperty('limit-uptime'))) $chktrue = "checked"; else $chktrue = "";
echo '<label for="'.$rid.'"></label>
<input type="checkbox" name="removal_list[]" value="'.$rid.'" id="'.$rid.'" class="styled" />';
<input type="checkbox" name="removal_list[]" value="'.$rid.'" id="'.$rid.'" '.$chktrue.' class="styled" /> &nbsp;&nbsp;&nbsp; ';
echo '<a title="Delete the Guest User Account" id="id'.$i.'" href="#delete'.$item->getProperty('name').'" data-toggle="modal" class="btn btn-danger btn-lg"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>&nbsp;&nbsp;';
include('modal_delete_guest.php'); ?>
<?php
@ -531,6 +548,10 @@
} ?>
</tbody>
</table>
<!--<div class="col-sm-2 col-sm-offset-3">
<button name="removal" id="removeall" data-dismiss="modal" onClick="removeAllSelected(this.form);" class="btn btn-danger"><i class="icon-save icon-large"></i></a>&nbsp;Remove All</button>&nbsp;&nbsp;&nbsp;
</div>
<div class="col-sm-2"> -->
<div class="col-sm-2 col-sm-offset-4">
<button name="removal" id="removal" data-dismiss="modal" onClick="removeSelected(this.form);" class="btn btn-success"><i class="icon-save icon-large"></i></a>&nbsp;Remove Selected</button>&nbsp;&nbsp;&nbsp;
</div>
@ -580,9 +601,14 @@
<?php
try
{
//use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
//$client = new RouterOS\Client("$host", "$user", "$pass");
$printRequest = new RouterOS\Request('/ip hotspot user print');
$printRequest->setArgument('.proplist', '.id,server,name,profile,limit-uptime,limit-bytes-total,uptime,bytes-in,bytes-out');
$printRequest->setQuery(RouterOS\Query::where('.id', '*0', RouterOS\Query::OP_EQ) ->not());
$printRequest->setArgument('.proplist','.id,server,name,profile,limit-uptime,limit-bytes-total,uptime,bytes-in,bytes-out');
$printRequest->setQuery(RouterOS\Query::where('.id','*0', RouterOS\Query::OP_EQ) ->not());
$idList = '';
$i = 0;
@ -606,7 +632,7 @@
}
}
catch (Exception $e) {
//echo '<script>cmodal("Access Denied!", "Error accessing validity expired users!", "error", "index.php")</script>';
echo '<script>cmodal("Access Denied!", "Error accessing validity expired users!'.$e->getMessage().'", "error", "index.php")</script>';
}
?>
</tbody>
@ -767,7 +793,7 @@
<?php $util->setMenu('/ip hotspot user'); ?>
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered" id="table-01">
<div class="alert alert-info">
<strong><i class="icon-user icon-large"></i><h3 class="text-center">User accounts not yet initiated any activities, and can be removed</h3></strong>
<strong><i class="icon-user icon-large"></i><h3 class="text-center">User accounts not yet initiated any activities, ie. accounts inactive at the moment</h3></strong>
</div>
<thead>
<tr>

View file

@ -22,10 +22,10 @@ require_once 'PEAR2/Autoload.php';
require_once 'config.php';
try {
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
include_once('home.php');
}
catch (Exception $e) {
}
catch (Exception $e) {
echo "Error Accessing Data: " . $e->getMessage();
include_once('settings.php');
}
?>

View file

@ -22,7 +22,7 @@
<div class="form-group">
<label class="control-label col-xs-2">Grace Period</label>
<div class="col-xs-3">
<input type="text" id="grace_period" title="Grace period allowed, if any" onChange="genClick();" tabindex="3">
<input type="text" id="grace_period" title="Grace period, if any in wdhms format" onChange="genClick();" tabindex="3">
</div>
<label class="control-label col-xs-2 pull-left">On Expiry</label>
<div class="col-xs-3 pull-left">
@ -66,13 +66,22 @@
<option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option>
<option value="10M">10 Mbps</option>
<option value="25M">25 Mbps</option>
<option value="50M">50 Mbps</option>
<option value="100M">100 Mbps</option>
<option value="500M">500 Mbps</option>
<option value="800M">800 Mbps</option>
<option value="1024M">1 Gbps</option>
<option value="10240M">10 Gbps</option>
<option value="20480M">20 Gbps</option>
<option value="102400M">100 Gbps</option>
</select>
</div>
<label class="control-label col-xs-2 pull-left">Rate limit - Upload(Tx)</label>
<div class="col-xs-3 pull-left">
<select class="myCombo" id="tx_rate_limit" title="Select the maximum Upload speed limit allowed for the profile from the list" onChange="genClick();" name="status" required tabindex="8">
<option></option>
<option value="128k">128 Kbps</option>
<option value="256k">256 Kbps</option>
<option value="512k">512 Kbps</option>
<option value="1M">1 Mbps</option>
@ -83,6 +92,16 @@
<option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option>
<option value="10M">10 Mbps</option>
<option value="25M">25 Mbps</option>
<option value="50M">50 Mbps</option>
<option value="100M">100 Mbps</option>
<option value="500M">500 Mbps</option>
<option value="800M">800 Mbps</option>
<option value="1024M">1 Gbps</option>
<option value="10240M">10 Gbps</option>
<option value="20480M">20 Gbps</option>
<option value="102400M">100 Gbps</option>
</select>
</div>
</div>
@ -94,7 +113,7 @@
</div>
<label class="control-label col-xs-2">Session Timeout</label>
<div class="col-xs-3 pull-left">
<input type="text" id="session_timeout" title="Session Timeout Value in the format 3d 00:00:00, Give 00:00:00 or none for No Limits" onChange="genClick();" tabindex="10">
<input type="text" id="session_timeout" title="Session Timeout Value in the format 3d 00:00:00, Give 00:00:00 or none for No Limits" onChange="genClick();" tabindex="10" >
</div>
</div>
<div class="form-group">

View file

@ -4,7 +4,7 @@
include ('header.php');
if ( !isset($_SESSION) ) session_start(); ?>
<body>
<div class="container">
<div class="container" style="margin-top:50px;">
<div class="no_print">
<div class="row">
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
@ -12,7 +12,7 @@ if ( !isset($_SESSION) ) session_start(); ?>
<div class="panel-heading"><h3 class="text-center">HotSpot User Voucher Printing</h3></div>
<div class="panel-body">
<form class="form-horizontal" method="post">
<div class="alert alert-info text-center"><strong>HotSpot User Voucher Printing</strong></div>
<div class="alert alert-info text-center"><strong>Printing of last set of vouchers</strong></div>
<div class="form-group">
<div class="col-xs-4">
<img src="images/shot1.png" width="240" height="100" class="center">