Compare commits

...

14 Commits

Author SHA1 Message Date
21d83268f7 2023.11.17 2023-11-17 14:44:22 +07:00
e886249091 redirect to home 2023-11-17 14:40:02 +07:00
d5ab0e1b44 Fix Error for Customer 2023-11-17 14:38:20 +07:00
05aca0356f edit changelog 2023-11-15 11:51:13 +07:00
cced38527b deactivate login logout fix 2023-11-15 11:49:03 +07:00
452642831c fix isLogin 2023-11-15 11:45:29 +07:00
69ea0d0b7f Customer Dashboard change 2023-11-15 11:39:05 +07:00
4b596d91bd Radius demo mode 2023-11-15 11:11:25 +07:00
9c5e3007a2 Fix Change package to another Mikrotik 2023-11-15 11:08:18 +07:00
d3893d88a4 dont show balance when edit active user 2023-11-15 10:53:39 +07:00
1ed55103a3 demo mode, not connecting to real router 2023-11-15 10:36:53 +07:00
bd8dd87384 fix bug cron and update plan 2023-11-09 14:52:41 +07:00
9190660c1c Fixed Error connecting to RouterOS during hotspot plan update
Fixed Error connecting to RouterOS during hotspot plan update
2023-10-30 17:15:40 +07:00
d241b2cec6 Update services.php
Fixed Error connecting to RouterOS when updating hotspot plan  from admin panel> services> Hotspot plan, edit plan
2023-10-30 12:18:36 +03:00
15 changed files with 296 additions and 132 deletions

View File

