Add files via upload

This commit is contained in:
Siby P Varkey 2018-07-09 12:14:27 +05:30 committed by GitHub
parent 39fe6034d9
commit b2e961ebcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 3903 additions and 4634 deletions

View file

@ -1,55 +1,55 @@
<?php
header('Content-Type: application/json');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
if ( !isset($_SESSION) ) session_start();
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
$profile_name=strtolower($_GET['profile_name']);
$session_timeout=$_GET['session_timeout'];
$shared_users=$_GET['shared_users'];
$mac_cookie_timeout=$_GET['mac_cookie_timeout'];
$keepalive_timeout=$_GET['keepalive_timeout'];
$rx_rate_limit=$_GET['rx_rate_limit'];
$tx_rate_limit=$_GET['tx_rate_limit'];
$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 ($_SESSION['user_level'] == 1) {
if (!empty($profile_name)) {
$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",
'session-timeout' => "$session_timeout",
'shared-users' => "$shared_users",
'mac-cookie-timeout' => "$mac_cookie_timeout",
'keepalive-timeout' => "$keepalive_timeout"
)
);
/*
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');
$util->setMenu('/ip hotspot user profile');
$util->unsetValue($id, 'session-timeout');
} */
echo 2; //Success
}
else
{
echo 1; //Profile name/Session Timeout Empty
}
}
else
{
echo 0; //Not Authorised
}
<?php
header('Content-Type: application/json');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
if ( !isset($_SESSION) ) session_start();
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
$profile_name=strtolower($_GET['profile_name']);
$session_timeout=$_GET['session_timeout'];
$shared_users=$_GET['shared_users'];
$mac_cookie_timeout=$_GET['mac_cookie_timeout'];
$keepalive_timeout=$_GET['keepalive_timeout'];
$rx_rate_limit=$_GET['rx_rate_limit'];
$tx_rate_limit=$_GET['tx_rate_limit'];
$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 ($_SESSION['user_level'] == 1) {
if (!empty($profile_name)) {
$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",
'session-timeout' => "$session_timeout",
'shared-users' => "$shared_users",
'mac-cookie-timeout' => "$mac_cookie_timeout",
'keepalive-timeout' => "$keepalive_timeout"
)
);
/*
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');
$util->setMenu('/ip hotspot user profile');
$util->unsetValue($id, 'session-timeout');
} */
echo 2; //Success
}
else
{
echo 1; //Profile name/Session Timeout Empty
}
}
else
{
echo 0; //Not Authorised
}
?>

View file

@ -1,34 +1,34 @@
<?php
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['username']))) {
include('dbconfig.php');
$password='password';
$password=sha1($password);
$username=strtolower($_GET['username']);
$firstname=$_GET['firstname'];
$lastname=$_GET['lastname'];
$user_level=$_GET['user_level'];
$status=$_GET['status'];
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE username =:username");
$stmt->execute(array(':username' => $username));
$count = $stmt->rowCount();
if ($count != 0) {
echo 1;
}
else
{
$stmt = $DB_con->prepare("insert into hotspot_users (username, password, firstname, lastname, date_added, user_level, status)
values(:username, :password, :firstname, :lastname, CURDATE(), :user_level, :status)");
$stmt->execute(array(':username' => $username, ':password' => $password, ':firstname' => $firstname,
':lastname' => $lastname, ':user_level' => $user_level, ':status' => $status));
echo 2;
}
}
else {
echo 0;
}
// End Adding a new System User Details, Returned from modal_add_user.php
<?php
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['username']))) {
include('dbconfig.php');
$password='password';
$password=sha1($password);
$username=strtolower($_GET['username']);
$firstname=$_GET['firstname'];
$lastname=$_GET['lastname'];
$user_level=$_GET['user_level'];
$status=$_GET['status'];
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE username =:username");
$stmt->execute(array(':username' => $username));
$count = $stmt->rowCount();
if ($count != 0) {
echo 1;
}
else
{
$stmt = $DB_con->prepare("insert into hotspot_users (username, password, firstname, lastname, date_added, user_level, status)
values(:username, :password, :firstname, :lastname, CURDATE(), :user_level, :status)");
$stmt->execute(array(':username' => $username, ':password' => $password, ':firstname' => $firstname,
':lastname' => $lastname, ':user_level' => $user_level, ':status' => $status));
echo 2;
}
}
else {
echo 0;
}
// End Adding a new System User Details, Returned from modal_add_user.php
?>

View file

@ -1,116 +1,121 @@
<?php
require_once 'settings.php';
if (isset($_GET['name'])) $username = $_GET['name'];
if (isset($_GET['psd'])) $password = $_GET['psd'];
if (isset($_GET['limit_uptime'])) $limit_uptime = $_GET['limit_uptime'];
if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes'];
if (isset($_GET['profile'])) $profile = $_GET['profile'];
if ( !isset($_SESSION) ) session_start();
$util->setMenu('/ip hotspot user');
$iv = count($util);
if ((!empty($username)) and (!empty($password)) and (!empty($profile))) {
if (intval($limit_bytes) != 0) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
else
{
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
)
);
$limit_bytes = 0; // For Adding it to Local database
}
if ($iv != count($util)) {
include('dbconfig.php');
$stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1");
$stmt->execute(array());
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$booking_id = $row['booking_id'];
$booking_id++;
$uid = $booking_id.'-1-'.date('dmY');
//$creator = $_SESSION['username'].'['.$_SESSION['id'].']';
$stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1");
$stmt->execute(array(':status' => 'Over'));
$stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times,
printed_last, status, group_of, booking_id, limit_uptime, limit_bytes, profile, uid)
values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of,
:booking_id, :limit_uptime, :limit_bytes, :profile, :uid)");
$stmt->execute(array(':created_by' => $_SESSION['username'], ':creator' => $_SESSION['id'], ':user_name' => $username, ':password' => $password,
':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => 1,
':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes,
':profile' => $profile, ':uid' => $uid));
// here starts Echo String
$echo_text ='
<div class="container">
<div class="row" style="padding-top:20px;">
<div class="col-sm-12 col-md-12">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="text-center">Hotspot User Voucher</h3></div>
<div class="panel-body">
<form id="userForm" class="form-horizontal" method="GET" action="" enctype="multipart/form-data">
<div class="col-sm-12 col-md-12">
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered" id="example">
<thead>
<tr>
<th width="10%"></th>
<th colspan="2">Username</th>
<th colspan="2">Password</th>
</tr>
</thead>
<tbody>';
$echo_text .= '<tr>
<td width="10%" style="margin:0px; border: 0px; padding: 2px;"><img src="images/logo.png" width="250" height="50"></td>
<td colspan="2"><input type="text" name="username" class="form-control" value="Username : '.$username.'" placeholder="User Name" readonly></td>
<td colspan="2"><input type="text" name="password" class="form-control" value="Password : '.$password.'" placeholder="Password" readonly></td>
</tr>
<tr>';
if (intval($limit_bytes) != 0) {
$echo_text .= '<td colspan="5">Validity : '.$limit_uptime.'ays; Counts from First login; Data usage Maximum : '.$limit_bytes_total.' Bytes; Bandwidth : '.$profile.'; HAPPY BROWSING...</td>';
}
else
{
$echo_text .= '<td colspan="5">Validity : '.$limit_uptime.'ays; Counts from First login; Bandwidth/Profile : '.$profile.'; HAPPY BROWSING...</td>';
}
$echo_text .= '
</tr>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-3 col-sm-offset-5">
<button onclick="window.print();" class="btn btn-primary" ><i class="icon-save icon-large"></i></a>&nbsp;PRINT</button>&nbsp;&nbsp;
<button onclick="document.getElementById("single").style.display="none !important;" type="reset" class="btn btn-danger"><i class="icon-save icon-large"></i></a>&nbsp;Reset</button>&nbsp;&nbsp;
<button data-dismiss="modal" class="btn btn-info" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>&nbsp;&nbsp;
</div>
</div>
</div>';
echo $echo_text;
}
else
{
echo '<script>cmodalOkCancel("ERROR/DUPLICATE", " Username '.$username.' is not added, Found as Duplicate. Try some other name", "error");</script>';
}
}
//End Adding a Guest User
<?php
//require_once 'settings.php';
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if (isset($_GET['name'])) $username = $_GET['name'];
if (isset($_GET['psd'])) $password = $_GET['psd'];
if (isset($_GET['limit_uptime'])) $limit_uptime = $_GET['limit_uptime'];
if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes'];
if (isset($_GET['profile'])) $profile = $_GET['profile'];
if ( !isset($_SESSION) ) session_start();
$util->setMenu('/ip hotspot user');
$iv = count($util);
if ((!empty($username)) and (!empty($password)) and (!empty($profile))) {
if (intval($limit_bytes) != 0) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
else
{
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
)
);
$limit_bytes = 0; // For Adding it to Local database
}
if ($iv != count($util)) {
include('dbconfig.php');
$stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1");
$stmt->execute(array());
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$booking_id = $row['booking_id'];
$booking_id++;
$uid = $booking_id.'-1-'.date('dmY');
//$creator = $_SESSION['username'].'['.$_SESSION['id'].']';
$stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1");
$stmt->execute(array(':status' => 'Over'));
$stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times,
printed_last, status, group_of, booking_id, limit_uptime, limit_bytes, profile, uid)
values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of,
:booking_id, :limit_uptime, :limit_bytes, :profile, :uid)");
$stmt->execute(array(':created_by' => $_SESSION['username'], ':creator' => $_SESSION['id'], ':user_name' => $username, ':password' => $password,
':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => 1,
':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes,
':profile' => $profile, ':uid' => $uid));
// here starts Echo String
$echo_text ='
<div class="container">
<div class="row" style="padding-top:20px;">
<div class="col-sm-12 col-md-12">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="text-center">Hotspot User Voucher</h3></div>
<div class="panel-body">
<form id="userForm" class="form-horizontal" method="GET" action="" enctype="multipart/form-data">
<div class="col-sm-12 col-md-12">
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered" id="example">
<thead>
<tr>
<th width="10%"></th>
<th colspan="2">Username</th>
<th colspan="2">Password</th>
</tr>
</thead>
<tbody>';
$echo_text .= '<tr>
<td width="10%" style="margin:0px; border: 0px; padding: 2px;"><img src="images/logo.png" width="250" height="50"></td>
<td colspan="2"><input type="text" name="username" class="form-control" value="Username : '.$username.'" placeholder="User Name" readonly></td>
<td colspan="2"><input type="text" name="password" class="form-control" value="Password : '.$password.'" placeholder="Password" readonly></td>
</tr>
<tr>';
if (intval($limit_bytes) != 0) {
$echo_text .= '<td colspan="5">Validity : '.$limit_uptime.'ays; Counts from First login; Data usage Maximum : '.$limit_bytes_total.' Bytes; Bandwidth : '.$profile.'; HAPPY BROWSING...</td>';
}
else
{
$echo_text .= '<td colspan="5">Validity : '.$limit_uptime.'ays; Counts from First login; Bandwidth/Profile : '.$profile.'; HAPPY BROWSING...</td>';
}
$echo_text .= '
</tr>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-3 col-sm-offset-5">
<button onclick="window.print();" class="btn btn-primary" ><i class="icon-save icon-large"></i></a>&nbsp;PRINT</button>&nbsp;&nbsp;
<button onclick="document.getElementById("single").style.display="none !important;" type="reset" class="btn btn-danger"><i class="icon-save icon-large"></i></a>&nbsp;Reset</button>&nbsp;&nbsp;
<button data-dismiss="modal" class="btn btn-info" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>&nbsp;&nbsp;
</div>
</div>
</div>';
echo $echo_text;
}
else
{
echo '<script>cmodalOkCancel("ERROR/DUPLICATE", " Username '.$username.' is not added, Found as Duplicate. Try some other name", "error");</script>';
}
}
//End Adding a Guest User
?>

View file

@ -1,90 +1,95 @@
<?php error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'settings.php';
if (isset($_GET['no_of_users'])) $no_of_users = $_GET['no_of_users'];
if (isset($_GET['pass_length'])) $passLength = $_GET['pass_length'];
if (isset($_GET['user_prefix'])) $user_prefix = $_GET['user_prefix'];
if (isset($_GET['limit_uptime'])) $limit_uptime = $_GET['limit_uptime'];
if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes'];
if (isset($_GET['profile'])) $profile = $_GET['profile'];
if (isset($_GET['same_pass'])) $same_pass = $_GET['same_pass'];
if ( !isset($_SESSION) ) session_start();
if($_SESSION['user_level'] >= 1 and $_SESSION['user_level'] <= 3) {
include('dbconfig.php');
$stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1");
$stmt->execute(array());
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$booking_id = $row['booking_id'];
$booking_id++;
$stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1");
$stmt->execute(array(':status' => 'Over'));
$stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times,
printed_last, status, group_of, booking_id, limit_uptime, limit_bytes, profile, uid)
values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of,
:booking_id, :limit_uptime, :limit_bytes, :profile, :uid)");
$k = 1;
for($i=0; $i < $no_of_users; $i++){
$passAlphabet = 'abcdefghikmnpqrstuvxyz23456789';
$passAlphabetLimit = strlen($passAlphabet)-1;
$pass = '';
$uid = '';
for ($j = 0; $j < $passLength; ++$j) {
$pass .= $passAlphabet[mt_rand(0, $passAlphabetLimit)];
}
for ($j = 0; $j < $passLength; ++$j) {
$uid .= $passAlphabet[mt_rand(0, $passAlphabetLimit)];
}
$user_name = $user_prefix.$uid;
if ($same_pass == 2) { $pass_word = $pass; } else { $pass_word = $user_name; }
$util->setMenu('/ip hotspot user');
$iv = count($util);
if (intval($limit_bytes) != 0) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$user_name",
'password' => "$pass_word",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
else
{
$util->add(
array(
'name' => "$user_name",
'password' => "$pass_word",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
)
);
$limit_bytes = 0; // For Adding it to Local database
}
if ($iv != count($util)) {
$uid = $booking_id.'-'.$k.'-'.$no_of_users.date('dmY');
//$creator = $_SESSION['username'].'['.$_SESSION['id'].']';
$stmt->execute(array(':created_by' => $_SESSION['username'], ':creator' => $_SESSION['id'], ':user_name' => $user_name, ':password' => $pass_word,
':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => $no_of_users,
':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes,
':profile' => $profile, ':uid' => $uid));
$k++;
}
}
echo $k - 1; //Successful
}
else
{
echo 0; // Not an Authorised User
}
<?php error_reporting(E_ALL);
ini_set('display_errors', 1);
//require_once 'settings.php';
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if (isset($_GET['no_of_users'])) $no_of_users = $_GET['no_of_users'];
if (isset($_GET['pass_length'])) $passLength = $_GET['pass_length'];
if (isset($_GET['user_prefix'])) $user_prefix = $_GET['user_prefix'];
if (isset($_GET['limit_uptime'])) $limit_uptime = $_GET['limit_uptime'];
if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes'];
if (isset($_GET['profile'])) $profile = $_GET['profile'];
if (isset($_GET['same_pass'])) $same_pass = $_GET['same_pass'];
if ( !isset($_SESSION) ) session_start();
if($_SESSION['user_level'] >= 1 and $_SESSION['user_level'] <= 3) {
include('dbconfig.php');
$stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1");
$stmt->execute(array());
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$booking_id = $row['booking_id'];
$booking_id++;
$stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1");
$stmt->execute(array(':status' => 'Over'));
$stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times,
printed_last, status, group_of, booking_id, limit_uptime, limit_bytes, profile, uid)
values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of,
:booking_id, :limit_uptime, :limit_bytes, :profile, :uid)");
$k = 1;
for($i=0; $i < $no_of_users; $i++){
$passAlphabet = 'abcdefghikmnpqrstuvxyz23456789';
$passAlphabetLimit = strlen($passAlphabet)-1;
$pass = '';
$uid = '';
for ($j = 0; $j < $passLength; ++$j) {
$pass .= $passAlphabet[mt_rand(0, $passAlphabetLimit)];
}
for ($j = 0; $j < $passLength; ++$j) {
$uid .= $passAlphabet[mt_rand(0, $passAlphabetLimit)];
}
$user_name = $user_prefix.$uid;
if ($same_pass == 2) { $pass_word = $pass; } else { $pass_word = $user_name; }
$util->setMenu('/ip hotspot user');
$iv = count($util);
if (intval($limit_bytes) != 0) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$user_name",
'password' => "$pass_word",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
else
{
$util->add(
array(
'name' => "$user_name",
'password' => "$pass_word",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
)
);
$limit_bytes = 0; // For Adding it to Local database
}
if ($iv != count($util)) {
$uid = $booking_id.'-'.$k.'-'.$no_of_users.date('dmY');
//$creator = $_SESSION['username'].'['.$_SESSION['id'].']';
$stmt->execute(array(':created_by' => $_SESSION['username'], ':creator' => $_SESSION['id'], ':user_name' => $user_name, ':password' => $pass_word,
':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => $no_of_users,
':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes,
':profile' => $profile, ':uid' => $uid));
$k++;
}
}
echo $k - 1; //Successful
}
else
{
echo 0; // Not an Authorised User
}
?>

