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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because one or more lines are too long

View file

@ -1,24 +1,24 @@
<?php <?php
$DB_host = "localhost"; $DB_host = "localhost";
$DB_user = "root"; $DB_user = "root";
$DB_pass = "root123"; $DB_pass = "root123";
$DB_name = "mikrotik"; $DB_name = "mikrotik";
try try
{ {
$DB_con = new PDO("mysql:host={$DB_host}",$DB_user,$DB_pass); $DB_con = new PDO("mysql:host={$DB_host}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbname = "`".str_replace("`","``",$DB_name)."`"; $dbname = "`".str_replace("`","``",$DB_name)."`";
$DB_con->query("CREATE DATABASE IF NOT EXISTS $dbname"); $DB_con->query("CREATE DATABASE IF NOT EXISTS $dbname");
$DB_con->query("use $dbname"); $DB_con->query("use $dbname");
} }
catch(PDOException $e) { catch(PDOException $e) {
echo "Error Creating/Locating Database $dbname: " . $e->getMessage(); echo "Error: " . $e->getMessage();
} }
/* Old Version, NOT creating DB if NOT Exist /* 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 = new PDO("mysql:host={$DB_host};dbname={$DB_name}",$DB_user,$DB_pass);
$DB_con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $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 <?php
use PEAR2\Net\RouterOS; use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php'; require_once 'PEAR2/Autoload.php';
require_once 'config.php'; require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass")); $util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'checkout'; } if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'checkout'; }
if (isset($_GET['username'])) $username = $_GET['username']; if (isset($_GET['username'])) $username = $_GET['username'];
/*Sample Call /*Sample Call
FORMAT: localhost/hotsoft.php?action=checkin&username=101&password=spice&limit_uptime=10d&limit_bytes=10&profile=default 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 & 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 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 username can be room number or any username
password - if password is not given, the given username will be the password 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_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 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 profile - if given any user profile name available in the Wifi hotspot
sample call: 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=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 192.168.100.10/hotsoft.php?action=checkout&username=101 - While checking out a room
Return Values Return Values
0 - Success (Successfully created user account or Successfully removed User account) 0 - Success (Successfully created user account or Successfully removed User account)
1 - Wrong action verb 1 - Wrong action verb
2 - Invalid or blank username 2 - Invalid or blank username
3 - Call with an already existing/Duplicate username 3 - Call with an already existing/Duplicate username
4 - 4 -
*/ */
if (strtolower($action) == 'checkin')) { if (strtolower($action) == 'checkin')) {
if (!empty($username)) { if (!empty($username)) {
if (isset($_GET['password'])) { $password = $_GET['password']; } else { $password = $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_uptime'])) $limit_uptime = $_GET['limit_uptime'];
if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes']; if (isset($_GET['limit_bytes'])) $limit_bytes = $_GET['limit_bytes'];
if (isset($_GET['profile'])) { $profile = $_GET['profile']; } else { $profile = 'default'; } if (isset($_GET['profile'])) { $profile = $_GET['profile']; } else { $profile = 'default'; }
$util->setMenu('/ip hotspot user'); $util->setMenu('/ip hotspot user');
$iv = count($util); $iv = count($util);
if ((intval($limit_bytes) != 0) and (!empty($limit_uptime))) { if ((intval($limit_bytes) != 0) and (!empty($limit_uptime))) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 ); $limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add( $util->add(
array( array(
'name' => "$username", 'name' => "$username",
'password' => "$password", 'password' => "$password",
'limit-uptime' => "$limit_uptime", 'limit-uptime' => "$limit_uptime",
'limit-bytes-total' => "$limit_bytes_total", 'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile" 'profile' => "$profile"
) )
); );
} }
elseif (intval($limit_bytes) != 0) { elseif (intval($limit_bytes) != 0) {
$limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 ); $limit_bytes_total = (intval($limit_bytes) * 1024 * 1024 * 1024 );
$util->add( $util->add(
array( array(
'name' => "$username", 'name' => "$username",
'password' => "$password", 'password' => "$password",
'limit-bytes-total' => "$limit_bytes_total", 'limit-bytes-total' => "$limit_bytes_total",
'profile' => "$profile" 'profile' => "$profile"
) )
); );
} }
else else
{ {
$util->add( $util->add(
array( array(
'name' => "$username", 'name' => "$username",
'password' => "$password", 'password' => "$password",
'limit-uptime' => "$limit_uptime", 'limit-uptime' => "$limit_uptime",
'profile' => "$profile" 'profile' => "$profile"
) )
); );
$limit_bytes = 0; // For Adding it to Local database $limit_bytes = 0; // For Adding it to Local database
} }
if ($iv != count($util)) { if ($iv != count($util)) {
include('dbconfig.php'); include('dbconfig.php');
$stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1"); $stmt = $DB_con->prepare("SELECT booking_id from hotspot_vouchers ORDER BY booking_id DESC LIMIT 1");
$stmt->execute(array()); $stmt->execute(array());
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$booking_id = $row['booking_id']; $booking_id = $row['booking_id'];
$booking_id++; $booking_id++;
$uid = $booking_id.'-1-'.date('dmY'); $uid = $booking_id.'-1-'.date('dmY');
$creator = 999; $creator = 999;
$created_by = 'Hotsoft'; $created_by = 'Hotsoft';
$stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1"); $stmt = $DB_con->prepare("UPDATE hotspot_vouchers set status=:status WHERE 1");
$stmt->execute(array(':status' => 'Over')); $stmt->execute(array(':status' => 'Over'));
$stmt = $DB_con->prepare("insert into hotspot_vouchers (created_on, created_by, creator, user_name, password, printed_times, $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) 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, values(NOW(), :created_by, :creator, :user_name, :password, :printed_times, :printed_last, :status, :group_of,
:booking_id, :limit_uptime, :limit_bytes, :profile, :uid)"); :booking_id, :limit_uptime, :limit_bytes, :profile, :uid)");
$stmt->execute(array(':created_by' => $created_by, ':creator' => $creator, ':user_name' => $username, ':password' => $password, $stmt->execute(array(':created_by' => $created_by, ':creator' => $creator, ':user_name' => $username, ':password' => $password,
':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => 1, ':printed_times' => 0, ':printed_last' => '', ':status' => 'Active', ':group_of' => 1,
':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes, ':booking_id' => $booking_id, ':limit_uptime' => $limit_uptime, ':limit_bytes' => $limit_bytes,
':profile' => $profile, ':uid' => $uid)); ':profile' => $profile, ':uid' => $uid));
echo 0; //Success echo 0; //Success
} }
else else
{ {
echo 3; // Duplicate/Existing username echo 3; // Duplicate/Existing username
} }
} }
else else
{ {
echo 2; //Blank Username echo 2; //Blank Username
} }
//End Adding a Guest User //End Adding a Guest User
} }
elseif (strtolower($action) == 'checkout')) { elseif (strtolower($action) == 'checkout')) {
//Removal //Removal
$username=trim($_GET['username']); $username=trim($_GET['username']);
if (!empty($username)) { if (!empty($username)) {
$printRequest = new RouterOS\Request('/ip/hotspot/user/print'); $printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id,name'); $printRequest->setArgument('.proplist', '.id,name');
$printRequest->setQuery(RouterOS\Query::where('name', $username)); $printRequest->setQuery(RouterOS\Query::where('name', $username));
$id = $client->sendSync($printRequest)->getProperty('.id'); $id = $client->sendSync($printRequest)->getProperty('.id');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove'); $removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
$removeRequest->setArgument('numbers', $id); $removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest); $client->sendSync($removeRequest);
echo 0; //Success echo 0; //Success
} }
else else
{ {
echo 2; //Blank Username echo 2; //Blank Username
} }
} }
else else
{ {
echo 1; //Wrong Action Verb echo 1; //Wrong Action Verb
} }
?> ?>