@ -2,6 +2,21 @@
# CHANGELOG # CHANGELOG
## 2023.11.17
- Error details not show in Customer
## 2023.11.15
- Customer Multi Router package
- Fix edit package, Admin can change Customer to another router
## 2023.11.9
- fix bug variable in cron
- fix update plan
## 2023.10.27 ## 2023.10.27
- Backup and restore database - Backup and restore database

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/) * PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by https://t.me/ibnux * by https://t.me/ibnux
@ -15,20 +16,20 @@ class Mikrotik
public static function getClient($ip, $user, $pass) public static function getClient($ip, $user, $pass)
{ {
global $ui; global $_app_stage;
//try { if ($_app_stage == 'demo') {
$iport = explode(":", $ip); return null;
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null); }
// } catch (Exception $e) { $iport = explode(":", $ip);
// $ui->assign("error_title", "Mikrotik Connection Error"); return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
// $ui->assign("error_message", "Unable to connect to the router : $ip<br>" . $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>');
// $ui->display('router-error.tpl');
// die();
// }
} }
public static function isUserLogin($client, $username) public static function isUserLogin($client, $username)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip hotspot active print', '/ip hotspot active print',
RouterOS\Query::where('user', $username) RouterOS\Query::where('user', $username)
@ -38,6 +39,10 @@ class Mikrotik
public static function logMeIn($client, $user, $pass, $ip, $mac) public static function logMeIn($client, $user, $pass, $ip, $mac)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$addRequest = new RouterOS\Request('/ip/hotspot/active/login'); $addRequest = new RouterOS\Request('/ip/hotspot/active/login');
$client->sendSync( $client->sendSync(
$addRequest $addRequest
@ -50,6 +55,10 @@ class Mikrotik
public static function logMeOut($client, $user) public static function logMeOut($client, $user)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip hotspot active print', '/ip hotspot active print',
RouterOS\Query::where('user', $user) RouterOS\Query::where('user', $user)
@ -64,6 +73,10 @@ class Mikrotik
public static function addHotspotPlan($client, $name, $sharedusers, $rate) public static function addHotspotPlan($client, $name, $sharedusers, $rate)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add'); $addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
$client->sendSync( $client->sendSync(
$addRequest $addRequest
@ -75,6 +88,10 @@ class Mikrotik
public static function setHotspotPlan($client, $name, $sharedusers, $rate) public static function setHotspotPlan($client, $name, $sharedusers, $rate)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip hotspot user profile print .proplist=.id', '/ip hotspot user profile print .proplist=.id',
RouterOS\Query::where('name', $name) RouterOS\Query::where('name', $name)
@ -95,6 +112,10 @@ class Mikrotik
public static function setHotspotExpiredPlan($client, $name, $pool) public static function setHotspotExpiredPlan($client, $name, $pool)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip hotspot user profile print .proplist=.id', '/ip hotspot user profile print .proplist=.id',
RouterOS\Query::where('name', $name) RouterOS\Query::where('name', $name)
@ -123,6 +144,10 @@ class Mikrotik
public static function removeHotspotPlan($client, $name) public static function removeHotspotPlan($client, $name)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip hotspot user profile print .proplist=.id', '/ip hotspot user profile print .proplist=.id',
RouterOS\Query::where('name', $name) RouterOS\Query::where('name', $name)
@ -138,6 +163,10 @@ class Mikrotik
public static function removeHotspotUser($client, $username) public static function removeHotspotUser($client, $username)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip hotspot user print .proplist=.id', '/ip hotspot user print .proplist=.id',
RouterOS\Query::where('name', $username) RouterOS\Query::where('name', $username)
@ -152,6 +181,10 @@ class Mikrotik
public static function addHotspotUser($client, $plan, $customer) public static function addHotspotUser($client, $plan, $customer)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$addRequest = new RouterOS\Request('/ip/hotspot/user/add'); $addRequest = new RouterOS\Request('/ip/hotspot/user/add');
if ($plan['typebp'] == "Limited") { if ($plan['typebp'] == "Limited") {
if ($plan['limit_type'] == "Time_Limit") { if ($plan['limit_type'] == "Time_Limit") {
@ -216,6 +249,10 @@ class Mikrotik
public static function setHotspotUser($client, $user, $pass) public static function setHotspotUser($client, $user, $pass)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print'); $printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id'); $printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $user)); $printRequest->setQuery(RouterOS\Query::where('name', $user));
@ -229,6 +266,10 @@ class Mikrotik
public static function setHotspotUserPackage($client, $user, $plan) public static function setHotspotUserPackage($client, $user, $plan)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request('/ip/hotspot/user/print'); $printRequest = new RouterOS\Request('/ip/hotspot/user/print');
$printRequest->setArgument('.proplist', '.id'); $printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $user)); $printRequest->setQuery(RouterOS\Query::where('name', $user));
@ -242,6 +283,10 @@ class Mikrotik
public static function removeHotspotActiveUser($client, $username) public static function removeHotspotActiveUser($client, $username)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print'); $onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
$onlineRequest->setArgument('.proplist', '.id'); $onlineRequest->setArgument('.proplist', '.id');
$onlineRequest->setQuery(RouterOS\Query::where('user', $username)); $onlineRequest->setQuery(RouterOS\Query::where('user', $username));
@ -254,7 +299,10 @@ class Mikrotik
public static function removePpoeUser($client, $username) public static function removePpoeUser($client, $username)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request('/ppp/secret/print'); $printRequest = new RouterOS\Request('/ppp/secret/print');
//$printRequest->setArgument('.proplist', '.id'); //$printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $username)); $printRequest->setQuery(RouterOS\Query::where('name', $username));
@ -266,6 +314,10 @@ class Mikrotik
public static function addPpoeUser($client, $plan, $customer) public static function addPpoeUser($client, $plan, $customer)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$addRequest = new RouterOS\Request('/ppp/secret/add'); $addRequest = new RouterOS\Request('/ppp/secret/add');
if (!empty($customer['pppoe_password'])) { if (!empty($customer['pppoe_password'])) {
$pass = $customer['pppoe_password']; $pass = $customer['pppoe_password'];
@ -284,6 +336,10 @@ class Mikrotik
public static function setPpoeUser($client, $user, $pass) public static function setPpoeUser($client, $user, $pass)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request('/ppp/secret/print'); $printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id'); $printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $user)); $printRequest->setQuery(RouterOS\Query::where('name', $user));
@ -297,6 +353,10 @@ class Mikrotik
public static function setPpoeUserPlan($client, $user, $plan) public static function setPpoeUserPlan($client, $user, $plan)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request('/ppp/secret/print'); $printRequest = new RouterOS\Request('/ppp/secret/print');
$printRequest->setArgument('.proplist', '.id'); $printRequest->setArgument('.proplist', '.id');
$printRequest->setQuery(RouterOS\Query::where('name', $user)); $printRequest->setQuery(RouterOS\Query::where('name', $user));
@ -310,6 +370,10 @@ class Mikrotik
public static function removePpoeActive($client, $username) public static function removePpoeActive($client, $username)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$onlineRequest = new RouterOS\Request('/ppp/active/print'); $onlineRequest = new RouterOS\Request('/ppp/active/print');
$onlineRequest->setArgument('.proplist', '.id'); $onlineRequest->setArgument('.proplist', '.id');
$onlineRequest->setQuery(RouterOS\Query::where('name', $username)); $onlineRequest->setQuery(RouterOS\Query::where('name', $username));
@ -322,6 +386,10 @@ class Mikrotik
public static function removePool($client, $name) public static function removePool($client, $name)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip pool print .proplist=.id', '/ip pool print .proplist=.id',
RouterOS\Query::where('name', $name) RouterOS\Query::where('name', $name)
@ -337,6 +405,10 @@ class Mikrotik
public static function addPool($client, $name, $ip_address) public static function addPool($client, $name, $ip_address)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$addRequest = new RouterOS\Request('/ip/pool/add'); $addRequest = new RouterOS\Request('/ip/pool/add');
$client->sendSync( $client->sendSync(
$addRequest $addRequest
@ -347,6 +419,10 @@ class Mikrotik
public static function setPool($client, $name, $ip_address) public static function setPool($client, $name, $ip_address)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ip pool print .proplist=.id', '/ip pool print .proplist=.id',
RouterOS\Query::where('name', $name) RouterOS\Query::where('name', $name)
@ -368,6 +444,10 @@ class Mikrotik
public static function addPpoePlan($client, $name, $pool, $rate) public static function addPpoePlan($client, $name, $pool, $rate)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$addRequest = new RouterOS\Request('/ppp/profile/add'); $addRequest = new RouterOS\Request('/ppp/profile/add');
$client->sendSync( $client->sendSync(
$addRequest $addRequest
@ -380,6 +460,10 @@ class Mikrotik
public static function setPpoePlan($client, $name, $pool, $rate) public static function setPpoePlan($client, $name, $pool, $rate)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ppp profile print .proplist=.id', '/ppp profile print .proplist=.id',
RouterOS\Query::where('name', $name) RouterOS\Query::where('name', $name)
@ -401,6 +485,10 @@ class Mikrotik
public static function removePpoePlan($client, $name) public static function removePpoePlan($client, $name)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$printRequest = new RouterOS\Request( $printRequest = new RouterOS\Request(
'/ppp profile print .proplist=.id', '/ppp profile print .proplist=.id',
RouterOS\Query::where('name', $name) RouterOS\Query::where('name', $name)

View File

@ -81,7 +81,7 @@ class Package
} }
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one(); $b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->where('routers', $router_name)->find_one();
$mikrotik = Mikrotik::info($router_name); $mikrotik = Mikrotik::info($router_name);
if ($p['validity_unit'] == 'Months') { if ($p['validity_unit'] == 'Months') {
@ -321,23 +321,64 @@ class Package
return true; return true;
} }
public static function changeTo($username, $plan_id) public static function changeTo($username, $plan_id, $from_id)
{ {
global $_c;
$c = ORM::for_table('tbl_customers')->where('username', $username)->find_one(); $c = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one();
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $c['id'])->find_one(); $b = ORM::for_table('tbl_user_recharges')->find_one($from_id);
$mikrotik = Mikrotik::info($p['routers']); if($p['routers'] == $b['routers']){
$mikrotik = Mikrotik::info($p['routers']);
}else{
$mikrotik = Mikrotik::info($b['routers']);
}
// delete first
if ($p['type'] == 'Hotspot') {
if ($b) {
if (!$p['is_radius']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
}
} else {
if (!$p['is_radius']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
}
}
} else {
if ($b) {
if (!$p['is_radius']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
}
} else {
if (!$p['is_radius']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
}
}
}
// call the next mikrotik
if($p['routers'] != $b['routers']){
$mikrotik = Mikrotik::info($p['routers']);
}
if ($p['type'] == 'Hotspot') { if ($p['type'] == 'Hotspot') {
if ($b) { if ($b) {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']); Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']);
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
} }
} else { } else {
@ -345,10 +386,6 @@ class Package
Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']); Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']);
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
} }
} }
@ -358,10 +395,6 @@ class Package
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p);
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
Mikrotik::addPpoeUser($client, $p, $c); Mikrotik::addPpoeUser($client, $p, $c);
} }
} else { } else {
@ -369,10 +402,6 @@ class Package
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p);
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']);
Mikrotik::removeHotspotActiveUser($client, $c['username']);
Mikrotik::removePpoeActive($client, $c['username']);
Mikrotik::addPpoeUser($client, $p, $c); Mikrotik::addPpoeUser($client, $p, $c);
} }
} }