View file

@ -1,16 +1,16 @@
<?php
if ( !isset($_SESSION) ) session_start();
include('dbconfig.php');
$np = $_GET['np'];
If ($_SESSION['user_level'] <= 3) {
$np = sha1($np);
$stmt = $DB_con->prepare("update hotspot_users set password = :np where user_id = :session_id");
$stmt->execute(array(':np' => $np, ':session_id' => $_SESSION['id']));
echo 1;
}
else
{
echo 0;
}
<?php
if ( !isset($_SESSION) ) session_start();
include('dbconfig.php');
$np = $_GET['np'];
If ($_SESSION['user_level'] <= 3) {
$np = sha1($np);
$stmt = $DB_con->prepare("update hotspot_users set password = :np where user_id = :session_id");
$stmt->execute(array(':np' => $np, ':session_id' => $_SESSION['id']));
echo 1;
}
else
{
echo 0;
}
?>

View file

@ -1,40 +1,40 @@
<?php
header('Content-Type: application/json');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
if ( !isset($_SESSION) ) session_start();
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
$profile_name=strtolower($_GET['profile_name']);
if ($_SESSION['user_level'] == 1) {
if (!empty($profile_name)) {
$printRequest = new RouterOS\Request('/ip hotspot user profile print');
$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $profile_name));
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
$idList .= ',' . $item->getProperty('.id');
}
$idList = substr($idList, 1);
//$idList now contains a comma separated list of all IDs.
$removeRequest = new RouterOS\Request('/ip hotspot user profile remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
echo 2; //Success
}
else
{
echo 1; //Profile name Empty
}
}
else
{
echo 0; //Not Authorised
}
<?php
header('Content-Type: application/json');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
if ( !isset($_SESSION) ) session_start();
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
$profile_name=strtolower($_GET['profile_name']);
if ($_SESSION['user_level'] == 1) {
if (!empty($profile_name)) {
$printRequest = new RouterOS\Request('/ip hotspot user profile print');
$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $profile_name));
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
$idList .= ',' . $item->getProperty('.id');
}
$idList = substr($idList, 1);
//$idList now contains a comma separated list of all IDs.
$removeRequest = new RouterOS\Request('/ip hotspot user profile remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
echo 2; //Success
}
else
{
echo 1; //Profile name Empty
}
}
else
{
echo 0; //Not Authorised
}
?>

View file

@ -1,16 +1,16 @@
<?php
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['user_id']))) {
include('dbconfig.php');
$id=$_GET['user_id'];
$myself = $_SESSION['id'];
$stmt = $DB_con->prepare("delete from hotspot_users where user_id=:id and user_id != :myself");
$stmt->execute(array(':id' => $id, ':myself' => $myself));
echo 1;
}
else
{
echo 0;
}
// End Adding a new System User Details, Returned from modal_add_user.php
<?php
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['user_id']))) {
include('dbconfig.php');
$id=$_GET['user_id'];
$myself = $_SESSION['id'];
$stmt = $DB_con->prepare("delete from hotspot_users where user_id=:id and user_id != :myself");
$stmt->execute(array(':id' => $id, ':myself' => $myself));
echo 1;
}
else
{
echo 0;
}
// End Adding a new System User Details, Returned from modal_add_user.php
?>

View file

@ -1,65 +1,65 @@
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
//$client = new RouterOS\Client("$host", "$user", "$pass");
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
$profile_name=strtolower($_GET['profile_name']);
$rx_rate_limit=$_GET['rx_rate_limit'];
$tx_rate_limit=$_GET['tx_rate_limit'];
$session_timeout=$_GET['session_timeout'];
$shared_users=$_GET['shared_users'];
$mac_cookie_timeout=$_GET['mac_cookie_timeout'];
$keepalive_timeout=$_GET['keepalive_timeout'];
if (empty($rx_rate_limit)) $rx_rate_limit = "256k";
if (empty($tx_rate_limit)) $tx_rate_limit = "128k";
$rate_limit = $rx_rate_limit.'/'.$tx_rate_limit;
if (empty($session_timeout)) $session_timeout = "1d 00:00:00";
if (empty($shared_users)) $shared_users = 1;
if (empty($mac_cookie_timeout)) $mac_cookie_timeout = "1d 00:00:00";
if (empty($keepalive_timeout)) $keepalive_timeout = "00:02:00";
if ($_SESSION['user_level'] == 1) {
if (!empty($profile_name)) {
$printRequest = new RouterOS\Request('/ip/hotspot/user/profile/print');
$printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $profile_name));
$id = $client->sendSync($printRequest)->getProperty('.id');
$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);
}
else
{
$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);
$client->sendSync($setRequest);
/*
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');
$util->setMenu('/ip hotspot user profile');
$util->unsetValue($id, 'session-timeout');
} */
echo 2; //Success
}
else
{
echo 1; //Profile name Improper
}
}
else
{
echo 0; //Not Authorised
}
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
//$client = new RouterOS\Client("$host", "$user", "$pass");
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
$profile_name=strtolower($_GET['profile_name']);
$rx_rate_limit=$_GET['rx_rate_limit'];
$tx_rate_limit=$_GET['tx_rate_limit'];
$session_timeout=$_GET['session_timeout'];
$shared_users=$_GET['shared_users'];
$mac_cookie_timeout=$_GET['mac_cookie_timeout'];
$keepalive_timeout=$_GET['keepalive_timeout'];
if (empty($rx_rate_limit)) $rx_rate_limit = "256k";
if (empty($tx_rate_limit)) $tx_rate_limit = "128k";
$rate_limit = $rx_rate_limit.'/'.$tx_rate_limit;
if (empty($session_timeout)) $session_timeout = "1d 00:00:00";
if (empty($shared_users)) $shared_users = 1;
if (empty($mac_cookie_timeout)) $mac_cookie_timeout = "1d 00:00:00";
if (empty($keepalive_timeout)) $keepalive_timeout = "00:02:00";
if ($_SESSION['user_level'] == 1) {
if (!empty($profile_name)) {
$printRequest = new RouterOS\Request('/ip/hotspot/user/profile/print');
$printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $profile_name));
$id = $client->sendSync($printRequest)->getProperty('.id');
$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);
}
else
{
$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);
$client->sendSync($setRequest);
/*
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');
$util->setMenu('/ip hotspot user profile');
$util->unsetValue($id, 'session-timeout');
} */
echo 2; //Success
}
else
{
echo 1; //Profile name Improper
}
}
else
{
echo 0; //Not Authorised
}
?>

View file

@ -1,35 +1,35 @@
<?php
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['user_id']))) {
include('dbconfig.php');
$user_id=$_GET['user_id'];
$username=strtolower($_GET['username']);
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE username = :username AND user_id != :user_id");
$stmt->execute(array(':username' => $username, ':user_id' => $user_id));
$count = $stmt->rowCount();
if ($count != 0) {
echo 1;
}
else
{
$firstname=$_GET['firstname'];
$lastname=$_GET['lastname'];
$user_level=$_GET['user_level'];
$status=$_GET['status'];
$stmt = $DB_con->prepare("update hotspot_users set username=:username, firstname = :firstname , lastname = :lastname,
user_level = :user_level, status = :status where user_id= :user_id");
$stmt->execute(array(':username' => $username, ':firstname' => $firstname, ':lastname' => $lastname,
':user_level' => $user_level, ':user_id' => $user_id, ':status' => $status));
echo 2;
}
}
else
{
echo 0;
}
// End Adding a new System User Details, Returned from modal_add_user.php
<?php
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['user_id']))) {
include('dbconfig.php');
$user_id=$_GET['user_id'];
$username=strtolower($_GET['username']);
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE username = :username AND user_id != :user_id");
$stmt->execute(array(':username' => $username, ':user_id' => $user_id));
$count = $stmt->rowCount();
if ($count != 0) {
echo 1;
}
else
{
$firstname=$_GET['firstname'];
$lastname=$_GET['lastname'];
$user_level=$_GET['user_level'];
$status=$_GET['status'];
$stmt = $DB_con->prepare("update hotspot_users set username=:username, firstname = :firstname , lastname = :lastname,
user_level = :user_level, status = :status where user_id= :user_id");
$stmt->execute(array(':username' => $username, ':firstname' => $firstname, ':lastname' => $lastname,
':user_level' => $user_level, ':user_id' => $user_id, ':status' => $status));
echo 2;
}
}
else
{
echo 0;
}
// End Adding a new System User Details, Returned from modal_add_user.php
?>

View file

@ -1,31 +1,31 @@
<?php
//Start Removing All Validity Expired Guest User Accounts
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] <= 3) {
$printRequest = new RouterOS\Request('/ip hotspot user print');
$printRequest->setArgument('.proplist', '.id,limit-uptime,uptime,name');
//$printRequest->setQuery(RouterOS\Query::where('name', 'admin', RouterOS\Query::OP_EQ) ->not());
$printRequest->setQuery(RouterOS\Query::where('.id', '*0', RouterOS\Query::OP_EQ) ->not());
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
if (!empty($item->getProperty('limit-uptime'))) {
if (!($item->getProperty('uptime') < $item->getProperty('limit-uptime'))) {
$idList .= ',' . $item->getProperty('.id');
}
}
}
$idList = substr($idList, 1);
//$idList now contains a comma separated list of all IDs.
$removeRequest = new RouterOS\Request('/ip hotspot user remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
}
//End Removing All Validity Expired Guest User Accounts
?>
<?php
//Start Removing All Validity Expired Guest User Accounts
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] <= 3) {
$printRequest = new RouterOS\Request('/ip hotspot user print');
$printRequest->setArgument('.proplist', '.id,limit-uptime,uptime,name');
//$printRequest->setQuery(RouterOS\Query::where('name', 'admin', RouterOS\Query::OP_EQ) ->not());
$printRequest->setQuery(RouterOS\Query::where('.id', '*0', RouterOS\Query::OP_EQ) ->not());
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
if (!empty($item->getProperty('limit-uptime'))) {
if (!($item->getProperty('uptime') < $item->getProperty('limit-uptime'))) {
$idList .= ',' . $item->getProperty('.id');
}
}
}
$idList = substr($idList, 1);
//$idList now contains a comma separated list of all IDs.
$removeRequest = new RouterOS\Request('/ip hotspot user remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
}
//End Removing All Validity Expired Guest User Accounts
?>

View file

@ -1,35 +1,35 @@
<?php
header('Content-Type: application/json');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] == 1) {
$util->setMenu('/ip hotspot user profile print');
$profile_name=$_GET['profile_name'];
$printRequest = new RouterOS\Request('/ip hotspot user profile print');
$printRequest->setArgument('.proplist', '.id,name,address-pool,rate-limit,session-timeout,shared-users,mac-cookie-timeout,keepalive-timeout');
$printRequest->setQuery(RouterOS\Query::where('name', $profile_name));
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
$tname = $item->getProperty("name");
$taddress_pool = $item->getProperty("address-pool");
$tshared_users = $item->getProperty("shared-users");
$trate_limit = $item->getProperty("rate-limit");
$tsession_timeout = $item->getProperty("session-timeout");
$tshared_users = $item->getProperty("shared-users");
$tmac_cookie_timeout = $item->getProperty("mac-cookie-timeout");
$tkeepalive_timeout = $item->getProperty("keepalive-timeout");
$arr = array('name' => $tname, 'address_pool' => $taddress_pool, 'rate_limit' => $trate_limit, 'session_timeout' => $tsession_timeout,
'shared_users' => $tshared_users, 'mac_cookie_timeout' => $tmac_cookie_timeout,
'keepalive_timeout' => $tkeepalive_timeout );
echo json_encode($arr);
}
}
<?php
header('Content-Type: application/json');
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] == 1) {
$util->setMenu('/ip hotspot user profile print');
$profile_name=$_GET['profile_name'];
$printRequest = new RouterOS\Request('/ip hotspot user profile print');
$printRequest->setArgument('.proplist', '.id,name,address-pool,rate-limit,session-timeout,shared-users,mac-cookie-timeout,keepalive-timeout');
$printRequest->setQuery(RouterOS\Query::where('name', $profile_name));
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
$tname = $item->getProperty("name");
$taddress_pool = $item->getProperty("address-pool");
$tshared_users = $item->getProperty("shared-users");
$trate_limit = $item->getProperty("rate-limit");
$tsession_timeout = $item->getProperty("session-timeout");
$tshared_users = $item->getProperty("shared-users");
$tmac_cookie_timeout = $item->getProperty("mac-cookie-timeout");
$tkeepalive_timeout = $item->getProperty("keepalive-timeout");
$arr = array('name' => $tname, 'address_pool' => $taddress_pool, 'rate_limit' => $trate_limit, 'session_timeout' => $tsession_timeout,
'shared_users' => $tshared_users, 'mac_cookie_timeout' => $tmac_cookie_timeout,
'keepalive_timeout' => $tkeepalive_timeout );
echo json_encode($arr);
}
}
?>