910
index.php
View file

@ -1,881 +1,31 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<?php <link rel="icon" href="favicon.ico" type="image/x-icon"/>
//Start session <?php
if ( !isset($_SESSION) ) session_start(); //Start session
//Check whether the session variables present or not, and assign them to Ordinary variables, if present. if ( !isset($_SESSION) ) session_start();
if (!isset($_SESSION['user_level']) || (trim($_SESSION['user_level']) == '' || (trim($_SESSION['user_level']) >= 4))) { //Check whether the session variables present or not, and assign them to Ordinary variables, if present.
header("location:login.php"); 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 <?php if ( !isset($_SESSION) ) session_start(); ?>
use PEAR2\Net\RouterOS; <?php error_reporting(E_ALL);
require_once 'PEAR2/Autoload.php'; ini_set('display_errors', 1); ?>
require_once 'config.php';
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass")); <?php include('header.php'); ?>
?> <?php include('dbconfig.php'); ?>
<?php
<body> use PEAR2\Net\RouterOS;
<div class="container"> require_once 'PEAR2/Autoload.php';
<div class="no_print"> require_once 'config.php';
<!-- Start Logo Section --> try {
<section id="logo-section" class="text-center"> $util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass"));
<div class="container"> $printRequest = new RouterOS\Request('/ip/hotspot/user/print');
<div class="row"> include_once('home.php');
<div class="col-md-12"> }
<div class="logo text-center"> catch (Exception $e) {
<h1>Easy HotSpot</h1> include_once('settings.php');
<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');
?> ?>

180
info.php
View file

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

192
login.php
View file

@ -1,97 +1,97 @@
<?php include('header.php'); ?> <?php include('header.php'); ?>
<?php if ( !isset($_SESSION) ) session_start(); ?> <?php if ( !isset($_SESSION) ) session_start(); ?>
<?php error_reporting(E_ALL); <?php error_reporting(E_ALL);
ini_set('display_errors', 1); ?> ini_set('display_errors', 1); ?>
<div class="container"> <div class="container">
<header> <header>
<h1 style="text-align:center;">Easy Hotspot</h1> <h1 style="text-align:center;">Easy Hotspot</h1>
<h2 style="text-align:center;">Simple HotSpot User Management Utility</h2> <h2 style="text-align:center;">Simple HotSpot User Management Utility</h2>
<h3 style="text-align:center;">By TEAM ZETOZONE</h3> <h3 style="text-align:center;">By TEAM ZETOZONE</h3>
</header> </header>
<div class="row"> <div class="row">
<div class="col-sm-6 col-sm-offset-3 well" style="box-shadow: 10px 10px 5px #888888;"> <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-primary">
<div class="panel panel-heading"> <div class="panel panel-heading">
<p><strong>Login using Registered Credentials</strong></p> <p><strong>Login using Registered Credentials</strong></p>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" id="loginform" action="" method="POST"> <form class="form-horizontal" id="loginform" action="" method="POST">
<div class="form-group form-group-sm"> <div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputEmail">Username</label> <label class="col-sm-2 control-label" for="inputEmail">Username</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="text" id="txt_username" name="username" placeholder="Registered Username" required class="form-control" autofocus> <input type="text" id="txt_username" name="username" placeholder="Registered Username" required class="form-control" autofocus>
</div> </div>
</div> </div>
<div class="form-group form-group-sm"> <div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="inputPassword">Password</label> <label class="col-sm-2 control-label" for="inputPassword">Password</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input type="password" id="txt_password" name="password" placeholder="Password" placeholder="Password" required class="form-control"> <input type="password" id="txt_password" name="password" placeholder="Password" placeholder="Password" required class="form-control">
</div> </div>
</div> </div>
<div class="form-group form-group-sm"> <div class="form-group form-group-sm">
<div class="col-sm-2 col-sm-offset-4"> <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> <button id="btn_login" name="btn_login" type="submit" class="btn btn-primary">&nbsp;Submit</button>
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<button id="btn_cancel" name="btn_cancel" type="reset" class="btn btn-success">&nbsp;Cancel</button> <button id="btn_cancel" name="btn_cancel" type="reset" class="btn btn-success">&nbsp;Cancel</button>
</div> </div>
</div> </div>
</form> </form>
<?php <?php
if (isset($_POST['btn_login'])){ if (isset($_POST['btn_login'])){
$username = $_POST['username']; $username = $_POST['username'];
$password = $_POST['password']; $password = $_POST['password'];
$password= sha1($password); $password= sha1($password);
include('dbconfig.php'); include('dbconfig.php');
try { try {
$stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1"); $stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1");
$stmt->execute(array()); $stmt->execute(array());
} }
catch(PDOException $e) { catch(PDOException $e) {
try { try {
include('database.php'); include('database.php');
$stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1"); $stmt = $DB_con->prepare("SELECT user_id FROM hotspot_users WHERE 1");
$stmt->execute(array()); $stmt->execute(array());
} }
catch(PDOException $e) { catch(PDOException $e) {
echo "Error Accessing Data: " . $e->getMessage(); echo "Error Accessing Data: " . $e->getMessage();
} }
} }
$count = $stmt->rowCount(); $count = $stmt->rowCount();
if( $count == 0 ) { if( $count == 0 ) {
$password = sha1('admin'); $password = sha1('admin');
$stmt = $DB_con->prepare("insert into hotspot_users (date_added, firstname, username, password, user_level, status, user_group, created_at) $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())"); values(CURDATE(), 'Administrator', :username, :password, :level, 'Active', 1, NOW())");
$stmt->execute(array(':username' => 'admin', ':password' => $password, ':level' => 1)); $stmt->execute(array(':username' => 'admin', ':password' => $password, ':level' => 1));
} }
try try
{ {
$stmt = $DB_con->prepare("SELECT * FROM hotspot_users WHERE username=:username AND password =:password AND status =:status"); $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')); $stmt->execute(array(':username' => $username, ':password' => $password, ':status' => 'Active'));
$count = $stmt->rowCount(); $count = $stmt->rowCount();
} }
catch(PDOException $e) { catch(PDOException $e) {
echo "Error: " . $e->getMessage(); echo "Error: " . $e->getMessage();
} }
if( $count == 1 ) { if( $count == 1 ) {
$row=$stmt->fetch(PDO::FETCH_ASSOC); $row=$stmt->fetch(PDO::FETCH_ASSOC);
$_SESSION['id']=$row['user_id']; $_SESSION['id']=$row['user_id'];
$_SESSION['username']=$row['firstname'].' '.$row['lastname']; $_SESSION['username']=$row['firstname'].' '.$row['lastname'];
$_SESSION['user_level']= $row['user_level']; $_SESSION['user_level']= $row['user_level'];
echo '<script language="javascript">window.location.href ="index.php";</script>'; echo '<script language="javascript">window.location.href ="index.php";</script>';
} }
else else
{ {
echo '<script>cmodal("Access Denied!", "No Active User account with the given Username/Password Combination!", "error", "index.php")</script>'; echo '<script>cmodal("Access Denied!", "No Active User account with the given Username/Password Combination!", "error", "index.php")</script>';
} }
} }
?> ?>
</div> </div>
</div> </div>
</div> </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 <?php
session_start(); session_start();
session_unset(); session_unset();
session_destroy(); session_destroy();
//echo '<script>window.open("backup.php", "_self").close(); top.close(); window.open("backup.php", "_self", ""); window.close();</script>'; //echo '<script>window.open("backup.php", "_self").close(); top.close(); window.open("backup.php", "_self", ""); window.close();</script>';
header('location:index.php'); 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="child-modal modal fade" id="change-password" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form class="form-horizontal" id="chPassword" method="post"> <form class="form-horizontal" id="chPassword" method="post">
<div class="modal-body"> <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="alert alert-info text-center"><strong>Welcome <?php echo $_SESSION['username'].', '; ?> Change Your Login Password</strong></div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-6">Type-in New Password</label> <label class="control-label col-sm-6">Type-in New Password</label>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="input-group"> <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"> <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 id='chPassword_np_errorloc' class="error_strings"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-6">Re-type New Password</label> <label class="control-label col-sm-6">Re-type New Password</label>
<div class="col-sm-6"> <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"> <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 id='chPassword_rp_errorloc' class="error_strings"></div>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="col-sm-3 col-sm-offset-3"> <div class="col-sm-3 col-sm-offset-3">
<div class="pull-right"> <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> <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> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="pull-left"> <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> <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>
</div> </div>
</div> </div>
</form> </form>
<!-- <script type="text/javascript"> <!-- <script type="text/javascript">
var frmvalidator = new Validator("chPassword"); var frmvalidator = new Validator("chPassword");
frmvalidator.EnableOnPageErrorDisplay(); frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether(); frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("np","req","Please enter your New Password"); frmvalidator.addValidation("np","req","Please enter your New Password");
frmvalidator.addValidation("np","regexp=^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$", 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"); "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","req","Please retype your New Password");
frmvalidator.addValidation("rp","regexp=^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$", 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"); "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"); frmvalidator.addValidation("np","eqelmnt=rp", "Both Passwords should be same");
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
window.onload = function (){ window.onload = function (){
eventHandler = function (e){ eventHandler = function (e){
if (e.keyCode === 13 ) //Enter key to Trap if (e.keyCode === 13 ) //Enter key to Trap
{ {
event.preventDefault(); event.preventDefault();
$("#update_pass").trigger('click'); /* $("#update_pass").trigger('click'); /*
var cti = document.activeElement.tabIndex; var cti = document.activeElement.tabIndex;
if (cti == 1 ) if (cti == 1 )
$('[tabindex=' + (cti + 1) + ']').focus(); $('[tabindex=' + (cti + 1) + ']').focus();
else else
$('[tabindex=' + (cti - 1) + ']').focus(); $('[tabindex=' + (cti - 1) + ']').focus();
return false; */ return false; */
} }
} }
window.addEventListener('keydown', eventHandler, false); window.addEventListener('keydown', eventHandler, false);
} ; } ;
</script> --> </script> -->
</div> </div>
</div> </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 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-dialog">
<div class="modal-content"> <div class="modal-content">
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post">
<div class="modal-body"> <div class="modal-body">
<div class="alert alert-info text-center"><strong>Delete Guest User</strong></div> <div class="alert alert-info text-center"><strong>Delete Guest User</strong></div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Username</label> <label class="control-label col-xs-3" for="inputEmail">Username</label>
<div class="col-xs-7"> <div class="col-xs-7">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span> <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> <input type="text" id="username" size="40" name="username" value="<?php echo $item->getProperty('name'); ?>" readonly>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3" for="inputPassword">Limit Uptime</label> <label class="control-label col-xs-3" for="inputPassword">Limit Uptime</label>
<div class="col-xs-7"> <div class="col-xs-7">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span> <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> <input type="text" name="uptime" value="<?php echo $item->getProperty('limit-uptime'); ?>" id="inputPassword" readonly>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Address</label> <label class="control-label col-xs-3" for="inputEmail">Address</label>
<div class="col-xs-7"> <div class="col-xs-7">
<input type="text" id="inputEmail" name="firstname" value="<?php echo $item->getProperty('address'); ?>" readonly> <input type="text" id="inputEmail" name="firstname" value="<?php echo $item->getProperty('address'); ?>" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Uptime</label> <label class="control-label col-xs-3" for="inputEmail">Uptime</label>
<div class="col-xs-7"> <div class="col-xs-7">
<input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('uptime'); ?>" readonly> <input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('uptime'); ?>" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Session time Left</label> <label class="control-label col-xs-3" for="inputEmail">Session time Left</label>
<div class="col-xs-7"> <div class="col-xs-7">
<input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('session-time-left'); ?>" readonly> <input type="text" id="inputEmail" name="lastname" value="<?php echo $item->getProperty('session-time-left'); ?>" readonly>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="col-sm-3 col-sm-offset-3"> <div class="col-sm-3 col-sm-offset-3">
<div class="pull-right"> <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> <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> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="pull-left"> <div class="pull-left">
<button class="btn btn-error" data-dismiss="modal" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button> <button class="btn btn-error" data-dismiss="modal" ><i class="icon-save icon-large"></i></a>&nbsp;BACK</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
</div> </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 id="getProfileModal" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post">
<div class="modal-body"> <div class="modal-body">
<div class="alert alert-info text-center"><strong>HotSpot User Profiles for Guest Users</strong></div> <div class="alert alert-info text-center"><strong>HotSpot User Profiles for Guest Users</strong></div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">Profile Name</label> <label class="control-label col-xs-3">Profile Name</label>
<div class="col-xs-7"> <div class="col-xs-7">
<div class="input-group"> <div class="input-group">
<input type="hidden" id="profile_id" name="id" > <input type="hidden" id="profile_id" name="id" >
<input type="text" id="profile_name" size="40" onChange="genClick();" required tabindex="1" autofocus> <input type="text" id="profile_name" size="40" onChange="genClick();" required tabindex="1" autofocus>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">Session Timeout</label> <label class="control-label col-xs-3">Session Timeout</label>
<div class="col-xs-7"> <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"> <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> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">Rate limit - Download(Rx)</label> <label class="control-label col-xs-3">Rate limit - Download(Rx)</label>
<div class="col-xs-3"> <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"> <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></option>
<option value="256k">256 Kbps</option> <option value="256k">256 Kbps</option>
<option value="512k">512 Kbps</option> <option value="512k">512 Kbps</option>
<option value="1M">1 Mbps</option> <option value="1M">1 Mbps</option>
<option value="2M">2 Mbps</option> <option value="2M">2 Mbps</option>
<option value="3M">3 Mbps</option> <option value="3M">3 Mbps</option>
<option value="4M">4 Mbps</option> <option value="4M">4 Mbps</option>
<option value="5M">5 Mbps</option> <option value="5M">5 Mbps</option>
<option value="6M">6 Mbps</option> <option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option> <option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option> <option value="8M">8 Mbps</option>
</select> </select>
</div> </div>
<label class="control-label col-xs-3 pull-left">Rate limit - Upload(Tx)</label> <label class="control-label col-xs-3 pull-left">Rate limit - Upload(Tx)</label>
<div class="col-xs-3 pull-left"> <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"> <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></option>
<option value="128k">128 Kbps</option> <option value="128k">128 Kbps</option>
<option value="256k">256 Kbps</option> <option value="256k">256 Kbps</option>
<option value="512k">512 Kbps</option> <option value="512k">512 Kbps</option>
<option value="1M">1 Mbps</option> <option value="1M">1 Mbps</option>
<option value="2M">2 Mbps</option> <option value="2M">2 Mbps</option>
<option value="3M">3 Mbps</option> <option value="3M">3 Mbps</option>
<option value="4M">4 Mbps</option> <option value="4M">4 Mbps</option>
<option value="5M">5 Mbps</option> <option value="5M">5 Mbps</option>
<option value="6M">6 Mbps</option> <option value="6M">6 Mbps</option>
<option value="7M">7 Mbps</option> <option value="7M">7 Mbps</option>
<option value="8M">8 Mbps</option> <option value="8M">8 Mbps</option>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">Shared Users</label> <label class="control-label col-xs-3">Shared Users</label>
<div class="col-xs-7"> <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"> <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> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">MAC Cookie Timeout</label> <label class="control-label col-xs-3">MAC Cookie Timeout</label>
<div class="col-xs-3"> <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"> <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> </div>
<label class="control-label col-xs-3 pull-left">Keep Alive Timeout</label> <label class="control-label col-xs-3 pull-left">Keep Alive Timeout</label>
<div class="col-xs-3 pull-left"> <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"> <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>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="col-sm-10 col-sm-offset-1"> <div class="col-sm-10 col-sm-offset-1">
<?php <?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="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="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="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>'; 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>
</div> </div>
</form> </form>
</div> </div>
</div> </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 id="getUserModal" class="child-modal modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<form class="form-horizontal" method="post"> <form class="form-horizontal" method="post">
<div class="modal-body"> <div class="modal-body">
<div class="alert alert-info text-center"><strong>Edit System User</strong></div> <div class="alert alert-info text-center"><strong>Edit System User</strong></div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">Username</label> <label class="control-label col-xs-3">Username</label>
<div class="col-xs-7"> <div class="col-xs-7">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span> <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="hidden" id="user_id" name="id" >
<input type="text" id="username" size="40" onChange="genClick();" name="username" required tabindex="1" autofocus> <input type="text" id="username" size="40" onChange="genClick();" name="username" required tabindex="1" autofocus>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">Firstname</label> <label class="control-label col-xs-3">Firstname</label>
<div class="col-xs-7"> <div class="col-xs-7">
<input type="text" id="firstname" onChange="genClick();" name="firstname" required tabindex="2"> <input type="text" id="firstname" onChange="genClick();" name="firstname" required tabindex="2">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">Lastname</label> <label class="control-label col-xs-3">Lastname</label>
<div class="col-xs-7"> <div class="col-xs-7">
<input type="text" id="lastname" onChange="genClick();" name="lastname" tabindex="3"> <input type="text" id="lastname" onChange="genClick();" name="lastname" tabindex="3">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">User Level</label> <label class="control-label col-xs-3">User Level</label>
<div class="col-xs-7"> <div class="col-xs-7">
<select id="user_level" onChange="genClick();" name="user_level" required tabindex="4"> <select id="user_level" onChange="genClick();" name="user_level" required tabindex="4">
<?php <?php
switch ($row['user_level']) { switch ($row['user_level']) {
case 1 : case 1 :
echo '<option value="1">Administrator</option>'; echo '<option value="1">Administrator</option>';
break; break;
case 2 : case 2 :
echo '<option value="2">Unit Head</option>'; echo '<option value="2">Unit Head</option>';
break; break;
case 3 : case 3 :
echo '<option value="3">System User</option>'; echo '<option value="3">System User</option>';
break; break;
} ?> } ?>
<option value="3">System User</option> <option value="3">System User</option>
<option value="2">Unit Head</option> <option value="2">Unit Head</option>
<option value="1">Administrator</option> <option value="1">Administrator</option>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-3">User Status</label> <label class="control-label col-xs-3">User Status</label>
<div class="col-xs-3"> <div class="col-xs-3">
<select class="myCombo" id="status" onChange="genClick();" name="user_status" required tabindex="5"> <select class="myCombo" id="status" onChange="genClick();" name="user_status" required tabindex="5">
<option></option> <option></option>
<option value="Active">Active</option> <option value="Active">Active</option>
<option value="Disabled">Disabled</option> <option value="Disabled">Disabled</option>
</select> </select>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="col-sm-12"> <div class="col-sm-12">
<?php <?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="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="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="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="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>'; 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>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>

View file

@ -1,6 +1,67 @@
<?php <?php
use PEAR2\Net\RouterOS; if (isset($_POST['btn_update'])){
require_once 'PEAR2/Autoload.php'; $newhost = $_POST['newhost'];
require_once 'config.php'; $newuser = $_POST['newuser'];
$util = new RouterOS\Util($client = new RouterOS\Client("$host", "$user", "$pass")); $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