Show error, and fix IP Port custom

This commit is contained in:
Ibnu Maksum 2022-08-23 16:33:21 +07:00
parent 90a08cb731
commit 6eaede3c6e
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
11 changed files with 1020 additions and 936 deletions

View File

@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
**/
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);
require ('system/boot.php');
App::_run();

View File

@ -46,9 +46,10 @@ switch ($action) {
$mikrotik = Router::_info($c['routers']);
if($c['type'] == 'Hotspot'){
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id');
@ -80,9 +81,10 @@ switch ($action) {
}else{
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id');

View File

@ -64,9 +64,10 @@ switch ($action) {
$mikrotik = Router::_info($c['routers']);
if($c['type'] == 'Hotspot'){
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id');
@ -90,9 +91,10 @@ switch ($action) {
}else{
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id');
@ -220,9 +222,10 @@ switch ($action) {
$mikrotik = Router::_info($c['routers']);
if($c['type'] == 'Hotspot'){
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id');
@ -249,9 +252,10 @@ switch ($action) {
}else{
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id');

View File

@ -65,9 +65,10 @@ switch ($action) {
$mikrotik = Router::_info($d['routers']);
if($d){
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ip pool print .proplist=name',
@ -106,9 +107,10 @@ switch ($action) {
$mikrotik = Router::_info($routers);
if($msg == ''){
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$addRequest = new RouterOS\Request('/ip/pool/add');
$client->sendSync($addRequest
@ -153,9 +155,10 @@ switch ($action) {
$mikrotik = Router::_info($routers);
if($msg == ''){
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":",$mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ip pool print .proplist=name',

View File

@ -91,9 +91,10 @@ switch ($action) {
if ($type == 'Hotspot') {
if ($b) {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
@ -191,9 +192,10 @@ switch ($action) {
$t->save();
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
/* iBNuX Added:
@ -285,9 +287,10 @@ switch ($action) {
if ($b) {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ppp secret print .proplist=name',
@ -338,9 +341,10 @@ switch ($action) {
$t->save();
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$addRequest = new RouterOS\Request('/ppp/secret/add');
$client->sendSync(
@ -424,9 +428,10 @@ switch ($action) {
if ($d) {
if ($d['type'] == 'Hotspot') {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ip hotspot user print .proplist=name',
@ -442,9 +447,10 @@ switch ($action) {
$d->delete();
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ppp secret print .proplist=name',
@ -682,9 +688,10 @@ switch ($action) {
if ($v1['type'] == 'Hotspot') {
if ($b) {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ip hotspot user print .proplist=name',
@ -781,9 +788,10 @@ switch ($action) {
$t->save();
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
/* iBNuX Added:
* Time limit to Mikrotik
@ -877,9 +885,10 @@ switch ($action) {
} else {
if ($b) {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ppp secret print .proplist=name',
@ -930,9 +939,10 @@ switch ($action) {
$t->save();
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$addRequest = new RouterOS\Request('/ppp/secret/add');
$client->sendSync(

View File

@ -1,21 +1,24 @@
<?php
/**
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* created by iBNuX
**/
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* created by iBNuX
**/
if (isset($routes['1'])) {
$do = $routes['1'];
} else {
$do = 'register-display';
}
use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
switch($do){
switch ($do) {
case 'post':
$username = _post('username');
@ -25,35 +28,34 @@ switch($do){
$address = _post('address');
$phonenumber = _post('phonenumber');
$code = _post('kodevoucher');
$v1 = ORM::for_table('tbl_voucher')->where('code',$code)->where('status',0)->find_one();
if ($v1){
$v1 = ORM::for_table('tbl_voucher')->where('code', $code)->where('status', 0)->find_one();
if ($v1) {
$msg = '';
if(Validator::Length($username,35,2) == false){
$msg .= 'Username should be between 3 to 55 characters'. '<br>';
if (Validator::Length($username, 35, 2) == false) {
$msg .= 'Username should be between 3 to 55 characters' . '<br>';
}
if(Validator::Length($fullname,36,2) == false){
$msg .= 'Full Name should be between 3 to 25 characters'. '<br>';
if (Validator::Length($fullname, 36, 2) == false) {
$msg .= 'Full Name should be between 3 to 25 characters' . '<br>';
}
if(!Validator::Length($password,35,2)){
$msg .= 'Password should be between 3 to 35 characters'. '<br>';
if (!Validator::Length($password, 35, 2)) {
$msg .= 'Password should be between 3 to 35 characters' . '<br>';
}
if($password != $cpassword){
$msg .= $_L['PasswordsNotMatch']. '<br>';
if ($password != $cpassword) {
$msg .= $_L['PasswordsNotMatch'] . '<br>';
}
$d = ORM::for_table('tbl_customers')->where('username',$username)->find_one();
if($d){
$msg .= $_L['account_already_exist']. '<br>';
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
if ($d) {
$msg .= $_L['account_already_exist'] . '<br>';
}
if($msg == ''){
if ($msg == '') {
$d = ORM::for_table('tbl_customers')->create();
$d->username = $username;
$d->password = $password;
$d->fullname = $fullname;
$d->address = $address;
$d->phonenumber = $phonenumber;
if($d->save()){
if ($d->save()) {
$user = $d->id();
//check voucher plan
$p = ORM::for_table('tbl_plans')->find_one($v1['id_plan']);
@ -65,52 +67,56 @@ switch($do){
$time = date("H:i:s");
$mikrotik = Router::_info($v1['routers']);
$date_exp = date("Y-m-d", mktime(0,0,0,date("m"),date("d") + $p['validity'],date("Y")));
$date_exp = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + $p['validity'], date("Y")));
if($v1['type'] == 'Hotspot'){
if ($v1['type'] == 'Hotspot') {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
/* iBNuX Added:
* Time limit to Mikrotik
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
*/
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
if($p['typebp']=="Limited"){
if($p['limit_type']=="Time_Limit"){
if($p['time_unit']=='Hrs')
$timelimit = $p['time_limit'].":00:00";
if ($p['typebp'] == "Limited") {
if ($p['limit_type'] == "Time_Limit") {
if ($p['time_unit'] == 'Hrs')
$timelimit = $p['time_limit'] . ":00:00";
else
$timelimit = "00:".$p['time_limit'].":00";
$client->sendSync($addRequest
$timelimit = "00:" . $p['time_limit'] . ":00";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
->setArgument('limit-uptime', $timelimit)
);
}else if($p['limit_type']=="Data_Limit"){
if($p['data_unit']=='GB')
$datalimit = $p['data_limit']."000000000";
} else if ($p['limit_type'] == "Data_Limit") {
if ($p['data_unit'] == 'GB')
$datalimit = $p['data_limit'] . "000000000";
else
$datalimit = $p['data_limit']."000000";
$client->sendSync($addRequest
$datalimit = $p['data_limit'] . "000000";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
->setArgument('limit-bytes-total', $datalimit)
);
}else if($p['limit_type']=="Both_Limit"){
if($p['time_unit']=='Hrs')
$timelimit = $p['time_limit'].":00:00";
} else if ($p['limit_type'] == "Both_Limit") {
if ($p['time_unit'] == 'Hrs')
$timelimit = $p['time_limit'] . ":00:00";
else
$timelimit = "00:".$p['time_limit'].":00";
if($p['data_unit']=='GB')
$datalimit = $p['data_limit']."000000000";
$timelimit = "00:" . $p['time_limit'] . ":00";
if ($p['data_unit'] == 'GB')
$datalimit = $p['data_limit'] . "000000000";
else
$datalimit = $p['data_limit']."000000";
$client->sendSync($addRequest
$datalimit = $p['data_limit'] . "000000";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
@ -118,8 +124,9 @@ switch($do){
->setArgument('limit-bytes-total', $datalimit)
);
}
}else{
$client->sendSync($addRequest
} else {
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
@ -142,7 +149,7 @@ switch($do){
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->invoice = "INV-" . _raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -157,15 +164,16 @@ switch($do){
$v1->status = "1";
$v1->user = $c['username'];
$v1->save();
}else{
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$addRequest = new RouterOS\Request('/ppp/secret/add');
$client->sendSync($addRequest
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('service', 'pppoe')
->setArgument('profile', $p['name_plan'])
@ -188,7 +196,7 @@ switch($do){
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->invoice = "INV-" . _raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -205,12 +213,12 @@ switch($do){
$v1->save();
}
r2(U . 'login', 's', $_L['Register_Success']);
}else{
} else {
$ui->assign('username', $username);
$ui->assign('fullname', $fullname);
$ui->assign('address', $address);
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify','<div class="alert alert-danger">
$ui->assign('notify', '<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
@ -218,28 +226,28 @@ switch($do){
$ui->display('register.tpl');
}
//r2(U . 'register', 's', $_L['account_created_successfully']);
}else{
} else {
$ui->assign('username', $username);
$ui->assign('fullname', $fullname);
$ui->assign('address', $address);
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify','<div class="alert alert-danger">
$ui->assign('notify', '<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
<div>'.$msg.'</div></div>');
<div>' . $msg . '</div></div>');
$ui->display('register.tpl');
}
}else{
} else {
$ui->assign('username', $username);
$ui->assign('fullname', $fullname);
$ui->assign('address', $address);
$ui->assign('phonenumber', $phonenumber);
$ui->assign('notify','<div class="alert alert-danger">
$ui->assign('notify', '<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">×</span>
</button>
<div>'.$_L['Voucher_Not_Valid'].'</div></div>');
<div>' . $_L['Voucher_Not_Valid'] . '</div></div>');
$ui->display('register.tpl');
//r2(U . 'register', 'e', $_L['Voucher_Not_Valid']);
}
@ -278,4 +286,3 @@ switch($do){
$ui->display('register.tpl');
break;
}

View File

@ -1,25 +1,27 @@
<?php
/**
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
* @license GNU General Public License version 2 or later; see LICENSE.txt
**/
**/
_admin();
$ui->assign('_title', $_L['Hotspot_Plans'].' - '. $config['CompanyName']);
$ui->assign('_title', $_L['Hotspot_Plans'] . ' - ' . $config['CompanyName']);
$ui->assign('_system_menu', 'services');
$action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if($admin['user_type'] != 'Admin' AND $admin['user_type'] != 'Sales'){
r2(U."dashboard",'e',$_L['Do_Not_Access']);
if ($admin['user_type'] != 'Admin' and $admin['user_type'] != 'Sales') {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
switch ($action) {
@ -27,24 +29,24 @@ switch ($action) {
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/hotspot.js"></script>');
$name = _post('name');
if ($name != ''){
$paginator = Paginator::bootstrap('tbl_plans','name_plan','%'.$name.'%','type','Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type','Hotspot')->where_like('tbl_plans.name_plan','%'.$name.'%')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
}else{
$paginator = Paginator::bootstrap('tbl_plans','type','Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type','Hotspot')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
if ($name != '') {
$paginator = Paginator::bootstrap('tbl_plans', 'name_plan', '%' . $name . '%', 'type', 'Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'Hotspot')->where_like('tbl_plans.name_plan', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} else {
$paginator = Paginator::bootstrap('tbl_plans', 'type', 'Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'Hotspot')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
}
$ui->assign('d',$d);
$ui->assign('paginator',$paginator);
$ui->assign('d', $d);
$ui->assign('paginator', $paginator);
$ui->display('hotspot.tpl');
break;
case 'add':
$d = ORM::for_table('tbl_bandwidth')->find_many();
$ui->assign('d',$d);
$ui->assign('d', $d);
$r = ORM::for_table('tbl_routers')->find_many();
$ui->assign('r',$r);
$ui->assign('r', $r);
$ui->display('hotspot-add.tpl');
break;
@ -52,15 +54,15 @@ switch ($action) {
case 'edit':
$id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if($d){
$ui->assign('d',$d);
if ($d) {
$ui->assign('d', $d);
$b = ORM::for_table('tbl_bandwidth')->find_many();
$ui->assign('b',$b);
$ui->assign('b', $b);
$r = ORM::for_table('tbl_routers')->find_many();
$ui->assign('r',$r);
$ui->assign('r', $r);
$ui->display('hotspot-edit.tpl');
}else{
} else {
r2(U . 'services/hotspot', 'e', $_L['Account_Not_Found']);
}
break;
@ -69,12 +71,13 @@ switch ($action) {
$id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if($d){
if ($d) {
$mikrotik = Router::_info($d['routers']);
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ip hotspot user profile print .proplist=name',
@ -83,7 +86,8 @@ switch ($action) {
$profileName = $client->sendSync($printRequest)->getProperty('name');
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
$client($removeRequest
$client(
$removeRequest
->setArgument('numbers', $profileName)
);
@ -109,35 +113,45 @@ switch ($action) {
$routers = _post('routers');
$msg = '';
if(Validator::UnsignedNumber($validity) == false){
$msg .= 'The validity must be a number'. '<br>';
if (Validator::UnsignedNumber($validity) == false) {
$msg .= 'The validity must be a number' . '<br>';
}
if(Validator::UnsignedNumber($price) == false){
$msg .= 'The price must be a number'. '<br>';
if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>';
}
if ($name == '' OR $id_bw == '' OR $price == '' OR $validity == '' OR $routers == ''){
$msg .= $_L['All_field_is_required']. '<br>';
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '') {
$msg .= $_L['All_field_is_required'] . '<br>';
}
$d = ORM::for_table('tbl_plans')->where('name_plan',$name)->where('type','Hotspot')->find_one();
if($d){
$msg .= $_L['Plan_already_exist']. '<br>';
$d = ORM::for_table('tbl_plans')->where('name_plan', $name)->where('type', 'Hotspot')->find_one();
if ($d) {
$msg .= $_L['Plan_already_exist'] . '<br>';
}
if($msg == ''){
$b = ORM::for_table('tbl_bandwidth')->where('id',$id_bw)->find_one();
if($b['rate_down_unit'] == 'Kbps'){ $unitdown = 'K'; }else{ $unitdown = 'M'; }
if($b['rate_up_unit'] == 'Kbps'){ $unitup = 'K'; }else{ $unitup = 'M'; }
$rate = $b['rate_up'].$unitup."/".$b['rate_down'].$unitdown;
if ($msg == '') {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K';
} else {
$unitdown = 'M';
}
if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K';
} else {
$unitup = 'M';
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$mikrotik = Router::_info($routers);
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
$client->sendSync($addRequest
$client->sendSync(
$addRequest
->setArgument('name', $name)
->setArgument('shared-users', $sharedusers)
->setArgument('rate-limit', $rate)
@ -161,7 +175,7 @@ switch ($action) {
$d->save();
r2(U . 'services/hotspot', 's', $_L['Created_Successfully']);
}else{
} else {
r2(U . 'services/add', 'e', $msg);
}
break;
@ -184,33 +198,42 @@ switch ($action) {
$routers = _post('routers');
$msg = '';
if(Validator::UnsignedNumber($validity) == false){
$msg .= 'The validity must be a number'. '<br>';
if (Validator::UnsignedNumber($validity) == false) {
$msg .= 'The validity must be a number' . '<br>';
}
if(Validator::UnsignedNumber($price) == false){
$msg .= 'The price must be a number'. '<br>';
if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>';
}
if ($name == '' OR $id_bw == '' OR $price == '' OR $validity == '' OR $routers == ''){
$msg .= $_L['All_field_is_required']. '<br>';
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '') {
$msg .= $_L['All_field_is_required'] . '<br>';
}
$d = ORM::for_table('tbl_plans')->where('id',$id)->find_one();
if($d){
}else{
$msg .= $_L['Data_Not_Found']. '<br>';
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
if ($d) {
} else {
$msg .= $_L['Data_Not_Found'] . '<br>';
}
if($msg == ''){
$b = ORM::for_table('tbl_bandwidth')->where('id',$id_bw)->find_one();
if($b['rate_down_unit'] == 'Kbps'){ $unitdown = 'K'; }else{ $unitdown = 'M'; }
if($b['rate_up_unit'] == 'Kbps'){ $unitup = 'K'; }else{ $unitup = 'M'; }
$rate = $b['rate_up'].$unitup."/".$b['rate_down'].$unitdown;
if ($msg == '') {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K';
} else {
$unitdown = 'M';
}
if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K';
} else {
$unitup = 'M';
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$mikrotik = Router::_info($routers);
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ip hotspot user profile print .proplist=name',
@ -219,7 +242,8 @@ switch ($action) {
$profileName = $client->sendSync($printRequest)->getProperty('name');
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
$client($setRequest
$client(
$setRequest
->setArgument('numbers', $profileName)
->setArgument('shared-users', $sharedusers)
->setArgument('rate-limit', $rate)
@ -241,8 +265,8 @@ switch ($action) {
$d->save();
r2(U . 'services/hotspot', 's', $_L['Updated_Successfully']);
}else{
r2(U . 'services/edit/'.$id, 'e', $msg);
} else {
r2(U . 'services/edit/' . $id, 'e', $msg);
}
break;
@ -250,26 +274,26 @@ switch ($action) {
$ui->assign('xfooter', '<script type="text/javascript" src="ui/lib/c/pppoe.js"></script>');
$name = _post('name');
if ($name != ''){
$paginator = Paginator::bootstrap('tbl_plans','name_plan','%'.$name.'%','type','Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type','PPPOE')->where_like('tbl_plans.name_plan','%'.$name.'%')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
}else{
$paginator = Paginator::bootstrap('tbl_plans','type','Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type','PPPOE')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
if ($name != '') {
$paginator = Paginator::bootstrap('tbl_plans', 'name_plan', '%' . $name . '%', 'type', 'Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE')->where_like('tbl_plans.name_plan', '%' . $name . '%')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
} else {
$paginator = Paginator::bootstrap('tbl_plans', 'type', 'Hotspot');
$d = ORM::for_table('tbl_bandwidth')->join('tbl_plans', array('tbl_bandwidth.id', '=', 'tbl_plans.id_bw'))->where('tbl_plans.type', 'PPPOE')->offset($paginator['startpoint'])->limit($paginator['limit'])->find_many();
}
$ui->assign('d',$d);
$ui->assign('paginator',$paginator);
$ui->assign('d', $d);
$ui->assign('paginator', $paginator);
$ui->display('pppoe.tpl');
break;
case 'pppoe-add':
$d = ORM::for_table('tbl_bandwidth')->find_many();
$ui->assign('d',$d);
$ui->assign('d', $d);
$p = ORM::for_table('tbl_pool')->find_many();
$ui->assign('p',$p);
$ui->assign('p', $p);
$r = ORM::for_table('tbl_routers')->find_many();
$ui->assign('r',$r);
$ui->assign('r', $r);
$ui->display('pppoe-add.tpl');
break;
@ -277,17 +301,17 @@ switch ($action) {
case 'pppoe-edit':
$id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if($d){
$ui->assign('d',$d);
if ($d) {
$ui->assign('d', $d);
$b = ORM::for_table('tbl_bandwidth')->find_many();
$ui->assign('b',$b);
$ui->assign('b', $b);
$p = ORM::for_table('tbl_pool')->find_many();
$ui->assign('p',$p);
$ui->assign('p', $p);
$r = ORM::for_table('tbl_routers')->find_many();
$ui->assign('r',$r);
$ui->assign('r', $r);
$ui->display('pppoe-edit.tpl');
}else{
} else {
r2(U . 'services/pppoe', 'e', $_L['Account_Not_Found']);
}
break;
@ -296,12 +320,13 @@ switch ($action) {
$id = $routes['2'];
$d = ORM::for_table('tbl_plans')->find_one($id);
if($d){
if ($d) {
$mikrotik = Router::_info($d['routers']);
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ppp profile print .proplist=name',
@ -310,7 +335,8 @@ switch ($action) {
$profileName = $client->sendSync($printRequest)->getProperty('name');
$removeRequest = new RouterOS\Request('/ppp/profile/remove');
$client($removeRequest
$client(
$removeRequest
->setArgument('numbers', $profileName)
);
@ -330,35 +356,45 @@ switch ($action) {
$pool = _post('pool_name');
$msg = '';
if(Validator::UnsignedNumber($validity) == false){
$msg .= 'The validity must be a number'. '<br>';
if (Validator::UnsignedNumber($validity) == false) {
$msg .= 'The validity must be a number' . '<br>';
}
if(Validator::UnsignedNumber($price) == false){
$msg .= 'The price must be a number'. '<br>';
if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>';
}
if ($name == '' OR $id_bw == '' OR $price == '' OR $validity == '' OR $routers == '' OR $pool == ''){
$msg .= $_L['All_field_is_required']. '<br>';
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '' or $pool == '') {
$msg .= $_L['All_field_is_required'] . '<br>';
}
$d = ORM::for_table('tbl_plans')->where('name_plan',$name)->find_one();
if($d){
$msg .= $_L['Plan_already_exist']. '<br>';
$d = ORM::for_table('tbl_plans')->where('name_plan', $name)->find_one();
if ($d) {
$msg .= $_L['Plan_already_exist'] . '<br>';
}
if($msg == ''){
$b = ORM::for_table('tbl_bandwidth')->where('id',$id_bw)->find_one();
if($b['rate_down_unit'] == 'Kbps'){ $unitdown = 'K'; }else{ $unitdown = 'M'; }
if($b['rate_up_unit'] == 'Kbps'){ $unitup = 'K'; }else{ $unitup = 'M'; }
$rate = $b['rate_up'].$unitup."/".$b['rate_down'].$unitdown;
if ($msg == '') {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K';
} else {
$unitdown = 'M';
}
if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K';
} else {
$unitup = 'M';
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$mikrotik = Router::_info($routers);
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$addRequest = new RouterOS\Request('/ppp/profile/add');
$client->sendSync($addRequest
$client->sendSync(
$addRequest
->setArgument('name', $name)
->setArgument('local-address', $pool)
->setArgument('remote-address', $pool)
@ -377,7 +413,7 @@ switch ($action) {
$d->save();
r2(U . 'services/pppoe', 's', $_L['Created_Successfully']);
}else{
} else {
r2(U . 'services/pppoe-add', 'e', $msg);
}
break;
@ -393,33 +429,42 @@ switch ($action) {
$pool = _post('pool_name');
$msg = '';
if(Validator::UnsignedNumber($validity) == false){
$msg .= 'The validity must be a number'. '<br>';
if (Validator::UnsignedNumber($validity) == false) {
$msg .= 'The validity must be a number' . '<br>';
}
if(Validator::UnsignedNumber($price) == false){
$msg .= 'The price must be a number'. '<br>';
if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>';
}
if ($name == '' OR $id_bw == '' OR $price == '' OR $validity == '' OR $routers == '' OR $pool == ''){
$msg .= $_L['All_field_is_required']. '<br>';
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '' or $pool == '') {
$msg .= $_L['All_field_is_required'] . '<br>';
}
$d = ORM::for_table('tbl_plans')->where('id',$id)->find_one();
if($d){
}else{
$msg .= $_L['Data_Not_Found']. '<br>';
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
if ($d) {
} else {
$msg .= $_L['Data_Not_Found'] . '<br>';
}
if($msg == ''){
$b = ORM::for_table('tbl_bandwidth')->where('id',$id_bw)->find_one();
if($b['rate_down_unit'] == 'Kbps'){ $unitdown = 'K'; }else{ $unitdown = 'M'; }
if($b['rate_up_unit'] == 'Kbps'){ $unitup = 'K'; }else{ $unitup = 'M'; }
$rate = $b['rate_up'].$unitup."/".$b['rate_down'].$unitdown;
if ($msg == '') {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K';
} else {
$unitdown = 'M';
}
if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K';
} else {
$unitup = 'M';
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$mikrotik = Router::_info($routers);
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request(
'/ppp profile print .proplist=name',
@ -428,7 +473,8 @@ switch ($action) {
$profileName = $client->sendSync($printRequest)->getProperty('name');
$setRequest = new RouterOS\Request('/ppp/profile/set');
$client($setRequest
$client(
$setRequest
->setArgument('numbers', $profileName)
->setArgument('local-address', $pool)
->setArgument('remote-address', $pool)
@ -445,8 +491,8 @@ switch ($action) {
$d->save();
r2(U . 'services/pppoe', 's', $_L['Updated_Successfully']);
}else{
r2(U . 'services/pppoe-edit/'.$id, 'e', $msg);
} else {
r2(U . 'services/pppoe-edit/' . $id, 'e', $msg);
}
break;

View File

@ -1,14 +1,15 @@
<?php
/**
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
* @license GNU General Public License version 2 or later; see LICENSE.txt
**/
**/
_auth();
$ui->assign('_title', $_L['Voucher'].'- '. $config['CompanyName']);
$ui->assign('_title', $_L['Voucher'] . '- ' . $config['CompanyName']);
$ui->assign('_system_menu', 'voucher');
$action = $routes['1'];
@ -16,6 +17,7 @@ $user = User::_info();
$ui->assign('_user', $user);
use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
switch ($action) {
@ -27,26 +29,27 @@ switch ($action) {
case 'activation-post':
$code = _post('code');
$v1 = ORM::for_table('tbl_voucher')->where('code',$code)->where('status',0)->find_one();
$v1 = ORM::for_table('tbl_voucher')->where('code', $code)->where('status', 0)->find_one();
$c = ORM::for_table('tbl_customers')->find_one($user['id']);
$p = ORM::for_table('tbl_plans')->find_one($v1['id_plan']);
$b = ORM::for_table('tbl_user_recharges')->where('customer_id',$user['id'])->find_one();
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->find_one();
$date_now = date("Y-m-d H:i:s");
$date_only = date("Y-m-d");
$time = date("H:i:s");
$mikrotik = Router::_info($v1['routers']);
$date_exp = date("Y-m-d", mktime(0,0,0,date("m"),date("d") + $p['validity'],date("Y")));
$date_exp = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") + $p['validity'], date("Y")));
if ($v1){
if($v1['type'] == 'Hotspot'){
if($b){
if ($v1) {
if ($v1['type'] == 'Hotspot') {
if ($b) {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id');
@ -62,39 +65,42 @@ switch ($action) {
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
*/
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
if($p['typebp']=="Limited"){
if($p['limit_type']=="Time_Limit"){
if($p['time_unit']=='Hrs')
$timelimit = $p['time_limit'].":00:00";
if ($p['typebp'] == "Limited") {
if ($p['limit_type'] == "Time_Limit") {
if ($p['time_unit'] == 'Hrs')
$timelimit = $p['time_limit'] . ":00:00";
else
$timelimit = "00:".$p['time_limit'].":00";
$client->sendSync($addRequest
$timelimit = "00:" . $p['time_limit'] . ":00";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
->setArgument('limit-uptime', $timelimit)
);
}else if($p['limit_type']=="Data_Limit"){
if($p['data_unit']=='GB')
$datalimit = $p['data_limit']."000000000";
} else if ($p['limit_type'] == "Data_Limit") {
if ($p['data_unit'] == 'GB')
$datalimit = $p['data_limit'] . "000000000";
else
$datalimit = $p['data_limit']."000000";
$client->sendSync($addRequest
$datalimit = $p['data_limit'] . "000000";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
->setArgument('limit-bytes-total', $datalimit)
);
}else if($p['limit_type']=="Both_Limit"){
if($p['time_unit']=='Hrs')
$timelimit = $p['time_limit'].":00:00";
} else if ($p['limit_type'] == "Both_Limit") {
if ($p['time_unit'] == 'Hrs')
$timelimit = $p['time_limit'] . ":00:00";
else
$timelimit = "00:".$p['time_limit'].":00";
if($p['data_unit']=='GB')
$datalimit = $p['data_limit']."000000000";
$timelimit = "00:" . $p['time_limit'] . ":00";
if ($p['data_unit'] == 'GB')
$datalimit = $p['data_limit'] . "000000000";
else
$datalimit = $p['data_limit']."000000";
$client->sendSync($addRequest
$datalimit = $p['data_limit'] . "000000";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
@ -102,8 +108,9 @@ switch ($action) {
->setArgument('limit-bytes-total', $datalimit)
);
}
}else{
$client->sendSync($addRequest
} else {
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
@ -125,7 +132,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->invoice = "INV-" . _raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -136,51 +143,54 @@ switch ($action) {
$t->routers = $v1['routers'];
$t->type = "Hotspot";
$t->save();
}else{
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
/* iBNuX Added:
* Time limit to Mikrotik
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
*/
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
if($p['typebp']=="Limited"){
if($p['limit_type']=="Time_Limit"){
if($p['time_unit']=='Hrs')
$timelimit = $p['time_limit'].":00:00";
if ($p['typebp'] == "Limited") {
if ($p['limit_type'] == "Time_Limit") {
if ($p['time_unit'] == 'Hrs')
$timelimit = $p['time_limit'] . ":00:00";
else
$timelimit = "00:".$p['time_limit'].":00";
$client->sendSync($addRequest
$timelimit = "00:" . $p['time_limit'] . ":00";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
->setArgument('limit-uptime', $timelimit)
);
}else if($p['limit_type']=="Data_Limit"){
if($p['data_unit']=='GB')
$datalimit = $p['data_limit']."000000000";
} else if ($p['limit_type'] == "Data_Limit") {
if ($p['data_unit'] == 'GB')
$datalimit = $p['data_limit'] . "000000000";
else
$datalimit = $p['data_limit']."000000";
$client->sendSync($addRequest
$datalimit = $p['data_limit'] . "000000";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
->setArgument('limit-bytes-total', $datalimit)
);
}else if($p['limit_type']=="Both_Limit"){
if($p['time_unit']=='Hrs')
$timelimit = $p['time_limit'].":00:00";
} else if ($p['limit_type'] == "Both_Limit") {
if ($p['time_unit'] == 'Hrs')
$timelimit = $p['time_limit'] . ":00:00";
else
$timelimit = "00:".$p['time_limit'].":00";
if($p['data_unit']=='GB')
$datalimit = $p['data_limit']."000000000";
$timelimit = "00:" . $p['time_limit'] . ":00";
if ($p['data_unit'] == 'GB')
$datalimit = $p['data_limit'] . "000000000";
else
$datalimit = $p['data_limit']."000000";
$client->sendSync($addRequest
$datalimit = $p['data_limit'] . "000000";
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
@ -188,8 +198,9 @@ switch ($action) {
->setArgument('limit-bytes-total', $datalimit)
);
}
}else{
$client->sendSync($addRequest
} else {
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
@ -212,7 +223,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->invoice = "INV-" . _raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -223,19 +234,18 @@ switch ($action) {
$t->routers = $v1['routers'];
$t->type = "Hotspot";
$t->save();
}
$v1->status = "1";
$v1->user = $c['username'];
$v1->save();
}else{
if($b){
} else {
if ($b) {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id');
@ -247,7 +257,8 @@ switch ($action) {
$client->sendSync($setRequest);
$addRequest = new RouterOS\Request('/ppp/secret/add');
$client->sendSync($addRequest
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('service', 'pppoe')
->setArgument('profile', $p['name_plan'])
@ -269,7 +280,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->invoice = "INV-" . _raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -280,15 +291,16 @@ switch ($action) {
$t->routers = $v1['routers'];
$t->type = "PPPOE";
$t->save();
}else{
} else {
try {
$client = new RouterOS\Client($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$iport = explode(":", $mikrotik['ip_address']);
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$addRequest = new RouterOS\Request('/ppp/secret/add');
$client->sendSync($addRequest
$client->sendSync(
$addRequest
->setArgument('name', $c['username'])
->setArgument('service', 'pppoe')
->setArgument('profile', $p['name_plan'])
@ -311,7 +323,7 @@ switch ($action) {
// insert table transactions
$t = ORM::for_table('tbl_transactions')->create();
$t->invoice = "INV-"._raid(5);
$t->invoice = "INV-" . _raid(5);
$t->username = $c['username'];
$t->plan_name = $p['name_plan'];
$t->price = $p['price'];
@ -329,18 +341,18 @@ switch ($action) {
$v1->save();
}
r2(U."voucher/list-activated",'s',$_L['Activation_Vouchers_Successfully']);
}else{
r2(U . "voucher/list-activated", 's', $_L['Activation_Vouchers_Successfully']);
} else {
r2(U . 'voucher/activation', 'e', $_L['Voucher_Not_Valid']);
}
break;
case 'list-activated':
$paginator = Paginator::bootstrap('tbl_transactions','username',$user['username']);
$d = ORM::for_table('tbl_transactions')->where('username',$user['username'])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
$paginator = Paginator::bootstrap('tbl_transactions', 'username', $user['username']);
$d = ORM::for_table('tbl_transactions')->where('username', $user['username'])->offset($paginator['startpoint'])->limit($paginator['limit'])->order_by_desc('id')->find_many();
$ui->assign('d',$d);
$ui->assign('paginator',$paginator);
$ui->assign('d', $d);
$ui->assign('paginator', $paginator);
$ui->display('user-activation-list.tpl');
break;

View File

@ -40,9 +40,10 @@ foreach ($d as $ds){
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
try {
$client = new RouterOS\Client($m['ip_address'], $m['username'], $m['password']);
$iport = explode(":",$m['ip_address']);
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
@ -81,9 +82,10 @@ foreach ($d as $ds){
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
try {
$client = new RouterOS\Client($m['ip_address'], $m['username'], $m['password']);
$iport = explode(":",$m['ip_address']);
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
} catch (Exception $e) {
die('Unable to connect to the router.');
die("Unable to connect to the router.<br>".$e->getMessage());
}
$printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id');

View File

@ -16,7 +16,7 @@
<div class="form-group">
<label class="col-md-2 control-label">{$_L['IP_Address']}</label>
<div class="col-md-6">
<input type="text" class="form-control" id="ip_address" name="ip_address">
<input type="text" placeholder="192.168.88.1:8728" class="form-control" id="ip_address" name="ip_address">
</div>
</div>
<div class="form-group">

View File

@ -17,7 +17,7 @@
<div class="form-group">
<label class="col-md-2 control-label">{$_L['IP_Address']}</label>
<div class="col-md-6">
<input type="text" class="form-control" id="ip_address" name="ip_address" value="{$d['ip_address']}">
<input type="text" placeholder="192.168.88.1:8728" class="form-control" id="ip_address" name="ip_address" value="{$d['ip_address']}">
</div>
</div>
<div class="form-group">