View file

@ -1,15 +1,15 @@
<?php
header('Content-Type: application/json');
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['user_id']))) {
include('dbconfig.php');
$user_id=$_GET['user_id'];
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE user_id =:user_id");
$stmt->execute(array(':user_id' => $user_id));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
echo json_encode($row);
}
// End Getting Sysuser details
<?php
header('Content-Type: application/json');
if ( !isset($_SESSION) ) session_start();
if (($_SESSION['user_level'] == 1) and (!empty($_GET['user_id']))) {
include('dbconfig.php');
$user_id=$_GET['user_id'];
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE user_id =:user_id");
$stmt->execute(array(':user_id' => $user_id));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
echo json_encode($row);
}
// End Getting Sysuser details
?>

View file

@ -1,38 +1,38 @@
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
$i = 0;
if ($_SESSION['user_level'] <= 3) {
$guest_list=$_GET['removal_list'];
if (count($guest_list) != 0) {
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id,name');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
foreach ($guest_list as $guest) {
$i++;
//$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $guest));
$id = $client->sendSync($printRequest)->getProperty('.id');
//$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
echo $i;
}
else
{
echo -1;
}
}
else
{
echo 0;
}
//$id = $client->sendSync(new Request('/ip/hotspot/user/profile/print .proplist=.id', null, Query::where('name', $profile_name)))->getArgument('.id');
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
$i = 0;
if ($_SESSION['user_level'] <= 3) {
$guest_list=$_GET['removal_list'];
if (count($guest_list) != 0) {
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id,name');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
foreach ($guest_list as $guest) {
$i++;
//$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $guest));
$id = $client->sendSync($printRequest)->getProperty('.id');
//$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
echo $i;
}
else
{
echo -1;
}
}
else
{
echo 0;
}
//$id = $client->sendSync(new Request('/ip/hotspot/user/profile/print .proplist=.id', null, Query::where('name', $profile_name)))->getArgument('.id');
?>

View file

@ -1,18 +1,18 @@
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
$guest_name=trim($_GET['username']);
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $guest_name));
$id = $client->sendSync($printRequest)->getProperty('.id');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
$guest_name=trim($_GET['username']);
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $guest_name));
$id = $client->sendSync($printRequest)->getProperty('.id');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
?>

View file

@ -1,26 +1,26 @@
<?php
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] == 1) {
include('dbconfig.php');
$user_id= $_GET['user_id'];
$password='password';
$password=sha1($password);
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE user_id = :user_id");
$stmt->execute(array(':user_id' => $user_id));
$count = $stmt->rowCount();
if ($count == 0){
echo 1;
}
else
{
$stmt = $DB_con->prepare("update hotspot_users set password=:password where user_id= :user_id");
$stmt->execute(array(':password' => $password, ':user_id' => $user_id));
echo 2;
}
}
else
{
echo 0;
}
//End Resetting a System User Password, called from modal_reset_psd.php Modal
<?php
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] == 1) {
include('dbconfig.php');
$user_id= $_GET['user_id'];
$password='password';
$password=sha1($password);
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE user_id = :user_id");
$stmt->execute(array(':user_id' => $user_id));
$count = $stmt->rowCount();
if ($count == 0){
echo 1;
}
else
{
$stmt = $DB_con->prepare("update hotspot_users set password=:password where user_id= :user_id");
$stmt->execute(array(':password' => $password, ':user_id' => $user_id));
echo 2;
}
}
else
{
echo 0;
}
//End Resetting a System User Password, called from modal_reset_psd.php Modal
?>

View file

@ -1,28 +1,28 @@
<?php
//Start Removing All Un-initiated Guest User Accounts
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] <= 2) {
$printRequest = new RouterOS\Request('/ip hotspot user print');
$printRequest->setArgument('.proplist', '.id,limit-uptime,uptime,name');
//$printRequest->setQuery(RouterOS\Query::where('name', 'default-trial', RouterOS\Query::OP_EQ) ->not());
$printRequest->setQuery(RouterOS\Query::where('.id', '*0', RouterOS\Query::OP_EQ) ->not());
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
if ($item->getProperty('uptime') == 0) {
$idList .= ',' . $item->getProperty('.id');
}
}
$idList = substr($idList, 1);
//$idList now contains a comma separated list of all IDs.
$removeRequest = new RouterOS\Request('/ip hotspot user remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
}
//End Removing All Un-initiated Guest User Accounts
?>
<?php
//Start Removing All Un-initiated Guest User Accounts
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if ( !isset($_SESSION) ) session_start();
if ($_SESSION['user_level'] <= 2) {
$printRequest = new RouterOS\Request('/ip hotspot user print');
$printRequest->setArgument('.proplist', '.id,limit-uptime,uptime,name');
//$printRequest->setQuery(RouterOS\Query::where('name', 'default-trial', RouterOS\Query::OP_EQ) ->not());
$printRequest->setQuery(RouterOS\Query::where('.id', '*0', RouterOS\Query::OP_EQ) ->not());
$idList = '';
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
if ($item->getProperty('uptime') == 0) {
$idList .= ',' . $item->getProperty('.id');
}
}
$idList = substr($idList, 1);
//$idList now contains a comma separated list of all IDs.
$removeRequest = new RouterOS\Request('/ip hotspot user remove');
$removeRequest->setArgument('numbers', $idList);
$client->sendSync($removeRequest);
}
//End Removing All Un-initiated Guest User Accounts
?>

View file

@ -1,66 +1,66 @@
<?php include('session.php'); ?>
<?php header( 'Content-Type: text/plain' ); ?>
<?php include('header.php'); ?>
<?php include('navbar.php'); ?>
<?php
$progress_val = 100; ?>
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar"
aria-valuenow="<?php echo $progress_val; ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo $progress_val; ?>%">
<?php echo $progress_val.'%'; ?>
</div>
</div>
<?php
$folder = $_SESSION['backup_folder'];
if (!is_dir($folder)) { mkdir($folder, 0777, true); }
chmod($folder, 0777);
$date = date('d-m-Y-H-i-s', time());
$filename = $folder."db-backup-".$date;
include('dbconfig.php');
define( 'DUMPFILE', $filename . '.sql' );
try {
//$DB_con = new PDO( 'mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASS );
$f = fopen( DUMPFILE, 'wt' );
$tables = $DB_con->query( 'SHOW TABLES' );
foreach ( $tables as $table ) {
//echo $table[0] . ' ... ';
flush();
$sql = '-- TABLE: ' . $table[0] . PHP_EOL;
$create = $DB_con->query( 'SHOW CREATE TABLE `' . $table[0] . '`' )->fetch();
$sql .= $create['Create Table'] . ';' . PHP_EOL;
fwrite( $f, $sql );
$rows = $DB_con->query( 'SELECT * FROM `' . $table[0] . '`' );
$rows->setFetchMode( PDO::FETCH_ASSOC );
foreach ( $rows as $row ) {
$row = array_map( array( $DB_con, 'quote' ), $row );
$sql = 'INSERT INTO `' . $table[0] . '` (`' . implode( '`, `', array_keys( $row ) ) . '`) VALUES (' . implode( ', ', $row ) . ');' . PHP_EOL;
fwrite( $f, $sql );
}
$sql = PHP_EOL;
$result = fwrite( $f, $sql );
if ( $result !== FALSE ) {
echo '';
} else {
// echo 'ERROR!!' . PHP_EOL;
}
flush();
}
fclose( $f );
} catch (Exception $e) {
echo 'Damn it! ' . $e->getMessage() . PHP_EOL;
}
?>
<a id="dlink" href=<?php echo '"'.$filename.'.sql"'?> download>
<script>
var btnDownload = function() {
document.getElementById("dlink").click();
window.location = "admin.php";
}
btns = [{text:"No",action:"admin.php",style:"cmodal-cancel"}, {text:"Yes",action:btnDownload,style:"cmodal-ok"}];
cmodalOkCancel("Backup Complete", "Backing-up of Database Tables to the Selected Path Completed Successfully. Do you want to download the backup ?", "information", btns);
<?php include('session.php'); ?>
<?php header( 'Content-Type: text/plain' ); ?>
<?php include('header.php'); ?>
<?php include('navbar.php'); ?>
<?php
$progress_val = 100; ?>
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar"
aria-valuenow="<?php echo $progress_val; ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo $progress_val; ?>%">
<?php echo $progress_val.'%'; ?>
</div>
</div>
<?php
$folder = $_SESSION['backup_folder'];
if (!is_dir($folder)) { mkdir($folder, 0777, true); }
chmod($folder, 0777);
$date = date('d-m-Y-H-i-s', time());
$filename = $folder."db-backup-".$date;
include('dbconfig.php');
define( 'DUMPFILE', $filename . '.sql' );
try {
//$DB_con = new PDO( 'mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASS );
$f = fopen( DUMPFILE, 'wt' );
$tables = $DB_con->query( 'SHOW TABLES' );
foreach ( $tables as $table ) {
//echo $table[0] . ' ... ';
flush();
$sql = '-- TABLE: ' . $table[0] . PHP_EOL;
$create = $DB_con->query( 'SHOW CREATE TABLE `' . $table[0] . '`' )->fetch();
$sql .= $create['Create Table'] . ';' . PHP_EOL;
fwrite( $f, $sql );
$rows = $DB_con->query( 'SELECT * FROM `' . $table[0] . '`' );
$rows->setFetchMode( PDO::FETCH_ASSOC );
foreach ( $rows as $row ) {
$row = array_map( array( $DB_con, 'quote' ), $row );
$sql = 'INSERT INTO `' . $table[0] . '` (`' . implode( '`, `', array_keys( $row ) ) . '`) VALUES (' . implode( ', ', $row ) . ');' . PHP_EOL;
fwrite( $f, $sql );
}
$sql = PHP_EOL;
$result = fwrite( $f, $sql );
if ( $result !== FALSE ) {
echo '';
} else {
// echo 'ERROR!!' . PHP_EOL;
}
flush();
}
fclose( $f );
} catch (Exception $e) {
echo 'Damn it! ' . $e->getMessage() . PHP_EOL;
}
?>
<a id="dlink" href=<?php echo '"'.$filename.'.sql"'?> download>
<script>
var btnDownload = function() {
document.getElementById("dlink").click();
window.location = "admin.php";
}
btns = [{text:"No",action:"admin.php",style:"cmodal-cancel"}, {text:"Yes",action:btnDownload,style:"cmodal-ok"}];
cmodalOkCancel("Backup Complete", "Backing-up of Database Tables to the Selected Path Completed Successfully. Do you want to download the backup ?", "information", btns);
</script>

View file

@ -1,5 +1,5 @@
<?php
$host = '192.168.0.200';
$user = 'admin';
$pass = 'admin';
$host = "168.1.0.200";
$user = "admin";
$pass = "admin";
?>

View file

