done, maybe, need to test all
This commit is contained in:
parent
c661976eae
commit
7a94254df9
@ -17,16 +17,21 @@ switch ($action) {
|
||||
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') {
|
||||
$m = Mikrotik::info($bill['routers']);
|
||||
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||
if (Mikrotik::isUserLogin($client, $user['username'])) {
|
||||
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 {
|
||||
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
||||
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{
|
||||
die(Lang::T('Your account not connected to internet'));
|
||||
$dvc = Package::getDevice($d);
|
||||
if (file_exists($dvc)) {
|
||||
require_once $dvc;
|
||||
if ((new $d['device'])->online_customer($user, $bill['routers'])) {
|
||||
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 {
|
||||
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
||||
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{
|
||||
die(Lang::T('Your account not connected to internet'));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
new Exception(Lang::T("Devices Not Found"));
|
||||
}
|
||||
} else {
|
||||
die('--');
|
||||
|
@ -8,7 +8,7 @@
|
||||
$maintenance_mode = $config['maintenance_mode'];
|
||||
if ($maintenance_mode == true){
|
||||
displayMaintenanceMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (User::getID()) {
|
||||
r2(U . 'home');
|
||||
@ -95,9 +95,18 @@ switch ($do) {
|
||||
// add customer to mikrotik
|
||||
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
||||
try {
|
||||
$m = Mikrotik::info($v1['routers']);
|
||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
|
||||
$p = ORM::for_table('tbl_plans')->where('id', $v1['id_plan'])->find_one();
|
||||
$dvc = Package::getDevice($p);
|
||||
if (file_exists($dvc)) {
|
||||
require_once $dvc;
|
||||
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $v1['routers']);
|
||||
} else {
|
||||
if (!empty($config['voucher_redirect'])) {
|
||||
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
|
||||
} else {
|
||||
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
|
||||
}
|
||||
}
|
||||
if (!empty($config['voucher_redirect'])) {
|
||||
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
|
||||
} else {
|
||||
@ -130,9 +139,18 @@ switch ($do) {
|
||||
$user->save();
|
||||
if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
||||
try {
|
||||
$m = Mikrotik::info($v1['routers']);
|
||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
|
||||
$p = ORM::for_table('tbl_plans')->where('id', $v1['id_plan'])->find_one();
|
||||
$dvc = Package::getDevice($p);
|
||||
if (file_exists($dvc)) {
|
||||
require_once $dvc;
|
||||
(new $p['device'])->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $v1['routers']);
|
||||
} else {
|
||||
if (!empty($config['voucher_redirect'])) {
|
||||
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, now you can login"));
|
||||
} else {
|
||||
r2(U . "login", 's', Lang::T("Voucher activation success, now you can login"));
|
||||
}
|
||||
}
|
||||
if (!empty($config['voucher_redirect'])) {
|
||||
r2($config['voucher_redirect'], 's', Lang::T("Voucher activation success, you are connected to internet"));
|
||||
} else {
|
||||
|
@ -128,7 +128,7 @@ switch ($action) {
|
||||
r2(U . "order/package", 'e', Lang::T("Transaction Not found"));
|
||||
}
|
||||
|
||||
$router = Mikrotik::info($trx['routers']);
|
||||
$router = ORM::for_table('tbl_routers')->where('name', $trx['routers'])->find_one();
|
||||
$plan = ORM::for_table('tbl_plans')->find_one($trx['plan_id']);
|
||||
$bandw = ORM::for_table('tbl_bandwidth')->find_one($plan['id_bw']);
|
||||
$invoice = ORM::for_table('tbl_transactions')->where("invoice", $trx['trx_invoice'])->find_one();
|
||||
|
@ -56,7 +56,8 @@ switch ($action) {
|
||||
$msg .= 'NAS IP Exists<br>';
|
||||
}
|
||||
if ($msg == '') {
|
||||
$id = Radius::nasAdd($shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community);
|
||||
require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php";
|
||||
(new Radius())->nasAdd($shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community);
|
||||
if ($id > 0) {
|
||||
r2(U . 'radius/nas-list/', 's', "NAS Added");
|
||||
} else {
|
||||
@ -113,7 +114,8 @@ switch ($action) {
|
||||
$type = null;
|
||||
}
|
||||
if ($msg == '') {
|
||||
if (Radius::nasUpdate($id, $shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community)) {
|
||||
require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php";
|
||||
if ((new Radius())->nasUpdate($id, $shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community)) {
|
||||
r2(U . 'radius/list/', 's', "NAS Saved");
|
||||
} else {
|
||||
r2(U . 'radius/nas-add', 'e', 'NAS NOT Exists');
|
||||
|
@ -41,14 +41,6 @@ switch ($action) {
|
||||
$logo = $UPLOAD_URL_PATH . DIRECTORY_SEPARATOR . 'logo.default.png';
|
||||
}
|
||||
$ui->assign('logo', $logo);
|
||||
if ($config['radius_enable'] && empty($config['radius_client'])) {
|
||||
try {
|
||||
$config['radius_client'] = Radius::getClient();
|
||||
$ui->assign('_c', $_c);
|
||||
} catch (Exception $e) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
$themes = [];
|
||||
$files = scandir('ui/themes/');
|
||||
foreach ($files as $file) {
|
||||
@ -109,7 +101,8 @@ switch ($action) {
|
||||
} else {
|
||||
if ($radius_enable) {
|
||||
try {
|
||||
Radius::getTableNas()->find_many();
|
||||
require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "Radius.php";
|
||||
(new Radius())->getTableNas()->find_many();
|
||||
} catch (Exception $e) {
|
||||
$ui->assign("error_title", "RADIUS Error");
|
||||
$ui->assign("error_message", "Radius table not found.<br><br>" .
|
||||
|
@ -93,7 +93,7 @@ class MikrotikHotspot
|
||||
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ip hotspot active print',
|
||||
RouterOS\Query::where('user', $customer['username'])
|
||||
RouterOS\Query::where('name', $customer['username'])
|
||||
);
|
||||
return $client->sendSync($printRequest)->getProperty('.id');
|
||||
}
|
||||
|
@ -208,6 +208,23 @@ class MikrotikPppoe
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function online_customer($customer, $router_name)
|
||||
{
|
||||
global $_app_stage;
|
||||
if ($_app_stage == 'demo') {
|
||||
return;
|
||||
}
|
||||
$mikrotik = $this->info($router_name);
|
||||
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$printRequest = new RouterOS\Request(
|
||||
'/ppp active print',
|
||||
RouterOS\Query::where('user', $customer['username'])
|
||||
);
|
||||
return $client->sendSync($printRequest)->getProperty('.id');
|
||||
}
|
||||
|
||||
|
||||
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||
{
|
||||
global $_app_stage;
|
||||
|
@ -220,12 +220,6 @@
|
||||
href="https://github.com/hotspotbilling/phpnuxbill/wiki/FreeRadius"
|
||||
target="_blank">Radius Instructions</a></p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">Radius Client</label>
|
||||
<div class="col-md-6">
|
||||
<input type="text" class="form-control" name="radius_client" value="{$_c['radius_client']}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-heading">
|
||||
<div class="btn-group pull-right">
|
||||
|
Loading…
x
Reference in New Issue
Block a user