hotspot plan radius

This commit is contained in:
Ibnu Maksum 2023-10-03 15:46:55 +07:00
parent 9e33a5740b
commit ce01771800
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
15 changed files with 393 additions and 242 deletions

View File

@ -65,6 +65,7 @@ CREATE TABLE `radgroupreply` (
`attribute` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `attribute` varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`op` char(2) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '=', `op` char(2) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '=',
`value` varchar(253) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' `value` varchar(253) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''
`plan_id` int(11) UNSIGNED NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE `radpostauth` ( CREATE TABLE `radpostauth` (

View File

@ -98,7 +98,7 @@ class Package
if ($p['type'] == 'Hotspot') { if ($p['type'] == 'Hotspot') {
if ($b) { if ($b) {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
@ -155,7 +155,7 @@ class Package
$t->type = "Hotspot"; $t->type = "Hotspot";
$t->save(); $t->save();
} else { } else {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
@ -202,7 +202,7 @@ class Package
} else { } else {
if ($b) { if ($b) {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
@ -260,7 +260,7 @@ class Package
$t->type = "PPPOE"; $t->type = "PPPOE";
$t->save(); $t->save();
} else { } else {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
@ -342,7 +342,7 @@ class Package
$mikrotik = Mikrotik::info($p['routers']); $mikrotik = Mikrotik::info($p['routers']);
if ($p['type'] == 'Hotspot') { if ($p['type'] == 'Hotspot') {
if ($b) { if ($b) {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
@ -351,7 +351,7 @@ class Package
Mikrotik::addHotspotUser($client, $p, $c); Mikrotik::addHotspotUser($client, $p, $c);
} }
} else { } else {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
@ -362,7 +362,7 @@ class Package
} }
} else { } else {
if ($b) { if ($b) {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);
@ -371,7 +371,7 @@ class Package
Mikrotik::addPpoeUser($client, $p, $c); Mikrotik::addPpoeUser($client, $p, $c);
} }
} else { } else {
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$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::removeHotspotUser($client, $c['username']);
Mikrotik::removePpoeUser($client, $c['username']); Mikrotik::removePpoeUser($client, $c['username']);

View File

@ -1,24 +1,42 @@
<?php <?php
class Radius { class Radius
{
public static function getTableNas(){ public static function getTableNas()
{
return ORM::for_table('nas', 'radius'); return ORM::for_table('nas', 'radius');
} }
public static function getTableCustomer(){ public static function getTableCustomer()
{
return ORM::for_table('radcheck', 'radius'); return ORM::for_table('radcheck', 'radius');
} }
public static function getTablePackage(){ public static function getTablePackage()
{
return ORM::for_table('radgroupreply', 'radius'); return ORM::for_table('radgroupreply', 'radius');
} }
public static function getTableUserPackage(){ public static function getTableUserPackage()
{
return ORM::for_table('radusergroup', 'radius'); return ORM::for_table('radusergroup', 'radius');
} }
public static function addNas($name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){ public static function nasList($search = null){
if($search == null){
return ORM::for_table('nas', 'radius')->find_many();
}else{
return ORM::for_table('nas', 'radius')
->where_like('nasname', $search)
->where_like('shortname', $search)
->where_like('description', $search)
->find_many();
}
}
public static function nasAdd($name, $ip, $ports, $secret, $description = "", $type = 'other', $server = null, $community = null)
{
$n = Radius::getTableNas()->create(); $n = Radius::getTableNas()->create();
$n->nasname = $ip; $n->nasname = $ip;
$n->shortname = $name; $n->shortname = $name;
@ -32,9 +50,10 @@ class Radius {
return $n->id(); return $n->id();
} }
public static function updateNas($id, $name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){ public static function nasUpdate($id, $name, $ip, $ports, $secret, $description = "", $type = 'other', $server = null, $community = null)
{
$n = Radius::getTableNas()->find_one($id); $n = Radius::getTableNas()->find_one($id);
if(empty($n)){ if (empty($n)) {
return false; return false;
} }
$n->nasname = $ip; $n->nasname = $ip;
@ -48,4 +67,64 @@ class Radius {
return $n->save(); return $n->save();
} }
public static function planAdd($plan_id, $plan_name, $rate, $pool = null)
{
$rates = explode('/', $rate);
$r = Radius::getTablePackage()->create();
$r->groupname = $plan_name;
$r->attribute = 'Ascend-Data-Rate';
$r->op = ':=';
$r->value = $rates[1];
$r->plan_id = $plan_id;
if ($r->save()) {
$r = Radius::getTablePackage()->create();
$r->groupname = $plan_name;
$r->attribute = 'Ascend-Xmit-Rate';
$r->op = ':=';
$r->value = $rates[0];
$r->plan_id = $plan_id;
if ($r->save()) {
if ($pool != null) {
$r = Radius::getTablePackage()->create();
$r->groupname = $plan_name;
$r->attribute = 'Framed-Pool';
$r->op = ':=';
$r->value = $pool;
$r->plan_id = $plan_id;
if ($r->save()) {
return true;
}
} else {
return true;
}
}
}
return false;
}
public static function planUpdate($plan_id, $plan_name, $rate, $pool = null)
{
$rates = explode('/', $rate);
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Ascend-Data-Rate')->findOne();
$r->groupname = $plan_name;
$r->value = $rates[1];
if ($r->save()) {
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Ascend-Xmit-Rate')->findOne();
$r->groupname = $plan_name;
$r->value = $rates[0];
if ($r->save()) {
if ($pool != null) {
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', 'Framed-Pool')->findOne();
$r->groupname = $plan_name;
$r->value = $pool;
if ($r->save()) {
return true;
}
} else {
return true;
}
}
}
return false;
}
} }

View File

@ -44,7 +44,7 @@ switch ($action) {
if ($c) { if ($c) {
$mikrotik = Mikrotik::info($c['routers']); $mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') { if ($c['type'] == 'Hotspot') {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotUser($client, $c['username'], $npass); Mikrotik::setHotspotUser($client, $c['username'], $npass);
Mikrotik::removeHotspotActiveUser($client, $user['username']); Mikrotik::removeHotspotActiveUser($client, $user['username']);
@ -57,7 +57,7 @@ switch ($action) {
r2(U . 'login'); r2(U . 'login');
} else { } else {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if(!empty($d['pppoe_password'])){ if(!empty($d['pppoe_password'])){
Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']); Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']);

View File

@ -165,13 +165,13 @@ switch ($action) {
if ($c) { if ($c) {
$mikrotik = Mikrotik::info($c['routers']); $mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') { if ($c['type'] == 'Hotspot') {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $d['username']); Mikrotik::removeHotspotUser($client, $d['username']);
Mikrotik::removeHotspotActiveUser($client, $d['username']); Mikrotik::removeHotspotActiveUser($client, $d['username']);
} }
} else { } else {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client, $d['username']); Mikrotik::removePpoeUser($client, $d['username']);
Mikrotik::removePpoeActive($client, $d['username']); Mikrotik::removePpoeActive($client, $d['username']);
@ -284,7 +284,7 @@ switch ($action) {
if ($c) { if ($c) {
$mikrotik = Mikrotik::info($c['routers']); $mikrotik = Mikrotik::info($c['routers']);
if ($c['type'] == 'Hotspot') { if ($c['type'] == 'Hotspot') {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotUser($client, $c['username'], $password); Mikrotik::setHotspotUser($client, $c['username'], $password);
Mikrotik::removeHotspotActiveUser($client, $user['username']); Mikrotik::removeHotspotActiveUser($client, $user['username']);
@ -293,7 +293,7 @@ switch ($action) {
$d->password = $password; $d->password = $password;
$d->save(); $d->save();
} else { } else {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
if (!empty($d['pppoe_password'])) { if (!empty($d['pppoe_password'])) {
Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']); Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']);

View File

@ -60,7 +60,7 @@ switch ($action) {
$d = ORM::for_table('tbl_pool')->find_one($id); $d = ORM::for_table('tbl_pool')->find_one($id);
$mikrotik = Mikrotik::info($d['routers']); $mikrotik = Mikrotik::info($d['routers']);
if ($d) { if ($d) {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePool($client, $d['pool_name']); Mikrotik::removePool($client, $d['pool_name']);
} }
@ -100,7 +100,7 @@ switch ($action) {
} }
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
if ($msg == '') { if ($msg == '') {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPool($client, $name, $ip_address); Mikrotik::addPool($client, $name, $ip_address);
} }
@ -137,7 +137,7 @@ switch ($action) {
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
if ($msg == '') { if ($msg == '') {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPool($client, $d['pool_name'], $ip_address); Mikrotik::setPool($client, $d['pool_name'], $ip_address);
} }

View File

@ -167,7 +167,7 @@ switch ($action) {
if ($d) { if ($d) {
run_hook('delete_customer_active_plan'); #HOOK run_hook('delete_customer_active_plan'); #HOOK
if ($d['type'] == 'Hotspot') { if ($d['type'] == 'Hotspot') {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $d['username']); Mikrotik::removeHotspotUser($client, $d['username']);
Mikrotik::removeHotspotActiveUser($client, $d['username']); Mikrotik::removeHotspotActiveUser($client, $d['username']);
@ -175,7 +175,7 @@ switch ($action) {
$d->delete(); $d->delete();
} else { } else {
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoeUser($client, $d['username']); Mikrotik::removePpoeUser($client, $d['username']);
Mikrotik::removePpoeActive($client, $d['username']); Mikrotik::removePpoeActive($client, $d['username']);

View File

@ -55,9 +55,9 @@ switch ($action) {
$msg .= 'NAS IP Exists<br>'; $msg .= 'NAS IP Exists<br>';
} }
if ($msg == '') { if ($msg == '') {
$id = Radius::addNas($shortname, $nasname, $ports, $secret, $description, $type, $server, $community); $id = Radius::nasAdd($shortname, $nasname, $ports, $secret, $description, $type, $server, $community);
if ($id > 0) { if ($id > 0) {
r2(U . 'radius/nas-edit/' . $id, 's', "NAS Added"); r2(U . 'radius/nas-list/', 's', "NAS Added");
} else { } else {
r2(U . 'radius/nas-add/', 'e', "NAS Added Failed"); r2(U . 'radius/nas-add/', 'e', "NAS Added Failed");
} }
@ -110,17 +110,8 @@ switch ($action) {
$type = null; $type = null;
} }
if ($msg == '') { if ($msg == '') {
$d->nasname = $nasname; if (Radius::nasUpdate($id, $shortname, $nasname, $ports, $secret, $description, $type, $server, $community)) {
$d->shortname = $shortname; r2(U . 'radius/list/', 's', "NAS Saved");
$d->secret = $secret;
$d->ports = $ports;
$d->type = $type;
$d->server = $server;
$d->community = $community;
$d->description = $description;
$d->save();
if (Radius::updateNas($id, $shortname, $nasname, $ports, $secret, $description, $type, $server, $community)) {
r2(U . 'radius/nas-edit/' . $id, 's', "NAS Saved");
} else { } else {
r2(U . 'radius/nas-add', 'e', 'NAS NOT Exists'); r2(U . 'radius/nas-add', 'e', 'NAS NOT Exists');
} }
@ -141,13 +132,9 @@ switch ($action) {
$ui->assign('_title', "Network Access Server"); $ui->assign('_title', "Network Access Server");
$name = _post('name'); $name = _post('name');
if (empty($name)) { if (empty($name)) {
$nas = ORM::for_table('nas', 'radius')->find_many(); $nas = Radius::nasList();
} else { } else {
$nas = ORM::for_table('nas', 'radius') $nas = Radius::nasList($name);
->where_like('nasname', $name)
->where_like('shortname', $name)
->where_like('description', $name)
->find_many();
} }
$ui->assign('name', $name); $ui->assign('name', $name);
$ui->assign('nas', $nas); $ui->assign('nas', $nas);

View File

@ -89,9 +89,7 @@ switch ($action) {
$msg .= $_L['Router_already_exist'] . '<br>'; $msg .= $_L['Router_already_exist'] . '<br>';
} }
if (!$config['radius_mode']) { Mikrotik::getClient($ip_address, $username, $password);
Mikrotik::getClient($ip_address, $username, $password);
}
if ($msg == '') { if ($msg == '') {
run_hook('add_router'); #HOOK run_hook('add_router'); #HOOK
@ -149,9 +147,7 @@ switch ($action) {
} }
if (!$config['radius_mode']) { Mikrotik::getClient($ip_address, $username, $password);
Mikrotik::getClient($ip_address, $username, $password);
}
if ($msg == '') { if ($msg == '') {

View File

@ -28,27 +28,31 @@ switch ($action) {
$log = ''; $log = '';
$router = ''; $router = '';
foreach ($plans as $plan) { foreach ($plans as $plan) {
if ($router != $plan['routers']) { if($plan['is_radius']){
$mikrotik = Mikrotik::info($plan['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); }else{
$router = $plan['routers']; if ($router != $plan['routers']) {
} $mikrotik = Mikrotik::info($plan['routers']);
if ($plan['rate_down_unit'] == 'Kbps') { $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$unitdown = 'K'; $router = $plan['routers'];
} else { }
$unitdown = 'M'; if ($plan['rate_down_unit'] == 'Kbps') {
} $unitdown = 'K';
if ($plan['rate_up_unit'] == 'Kbps') { } else {
$unitup = 'K'; $unitdown = 'M';
} else { }
$unitup = 'M'; if ($plan['rate_up_unit'] == 'Kbps') {
} $unitup = 'K';
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown; } else {
Mikrotik::addHotspotPlan($client, $plan['name_plan'], $plan['shared_users'], $rate); $unitup = 'M';
$log .= "DONE : $plan[name_plan], $plan[shared_users], $rate<br>"; }
if (!empty($plan['pool_expired'])) { $rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired']); Mikrotik::addHotspotPlan($client, $plan['name_plan'], $plan['shared_users'], $rate);
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]<br>"; $log .= "DONE : $plan[name_plan], $plan[shared_users], $rate<br>";
if (!empty($plan['pool_expired'])) {
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired']);
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]<br>";
}
} }
} }
r2(U . 'services/hotspot', 's', $log); r2(U . 'services/hotspot', 's', $log);
@ -132,7 +136,7 @@ switch ($action) {
$d = ORM::for_table('tbl_plans')->find_one($id); $d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) { if ($d) {
run_hook('delete_plan'); #HOOK run_hook('delete_plan'); #HOOK
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$mikrotik = Mikrotik::info($d['routers']); $mikrotik = Mikrotik::info($d['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotPlan($client, $d['name_plan']); Mikrotik::removeHotspotPlan($client, $d['name_plan']);
@ -146,6 +150,7 @@ switch ($action) {
case 'add-post': case 'add-post':
$name = _post('name'); $name = _post('name');
$radius = _post('radius');
$typebp = _post('typebp'); $typebp = _post('typebp');
$limit_type = _post('limit_type'); $limit_type = _post('limit_type');
$time_limit = _post('time_limit'); $time_limit = _post('time_limit');
@ -168,10 +173,14 @@ switch ($action) {
if (Validator::UnsignedNumber($price) == false) { if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>'; $msg .= 'The price must be a number' . '<br>';
} }
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '') { if ($name == '' or $id_bw == '' or $price == '' or $validity == '') {
$msg .= $_L['All_field_is_required'] . '<br>'; $msg .= $_L['All_field_is_required'] . '<br>';
} }
if(empty($radius)){
if ($routers == '') {
$msg .= $_L['All_field_is_required'] . '<br>';
}
}
$d = ORM::for_table('tbl_plans')->where('name_plan', $name)->where('type', 'Hotspot')->find_one(); $d = ORM::for_table('tbl_plans')->where('name_plan', $name)->where('type', 'Hotspot')->find_one();
if ($d) { if ($d) {
$msg .= $_L['Plan_already_exist'] . '<br>'; $msg .= $_L['Plan_already_exist'] . '<br>';
@ -183,25 +192,20 @@ switch ($action) {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one(); $b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') { if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K'; $unitdown = 'K';
$raddown = '000';
} else { } else {
$unitdown = 'M'; $unitdown = 'M';
$raddown = '000000';
} }
if ($b['rate_up_unit'] == 'Kbps') { if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K'; $unitup = 'K';
$radup = '000';
} else { } else {
$unitup = 'M'; $unitup = 'M';
$radup = '000000';
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'].$radup.'/'.$b['rate_down'].$raddown;
if (!$config['radius_mode']) {
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
if (!empty($pool_expired)) {
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired);
}
}
$d = ORM::for_table('tbl_plans')->create(); $d = ORM::for_table('tbl_plans')->create();
$d->name_plan = $name; $d->name_plan = $name;
@ -217,10 +221,29 @@ switch ($action) {
$d->validity = $validity; $d->validity = $validity;
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->shared_users = $sharedusers; $d->shared_users = $sharedusers;
$d->routers = $routers; if(!empty($radius)){
$d->pool_expired = $pool_expired; $d->is_radius = 1;
$d->routers = '';
}else{
$d->is_radius = 0;
$d->routers = $routers;
$d->pool_expired = $pool_expired;
}
$d->enabled = $enabled; $d->enabled = $enabled;
$d->save(); $d->save();
$plan_id = $d->id();
if ($config['radius_enable']) {
Radius::planAdd($plan_id, $name, $radiusRate);
}else{
$mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
if (!empty($pool_expired)) {
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired);
}
}
r2(U . 'services/hotspot', 's', $_L['Created_Successfully']); r2(U . 'services/hotspot', 's', $_L['Created_Successfully']);
} else { } else {
@ -243,7 +266,6 @@ switch ($action) {
$sharedusers = _post('sharedusers'); $sharedusers = _post('sharedusers');
$validity = _post('validity'); $validity = _post('validity');
$validity_unit = _post('validity_unit'); $validity_unit = _post('validity_unit');
$routers = _post('routers');
$pool_expired = _post('pool_expired'); $pool_expired = _post('pool_expired');
$enabled = _post('enabled'); $enabled = _post('enabled');
@ -254,10 +276,9 @@ switch ($action) {
if (Validator::UnsignedNumber($price) == false) { if (Validator::UnsignedNumber($price) == false) {
$msg .= 'The price must be a number' . '<br>'; $msg .= 'The price must be a number' . '<br>';
} }
if ($name == '' or $id_bw == '' or $price == '' or $validity == '' or $routers == '') { if ($name == '' or $id_bw == '' or $price == '' or $validity == '') {
$msg .= $_L['All_field_is_required'] . '<br>'; $msg .= $_L['All_field_is_required'] . '<br>';
} }
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one(); $d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
if ($d) { if ($d) {
} else { } else {
@ -268,17 +289,24 @@ switch ($action) {
$b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one(); $b = ORM::for_table('tbl_bandwidth')->where('id', $id_bw)->find_one();
if ($b['rate_down_unit'] == 'Kbps') { if ($b['rate_down_unit'] == 'Kbps') {
$unitdown = 'K'; $unitdown = 'K';
$raddown = '000';
} else { } else {
$unitdown = 'M'; $unitdown = 'M';
$raddown = '000000';
} }
if ($b['rate_up_unit'] == 'Kbps') { if ($b['rate_up_unit'] == 'Kbps') {
$unitup = 'K'; $unitup = 'K';
$radup = '000';
} else { } else {
$unitup = 'M'; $unitup = 'M';
$radup = '000000';
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'].$radup.'/'.$b['rate_down'].$raddown;
if (!$config['radius_mode']) { if ($config['radius_enable']) {
Radius::planUpdate($id, $name, $radiusRate);
}else{
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate); Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate);
@ -299,7 +327,6 @@ switch ($action) {
$d->validity = $validity; $d->validity = $validity;
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->shared_users = $sharedusers; $d->shared_users = $sharedusers;
$d->routers = $routers;
$d->pool_expired = $pool_expired; $d->pool_expired = $pool_expired;
$d->enabled = $enabled; $d->enabled = $enabled;
$d->save(); $d->save();
@ -364,7 +391,7 @@ switch ($action) {
$d = ORM::for_table('tbl_plans')->find_one($id); $d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) { if ($d) {
run_hook('delete_ppoe'); #HOOK run_hook('delete_ppoe'); #HOOK
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$mikrotik = Mikrotik::info($d['routers']); $mikrotik = Mikrotik::info($d['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removePpoePlan($client, $d['name_plan']); Mikrotik::removePpoePlan($client, $d['name_plan']);
@ -416,7 +443,7 @@ switch ($action) {
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::addPpoePlan($client, $name, $pool, $rate); Mikrotik::addPpoePlan($client, $name, $pool, $rate);
@ -487,7 +514,7 @@ switch ($action) {
} }
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown; $rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if (!$config['radius_mode']) { if (!$config['radius_enable']) {
$mikrotik = Mikrotik::info($routers); $mikrotik = Mikrotik::info($routers);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::setPpoePlan($client, $name, $pool, $rate); Mikrotik::setPpoePlan($client, $name, $pool, $rate);

View File

@ -92,7 +92,7 @@ foreach ($d as $ds) {
$m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one(); $m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
if(!empty($p['pool_expired'])){ if(!empty($p['pool_expired'])){
Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL '.$p['pool_expired']); Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL '.$p['pool_expired']);
@ -139,7 +139,7 @@ foreach ($d as $ds) {
$m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one(); $m = ORM::for_table('tbl_routers')->where('name', $ds['routers'])->find_one();
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
if (!$_c['radius_mode']) { if (!$_c['radius_enable']) {
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']); $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
if(!empty($p['pool_expired'])){ if(!empty($p['pool_expired'])){
Mikrotik::setPpoeUserPlan($client, $c['username'], 'EXPIRED NUXBILL '.$p['pool_expired']); Mikrotik::setPpoeUserPlan($client, $c['username'], 'EXPIRED NUXBILL '.$p['pool_expired']);

View File

@ -76,8 +76,8 @@
<label class="col-md-2 control-label text-muted">Enable Radius</label> <label class="col-md-2 control-label text-muted">Enable Radius</label>
<div class="col-md-6"> <div class="col-md-6">
<select name="radius_enable" id="radius_enable" class="form-control text-muted" onchange="alert('still not worked yet :)\nbut you can see any feature on development')"> <select name="radius_enable" id="radius_enable" class="form-control text-muted" onchange="alert('still not worked yet :)\nbut you can see any feature on development')">
<option value="no">No</option> <option value="0">No</option>
<option value="yes" {if $_c['radius_enable']}selected="selected" {/if}>Yes</option> <option value="1" {if $_c['radius_enable']}selected="selected" {/if}>Yes</option>
</select> </select>
</div> </div>
<p class="help-block col-md-4 text-red">Radius Not Yet Ready</p> <p class="help-block col-md-4 text-red">Radius Not Yet Ready</p>

View File

@ -17,7 +17,7 @@
</label> </label>
</div> </div>
</div> </div>
{if $_c['radius_enable'] == 'yes'} {if $_c['radius_enable']}
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">Radius</label> <label class="col-md-2 control-label">Radius</label>
<div class="col-md-10"> <div class="col-md-10">
@ -167,10 +167,19 @@
{literal} {literal}
<script> <script>
function isRadius(cek){ function isRadius(cek) {
if(cek.checked){ if (cek.checked) {
$("#routerChoose").addClass('hidden'); $("#routerChoose").addClass('hidden');
}else{ document.getElementById("routers").required = false;
document.getElementById("Limited").disabled = true;
document.getElementById("Unlimited").checked = true;
document.getElementById("Limited").checked = false;
$('#Type').hide();
$('#TimeLimit').hide();
$('#DataLimit').hide();
} else {
document.getElementById("Limited").disabled = false;
document.getElementById("routers").required = true;
$("#routerChoose").removeClass('hidden'); $("#routerChoose").removeClass('hidden');
} }
} }

View File

@ -1,142 +1,194 @@
{include file="sections/header.tpl"} {include file="sections/header.tpl"}
<div class="row"> <div class="row">
<div class="col-sm-12 col-md-12"> <div class="col-sm-12 col-md-12">
<div class="panel panel-primary panel-hovered panel-stacked mb30"> <div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">{$_L['Edit_Plan']}</div> <div class="panel-heading">{$_L['Edit_Plan']}</div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}services/edit-post"> <form class="form-horizontal" method="post" role="form" action="{$_url}services/edit-post">
<input type="hidden" name="id" value="{$d['id']}"> <input type="hidden" name="id" value="{$d['id']}">
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label> <label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10"> <div class="col-md-10">
<label class="radio-inline warning"> <label class="radio-inline warning">
<input type="radio" {if $d['enabled'] == 1}checked{/if} name="enabled" value="1"> Enable <input type="radio" {if $d['enabled'] == 1}checked{/if} name="enabled" value="1"> Enable
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" {if $d['enabled'] == 0}checked{/if} name="enabled" value="0"> Disable <input type="radio" {if $d['enabled'] == 0}checked{/if} name="enabled" value="0">
</label> Disable
</div> </label>
</div>
</div>
{if $_c['radius_enable'] and $d['is_radius']}
<div class="form-group">
<label class="col-md-2 control-label">Radius</label>
<div class="col-md-10">
<label class="label label-primary">RADIUS</label>
</div> </div>
<div class="form-group"> </div>
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label> {/if}
<div class="col-md-6"> <div class="form-group">
<input type="text" class="form-control" id="name" name="name" maxlength="40" value="{$d['name_plan']}"> <label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
</div> <div class="col-md-6">
</div> <input type="text" class="form-control" id="name" name="name" maxlength="40"
<div class="form-group"> value="{$d['name_plan']}">
<label class="col-md-2 control-label">{$_L['Plan_Type']}</label> </div>
<div class="col-md-10"> </div>
<input type="radio" id="Unlimited" name="typebp" value="Unlimited" {if $d['typebp'] eq 'Unlimited'} checked {/if}> {$_L['Unlimited']} <div class="form-group">
<input type="radio" id="Limited" name="typebp" value="Limited" {if $d['typebp'] eq 'Limited'} checked {/if}> {$_L['Limited']} <label class="col-md-2 control-label">{$_L['Plan_Type']}</label>
</div> <div class="col-md-10">
</div> <input type="radio" id="Unlimited" name="typebp" value="Unlimited"
<div {if $d['typebp'] eq 'Unlimited'} style="display:none;" {/if} id="Type"> {if $d['typebp'] eq 'Unlimited'} checked {/if}> {$_L['Unlimited']}
<div class="form-group"> <input type="radio" id="Limited" {if $_c['radius_enable'] and $d['is_radius']}disabled{/if} name="typebp" value="Limited"
<label class="col-md-2 control-label">{$_L['Limit_Type']}</label> {if $d['typebp'] eq 'Limited'} checked {/if}> {$_L['Limited']}
<div class="col-md-10"> </div>
<input type="radio" id="Time_Limit" name="limit_type" value="Time_Limit" {if $d['limit_type'] eq 'Time_Limit'} checked {/if}> {$_L['Time_Limit']} </div>
<input type="radio" id="Data_Limit" name="limit_type" value="Data_Limit" {if $d['limit_type'] eq 'Data_Limit'} checked {/if}> {$_L['Data_Limit']} <div {if $d['typebp'] eq 'Unlimited'} style="display:none;" {/if} id="Type">
<input type="radio" id="Both_Limit" name="limit_type" value="Both_Limit" {if $d['limit_type'] eq 'Both_Limit'} checked {/if}> {$_L['Both_Limit']} <div class="form-group">
</div> <label class="col-md-2 control-label">{$_L['Limit_Type']}</label>
</div> <div class="col-md-10">
</div> <input type="radio" id="Time_Limit" name="limit_type" value="Time_Limit"
<div {if $d['typebp'] eq 'Unlimited'} style="display:none;" {elseif ($d['time_limit']) eq '0'} style="display:none;" {/if} id="TimeLimit"> {if $d['limit_type'] eq 'Time_Limit'} checked {/if}> {$_L['Time_Limit']}
<div class="form-group"> <input type="radio" id="Data_Limit" name="limit_type" value="Data_Limit"
<label class="col-md-2 control-label">{$_L['Time_Limit']}</label> {if $d['limit_type'] eq 'Data_Limit'} checked {/if}> {$_L['Data_Limit']}
<div class="col-md-4"> <input type="radio" id="Both_Limit" name="limit_type" value="Both_Limit"
<input type="text" class="form-control" id="time_limit" name="time_limit" value="{$d['time_limit']}"> {if $d['limit_type'] eq 'Both_Limit'} checked {/if}> {$_L['Both_Limit']}
</div> </div>
<div class="col-md-2"> </div>
<select class="form-control" id="time_unit" name="time_unit" > </div>
<option value="Hrs" {if $d['time_unit'] eq 'Hrs'} selected {/if}>{$_L['Hrs']}</option> <div {if $d['typebp'] eq 'Unlimited'} style="display:none;"
<option value="Mins" {if $d['time_unit'] eq 'Mins'} selected {/if}>{$_L['Mins']}</option> {elseif ($d['time_limit']) eq '0'}
</select> style="display:none;" {/if} id="TimeLimit">
</div> <div class="form-group">
</div> <label class="col-md-2 control-label">{$_L['Time_Limit']}</label>
</div> <div class="col-md-4">
<div {if $d['typebp'] eq 'Unlimited'} style="display:none;" {elseif ($d['data_limit']) eq '0'} style="display:none;" {/if} id="DataLimit"> <input type="text" class="form-control" id="time_limit" name="time_limit"
<div class="form-group"> value="{$d['time_limit']}">
<label class="col-md-2 control-label">{$_L['Data_Limit']}</label> </div>
<div class="col-md-4"> <div class="col-md-2">
<input type="text" class="form-control" id="data_limit" name="data_limit" value="{$d['data_limit']}"> <select class="form-control" id="time_unit" name="time_unit">
</div> <option value="Hrs" {if $d['time_unit'] eq 'Hrs'} selected {/if}>{$_L['Hrs']}
<div class="col-md-2"> </option>
<select class="form-control" id="data_unit" name="data_unit"> <option value="Mins" {if $d['time_unit'] eq 'Mins'} selected {/if}>{$_L['Mins']}
<option value="MB" {if $d['data_unit'] eq 'MB'} selected {/if}>MBs</option> </option>
<option value="GB" {if $d['data_unit'] eq 'GB'} selected {/if}>GBs</option> </select>
</select> </div>
</div> </div>
</div> </div>
</div> <div {if $d['typebp'] eq 'Unlimited'} style="display:none;"
<div class="form-group"> {elseif ($d['data_limit']) eq '0'}
<label class="col-md-2 control-label"><a href="{$_url}bandwidth/add">{$_L['BW_Name']}</a></label> style="display:none;" {/if} id="DataLimit">
<div class="col-md-6"> <div class="form-group">
<select id="id_bw" name="id_bw" class="form-control select2"> <label class="col-md-2 control-label">{$_L['Data_Limit']}</label>
{foreach $b as $bs} <div class="col-md-4">
<option value="{$bs['id']}" {if $d['id_bw'] eq $bs['id']} selected {/if}>{$bs['name_bw']}</option> <input type="text" class="form-control" id="data_limit" name="data_limit"
{/foreach} value="{$d['data_limit']}">
</select> </div>
</div> <div class="col-md-2">
</div> <select class="form-control" id="data_unit" name="data_unit">
<div class="form-group"> <option value="MB" {if $d['data_unit'] eq 'MB'} selected {/if}>MBs</option>
<label class="col-md-2 control-label">{$_L['Plan_Price']}</label> <option value="GB" {if $d['data_unit'] eq 'GB'} selected {/if}>GBs</option>
<div class="col-md-6"> </select>
<div class="input-group"> </div>
<span class="input-group-addon">{$_c['currency_code']}</span> </div>
<input type="number" class="form-control" name="price" value="{$d['price']}" required> </div>
</div> <div class="form-group">
</div> <label class="col-md-2 control-label"><a
</div> href="{$_url}bandwidth/add">{$_L['BW_Name']}</a></label>
<div class="form-group"> <div class="col-md-6">
<label class="col-md-2 control-label">{$_L['Shared_Users']}</label> <select id="id_bw" name="id_bw" class="form-control select2">
<div class="col-md-6"> {foreach $b as $bs}
<input type="text" class="form-control" id="sharedusers" name="sharedusers" value="{$d['shared_users']}"> <option value="{$bs['id']}" {if $d['id_bw'] eq $bs['id']} selected {/if}>
</div> {$bs['name_bw']}</option>
</div> {/foreach}
<div class="form-group"> </select>
<label class="col-md-2 control-label">{$_L['Plan_Validity']}</label> </div>
<div class="col-md-4"> </div>
<input type="text" class="form-control" id="validity" name="validity" value="{$d['validity']}"> <div class="form-group">
</div> <label class="col-md-2 control-label">{$_L['Plan_Price']}</label>
<div class="col-md-2"> <div class="col-md-6">
<select class="form-control" id="validity_unit" name="validity_unit"> <div class="input-group">
<option value="Mins" {if $d['validity_unit'] eq 'Mins'} selected {/if}>{$_L['Mins']}</option> <span class="input-group-addon">{$_c['currency_code']}</span>
<option value="Hrs" {if $d['validity_unit'] eq 'Hrs'} selected {/if}>{$_L['Hrs']}</option> <input type="number" class="form-control" name="price" value="{$d['price']}" required>
<option value="Days" {if $d['validity_unit'] eq 'Days'} selected {/if}>{$_L['Days']}</option> </div>
<option value="Months" {if $d['validity_unit'] eq 'Months'} selected {/if}>{$_L['Months']}</option> </div>
</select> </div>
</div> <div class="form-group">
</div> <label class="col-md-2 control-label">{$_L['Shared_Users']}</label>
<div class="form-group"> <div class="col-md-6">
<label class="col-md-2 control-label"><a href="{$_url}routers/add">{$_L['Router_Name']}</a></label> <input type="text" class="form-control" id="sharedusers" name="sharedusers"
<div class="col-md-6"> value="{$d['shared_users']}">
<input type="text" class="form-control" id="routers" name="routers" value="{$d['routers']}" readonly> </div>
</div> </div>
</div> <div class="form-group">
<div class="form-group"> <label class="col-md-2 control-label">{$_L['Plan_Validity']}</label>
<label class="col-md-2 control-label"><a href="{$_url}pool/add">{Lang::T('Expired IP Pool')}</a></label> <div class="col-md-4">
<div class="col-md-6"> <input type="text" class="form-control" id="validity" name="validity"
<select id="pool_expired" name="pool_expired" class="form-control select2"> value="{$d['validity']}">
<option value=''>{$_L['Select_Pool']}</option> </div>
{foreach $p as $ps} <div class="col-md-2">
<option value="{$ps['pool_name']}" {if $d['pool_expired'] eq $ps['pool_name']} selected {/if}>{$ps['pool_name']}</option> <select class="form-control" id="validity_unit" name="validity_unit">
{/foreach} <option value="Mins" {if $d['validity_unit'] eq 'Mins'} selected {/if}>{$_L['Mins']}
</select> </option>
</div> <option value="Hrs" {if $d['validity_unit'] eq 'Hrs'} selected {/if}>{$_L['Hrs']}
</div> </option>
<option value="Days" {if $d['validity_unit'] eq 'Days'} selected {/if}>{$_L['Days']}
</option>
<option value="Months" {if $d['validity_unit'] eq 'Months'} selected {/if}>
{$_L['Months']}</option>
</select>
</div>
</div>
<span id="routerChoose" class="{if $d['is_radius']}hidden{/if}">
<div class="form-group">
<label class="col-md-2 control-label"><a
href="{$_url}routers/add">{$_L['Router_Name']}</a></label>
<div class="col-md-6">
<input type="text" class="form-control" id="routers" name="routers"
value="{$d['routers']}" readonly>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label"><a
href="{$_url}pool/add">{Lang::T('Expired IP Pool')}</a></label>
<div class="col-md-6">
<select id="pool_expired" name="pool_expired" class="form-control select2">
<option value=''>{$_L['Select_Pool']}</option>
{foreach $p as $ps}
<option value="{$ps['pool_name']}" {if $d['pool_expired'] eq $ps['pool_name']}
selected {/if}>{$ps['pool_name']}</option>
{/foreach}
</select>
</div>
</div>
</span>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button class="btn btn-success waves-effect waves-light"
type="submit">{$_L['Save']}</button>
Or <a href="{$_url}services/hotspot">{$_L['Cancel']}</a>
</div>
</div>
</form>
<div class="form-group"> </div>
<div class="col-md-offset-2 col-md-10"> </div>
<button class="btn btn-success waves-effect waves-light" type="submit">{$_L['Save']}</button> </div>
Or <a href="{$_url}services/hotspot">{$_L['Cancel']}</a> </div>
</div>
</div>
</form>
</div> {literal}
</div> <script>
</div> function isRadius(cek) {
</div> if (cek.checked) {
$("#routerChoose").addClass('hidden');
{include file="sections/footer.tpl"} document.getElementById("routers").required = false;
document.getElementById("Limited").disabled = true;
} else {
document.getElementById("Limited").disabled = false;
document.getElementById("routers").required = true;
$("#routerChoose").removeClass('hidden');
}
}
</script>
{/literal}
{include file="sections/footer.tpl"}

View File

@ -58,7 +58,7 @@
<td>{$ds['data_limit']} {$ds['data_unit']}</td> <td>{$ds['data_limit']} {$ds['data_unit']}</td>
<td>{$ds['validity']} {$ds['validity_unit']}</td> <td>{$ds['validity']} {$ds['validity_unit']}</td>
<td> <td>
{if $ds['is_radius']==1} {if $ds['is_radius']}
<span class="label label-primary">RADIUS</span> <span class="label label-primary">RADIUS</span>
{else} {else}
{if $ds['routers']!=''} {if $ds['routers']!=''}