@ -1,60 +1,60 @@
<?php
$stmt = $DB_con->prepare("SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'");
$stmt->execute(array());
$stmt = $DB_con->prepare("SET time_zone = '+05:30'");
$stmt->execute(array());
$stmt = $DB_con->prepare("CREATE TABLE IF NOT EXISTS `hotspot_users` (
`user_id` int(11) NOT NULL,
`email` varchar(200) NOT NULL,
`date_added` date NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`password` varchar(60) NOT NULL,
`created_at` datetime NOT NULL,
`username` varchar(30) NOT NULL,
`user_level` int(11) NOT NULL DEFAULT '3',
`user_group` int(1) NOT NULL,
`image_path` varchar(50) NOT NULL,
`thumb_path` varchar(50) NOT NULL,
`status` varchar(20) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_users`
ADD PRIMARY KEY (`user_id`),
ADD KEY `username` (`username`)");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1");
$stmt->execute(array());
$stmt = $DB_con->prepare("CREATE TABLE IF NOT EXISTS `hotspot_vouchers` (
`id` int(11) NOT NULL,
`created_on` datetime DEFAULT NULL,
`created_by` varchar(30) DEFAULT NULL,
`creator` int(3) DEFAULT NULL,
`user_name` varchar(30) DEFAULT NULL,
`password` varchar(30) DEFAULT NULL,
`printed_times` int(3) DEFAULT NULL,
`printed_last` varchar(30) DEFAULT NULL,
`status` varchar(10) DEFAULT NULL,
`group_of` int(4) DEFAULT NULL,
`booking_id` int(11) DEFAULT NULL,
`limit_uptime` varchar(30) DEFAULT NULL,
`limit_bytes` varchar(30) DEFAULT NULL,
`profile` varchar(30) DEFAULT NULL,
`uid` VARCHAR(30) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_vouchers`
ADD PRIMARY KEY (`id`)");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_vouchers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT");
$stmt->execute(array());
<?php
$stmt = $DB_con->prepare("SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO'");
$stmt->execute(array());
$stmt = $DB_con->prepare("SET time_zone = '+05:30'");
$stmt->execute(array());
$stmt = $DB_con->prepare("CREATE TABLE IF NOT EXISTS `hotspot_users` (
`user_id` int(11) NOT NULL,
`email` varchar(200) NOT NULL,
`date_added` date NOT NULL,
`firstname` varchar(30) NOT NULL,
`lastname` varchar(30) NOT NULL,
`password` varchar(60) NOT NULL,
`created_at` datetime NOT NULL,
`username` varchar(30) NOT NULL,
`user_level` int(11) NOT NULL DEFAULT '3',
`user_group` int(1) NOT NULL,
`image_path` varchar(50) NOT NULL,
`thumb_path` varchar(50) NOT NULL,
`status` varchar(20) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_users`
ADD PRIMARY KEY (`user_id`),
ADD KEY `username` (`username`)");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1");
$stmt->execute(array());
$stmt = $DB_con->prepare("CREATE TABLE IF NOT EXISTS `hotspot_vouchers` (
`id` int(11) NOT NULL,
`created_on` datetime DEFAULT NULL,
`created_by` varchar(30) DEFAULT NULL,
`creator` int(3) DEFAULT NULL,
`user_name` varchar(30) DEFAULT NULL,
`password` varchar(30) DEFAULT NULL,
`printed_times` int(3) DEFAULT NULL,
`printed_last` varchar(30) DEFAULT NULL,
`status` varchar(10) DEFAULT NULL,
`group_of` int(4) DEFAULT NULL,
`booking_id` int(11) DEFAULT NULL,
`limit_uptime` varchar(30) DEFAULT NULL,
`limit_bytes` varchar(30) DEFAULT NULL,
`profile` varchar(30) DEFAULT NULL,
`uid` VARCHAR(30) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_vouchers`
ADD PRIMARY KEY (`id`)");
$stmt->execute(array());
$stmt = $DB_con->prepare("ALTER TABLE `hotspot_vouchers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT");
$stmt->execute(array());
?>

File diff suppressed because one or more lines are too long

View file

@ -1,24 +1,24 @@
<?php
$DB_host = "localhost";
$DB_user = "root";
$DB_pass = "root123";
$DB_name = "mikrotik";
try
{
$DB_con = new PDO("mysql:host={$DB_host}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbname = "`".str_replace("`","``",$DB_name)."`";
$DB_con->query("CREATE DATABASE IF NOT EXISTS $dbname");
$DB_con->query("use $dbname");
}
catch(PDOException $e) {
echo "Error Creating/Locating Database $dbname: " . $e->getMessage();
}
/* Old Version, NOT creating DB if NOT Exist
$DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
*/
<?php
$DB_host = "localhost";
$DB_user = "root";
$DB_pass = "root123";
$DB_name = "mikrotik";
try
{
$DB_con = new PDO("mysql:host={$DB_host}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbname = "`".str_replace("`","``",$DB_name)."`";
$DB_con->query("CREATE DATABASE IF NOT EXISTS $dbname");
$DB_con->query("use $dbname");
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
/* Old Version, NOT creating DB if NOT Exist
$DB_con = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
*/
?>

1906
header.php

File diff suppressed because it is too large Load diff

870
home.php Normal file
View file

@ -0,0 +1,870 @@
<body>
<div class="container">
<div class="no_print">
<!-- Start Logo Section -->
<section id="logo-section" class="text-center">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="logo text-center">
<h1>Easy HotSpot</h1>
<span style="color:#333333;font-size:20px;font-weight:bold">WiFi Hotspot User Management Utility</span>
<span style="color:#888888;font-size:20px;font-weight:bold">By Team Zetozone, Ph:+91 9020 150 150</span>
</div>
</div>
</div>
</div>
</section>
<!-- End Logo Section -->
<!-- Start Main Body Section -->
<div class="mainbody-section text-center">
<div class="container">
<div class="row">
<div class="col-md-2">
<div class="menu-item blue">
<a href="#single-user" data-toggle="modal">
<i class="fa fa-child"></i>
<p>Add Single User</p>
</a>
</div>
<div class="menu-item red">
<a href="#multi-user" data-toggle="modal">
<i class="fa fa-users"></i>
<p>Add Multiple Users</p>
</a>
</div>
</div>
<div class="col-md-2">
<div class="menu-item skyblue">
<a href="#active-users" data-toggle="modal">
<i class="fa fa-signal"></i>
<p>List Active Users</p>
</a>
</div>
<div class="menu-item purple">
<a href="#remove-selected" data-toggle="modal">
<i class="fa fa-ban"></i>
<p>Remove Selected Users</p>
</a>
</div>
</div>
<div class="col-md-2">
<div class="menu-item coral">
<a href="#server-log" data-toggle="modal">
<i class="fa fa-paw"></i>
<p>Server Log</p>
</a>
</div>
<div class="menu-item navy">
<a href="voucher.php">
<i class="fa fa-bars"></i>
<p>Voucher Printing</p>
</a>
</div>
</div>
<div class="col-md-2">
<div class="menu-item fuchsia">
<a href="#remove-uninitiated" data-toggle="modal">
<i class="fa fa-gears"></i>
<p>Remove Un-Initiated</p>
</a>
</div>
<div class="menu-item gold">
<a href="#profiler" data-toggle="modal">
<i class="fa fa-user"></i>
<p>HotSpot User Profiles</p>
</a>
</div>
</div>
<div class="col-md-2">
<div class="menu-item olive">
<a href="#remove-expired" data-toggle="modal">
<i class="fa fa-bug"></i>
<p>Remove All Expired</p>
</a>
</div>
<div class="menu-item purple">
<a href="#system-user" data-toggle="modal">
<i class="fa fa-user-md"></i>
<p>System Users</p>
</a>
</div>
</div>
<div class="col-md-2">
<div class="menu-item green">
<a href="#list-users" data-toggle="modal">
<i class="fa fa-ambulance"></i>
<p>List Inactive Users</p>
</a>
</div>
<div class="menu-item blue">
<a href="index.php" >
<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
<p>Refresh</p>
</a>
</div>
</div>
</div>
<input type="button" style="background-color: #f0ff0a;" onclick="log_out()" value="<?php echo 'Logout ('.$_SESSION['username'].')'; ?>"/>
</div>
</div>
</div>
<!-- End Main Body Section -->
<!-- 1. End Single Guest User Creation Experiment Section -->
<div class="child-modal modal fade" id="single-user" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="text-center">Single User Creation</h3></div>
<div class="panel-body">
<div class="form-horizontal">
<div class="form-group form-group-sm">
<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 >
</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>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" >Time Limit (Days)</label>
<div class="col-sm-6">
<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>
</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>
<div class="col-sm-6">
<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>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" >Bandwidth (Mbps) Profile</label>
<div class="col-sm-6">
<?php
$util->setMenu('/ip hotspot user profile');
echo '<select class="myCombo" id="sprofile" name="sprofile" required>';
foreach ($util->getAll() as $item) {
echo '<option>', $item->getProperty('name'), '</option>';
}
echo '</select>'; ?>
</div>
</div>
<div class="col-sm-4">
<div class="col-sm-3 col-sm-offset-3">
<div class="pull-right">
<button name="issuing" id="issuing" onClick="ajaxSingle()" class="btn btn-success"><i class="icon-save icon-large"></i></a>&nbsp;Issue</button>
</div>
</div>
<div class="col-sm-3">
<div class="pull-left">
<button data-dismiss="modal" class="btn btn-warning" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="single"></div>
</div>
</div>
</div>
<!-- 1. End Single Guest User Creation Experiment Section -->
<!-- 2. Start Multi Guest User Creation Section -->
<div class="child-modal modal fade" id="multi-user" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="text-center">Create Multiple Users</h3></div>
<div class="panel-body">
<div class="form-horizontal">
<div class="form-group form-group-sm">
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="no_of_users">Users</label>
<div class="col-sm-6">
<input type="number" min="2" max="150" id="no_of_users" name="no_of_users" value="2" autofocus >
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="user_prefix">Name Prefix</label>
<div class="col-sm-6">
<input type="text" id="user_prefix" name="user_prefix">
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="pass_length">Password length</label>
<div class="col-sm-6">
<input type="number" min="4" max="10" id="pass_length" name="pass_length" value="5">
</div>
</div>
</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>
<div class="col-sm-6">
<select class="myCombo" id="limit_uptime" name="limit_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>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="profile">Bandwidth (Mbps) Profile</label>
<div class="col-sm-6">
<?php
$util->setMenu('/ip hotspot user profile');
echo '<select class="myCombo" id="profile" name="profile">';
foreach ($util->getAll() as $item) {
echo '<option>', $item->getProperty('name'), '</option>';
}
echo '</select>'; ?>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label">Username & Password</label>
<div class="col-sm-6">
<select class="myCombo" id="same_pass" name="same_pass">
<option value="1">Same</option>
<option value="2">Different</option>
</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>
<div class="col-sm-6">
<select class="myCombo" id="limit_bytes" name="limit_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>
</div>
</div>
<div class="col-sm-2">
<div class="pull-right">
<button name="missuing" id="missuing" onClick="ajaxMultiple()" class="btn btn-success">&nbsp; Issue</button>
</div>
</div>
<div class="col-sm-2">
<div class="pull-left">
<button data-dismiss="modal" class="btn btn-warning"><i class="icon-save icon-large"></i>&nbsp; BACK </button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="multiple"></div>
</div>
</div>
</div>
<!-- 2. End Multi Guest User Creation Section -->
<!-- 3. Start List All Inactive Users Section -->
<div class="child-modal modal fade" id="list-users" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?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>
</div>
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Profile</th>
<th>Bytes In</th>
<th>Bytes Out</th>
<th>Total Permitted Usage</th>
<th>Time Used</th>
<th>Validity Limit</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
if ($item->getProperty('limit-bytes-total')) {
$limit_bytes_total = $item->getProperty('limit-bytes-total').' Bytes';
}
else { $limit_bytes_total = 'Unlimited'; }
if ($item->getProperty('limit-uptime')) {
$limit_uptime = $item->getProperty('limit-uptime');
}
else { $limit_uptime = 'Not Limited'; }
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('name'),'</td>';
echo '<td>', $item->getProperty('profile'), '</td>';
echo '<td>', $item->getProperty('bytes-in'), '</td>';
echo '<td>', $item->getProperty('bytes-out'), '</td>';
echo '<td>', $limit_bytes_total, '</td>';
echo '<td>', $item->getProperty('uptime'), '</td>';
echo '<td>', $limit_uptime, '</td>';
echo '</tr>';
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
<!-- 3. End List All Inactive Users Section -->
<!-- 4. Start List Active Users Section -->
<div class="child-modal modal fade" id="active-users" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?php $util->setMenu('/ip hotspot active'); ?>
<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 Active at the moment</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Server</th>
<th>Domain</th>
<th>User</th>
<th>IP Address</th>
<th>Uptime</th>
<th>Session Time left</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('server'),'</td>';
echo '<td>', $item->getProperty('domain'), '</td>';
echo '<td>', $item->getProperty('user'),'</td>';
echo '<td>', $item->getProperty('address'), '</td>';
echo '<td>', $item->getProperty('uptime'), '</td>';
echo '<td>', $item->getProperty('session-time-left'), '</td>';
echo '</tr>';
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
<!-- 4. End List Active Users Section -->
<!-- 5. Start Remove Selected users Section -->
<div class="child-modal modal fade" id="remove-selected" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<form id="checkboxForm" class="form-horizontal">
<div class="form-group">
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?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>
</div>
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Profile</th>
<th>Bytes In</th>
<th>Bytes Out</th>
<th>Total Permitted Usage</th>
<th>Time Used</th>
<th>Validity Limit</th>
<?php if($_SESSION['user_level'] <= 2) { //Administrator/Unit Head Only
echo '<th>Remove</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
if ($item->getProperty('limit-bytes-total')) {
$limit_bytes_total = $item->getProperty('limit-bytes-total').' Bytes';
}
else { $limit_bytes_total = 'Unlimited'; }
if ($item->getProperty('limit-uptime')) {
$limit_uptime = $item->getProperty('limit-uptime');
}
else { $limit_uptime = 'Not Limited'; }
echo '<tr>';
echo '<td>'.$i.'</td>';
$rid = $item->getProperty('name');
echo '<td>', $rid,'</td>';
echo '<td>', $item->getProperty('profile'), '</td>';
echo '<td>', $item->getProperty('bytes-in'), '</td>';
echo '<td>', $item->getProperty('bytes-out'), '</td>';
echo '<td>', $limit_bytes_total, '</td>';
echo '<td>', $item->getProperty('uptime'), '</td>';
echo '<td>', $limit_uptime, '</td>';
if($_SESSION['user_level'] <= 2) { //Administrator/Unit Head Only
echo '<td>';
echo '<label for="'.$rid.'"></label>
<input type="checkbox" name="removal_list[]" value="'.$rid.'" id="'.$rid.'" class="styled" />';
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
echo '</td>';
}
echo '</tr>';
} ?>
</tbody>
</table>
<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>
<div class="col-sm-2">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- 5. End Remove Selected users Section -->
<!-- 6. Start Remove All Expired Guest Users Section -->
<div class="child-modal modal fade" id="remove-expired" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<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">Validity expired users available in System</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Server</th>
<th>User</th>
<th>Profile</th>
<th>Limit Uptime</th>
<th>Uptime</th>
<th>Limit Bytes Total</th>
<th>Bytes In</th>
<th>Bytes Out</th>
</tr>
</thead>
<tbody>
<?php
try
{
$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());
$idList = '';
$i = 0;
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
if (!empty($item->getProperty('limit-uptime'))) {
if (!($item->getProperty('uptime') < $item->getProperty('limit-uptime'))) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('server'),'</td>';
echo '<td>', $item->getProperty('name'), '</td>';
echo '<td>', $item->getProperty('profile'), '</td>';
echo '<td>', $item->getProperty('limit-uptime'), '</td>';
echo '<td>', $item->getProperty('uptime'),'</td>';
echo '<td>', $item->getProperty('limit-bytes-total'), '</td>';
echo '<td>', $item->getProperty('bytes-in'), '</td>';
echo '<td>', $item->getProperty('bytes-out'), '</td>';
echo '</tr>';
}
}
}
}
catch (Exception $e) {
//echo '<script>cmodal("Access Denied!", "Error accessing validity expired users!", "error", "index.php")</script>';
}
?>
</tbody>
</table>
</div>
<div class="col-sm-3 col-sm-offset-5">
<button name="uissuing" id="uissuing" onClick="ajaxExpired();" class="btn btn-success"><i class="icon-save icon-large"></i></a>&nbsp;Remove All</button>&nbsp;&nbsp;&nbsp;
<button data-dismiss="modal" class="btn btn-info" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
<!-- 6. Start Remove All Expired Guest Users Section -->
<!-- 7. Start Server Log Section -->
<div class="child-modal modal fade" id="server-log" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<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">Server Event Log - Last 1000 activities</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Time</th>
<th>Topic</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->setMenu('/log')->getAll() as $entry) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $entry('time'),'</td>';
echo '<td>', $entry('topics'), '</td>';
echo '<td>', $entry('message'), '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
<!--</div>-->
</div>
</div>
</div>
<!-- 7. End Server Log Section -->
<!-- 9. Start System User Management Section -->
<div class="child-modal modal fade" id="system-user" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl"></div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<a href="#change-password" data-toggle="modal" class="btn btn-primary btn-lg center-element"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span>Change My Password</a>&nbsp;&nbsp;
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<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">System Users managing Hotspot Activities</h3></strong>
</div>
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Level</th>
<?php if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<th>Actions</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE 1");
$stmt->execute(array());
while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
$id=$row['user_id'];
if ($row['status'] == 'Active') { echo '<tr class="alert-info">'; } else { echo '<tr class="alert-danger">'; }
?>
<td><?php echo $row['username']; ?></td>
<td><?php echo '..............'; ?></td>
<td><?php echo $row['firstname']; ?></td>
<td><?php echo $row['lastname']; ?></td>
<?php
switch ($row['user_level']) {
case 1 :
echo '<td>Administrator</td>';
break;
case 2 :
echo '<td>Unit Head</td>';
break;
case 3 :
echo '<td>System User</td>';
break;
}
if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<td>';
echo '<a title="Get Details of User & More Actions" id="'.$id.'" data-id="'.$id.'" name="'.$id.'" href="#getUserModal" data-toggle="modal" class="btn btn-primary btn-lg"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a>&nbsp;&nbsp;';
echo '</td>';
} ?>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 9. End System User Management Section -->
<!-- 10. Start Remove All Un-Initiated Guest Users Section -->
<div class="child-modal modal fade" id="remove-uninitiated" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?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>
</div>
<thead>
<tr>
<th>#</th>
<th>Server</th>
<th>User</th>
<th>Profile</th>
<th>Uptime Limit</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
if ($item->getProperty('uptime') == 0) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('server'),'</td>';
echo '<td>', $item->getProperty('name'),'</td>';
echo '<td>', $item->getProperty('profile'),'</td>';
echo '<td>', $item->getProperty('limit-uptime'), '</td>';
echo '</tr>';
}
} ?>
</tbody>
</table>
</div>
<div class="col-sm-3 col-sm-offset-5">
<?php if($_SESSION['user_level'] <= 2) {
echo '<button name="uissuing" id="uissuing" onClick="ajaxUninitiated();" class="btn btn-success"><i class="icon-save icon-large"></i></a>&nbsp;Remove All</button>&nbsp;&nbsp;&nbsp;';
} ?>
<button data-dismiss="modal" class="btn btn-info" ><i class="icon-save icon-large"></i></a>&nbsp;CANCEL</button>
</div>
</div>
</div>
</div>
<!-- 10. Start Remove All Un-Initiated Guest Users Section -->
<!-- 11. Start HotSpot User Profiles Management Section -->
<div class="child-modal modal fade" id="profiler" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl"></div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?php $util->setMenu('/ip hotspot user profile'); ?>
<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">HotSpot User Profiles Available</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Session Timeout</th>
<th>Keepalive Timeout</th>
<th>Shared Users</th>
<th>Rate Limit(Rx/Tx)</th>
<th>MAC Cookie Timeout</th>
<?php if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<th>Actions</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('name'),'</td>';
echo '<td>', $item->getProperty('session-timeout'), '</td>';
echo '<td>', $item->getProperty('keepalive-timeout'), '</td>';
echo '<td>', $item->getProperty('shared-users'), '</td>';
echo '<td>', $item->getProperty('rate-limit'), '</td>';
echo '<td>', $item->getProperty('mac-cookie-timeout'), '</td>';
if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<td>';
echo '<a title="Get Details of the Profile & More Actions" id="'.$id.'" data-id="'.$item->getProperty('name').'" name="'.$id.'" href="#getProfileModal" data-toggle="modal" class="btn btn-primary btn-lg"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a>';
echo '</td>';
} ?>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 11. End HotSpot User Profiles Management Section -->
</div>
</body>
<?php
include('modal_change_pass.php');
include('modal_get_user.php');
include('modal_get_profiles.php');
?>