View File

@ -297,6 +297,10 @@ class Radius
public static function disconnectCustomer($username) public static function disconnectCustomer($username)
{ {
global $_app_stage;
if ($_app_stage == 'demo') {
return null;
}
$nas = Radius::getTableNas()->findMany(); $nas = Radius::getTableNas()->findMany();
$count = count($nas) * 15; $count = count($nas) * 15;
set_time_limit($count); set_time_limit($count);

View File

@ -22,7 +22,7 @@ class User
public static function _billing() public static function _billing()
{ {
$id = $_SESSION['uid']; $id = $_SESSION['uid'];
$d = ORM::for_table('tbl_user_recharges')->where('customer_id', $id)->find_one(); $d = ORM::for_table('tbl_user_recharges')->where('customer_id', $id)->find_many();
return $d; return $d;
} }
} }

View File

@ -116,7 +116,11 @@ try {
$ui->setConfigDir(File::pathFixer('ui/conf/')); $ui->setConfigDir(File::pathFixer('ui/conf/'));
$ui->setCacheDir(File::pathFixer('ui/cache/')); $ui->setCacheDir(File::pathFixer('ui/cache/'));
$ui->assign("error_title", "PHPNuxBill Crash"); $ui->assign("error_title", "PHPNuxBill Crash");
$ui->assign("error_message", $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>'); if (isset($_SESSION['uid'])) {
$ui->assign("error_message", $e->getMessage() . '<br>');
}else{
$ui->assign("error_message", $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>');
}
$ui->display('router-error.tpl'); $ui->display('router-error.tpl');
die(); die();
} }
@ -341,8 +345,11 @@ try {
r2(U . 'dashboard', 'e', 'not found'); r2(U . 'dashboard', 'e', 'not found');
} }
} catch (Exception $e) { } catch (Exception $e) {
$ui->assign("error_title", "PHPNuxBill Crash"); if (isset($_SESSION['uid'])) {
r2(U . 'home' , 'e', $e->getMessage());
}
$ui->assign("error_message", $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>'); $ui->assign("error_message", $e->getMessage() . '<br><pre>' . $e->getTraceAsString() . '</pre>');
$ui->assign("error_title", "PHPNuxBill Crash");
$ui->display('router-error.tpl'); $ui->display('router-error.tpl');
die(); die();
} }