View file

@ -1,133 +1,133 @@
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'checkout'; }
if (isset($_GET['username'])) $username = $_GET['username'];
/*Sample Call
FORMAT: localhost/hotsoft.php?action=checkin&username=101&password=spice&limit_uptime=10d&limit_bytes=10&profile=default
action & username are REQUIRED, all other fields are optional
action can be 'checkin' or 'checkout'. if action is 'checkout', only user name need to be specified
username can be room number or any username
password - if password is not given, the given username will be the password
limit_uptime - if given in the format '10d' for 10 days, '1d 10:30:00' for 1 day 10 hours and 30 minutes
limit_bytes - if given the total upload/download bytes in GB, eg '10' means 10Gb
profile - if given any user profile name available in the Wifi hotspot
sample call:
192.168.100.10/hotsoft.php?action=checkin&username=101&password=spice - While checking in a room
192.168.100.10/hotsoft.php?action=checkout&username=101 - While checking out a room
Return Values
0 - Success (Successfully created user account or Successfully removed User account)
1 - Wrong action verb
2 - Invalid or blank username
3 - Call with an already existing/Duplicate username
4 -
*/
if (strtolower($action) == 'checkin')) {
if (!empty($username)) {
if (isset($_GET['password'])) { $password = $_GET['password']; } else { $password = $username; }
if (isset($_GET['limit_uptime'])) $limit_uptime = $_GET['limit_uptime'];
if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes'];
if (isset($_GET['profile'])) { $profile = $_GET['profile']; } else { $profile = 'default'; }
$util->setMenu('/ip hotspot user');
$iv = count($util);
if ((intval($limit_bytes) != 0) and (!empty($limit_uptime))) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
elseif (intval($limit_bytes) != 0) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
else
{
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
)
);
$limit_bytes = 0; // For Adding it to Local database
}
if ($iv != count($util)) {
include('dbconfig.php');
$stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1");
$stmt->execute(array());
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$booking_id = $row['booking_id'];
$booking_id++;
$uid = $booking_id.'-1-'.date('dmY');
$creator = 999;
$created_by = 'Hotsoft';
$stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1");
$stmt->execute(array(':status' => 'Over'));
$stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times,
printed_last, status, group_of, booking_id, limit_uptime, limit_bytes, profile, uid)
values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of,
:booking_id, :limit_uptime, :limit_bytes, :profile, :uid)");
$stmt->execute(array(':created_by' => $created_by, ':creator' => $creator, ':user_name' => $username, ':password' => $password,
':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => 1,
':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes,
':profile' => $profile, ':uid' => $uid));
echo 0; //Success
}
else
{
echo 3; // Duplicate/Existing username
}
}
else
{
echo 2; //Blank Username
}
//End Adding a Guest User
}
elseif (strtolower($action) == 'checkout')) {
//Removal
$username=trim($_GET['username']);
if (!empty($username)) {
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $username));
$id = $client->sendSync($printRequest)->getProperty('.id');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
echo 0; //Success
}
else
{
echo 2; //Blank Username
}
}
else
{
echo 1; //Wrong Action Verb
}
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'checkout'; }
if (isset($_GET['username'])) $username = $_GET['username'];
/*Sample Call
FORMAT: localhost/hotsoft.php?action=checkin&username=101&password=spice&limit_uptime=10d&limit_bytes=10&profile=default
action & username are REQUIRED, all other fields are optional
action can be 'checkin' or 'checkout'. if action is 'checkout', only user name need to be specified
username can be room number or any username
password - if password is not given, the given username will be the password
limit_uptime - if given in the format '10d' for 10 days, '1d 10:30:00' for 1 day 10 hours and 30 minutes
limit_bytes - if given the total upload/download bytes in GB, eg '10' means 10Gb
profile - if given any user profile name available in the Wifi hotspot
sample call:
192.168.100.10/hotsoft.php?action=checkin&username=101&password=spice - While checking in a room
192.168.100.10/hotsoft.php?action=checkout&username=101 - While checking out a room
Return Values
0 - Success (Successfully created user account or Successfully removed User account)
1 - Wrong action verb
2 - Invalid or blank username
3 - Call with an already existing/Duplicate username
4 -
*/
if (strtolower($action) == 'checkin')) {
if (!empty($username)) {
if (isset($_GET['password'])) { $password = $_GET['password']; } else { $password = $username; }
if (isset($_GET['limit_uptime'])) $limit_uptime = $_GET['limit_uptime'];
if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes'];
if (isset($_GET['profile'])) { $profile = $_GET['profile']; } else { $profile = 'default'; }
$util->setMenu('/ip hotspot user');
$iv = count($util);
if ((intval($limit_bytes) != 0) and (!empty($limit_uptime))) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
elseif (intval($limit_bytes) != 0) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile"
)
);
}
else
{
$util->add(
array(
'name' => "$username",
'password' => "$password",
'limit-uptime' => "$limit_uptime",
'profile' => "$profile"
)
);
$limit_bytes = 0; // For Adding it to Local database
}
if ($iv != count($util)) {
include('dbconfig.php');
$stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1");
$stmt->execute(array());
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$booking_id = $row['booking_id'];
$booking_id++;
$uid = $booking_id.'-1-'.date('dmY');
$creator = 999;
$created_by = 'Hotsoft';
$stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1");
$stmt->execute(array(':status' => 'Over'));
$stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times,
printed_last, status, group_of, booking_id, limit_uptime, limit_bytes, profile, uid)
values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of,
:booking_id, :limit_uptime, :limit_bytes, :profile, :uid)");
$stmt->execute(array(':created_by' => $created_by, ':creator' => $creator, ':user_name' => $username, ':password' => $password,
':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => 1,
':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes,
':profile' => $profile, ':uid' => $uid));
echo 0; //Success
}
else
{
echo 3; // Duplicate/Existing username
}
}
else
{
echo 2; //Blank Username
}
//End Adding a Guest User
}
elseif (strtolower($action) == 'checkout')) {
//Removal
$username=trim($_GET['username']);
if (!empty($username)) {
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $username));
$id = $client->sendSync($printRequest)->getProperty('.id');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
echo 0; //Success
}
else
{
echo 2; //Blank Username
}
}
else
{
echo 1; //Wrong Action Verb
}
?>

910
index.php
View file

@ -1,881 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<?php
//Start session
if ( !isset($_SESSION) ) session_start();
//Check whether the session variables present or not, and assign them to Ordinary variables, if present.
if (!isset($_SESSION['user_level']) || (trim($_SESSION['user_level']) == '' || (trim($_SESSION['user_level']) >= 4))) {
header("location:login.php");
}
?>
<?php include('header.php'); ?>
<?php include('dbconfig.php'); ?>
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
?>
<body>
<div class="container">
<div class="no_print">
<!-- Start Logo Section -->
<section id="logo-section" class="text-center">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="logo text-center">
<h1>Easy HotSpot</h1>
<span style="color:#333333;font-size:20px;font-weight:bold">Simple Hotspot User Management Utility</span>
<span style="color:#888888;font-size:20px;font-weight:bold">By Team Zetozone, Ph:+91 9020 150 150</span>
</div>
</div>
</div>
</div>
</section>
<!-- End Logo Section -->
<!-- Start Main Body Section -->
<div class="mainbody-section text-center">
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="menu-item blue">
<a href="#single-user" data-toggle="modal">
<i class="fa fa-child"></i>
<p>Add Single User</p>
</a>
</div>
<div class="menu-item red">
<a href="#multi-user" data-toggle="modal">
<i class="fa fa-users"></i>
<p>Add Multiple Users</p>
</a>
</div>
<div class="menu-item green">
<a href="#list-users" data-toggle="modal">
<i class="fa fa-ambulance"></i>
<p>List Inactive Users</p>
</a>
</div>
</div>
<div class="col-md-3">
<div class="menu-item skyblue">
<a href="#active-users" data-toggle="modal">
<i class="fa fa-signal"></i>
<p>List Active Users</p>
</a>
</div>
<div class="menu-item purple">
<a href="#remove-selected" data-toggle="modal">
<i class="fa fa-ban"></i>
<p>Remove Selected Users</p>
</a>
</div>
<div class="menu-item olive">
<a href="#remove-expired" data-toggle="modal">
<i class="fa fa-bug"></i>
<p>Remove All Expired Users</p>
</a>
</div>
</div>
<div class="col-md-3">
<div class="menu-item coral">
<a href="#server-log" data-toggle="modal">
<i class="fa fa-paw"></i>
<p>Server Log</p>
</a>
</div>
<div class="menu-item navy">
<a href="voucher.php">
<i class="fa fa-bars"></i>
<p>Voucher Printing</p>
</a>
</div>
<div class="menu-item purple">
<a href="#system-user" data-toggle="modal">
<i class="fa fa-user-md"></i>
<p>System Users</p>
</a>
</div>
</div>
<div class="col-md-3">
<div class="menu-item fuchsia">
<a href="#remove-uninitiated" data-toggle="modal">
<i class="fa fa-gears"></i>
<p>Remove Un-Initiated Guests</p>
</a>
</div>
<div class="menu-item gold">
<a href="#profiler" data-toggle="modal">
<i class="fa fa-user"></i>
<p>HotSpot User Profiles</p>
</a>
</div>
<div class="menu-item blue">
<a href="index.php" >
<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
<p>Refresh</p>
</a>
</div>
</div>
</div>
<input type="button" style="background-color: #f0ff0a;" onclick="log_out()" value="<?php echo $_SESSION['username']; ?>"/>
</div>
</div>
</div>
<!-- End Main Body Section -->
<!-- 1. End Single Guest User Creation Experiment Section -->
<div class="child-modal modal fade" id="single-user" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="text-center">Single User Creation</h3></div>
<div class="panel-body">
<div class="form-horizontal">
<div class="form-group form-group-sm">
<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 >
</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>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" >Time Limit (Days)</label>
<div class="col-sm-6">
<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>
</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>
<div class="col-sm-6">
<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>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" >Bandwidth (Mbps) Profile</label>
<div class="col-sm-6">
<?php
$util->setMenu('/ip hotspot user profile');
echo '<select class="myCombo" id="sprofile" name="sprofile" required>';
foreach ($util->getAll() as $item) {
echo '<option>', $item->getProperty('name'), '</option>';
}
echo '</select>'; ?>
</div>
</div>
<div class="col-sm-4">
<div class="col-sm-3 col-sm-offset-3">
<div class="pull-right">
<button name="issuing" id="issuing" onClick="ajaxSingle()" class="btn btn-success"><i class="icon-save icon-large"></i></a>&nbsp;Issue</button>
</div>
</div>
<div class="col-sm-3">
<div class="pull-left">
<button data-dismiss="modal" class="btn btn-warning" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="single"></div>
</div>
</div>
</div>
<!-- 1. End Single Guest User Creation Experiment Section -->
<!-- 2. Start Multi Guest User Creation Section -->
<div class="child-modal modal fade" id="multi-user" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="text-center">Create Multiple Users</h3></div>
<div class="panel-body">
<div class="form-horizontal">
<div class="form-group form-group-sm">
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="no_of_users">Users</label>
<div class="col-sm-6">
<input type="number" min="2" max="150" id="no_of_users" name="no_of_users" value="2" autofocus >
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="user_prefix">Name Prefix</label>
<div class="col-sm-6">
<input type="text" id="user_prefix" name="user_prefix">
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="pass_length">Password length</label>
<div class="col-sm-6">
<input type="number" min="4" max="10" id="pass_length" name="pass_length" value="5">
</div>
</div>
</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>
<div class="col-sm-6">
<select class="myCombo" id="limit_uptime" name="limit_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>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label" for="profile">Bandwidth (Mbps) Profile</label>
<div class="col-sm-6">
<?php
$util->setMenu('/ip hotspot user profile');
echo '<select class="myCombo" id="profile" name="profile">';
foreach ($util->getAll() as $item) {
echo '<option>', $item->getProperty('name'), '</option>';
}
echo '</select>'; ?>
</div>
</div>
<div class="col-sm-4">
<label class="col-sm-6 control-label">Username & Password</label>
<div class="col-sm-6">
<select class="myCombo" id="same_pass" name="same_pass">
<option value="1">Same</option>
<option value="2">Different</option>
</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>
<div class="col-sm-6">
<select class="myCombo" id="limit_bytes" name="limit_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>
</div>
</div>
<div class="col-sm-2">
<div class="pull-right">
<button name="missuing" id="missuing" onClick="ajaxMultiple()" class="btn btn-success">&nbsp; Issue</button>
</div>
</div>
<div class="col-sm-2">
<div class="pull-left">
<button data-dismiss="modal" class="btn btn-warning"><i class="icon-save icon-large"></i>&nbsp; BACK </button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="multiple"></div>
</div>
</div>
</div>
<!-- 2. End Multi Guest User Creation Section -->
<!-- 3. Start List All Inactive Users Section -->
<div class="child-modal modal fade" id="list-users" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?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>
</div>
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Profile</th>
<th>Bytes In</th>
<th>Bytes Out</th>
<th>Total Permitted Usage</th>
<th>Time Used</th>
<th>Validity Limit</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
if ($item->getProperty('limit-bytes-total')) {
$limit_bytes_total = $item->getProperty('limit-bytes-total').' Bytes';
}
else { $limit_bytes_total = 'Unlimited'; }
if ($item->getProperty('limit-uptime')) {
$limit_uptime = $item->getProperty('limit-uptime');
}
else { $limit_uptime = 'Not Limited'; }
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('name'),'</td>';
echo '<td>', $item->getProperty('profile'), '</td>';
echo '<td>', $item->getProperty('bytes-in'), '</td>';
echo '<td>', $item->getProperty('bytes-out'), '</td>';
echo '<td>', $limit_bytes_total, '</td>';
echo '<td>', $item->getProperty('uptime'), '</td>';
echo '<td>', $limit_uptime, '</td>';
echo '</tr>';
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
<!-- 3. End List All Inactive Users Section -->
<!-- 4. Start List Active Users Section -->
<div class="child-modal modal fade" id="active-users" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?php $util->setMenu('/ip hotspot active'); ?>
<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 Active at the moment</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Server</th>
<th>Domain</th>
<th>User</th>
<th>IP Address</th>
<th>Uptime</th>
<th>Session Time left</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('server'),'</td>';
echo '<td>', $item->getProperty('domain'), '</td>';
echo '<td>', $item->getProperty('user'),'</td>';
echo '<td>', $item->getProperty('address'), '</td>';
echo '<td>', $item->getProperty('uptime'), '</td>';
echo '<td>', $item->getProperty('session-time-left'), '</td>';
echo '</tr>';
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
<!-- 4. End List Active Users Section -->
<!-- 5. Start Remove Selected users Section -->
<div class="child-modal modal fade" id="remove-selected" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<form id="checkboxForm" class="form-horizontal">
<div class="form-group">
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?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>
</div>
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Profile</th>
<th>Bytes In</th>
<th>Bytes Out</th>
<th>Total Permitted Usage</th>
<th>Time Used</th>
<th>Validity Limit</th>
<?php if($_SESSION['user_level'] <= 2) { //Administrator/Unit Head Only
echo '<th>Remove</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
if ($item->getProperty('limit-bytes-total')) {
$limit_bytes_total = $item->getProperty('limit-bytes-total').' Bytes';
}
else { $limit_bytes_total = 'Unlimited'; }
if ($item->getProperty('limit-uptime')) {
$limit_uptime = $item->getProperty('limit-uptime');
}
else { $limit_uptime = 'Not Limited'; }
echo '<tr>';
echo '<td>'.$i.'</td>';
$rid = $item->getProperty('name');
echo '<td>', $rid,'</td>';
echo '<td>', $item->getProperty('profile'), '</td>';
echo '<td>', $item->getProperty('bytes-in'), '</td>';
echo '<td>', $item->getProperty('bytes-out'), '</td>';
echo '<td>', $limit_bytes_total, '</td>';
echo '<td>', $item->getProperty('uptime'), '</td>';
echo '<td>', $limit_uptime, '</td>';
if($_SESSION['user_level'] <= 2) { //Administrator/Unit Head Only
echo '<td>';
echo '<label for="'.$rid.'"></label>
<input type="checkbox" name="removal_list[]" value="'.$rid.'" id="'.$rid.'" class="styled" />';
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
echo '</td>';
}
echo '</tr>';
} ?>
</tbody>
</table>
<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>
<div class="col-sm-2">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- 5. End Remove Selected users Section -->
<!-- 6. Start Remove All Expired Guest Users Section -->
<div class="child-modal modal fade" id="remove-expired" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<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">Validity expired users available in System</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Server</th>
<th>User</th>
<th>Profile</th>
<th>Limit Uptime</th>
<th>Uptime</th>
<th>Limit Bytes Total</th>
<th>Bytes In</th>
<th>Bytes Out</th>
</tr>
</thead>
<tbody>
<?php
$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());
$idList = '';
$i = 0;
foreach ($client->sendSync($printRequest)->getAllOfType(RouterOS\Response::TYPE_DATA) as $item) {
if (!empty($item->getProperty('limit-uptime'))) {
if (!($item->getProperty('uptime') < $item->getProperty('limit-uptime'))) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('server'),'</td>';
echo '<td>', $item->getProperty('name'), '</td>';
echo '<td>', $item->getProperty('profile'), '</td>';
echo '<td>', $item->getProperty('limit-uptime'), '</td>';
echo '<td>', $item->getProperty('uptime'),'</td>';
echo '<td>', $item->getProperty('limit-bytes-total'), '</td>';
echo '<td>', $item->getProperty('bytes-in'), '</td>';
echo '<td>', $item->getProperty('bytes-out'), '</td>';
echo '</tr>';
}
}
}
?>
</tbody>
</table>
</div>
<div class="col-sm-3 col-sm-offset-5">
<button name="uissuing" id="uissuing" onClick="ajaxExpired();" class="btn btn-success"><i class="icon-save icon-large"></i></a>&nbsp;Remove All</button>&nbsp;&nbsp;&nbsp;
<button data-dismiss="modal" class="btn btn-info" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
<!-- 6. Start Remove All Expired Guest Users Section -->
<!-- 7. Start Server Log Section -->
<div class="child-modal modal fade" id="server-log" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<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">Server Event Log - Last 1000 activities</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Time</th>
<th>Topic</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->setMenu('/log')->getAll() as $entry) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $entry('time'),'</td>';
echo '<td>', $entry('topics'), '</td>';
echo '<td>', $entry('message'), '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
<!--</div>-->
</div>
</div>
</div>
<!-- 7. End Server Log Section -->
<!-- 9. Start System User Management Section -->
<div class="child-modal modal fade" id="system-user" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl"></div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<a href="#change-password" data-toggle="modal" class="btn btn-primary btn-lg center-element"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span>Change My Password</a>&nbsp;&nbsp;
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<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">System Users managing Hotspot Activities</h3></strong>
</div>
<thead>
<tr>
<th>Username</th>
<th>Password</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Level</th>
<?php if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<th>Actions</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE 1");
$stmt->execute(array());
while($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
$id=$row['user_id'];
if ($row['status'] == 'Active') { echo '<tr class="alert-info">'; } else { echo '<tr class="alert-danger">'; }
?>
<td><?php echo $row['username']; ?></td>
<td><?php echo '..............'; ?></td>
<td><?php echo $row['firstname']; ?></td>
<td><?php echo $row['lastname']; ?></td>
<?php
switch ($row['user_level']) {
case 1 :
echo '<td>Administrator</td>';
break;
case 2 :
echo '<td>Unit Head</td>';
break;
case 3 :
echo '<td>System User</td>';
break;
}
if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<td>';
echo '<a title="Get Details of User & More Actions" id="'.$id.'" data-id="'.$id.'" name="'.$id.'" href="#getUserModal" data-toggle="modal" class="btn btn-primary btn-lg"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a>&nbsp;&nbsp;';
echo '</td>';
} ?>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 9. End System User Management Section -->
<!-- 10. Start Remove All Un-Initiated Guest Users Section -->
<div class="child-modal modal fade" id="remove-uninitiated" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?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>
</div>
<thead>
<tr>
<th>#</th>
<th>Server</th>
<th>User</th>
<th>Profile</th>
<th>Uptime Limit</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
if ($item->getProperty('uptime') == 0) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('server'),'</td>';
echo '<td>', $item->getProperty('name'),'</td>';
echo '<td>', $item->getProperty('profile'),'</td>';
echo '<td>', $item->getProperty('limit-uptime'), '</td>';
echo '</tr>';
}
} ?>
</tbody>
</table>
</div>
<div class="col-sm-3 col-sm-offset-5">
<?php if($_SESSION['user_level'] <= 2) {
echo '<button name="uissuing" id="uissuing" onClick="ajaxUninitiated();" class="btn btn-success"><i class="icon-save icon-large"></i></a>&nbsp;Remove All</button>&nbsp;&nbsp;&nbsp;';
} ?>
<button data-dismiss="modal" class="btn btn-info" ><i class="icon-save icon-large"></i></a>&nbsp;CANCEL</button>
</div>
</div>
</div>
</div>
<!-- 10. Start Remove All Un-Initiated Guest Users Section -->
<!-- 11. Start HotSpot User Profiles Management Section -->
<div class="child-modal modal fade" id="profiler" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl"></div>
</div>
</div>
<div class="container">
<div class="no_print">
<div class="row">
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
<div class="col-sm-12 col-md-12 thumbnail" style="box-shadow: 10px 10px 5px #888888;">
<?php $util->setMenu('/ip hotspot user profile'); ?>
<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">HotSpot User Profiles Available</h3></strong>
</div>
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Session Timeout</th>
<th>Keepalive Timeout</th>
<th>Shared Users</th>
<th>Rate Limit(Rx/Tx)</th>
<th>MAC Cookie Timeout</th>
<?php if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<th>Actions</th>';
} ?>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($util->getAll() as $item) {
$i++;
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>', $item->getProperty('name'),'</td>';
echo '<td>', $item->getProperty('session-timeout'), '</td>';
echo '<td>', $item->getProperty('keepalive-timeout'), '</td>';
echo '<td>', $item->getProperty('shared-users'), '</td>';
echo '<td>', $item->getProperty('rate-limit'), '</td>';
echo '<td>', $item->getProperty('mac-cookie-timeout'), '</td>';
if($_SESSION['user_level'] == 1) { //Administrator Only
echo '<td>';
echo '<a title="Get Details of the Profile & More Actions" id="'.$id.'" data-id="'.$item->getProperty('name').'" name="'.$id.'" href="#getProfileModal" data-toggle="modal" class="btn btn-primary btn-lg"><i class="fa fa-caret-square-o-down" aria-hidden="true"></i></a>';
echo '</td>';
} ?>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
<div class="col-sm-2 col-sm-offset-5">
<button data-dismiss="modal" class="btn btn-info center-element" ><i class="icon-save icon-large"></i>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 11. End HotSpot User Profiles Management Section -->
</div>
</body>
<?php
include('modal_change_pass.php');
include('modal_get_user.php');
include('modal_delete_user.php');
include('modal_edit_user.php');
include('modal_reset_pass.php');
include('modal_get_profiles.php');
<!DOCTYPE html>
<html lang="en">
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<?php
//Start session
if ( !isset($_SESSION) ) session_start();
//Check whether the session variables present or not, and assign them to Ordinary variables, if present.
if (!isset($_SESSION['user_level']) || (trim($_SESSION['user_level']) == '' || (trim($_SESSION['user_level']) >= 4))) {
header("location:login.php");
}
?>
<?php if ( !isset($_SESSION) ) session_start(); ?>
<?php error_reporting(E_ALL);
ini_set('display_errors', 1); ?>
<?php include('header.php'); ?>
<?php include('dbconfig.php'); ?>
<?php
use PEAR2\Net\RouterOS;
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) {
include_once('settings.php');
}
?>

180
info.php
View file

@ -1,91 +1,91 @@
<?php
echo '<br><h1>PHP Info of this Machine</h1><br><br>';
echo phpinfo();
/*
* Md. Nazmul Basher
ob_start(); // Turn on output buffering
system(ipconfig /all); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer
$findme = “Physical”;
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address
echo "MAC ID: ";
echo $pmac;
echo $mac;
function getMacLinux() {
exec('netstat -ie', $result);
if(is_array($result)) {
$iface = array();
foreach($result as $key => $line) {
if($key > 0) {
$tmp = str_replace(" ", "", substr($line, 0, 10));
if($tmp <> "") {
$macpos = strpos($line, "HWaddr");
if($macpos !== false) {
$iface[] = array('iface' => $tmp, 'mac' => strtolower(substr($line, $macpos+7, 17)));
}
}
}
}
return $iface[0]['mac'];
} else {
return "notfound";
}
}
echo 'Linux Mac ID : '.getMaclinux();
$ip=$_SERVER['SERVER_ADDR'];
echo "Server IP: {$ip}<br />
Server Mac: ";
$conf=exec('netstat -ie');
$prots=explode("\n\n",$conf);
if($ip=='127.0.0.1')$ip='192.168.';
foreach($prots as $prot){
if(strpos($prot,' addr:'.$ip) && preg_match('/(?:\s+)HWaddr(?:\s+)(?P<mac>[a-f0-9\:]+)/',$prot,$match)){
echo $match['mac'];
}
}
$ipAddress=$_SERVER['REMOTE_ADDR'];
$macAddr=false;
#run the external command, break output into lines
$arp=`arp -a $ipAddress`;
$lines=explode("\n", $arp);
#look for the output line describing our IP address
foreach($lines as $line)
{
$cols=preg_split('/\s+/', trim($line));
if ($cols[0]==$ipAddress)
{
$macAddr=$cols[1];
}
}
echo $lines[1];
echo $cols[1];
echo $macAddr;
*/
//===========================================
ob_start();
$cmd = system("getmac");
ob_end_clean();
echo 'Your MAC ID : '. substr($cmd,0,17);
/*
echo '<br><br><br>';
echo '<br>New Get Mac: '.substr($cmd,0,17).'<br>';
echo 'Location: '.strstr($cmd, '{');
$cmd = system("nbtstat -a ip.of.remote.machine");
echo '<br>Another ID New Get Mac: '.$cmd; */
<?php
echo '<br><h1>PHP Info of this Machine</h1><br><br>';
echo phpinfo();
/*
* Md. Nazmul Basher
ob_start(); // Turn on output buffering
system(ipconfig /all); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer
$findme = “Physical”;
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address
echo "MAC ID: ";
echo $pmac;
echo $mac;
function getMacLinux() {
exec('netstat -ie', $result);
if(is_array($result)) {
$iface = array();
foreach($result as $key => $line) {
if($key > 0) {
$tmp = str_replace(" ", "", substr($line, 0, 10));
if($tmp <> "") {
$macpos = strpos($line, "HWaddr");
if($macpos !== false) {
$iface[] = array('iface' => $tmp, 'mac' => strtolower(substr($line, $macpos+7, 17)));
}
}
}
}
return $iface[0]['mac'];
} else {
return "notfound";
}
}
echo 'Linux Mac ID : '.getMaclinux();
$ip=$_SERVER['SERVER_ADDR'];
echo "Server IP: {$ip}<br />
Server Mac: ";
$conf=exec('netstat -ie');
$prots=explode("\n\n",$conf);
if($ip=='127.0.0.1')$ip='192.168.';
foreach($prots as $prot){
if(strpos($prot,' addr:'.$ip) && preg_match('/(?:\s+)HWaddr(?:\s+)(?P<mac>[a-f0-9\:]+)/',$prot,$match)){
echo $match['mac'];
}
}
$ipAddress=$_SERVER['REMOTE_ADDR'];
$macAddr=false;
#run the external command, break output into lines
$arp=`arp -a $ipAddress`;
$lines=explode("\n", $arp);
#look for the output line describing our IP address
foreach($lines as $line)
{
$cols=preg_split('/\s+/', trim($line));
if ($cols[0]==$ipAddress)
{
$macAddr=$cols[1];
}
}
echo $lines[1];
echo $cols[1];
echo $macAddr;
*/
//===========================================
ob_start();
$cmd = system("getmac");
ob_end_clean();
echo 'Your MAC ID : '. substr($cmd,0,17);
/*
echo '<br><br><br>';
echo '<br>New Get Mac: '.substr($cmd,0,17).'<br>';
echo 'Location: '.strstr($cmd, '{');
$cmd = system("nbtstat -a ip.of.remote.machine");
echo '<br>Another ID New Get Mac: '.$cmd; */
?>