View File

@ -12,18 +12,18 @@ _auth();
$action = $routes['1']; $action = $routes['1'];
$user = User::_info(); $user = User::_info();
$bill = User::_billing();
switch ($action) { switch ($action) {
case 'isLogin': case 'isLogin':
$bill = ORM::for_table('tbl_user_recharges')->where('id', $routes['2'])->where('username', $user['username'])->findOne();
if ($bill['type'] == 'Hotspot' && $bill['status'] == 'on') { if ($bill['type'] == 'Hotspot' && $bill['status'] == 'on') {
$m = Mikrotik::info($bill['routers']); $m = Mikrotik::info($bill['routers']);
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
if (Mikrotik::isUserLogin($client, $user['username'])) { if (Mikrotik::isUserLogin($client, $user['username'])) {
die('<a href="' . U . 'home&mikrotik=logout" onclick="return confirm(\''.Lang::T('Disconnect Internet?').'\')" class="btn btn-success btn-xs btn-block">'.Lang::T('You are Online, Logout?').'</a>'); die('<a href="' . U . 'home&mikrotik=logout&id='.$bill['id'].'" onclick="return confirm(\''.Lang::T('Disconnect Internet?').'\')" class="btn btn-success btn-xs btn-block">'.Lang::T('You are Online, Logout?').'</a>');
} else { } else {
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) { if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
die('<a href="' . U . 'home&mikrotik=login" onclick="return confirm(\''.Lang::T('Connect to Internet?').'\')" class="btn btn-danger btn-xs btn-block">'.Lang::T('Not Online, Login now?').'</a>'); die('<a href="' . U . 'home&mikrotik=login&id='.$bill['id'].'" onclick="return confirm(\''.Lang::T('Connect to Internet?').'\')" class="btn btn-danger btn-xs btn-block">'.Lang::T('Not Online, Login now?').'</a>');
}else{ }else{
die(Lang::T('Your account not connected to internet')); die(Lang::T('Your account not connected to internet'));
} }

View File

@ -84,27 +84,29 @@ if (_post('send') == 'balance') {
if ($router) { if ($router) {
r2(U . "order/send/$router[id]/$active[plan_id]&u=" . trim(_post('username')), 's', Lang::T('Review package before recharge')); r2(U . "order/send/$router[id]/$active[plan_id]&u=" . trim(_post('username')), 's', Lang::T('Review package before recharge'));
} else { } else {
r2(U . 'package/order', 'w', Lang::T('Your friend do not have active package')); r2(U . 'home', 'w', Lang::T('Your friend do not have active package'));
} }
} }
//Client Page $ui->assign('_bills', User::_billing());
$bill = User::_billing();
$ui->assign('_bill', $bill);
if(isset($_GET['recharge']) && $_GET['recharge'] == 1){ if(isset($_GET['recharge']) && !empty($_GET['recharge'])){
$router = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one(); $bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['recharge'])->where('username', $user['username'])->findOne();
if ($config['enable_balance'] == 'yes') { if ($bill) {
$plan = ORM::for_table('tbl_plans')->find_one($bill['plan_id']); $router = ORM::for_table('tbl_routers')->where('name', $bill['routers'])->find_one();
if($user['balance']>$plan['price']){ if ($config['enable_balance'] == 'yes') {
r2(U . "order/pay/$router[id]/$bill[plan_id]", 'e', 'Order Plan'); $plan = ORM::for_table('tbl_plans')->find_one($bill['plan_id']);
if($user['balance']>$plan['price']){
r2(U . "order/pay/$router[id]/$bill[plan_id]", 'e', 'Order Plan');
}else{
r2(U . "order/buy/$router[id]/$bill[plan_id]", 'e', 'Order Plan');
}
}else{ }else{
r2(U . "order/buy/$router[id]/$bill[plan_id]", 'e', 'Order Plan'); r2(U . "order/buy/$router[id]/$bill[plan_id]", 'e', 'Order Plan');
} }
}else{
r2(U . "order/buy/$router[id]/$bill[plan_id]", 'e', 'Order Plan');
} }
}else if(isset($_GET['deactivate']) && $_GET['deactivate'] == 1){ }else if(isset($_GET['deactivate']) && !empty($_GET['deactivate'])){
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['deactivate'])->where('username', $user['username'])->findOne();
if ($bill) { if ($bill) {
$p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one();
if($p['is_radius']){ if($p['is_radius']){
@ -139,6 +141,7 @@ if(isset($_GET['recharge']) && $_GET['recharge'] == 1){
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) { if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
$ui->assign('nux_mac', $_SESSION['nux-mac']); $ui->assign('nux_mac', $_SESSION['nux-mac']);
$ui->assign('nux_ip', $_SESSION['nux-ip']); $ui->assign('nux_ip', $_SESSION['nux-ip']);
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['id'])->where('username', $user['username'])->findOne();
if ($_GET['mikrotik'] == 'login') { if ($_GET['mikrotik'] == 'login') {
$m = Mikrotik::info($bill['routers']); $m = Mikrotik::info($bill['routers']);
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); $c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);

View File

@ -171,7 +171,7 @@ switch ($action) {
$d = ORM::for_table('tbl_user_recharges')->find_one($id); $d = ORM::for_table('tbl_user_recharges')->find_one($id);
if ($d) { if ($d) {
$ui->assign('d', $d); $ui->assign('d', $d);
$p = ORM::for_table('tbl_plans')->where('enabled', '1')->find_many(); $p = ORM::for_table('tbl_plans')->where('enabled', '1')->where_not_equal('type', 'Balance')->find_many();
$ui->assign('p', $p); $ui->assign('p', $p);
run_hook('view_edit_customer_plan'); #HOOK run_hook('view_edit_customer_plan'); #HOOK
$ui->display('prepaid-edit.tpl'); $ui->display('prepaid-edit.tpl');
@ -219,7 +219,11 @@ switch ($action) {
} else { } else {
$msg .= $_L['Data_Not_Found'] . '<br>'; $msg .= $_L['Data_Not_Found'] . '<br>';
} }
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one();
if ($d) {
} else {
$msg .= ' Plan Not Found<br>';
}
if ($msg == '') { if ($msg == '') {
run_hook('edit_customer_plan'); #HOOK run_hook('edit_customer_plan'); #HOOK
$d->username = $username; $d->username = $username;
@ -227,8 +231,9 @@ switch ($action) {
//$d->recharged_on = $recharged_on; //$d->recharged_on = $recharged_on;
$d->expiration = $expiration; $d->expiration = $expiration;
$d->time = $time; $d->time = $time;
$d->routers = $p['routers'];
$d->save(); $d->save();
Package::changeTo($username, $id_plan); Package::changeTo($username, $id_plan, $id);
_log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['plan_name'] . '][' . Lang::moneyFormat($d['price']) . ']', 'Admin', $admin['id']); _log('[' . $admin['username'] . ']: ' . 'Edit Plan for Customer ' . $d['username'] . ' to [' . $d['plan_name'] . '][' . Lang::moneyFormat($d['price']) . ']', 'Admin', $admin['id']);
r2(U . 'prepaid/list', 's', $_L['Updated_Successfully']); r2(U . 'prepaid/list', 's', $_L['Updated_Successfully']);
} else { } else {

View File

@ -302,7 +302,7 @@ switch ($action) {
$validity_unit = _post('validity_unit'); $validity_unit = _post('validity_unit');
$pool_expired = _post('pool_expired'); $pool_expired = _post('pool_expired');
$enabled = _post('enabled'); $enabled = _post('enabled');
$routers = _post('routers');
$msg = ''; $msg = '';
if (Validator::UnsignedNumber($validity) == false) { if (Validator::UnsignedNumber($validity) == false) {
$msg .= 'The validity must be a number' . '<br>'; $msg .= 'The validity must be a number' . '<br>';

View File

@ -118,7 +118,7 @@ foreach ($d as $ds) {
if (empty($p['pool_expired'])) { if (empty($p['pool_expired'])) {
print_r(Radius::customerDeactivate($c['username'])); print_r(Radius::customerDeactivate($c['username']));
} else { } else {
Radius::upsertCustomerAttr($c['username'], 'Framed-Pool', $plan['pool_expired'], ':='); Radius::upsertCustomerAttr($c['username'], 'Framed-Pool', $p['pool_expired'], ':=');
print_r(Radius::disconnectCustomer($c['username'])); print_r(Radius::disconnectCustomer($c['username']));
} }
} else { } else {
@ -172,7 +172,7 @@ foreach ($d as $ds) {
if (empty($p['pool_expired'])) { if (empty($p['pool_expired'])) {
print_r(Radius::customerDeactivate($c['username'])); print_r(Radius::customerDeactivate($c['username']));
} else { } else {
Radius::upsertCustomerAttr($c['username'], 'Framed-Pool', $plan['pool_expired'], ':='); Radius::upsertCustomerAttr($c['username'], 'Framed-Pool', $p['pool_expired'], ':=');
print_r(Radius::disconnectCustomer($c['username'])); print_r(Radius::disconnectCustomer($c['username']));
} }
} else { } else {

View File

@ -408,3 +408,4 @@ $_L['Change_title_in_user_Plan_order'] = 'Change title in user Plan order';
$_L['Logs'] = 'Logs'; $_L['Logs'] = 'Logs';
$_L['Voucher_Format'] = 'Voucher Format'; $_L['Voucher_Format'] = 'Voucher Format';
$_L['Resend_To_Customer'] = 'Resend To Customer'; $_L['Resend_To_Customer'] = 'Resend To Customer';
$_L['Your_friend_do_not_have_active_package'] = 'Your friend do not have active package';

View File

@ -23,7 +23,7 @@
<select id="id_plan" name="id_plan" class="form-control select2"> <select id="id_plan" name="id_plan" class="form-control select2">
{foreach $p as $ps} {foreach $p as $ps}
<option value="{$ps['id']}" {if $d['plan_id'] eq $ps['id']} selected {/if}> <option value="{$ps['id']}" {if $d['plan_id'] eq $ps['id']} selected {/if}>
{$ps['name_plan']}</option> {if $ps['is_radius']=='1'}Radius{else}{$ps['routers']}{/if} - {$ps['name_plan']}</option>
{/foreach} {/foreach}
</select> </select>
</div> </div>

View File

@ -8,7 +8,7 @@
<div class="box-header"> <div class="box-header">
<h3 class="box-title">{Lang::T('Unpaid Order')}</h3> <h3 class="box-title">{Lang::T('Unpaid Order')}</h3>
</div> </div>
<table class="table table-condensed table-bordered table-striped table-hover"> <table class="table table-condensed table-bordered table-striped table-hover" style="margin-bottom: 0px;">
<tbody> <tbody>
<tr> <tr>
<td>{Lang::T('expired')}</td> <td>{Lang::T('expired')}</td>
@ -62,7 +62,8 @@
<div class="box-header"> <div class="box-header">
<h3 class="box-title">{$_L['Account_Information']}</h3> <h3 class="box-title">{$_L['Account_Information']}</h3>
</div> </div>
<table class="table table-bordered table-striped table-bordered table-hover"> <table class="table table-bordered table-striped table-bordered table-hover mb-0"
style="margin-bottom: 0px;">
<tr> <tr>
<td class="small text-success text-uppercase text-normal">{$_L['Username']}</td> <td class="small text-success text-uppercase text-normal">{$_L['Username']}</td>
<td class="small mb15">{$_user['username']}</td> <td class="small mb15">{$_user['username']}</td>
@ -88,84 +89,95 @@
</td> </td>
</tr> </tr>
{/if} {/if}
{if $_bill} </table>
{if $_bills}
{foreach $_bills as $_bill}
{if $_bill['routers'] != 'radius'} {if $_bill['routers'] != 'radius'}
<tr> <div class="box-header">
<td class="small text-primary text-uppercase text-normal">{strtoupper(Lang::T('Location'))}</td> <h3 class="box-title">{$_bill['routers']}</h3>
<td class="small mb15">{$_bill['routers']}</td> </div>
</tr> {else}
<div class="box-header">
<h3 class="box-title">{if $_c['radius_plan']==''}Radius Plan{else}{$_c['radius_plan']}{/if}</h3>
</div>
{/if} {/if}
<tr> <table class="table table-bordered table-striped table-bordered table-hover" style="margin-bottom: 0px;">
<td class="small text-primary text-uppercase text-normal">{$_L['Plan_Name']}</td>
<td class="small mb15">
{$_bill['namebp']}
{if $_bill['status'] == 'on'}
<a class="label label-danger pull-right" href="{$_url}home&deactivate=1"
onclick="return confirm('{Lang::T('Deactivate')}?')">{Lang::T('Deactivate')}</a>
{else}
<a class="label label-warning pull-right" href="{$_url}order/package">{Lang::T('expired')}</a>
{/if}
</td>
</tr>
<tr>
<td class="small text-info text-uppercase text-normal">{$_L['Created_On']}</td>
<td class="small mb15">
{if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])}
{/if}&nbsp;</td>
</tr>
<tr>
<td class="small text-danger text-uppercase text-normal">{$_L['Expires_On']}</td>
<td class="small mb15 text-danger">
{if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}&nbsp;
<a class="label label-primary pull-right" href="{$_url}home&recharge=1"
onclick="return confirm('{Lang::T('Recharge')}?')">{Lang::T('Recharge')}</a>
</td>
</tr>
{if $nux_ip}
<tr> <tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current IP')}</td> <td class="small text-primary text-uppercase text-normal">{$_L['Plan_Name']}</td>
<td class="small mb15">{$nux_ip}</td> <td class="small mb15">
</tr> {$_bill['namebp']}
{/if} {if $_bill['status'] == 'on'}
{if $nux_mac} <a class="label label-danger pull-right" href="{$_url}home&deactivate={$_bill['id']}"
<tr> onclick="return confirm('{Lang::T('Deactivate')}?')">{Lang::T('Deactivate')}</a>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current MAC')}</td> {else}
<td class="small mb15">{$nux_mac}</td> <a class="label label-warning pull-right" href="{$_url}order/package">{Lang::T('expired')}</a>
</tr> {/if}
{/if}
{if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on' && $_bill['routers'] != 'radius'}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Login Status')}</td>
<td class="small mb15" id="login_status">
<img src="ui/ui/images/loading.gif">
</td> </td>
</tr> </tr>
{/if} <tr>
{/if} <td class="small text-info text-uppercase text-normal">{$_L['Created_On']}</td>
</table> <td class="small mb15">
{if $_c['disable_voucher'] == 'yes'} {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['recharged_on'],$_bill['recharged_time'])}
<div class="box-footer"> {/if}&nbsp;</td>
{if $_c['payment_gateway'] != 'none' or $_c['payment_gateway'] == '' } </tr>
<a href="{$_url}order/package" class="btn btn-primary btn-block"> <tr>
<i class="ion ion-ios-cart"></i> <td class="small text-danger text-uppercase text-normal">{$_L['Expires_On']}</td>
{Lang::T('Order Package')} <td class="small mb15 text-danger">
</a> {if $_bill['time'] ne ''}{Lang::dateAndTimeFormat($_bill['expiration'],$_bill['time'])}{/if}&nbsp;
{/if} <a class="label label-primary pull-right" href="{$_url}home&recharge={$_bill['id']}"
</div> onclick="return confirm('{Lang::T('Recharge')}?')">{Lang::T('Recharge')}</a>
</td>
</tr>
{if $nux_ip}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current IP')}</td>
<td class="small mb15">{$nux_ip}</td>
</tr>
{/if}
{if $nux_mac}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Current MAC')}</td>
<td class="small mb15">{$nux_mac}</td>
</tr>
{/if}
{if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on' && $_bill['routers'] != 'radius'}
<tr>
<td class="small text-primary text-uppercase text-normal">{Lang::T('Login Status')}</td>
<td class="small mb15" id="login_status_{$_bill['id']}">
<img src="ui/ui/images/loading.gif">
</td>
</tr>
{/if}
</table>
{/foreach}
{/if} {/if}
</div> </div>
{if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on'} {if $_c['disable_voucher'] == 'yes'}
<script> <div class="box-footer">
setTimeout(() => { {if $_c['payment_gateway'] != 'none' or $_c['payment_gateway'] == '' }
$.ajax({ <a href="{$_url}order/package" class="btn btn-primary btn-block">
url: "index.php?_route=autoload_user/isLogin", <i class="ion ion-ios-cart"></i>
cache: false, {Lang::T('Order Package')}
success: function(msg) { </a>
$("#login_status").html(msg); {/if}
} </div>
}); {/if}
}, 2000); {if $_bills}
</script> {foreach $_bills as $_bill}
{if $_bill['type'] == 'Hotspot' && $_bill['status'] == 'on'}
<script>
setTimeout(() => {
$.ajax({
url: "index.php?_route=autoload_user/isLogin/{$_bill['id']}",
cache: false,
success: function(msg) {
$("#login_status_{$_bill['id']}").html(msg);
}
});
}, 2000);
</script>
{/if}
{/foreach}
{/if} {/if}
{if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes'} {if $_c['enable_balance'] == 'yes' && $_c['allow_balance_transfer'] == 'yes'}
<div class="box box-primary box-solid mb30"> <div class="box box-primary box-solid mb30">

View File

@ -1,3 +1,3 @@
{ {
"version": "2023.10.27" "version": "2023.11.17"
} }