192
login.php
View file

@ -1,97 +1,97 @@
<?php include('header.php'); ?>
<?php if ( !isset($_SESSION) ) session_start(); ?>
<?php error_reporting(E_ALL);
ini_set('display_errors', 1); ?>
<div class="container">
<header>
<h1 style="text-align:center;">Easy Hotspot</h1>
<h2 style="text-align:center;">Simple HotSpot User Management Utility</h2>
<h3 style="text-align:center;">By TEAM ZETOZONE</h3>
</header>
<div class="row">
<div class="col-sm-6 col-sm-offset-3 well" style="box-shadow: 10px 10px 5px #888888;">
<div class="panel panel-primary">
<div class="panel panel-heading">
<p><strong>Login using Registered Credentials</strong></p>
</div>
<div class="panel-body">
<form class="form-horizontal" id="loginform" action="" method="POST">
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputEmail">Username</label>
<div class="col-sm-8">
<input type="text" id="txt_username" name="username" placeholder="Registered Username" required class="form-control" autofocus>
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputPassword">Password</label>
<div class="col-sm-8">
<input type="password" id="txt_password" name="password" placeholder="Password" placeholder="Password" required class="form-control">
</div>
</div>
<div class="form-group form-group-sm">
<div class="col-sm-2 col-sm-offset-4">
<button id="btn_login" name="btn_login" type="submit" class="btn btn-primary">&nbsp;Submit</button>
</div>
<div class="col-sm-2">
<button id="btn_cancel" name="btn_cancel" type="reset" class="btn btn-success">&nbsp;Cancel</button>
</div>
</div>
</form>
<?php
if (isset($_POST['btn_login'])){
$username = $_POST['username'];
$password = $_POST['password'];
$password= sha1($password);
include('dbconfig.php');
try {
$stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1");
$stmt->execute(array());
}
catch(PDOException $e) {
try {
include('database.php');
$stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1");
$stmt->execute(array());
}
catch(PDOException $e) {
echo "Error Accessing Data: " . $e->getMessage();
}
}
$count = $stmt->rowCount();
if( $count == 0 ) {
$password = sha1('admin');
$stmt = $DB_con->prepare("insert into hotspot_users (date_added, firstname, username, password, user_level, status, user_group, created_at)
values(CURDATE(), 'Administrator', :username, :password, :level, 'Active', 1, NOW())");
$stmt->execute(array(':username' => 'admin', ':password' => $password, ':level' => 1));
}
try
{
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE username=:username AND password =:password AND status =:status");
$stmt->execute(array(':username' => $username, ':password' => $password, ':status' => 'Active'));
$count = $stmt->rowCount();
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
if( $count == 1 ) {
$row=$stmt->fetch(PDO::FETCH_ASSOC);
$_SESSION['id']=$row['user_id'];
$_SESSION['username']=$row['firstname'].' '.$row['lastname'];
$_SESSION['user_level']= $row['user_level'];
echo '<script language="javascript">window.location.href ="index.php";</script>';
}
else
{
echo '<script>cmodal("Access Denied!", "No Active User account with the given Username/Password Combination!", "error", "index.php")</script>';
}
}
?>
</div>
</div>
</div>
</div>
<?php include('header.php'); ?>
<?php if ( !isset($_SESSION) ) session_start(); ?>
<?php error_reporting(E_ALL);
ini_set('display_errors', 1); ?>
<div class="container">
<header>
<h1 style="text-align:center;">Easy Hotspot</h1>
<h2 style="text-align:center;">Simple HotSpot User Management Utility</h2>
<h3 style="text-align:center;">By TEAM ZETOZONE</h3>
</header>
<div class="row">
<div class="col-sm-6 col-sm-offset-3 well" style="box-shadow: 10px 10px 5px #888888;">
<div class="panel panel-primary">
<div class="panel panel-heading">
<p><strong>Login using Registered Credentials</strong></p>
</div>
<div class="panel-body">
<form class="form-horizontal" id="loginform" action="" method="POST">
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputEmail">Username</label>
<div class="col-sm-8">
<input type="text" id="txt_username" name="username" placeholder="Registered Username" required class="form-control" autofocus>
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputPassword">Password</label>
<div class="col-sm-8">
<input type="password" id="txt_password" name="password" placeholder="Password" placeholder="Password" required class="form-control">
</div>
</div>
<div class="form-group form-group-sm">
<div class="col-sm-2 col-sm-offset-4">
<button id="btn_login" name="btn_login" type="submit" class="btn btn-primary">&nbsp;Submit</button>
</div>
<div class="col-sm-2">
<button id="btn_cancel" name="btn_cancel" type="reset" class="btn btn-success">&nbsp;Cancel</button>
</div>
</div>
</form>
<?php
if (isset($_POST['btn_login'])){
$username = $_POST['username'];
$password = $_POST['password'];
$password= sha1($password);
include('dbconfig.php');
try {
$stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1");
$stmt->execute(array());
}
catch(PDOException $e) {
try {
include('database.php');
$stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1");
$stmt->execute(array());
}
catch(PDOException $e) {
echo "Error Accessing Data: " . $e->getMessage();
}
}
$count = $stmt->rowCount();
if( $count == 0 ) {
$password = sha1('admin');
$stmt = $DB_con->prepare("insert into hotspot_users (date_added, firstname, username, password, user_level, status, user_group, created_at)
values(CURDATE(), 'Administrator', :username, :password, :level, 'Active', 1, NOW())");
$stmt->execute(array(':username' => 'admin', ':password' => $password, ':level' => 1));
}
try
{
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE username=:username AND password =:password AND status =:status");
$stmt->execute(array(':username' => $username, ':password' => $password, ':status' => 'Active'));
$count = $stmt->rowCount();
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
if( $count == 1 ) {
$row=$stmt->fetch(PDO::FETCH_ASSOC);
$_SESSION['id']=$row['user_id'];
$_SESSION['username']=$row['firstname'].' '.$row['lastname'];
$_SESSION['user_level']= $row['user_level'];
echo '<script language="javascript">window.location.href ="index.php";</script>';
}
else
{
echo '<script>cmodal("Access Denied!", "No Active User account with the given Username/Password Combination!", "error", "index.php")</script>';
}
}
?>
</div>
</div>
</div>
</div>
</div>

49
logme.php Normal file
View file

@ -0,0 +1,49 @@
<?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();
?>
<div style="padding-top: 5%;" class="login-box">
<div class="card">
<div class="card-body login-card-body">
<div class="text-center">
<img class="img-fluid" src="img/favicon.png" alt="User profile picture">
</div>
<h3 style="margin: 30px;" class="text-center">MIKHMON</h3>
<form autocomplete="off" action="" method="post">
<div class="form-group has-feedback">
<input class="form-control form-control-sm" type="text" name="user" placeholder="User" required="1" autofocus>
</div>
<div class="form-group has-feedback">
<input class="form-control form-control-sm" type="password" name="pass" placeholder="Password" required="1">
</div>
<div class="row">
<div class="col-12">
<input class="btn btn-primary btn-block" type="submit" name="login" value="Login">
</div>
</div>
</form>
<div style="margin-top: 10px;" class="block">
<?php echo $error; ?>
</div>
</div>
</div>
</div>
</body>
</html>

View file

@ -1,7 +1,7 @@
<?php
session_start();
session_unset();
session_destroy();
//echo '<script>window.open("backup.php", "_self").close(); top.close(); window.open("backup.php", "_self", ""); window.close();</script>';
header('location:index.php');
<?php
session_start();
session_unset();
session_destroy();
//echo '<script>window.open("backup.php", "_self").close(); top.close(); window.open("backup.php", "_self", ""); window.close();</script>';
header('location:index.php');
?>

View file

@ -1,72 +1,72 @@
<div class="child-modal modal fade" id="change-password" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" id="chPassword" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>Welcome <?php echo $_SESSION['username'].', '; ?> Change Your Login Password</strong></div>
<div class="form-group">
<label class="control-label col-sm-6">Type-in New Password</label>
<div class="col-sm-6">
<div class="input-group">
<input type="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length" name="np" id="newpassword" placeholder="New Password" required="true" autofocus tabindex="1">
<div id='chPassword_np_errorloc' class="error_strings"></div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6">Re-type New Password</label>
<div class="col-sm-6">
<input type="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length" name="rp" id="retypepassword" placeholder="Re-type New Password" required="true" tabindex="2">
<div id='chPassword_rp_errorloc' class="error_strings"></div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-12">
<div class="col-sm-3 col-sm-offset-3">
<div class="pull-right">
<button name="update_pass" id="update_pass" type="submit" onClick="changePass(this.form);" class="btn btn-success" data-dismiss="modal" tabindex="3"><i class="icon-save icon-large"></i>&nbsp;Update</button>
</div>
</div>
<div class="col-sm-6">
<div class="pull-left">
<a href="index.php" data-dismiss="modal" class="btn btn-info" tabindex="4"><i class="icon-arrow-left icon-large"></i>&nbsp;Cancel</a>
</div>
</div>
</div>
</div>
</form>
<!-- <script type="text/javascript">
var frmvalidator = new Validator("chPassword");
frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("np","req","Please enter your New Password");
frmvalidator.addValidation("np","regexp=^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$",
"Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length");
frmvalidator.addValidation("rp","req","Please retype your New Password");
frmvalidator.addValidation("rp","regexp=^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$",
"Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length");
frmvalidator.addValidation("np","eqelmnt=rp", "Both Passwords should be same");
</script>
<script type="text/javascript">
window.onload = function (){
eventHandler = function (e){
if (e.keyCode === 13 ) //Enter key to Trap
{
event.preventDefault();
$("#update_pass").trigger('click'); /*
var cti = document.activeElement.tabIndex;
if (cti == 1 )
$('[tabindex=' + (cti + 1) + ']').focus();
else
$('[tabindex=' + (cti - 1) + ']').focus();
return false; */
}
}
window.addEventListener('keydown', eventHandler, false);
} ;
</script> -->
</div>
</div>
<div class="child-modal modal fade" id="change-password" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" id="chPassword" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>Welcome <?php echo $_SESSION['username'].', '; ?> Change Your Login Password</strong></div>
<div class="form-group">
<label class="control-label col-sm-6">Type-in New Password</label>
<div class="col-sm-6">
<div class="input-group">
<input type="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length" name="np" id="newpassword" placeholder="New Password" required="true" autofocus tabindex="1">
<div id='chPassword_np_errorloc' class="error_strings"></div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-6">Re-type New Password</label>
<div class="col-sm-6">
<input type="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length" name="rp" id="retypepassword" placeholder="Re-type New Password" required="true" tabindex="2">
<div id='chPassword_rp_errorloc' class="error_strings"></div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-12">
<div class="col-sm-3 col-sm-offset-3">
<div class="pull-right">
<button name="update_pass" id="update_pass" type="submit" onClick="changePass(this.form);" class="btn btn-success" data-dismiss="modal" tabindex="3"><i class="icon-save icon-large"></i>&nbsp;Update</button>
</div>
</div>
<div class="col-sm-6">
<div class="pull-left">
<a href="index.php" data-dismiss="modal" class="btn btn-info" tabindex="4"><i class="icon-arrow-left icon-large"></i>&nbsp;Cancel</a>
</div>
</div>
</div>
</div>
</form>
<!-- <script type="text/javascript">
var frmvalidator = new Validator("chPassword");
frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("np","req","Please enter your New Password");
frmvalidator.addValidation("np","regexp=^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$",
"Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length");
frmvalidator.addValidation("rp","req","Please retype your New Password");
frmvalidator.addValidation("rp","regexp=^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$",
"Must contain at least one number, one uppercase letter, one lowercase letter and at least 8 characters length");
frmvalidator.addValidation("np","eqelmnt=rp", "Both Passwords should be same");
</script>
<script type="text/javascript">
window.onload = function (){
eventHandler = function (e){
if (e.keyCode === 13 ) //Enter key to Trap
{
event.preventDefault();
$("#update_pass").trigger('click'); /*
var cti = document.activeElement.tabIndex;
if (cti == 1 )
$('[tabindex=' + (cti + 1) + ']').focus();
else
$('[tabindex=' + (cti - 1) + ']').focus();
return false; */
}
}
window.addEventListener('keydown', eventHandler, false);
} ;
</script> -->
</div>
</div>
</div>

View file

@ -1,61 +1,61 @@
<div id="delete<?php echo $item->getProperty('name'); ?>" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>Delete Guest User</strong></div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Username</label>
<div class="col-xs-7">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input type="text" id="username" size="40" name="username" value="<?php echo $item->getProperty('name'); ?>" readonly>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputPassword">Limit Uptime</label>
<div class="col-xs-7">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
<input type="text" name="uptime" value="<?php echo $item->getProperty('limit-uptime'); ?>" id="inputPassword" readonly>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Address</label>
<div class="col-xs-7">
<input type="text" id="inputEmail" name="firstname" value="<?php echo $item->getProperty('address'); ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Uptime</label>
<div class="col-xs-7">
<input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('uptime'); ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Session time Left</label>
<div class="col-xs-7">
<input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('session-time-left'); ?>" readonly>
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-12">
<div class="col-sm-3 col-sm-offset-3">
<div class="pull-right">
<button name="issuing" id="issuing" onClick="removeAjax('<?php echo $item->getProperty('name'); ?>')" class="btn btn-success" data-dismiss="modal"><i class="icon-save icon-large"></i></a>&nbsp;Remove</button>
</div>
</div>
<div class="col-sm-6">
<div class="pull-left">
<button class="btn btn-error" data-dismiss="modal" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<div id="delete<?php echo $item->getProperty('name'); ?>" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>Delete Guest User</strong></div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Username</label>
<div class="col-xs-7">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input type="text" id="username" size="40" name="username" value="<?php echo $item->getProperty('name'); ?>" readonly>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputPassword">Limit Uptime</label>
<div class="col-xs-7">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
<input type="text" name="uptime" value="<?php echo $item->getProperty('limit-uptime'); ?>" id="inputPassword" readonly>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Address</label>
<div class="col-xs-7">
<input type="text" id="inputEmail" name="firstname" value="<?php echo $item->getProperty('address'); ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Uptime</label>
<div class="col-xs-7">
<input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('uptime'); ?>" readonly>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Session time Left</label>
<div class="col-xs-7">
<input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('session-time-left'); ?>" readonly>
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-12">
<div class="col-sm-3 col-sm-offset-3">
<div class="pull-right">
<button name="issuing" id="issuing" onClick="removeAjax('<?php echo $item->getProperty('name'); ?>')" class="btn btn-success" data-dismiss="modal"><i class="icon-save icon-large"></i></a>&nbsp;Remove</button>
</div>
</div>
<div class="col-sm-6">
<div class="pull-left">
<button class="btn btn-error" data-dismiss="modal" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>

View file

@ -1,88 +1,88 @@
<div id="getProfileModal" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>HotSpot User Profiles for Guest Users</strong></div>
<div class="form-group">
<label class="control-label col-xs-3">Profile Name</label>
<div class="col-xs-7">
<div class="input-group">
<input type="hidden" id="profile_id" name="id" >
<input type="text" id="profile_name" size="40" onChange="genClick();" required tabindex="1" autofocus>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Session Timeout</label>
<div class="col-xs-7">
<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="2">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Rate limit - Download(Rx)</label>
<div class="col-xs-3">
<select class="myCombo" id="rx_rate_limit" title="Select the maximum Download speed limit allowed for the profile from the list" onChange="genClick();" name="status" required tabindex="3">
<option></option>
<option value="256k">256 Kbps</option>
<option value="512k">512 Kbps</option>
<option value="1M">1 Mbps</option>
<option value="2M">2 Mbps</option>
<option value="3M">3 Mbps</option>
<option value="4M">4 Mbps</option>
<option value="5M">5 Mbps</option>
<option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option>
</select>
</div>
<label class="control-label col-xs-3 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="4">
<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>
<option value="2M">2 Mbps</option>
<option value="3M">3 Mbps</option>
<option value="4M">4 Mbps</option>
<option value="5M">5 Mbps</option>
<option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Shared Users</label>
<div class="col-xs-7">
<input type="number" id="shared_users" title="Select No of users allowed to share a connection ( 1- 5 )" min=1 max=5 onChange="genClick();" tabindex="5">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">MAC Cookie Timeout</label>
<div class="col-xs-3">
<input type="text" id="mac_cookie_timeout" size="12" title="MAC Cookie Timeout Value in the format 1d 00:00:00" onChange="genClick();" tabindex="6">
</div>
<label class="control-label col-xs-3 pull-left">Keep Alive Timeout</label>
<div class="col-xs-3 pull-left">
<input type="text" id="keepalive_timeout" size="12" title="Keepalive Timeout Value in the format 00:00:00" onChange="genClick();" tabindex="7">
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-10 col-sm-offset-1">
<?php
echo '<button name="add_profile" id="add_profile" onClick="addprofile(this.form);" class="btn btn-info" data-dismiss="modal" tabindex="8"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>Add New</button>';
echo '<button name="edit_profile" id="edit_profile" onChange="genClick();" onClick="editprofile(this.form);" class="btn btn-success" data-dismiss="modal" tabindex="9"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>Update</button>';
echo '<button name="delete_profile" id="delete_profile" onClick="deleteprofile(this.form);" class="btn btn-danger" data-dismiss="modal" tabindex="10"><i class="fa fa-trash" aria-hidden="true"></i>Delete Profile</button>';
echo '<button name="close_btn" id="close_btn" class="btn btn-warning" data-dismiss="modal" aria-hidden="true" tabindex="11"><i class="fa fa-times" aria-hidden="true"></i>Close</button>';
?>
</div>
</div>
</form>
</div>
</div>
<div id="getProfileModal" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>HotSpot User Profiles for Guest Users</strong></div>
<div class="form-group">
<label class="control-label col-xs-3">Profile Name</label>
<div class="col-xs-7">
<div class="input-group">
<input type="hidden" id="profile_id" name="id" >
<input type="text" id="profile_name" size="40" onChange="genClick();" required tabindex="1" autofocus>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Session Timeout</label>
<div class="col-xs-7">
<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="2">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Rate limit - Download(Rx)</label>
<div class="col-xs-3">
<select class="myCombo" id="rx_rate_limit" title="Select the maximum Download speed limit allowed for the profile from the list" onChange="genClick();" name="status" required tabindex="3">
<option></option>
<option value="256k">256 Kbps</option>
<option value="512k">512 Kbps</option>
<option value="1M">1 Mbps</option>
<option value="2M">2 Mbps</option>
<option value="3M">3 Mbps</option>
<option value="4M">4 Mbps</option>
<option value="5M">5 Mbps</option>
<option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option>
</select>
</div>
<label class="control-label col-xs-3 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="4">
<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>
<option value="2M">2 Mbps</option>
<option value="3M">3 Mbps</option>
<option value="4M">4 Mbps</option>
<option value="5M">5 Mbps</option>
<option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Shared Users</label>
<div class="col-xs-7">
<input type="number" id="shared_users" title="Select No of users allowed to share a connection ( 1- 5 )" min=1 max=5 onChange="genClick();" tabindex="5">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">MAC Cookie Timeout</label>
<div class="col-xs-3">
<input type="text" id="mac_cookie_timeout" size="12" title="MAC Cookie Timeout Value in the format 1d 00:00:00" onChange="genClick();" tabindex="6">
</div>
<label class="control-label col-xs-3 pull-left">Keep Alive Timeout</label>
<div class="col-xs-3 pull-left">
<input type="text" id="keepalive_timeout" size="12" title="Keepalive Timeout Value in the format 00:00:00" onChange="genClick();" tabindex="7">
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-10 col-sm-offset-1">
<?php
echo '<button name="add_profile" id="add_profile" onClick="addprofile(this.form);" class="btn btn-info" data-dismiss="modal" tabindex="8"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>Add New</button>';
echo '<button name="edit_profile" id="edit_profile" onChange="genClick();" onClick="editprofile(this.form);" class="btn btn-success" data-dismiss="modal" tabindex="9"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>Update</button>';
echo '<button name="delete_profile" id="delete_profile" onClick="deleteprofile(this.form);" class="btn btn-danger" data-dismiss="modal" tabindex="10"><i class="fa fa-trash" aria-hidden="true"></i>Delete Profile</button>';
echo '<button name="close_btn" id="close_btn" class="btn btn-warning" data-dismiss="modal" aria-hidden="true" tabindex="11"><i class="fa fa-times" aria-hidden="true"></i>Close</button>';
?>
</div>
</div>
</form>
</div>
</div>
</div>

View file

@ -1,76 +1,76 @@
<div id="getUserModal" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>Edit System User</strong></div>
<div class="form-group">
<label class="control-label col-xs-3">Username</label>
<div class="col-xs-7">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input type="hidden" id="user_id" name="id" >
<input type="text" id="username" size="40" onChange="genClick();" name="username" required tabindex="1" autofocus>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Firstname</label>
<div class="col-xs-7">
<input type="text" id="firstname" onChange="genClick();" name="firstname" required tabindex="2">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Lastname</label>
<div class="col-xs-7">
<input type="text" id="lastname" onChange="genClick();" name="lastname" tabindex="3">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">User Level</label>
<div class="col-xs-7">
<select id="user_level" onChange="genClick();" name="user_level" required tabindex="4">
<?php
switch ($row['user_level']) {
case 1 :
echo '<option value="1">Administrator</option>';
break;
case 2 :
echo '<option value="2">Unit Head</option>';
break;
case 3 :
echo '<option value="3">System User</option>';
break;
} ?>
<option value="3">System User</option>
<option value="2">Unit Head</option>
<option value="1">Administrator</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">User Status</label>
<div class="col-xs-3">
<select class="myCombo" id="status" onChange="genClick();" name="user_status" required tabindex="5">
<option></option>
<option value="Active">Active</option>
<option value="Disabled">Disabled</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-12">
<?php
echo '<button name="add_user" id="add_user" onClick="addsysuser(this.form)" class="btn btn-primary" data-dismiss="modal"><i class="icon-save icon-large"></i>Add User</button>';
echo '<button name="edit_user" id="edit_user" onChange="genClick();" onClick="edituser(this.form);" class="btn btn-success" data-dismiss="modal" tabindex="6"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>Update</button>';
echo '<button name="delete_user" id="delete_user" onClick="deleteuser(this.form);" class="btn btn-danger" data-dismiss="modal" tabindex="7"><i class="fa fa-trash" aria-hidden="true"></i>Remove User</button>';
echo '<button name="reset_psd" id="reset_psd" onClick="resetpass(this.form);" class="btn btn-info" data-dismiss="modal" tabindex="8"><i class="fa fa-bolt" aria-hidden="true"></i>Reset Pass</button>';
echo '<button name="close_btn" id="close_btn" class="btn btn-warning" data-dismiss="modal" aria-hidden="true" tabindex="9"><i class="fa fa-times" aria-hidden="true"></i>Close</button>';
?>
</div>
</div>
</form>
</div>
</div>
<div id="getUserModal" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" method="post">
<div class="modal-body">
<div class="alert alert-info text-center"><strong>Edit System User</strong></div>
<div class="form-group">
<label class="control-label col-xs-3">Username</label>
<div class="col-xs-7">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input type="hidden" id="user_id" name="id" >
<input type="text" id="username" size="40" onChange="genClick();" name="username" required tabindex="1" autofocus>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Firstname</label>
<div class="col-xs-7">
<input type="text" id="firstname" onChange="genClick();" name="firstname" required tabindex="2">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Lastname</label>
<div class="col-xs-7">
<input type="text" id="lastname" onChange="genClick();" name="lastname" tabindex="3">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">User Level</label>
<div class="col-xs-7">
<select id="user_level" onChange="genClick();" name="user_level" required tabindex="4">
<?php
switch ($row['user_level']) {
case 1 :
echo '<option value="1">Administrator</option>';
break;
case 2 :
echo '<option value="2">Unit Head</option>';
break;
case 3 :
echo '<option value="3">System User</option>';
break;
} ?>
<option value="3">System User</option>
<option value="2">Unit Head</option>
<option value="1">Administrator</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">User Status</label>
<div class="col-xs-3">
<select class="myCombo" id="status" onChange="genClick();" name="user_status" required tabindex="5">
<option></option>
<option value="Active">Active</option>
<option value="Disabled">Disabled</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-sm-12">
<?php
echo '<button name="add_user" id="add_user" onClick="addsysuser(this.form)" class="btn btn-primary" data-dismiss="modal"><i class="icon-save icon-large"></i>Add User</button>';
echo '<button name="edit_user" id="edit_user" onChange="genClick();" onClick="edituser(this.form);" class="btn btn-success" data-dismiss="modal" tabindex="6"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>Update</button>';
echo '<button name="delete_user" id="delete_user" onClick="deleteuser(this.form);" class="btn btn-danger" data-dismiss="modal" tabindex="7"><i class="fa fa-trash" aria-hidden="true"></i>Remove User</button>';
echo '<button name="reset_psd" id="reset_psd" onClick="resetpass(this.form);" class="btn btn-info" data-dismiss="modal" tabindex="8"><i class="fa fa-bolt" aria-hidden="true"></i>Reset Pass</button>';
echo '<button name="close_btn" id="close_btn" class="btn btn-warning" data-dismiss="modal" aria-hidden="true" tabindex="9"><i class="fa fa-times" aria-hidden="true"></i>Close</button>';
?>
</div>
</div>
</form>
</div>
</div>
</div>

View file

@ -1,6 +1,67 @@
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
?>
<?php
if (isset($_POST['btn_update'])){
$newhost = $_POST['newhost'];
$newuser = $_POST['newuser'];
$newpass = $_POST['newpass'];
$file = 'config.php';
$message = '<?php '."\n";
$message = $message.'$host = "'.$newhost.'";'."\n";
$message = $message.'$user = "'.$newuser.'";'."\n";
$message = $message.'$pass = "'.$newpass.'";'."\n";
$message = $message."?>";
try {
file_put_contents($file, $message);
echo '<script>cmodal("Success!", "Successfully saved the new settings!", "success", "index.php")</script>';
}
catch(PDOException $e) {
echo '<script>cmodal("Access Denied!", "Error while updating settings!", "error", "index.php")</script>';
}
}
?>
<div class="container">
<header>
<h1 style="text-align:center;">Easy Hotspot</h1>
<h2 style="text-align:center;">Simple HotSpot User Management Utility</h2>
<h3 style="text-align:center;">By TEAM ZETOZONE</h3>
</header>
<div class="row">
<div class="col-sm-6 col-sm-offset-3 well" style="box-shadow: 10px 10px 5px #888888;">
<div class="panel panel-primary">
<div class="panel panel-heading">
<p><strong>Please update the below settings</strong></p>
</div>
<div class="panel-body">
<form class="form-horizontal" id="loginform" action="" method="POST">
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputEmail">Host IP</label>
<div class="col-sm-8">
<input type="text" id="txt_username" name="newhost" placeholder="Registered Username" value="<?php echo $host; ?>" required class="form-control" autofocus>
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputEmail">Username</label>
<div class="col-sm-8">
<input type="text" id="txt_username" name="newuser" placeholder="Registered Username" value="<?php echo $user; ?>" required class="form-control" autofocus>
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputPassword">Password</label>
<div class="col-sm-8">
<input type="password" id="txt_password" name="newpass" placeholder="Password" placeholder="Password" value="<?php echo $pass; ?>" required class="form-control">
</div>
</div>
<div class="form-group form-group-sm">
<div class="col-sm-2 col-sm-offset-4">
<button id="btn_update" name="btn_update" type="submit" class="btn btn-primary">&nbsp;Submit</button>
</div>
<div class="col-sm-2">
<button id="btn_cancel" name="btn_cancel" type="close" class="btn btn-success">&nbsp;Cancel</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>

File diff suppressed because it is too large Load diff