Assign router to NAS
This commit is contained in:
parent
02a68589a1
commit
ef25633275
@ -9,7 +9,8 @@ CREATE TABLE `nas` (
|
|||||||
`secret` varchar(60) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'secret',
|
`secret` varchar(60) COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'secret',
|
||||||
`server` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
`server` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||||
`community` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
`community` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||||
`description` varchar(200) COLLATE utf8mb4_general_ci DEFAULT 'RADIUS Client'
|
`description` varchar(200) COLLATE utf8mb4_general_ci DEFAULT 'RADIUS Client',
|
||||||
|
`routers` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `radacct`;
|
DROP TABLE IF EXISTS `radacct`;
|
||||||
|
@ -43,7 +43,7 @@ class Radius
|
|||||||
return ORM::for_table('radusergroup', 'radius');
|
return ORM::for_table('radusergroup', 'radius');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nasAdd($name, $ip, $ports, $secret, $description = "", $type = 'other', $server = null, $community = null)
|
public static function nasAdd($name, $ip, $ports, $secret, $routers = "", $description = "", $type = 'other', $server = null, $community = null)
|
||||||
{
|
{
|
||||||
$n = Radius::getTableNas()->create();
|
$n = Radius::getTableNas()->create();
|
||||||
$n->nasname = $ip;
|
$n->nasname = $ip;
|
||||||
@ -54,11 +54,12 @@ class Radius
|
|||||||
$n->description = $description;
|
$n->description = $description;
|
||||||
$n->server = $server;
|
$n->server = $server;
|
||||||
$n->community = $community;
|
$n->community = $community;
|
||||||
|
$n->routers = $routers;
|
||||||
$n->save();
|
$n->save();
|
||||||
return $n->id();
|
return $n->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function nasUpdate($id, $name, $ip, $ports, $secret, $description = "", $type = 'other', $server = null, $community = null)
|
public static function nasUpdate($id, $name, $ip, $ports, $secret, $routers = "", $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)) {
|
||||||
@ -72,6 +73,7 @@ class Radius
|
|||||||
$n->description = $description;
|
$n->description = $description;
|
||||||
$n->server = $server;
|
$n->server = $server;
|
||||||
$n->community = $community;
|
$n->community = $community;
|
||||||
|
$n->routers = $routers;
|
||||||
return $n->save();
|
return $n->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,17 +121,17 @@ class Radius
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function customerDeactivate($username, $radiusDisconnect = true) {
|
public static function customerDeactivate($username, $radiusDisconnect = true)
|
||||||
{
|
{ {
|
||||||
global $radius_pass;
|
global $radius_pass;
|
||||||
$r = Radius::getTableCustomer()->where_equal('username', $username)->whereEqual('attribute', 'Cleartext-Password')->findOne();
|
$r = Radius::getTableCustomer()->where_equal('username', $username)->whereEqual('attribute', 'Cleartext-Password')->findOne();
|
||||||
if ($r) {
|
if ($r) {
|
||||||
// no need to delete, because it will make ID got higher
|
// no need to delete, because it will make ID got higher
|
||||||
// we just change the password
|
// we just change the password
|
||||||
$r->value = md5(time() . $username . $radius_pass);
|
$r->value = md5(time() . $username . $radius_pass);
|
||||||
$r->save();
|
$r->save();
|
||||||
if($radiusDisconnect)
|
if ($radiusDisconnect)
|
||||||
return Radius::disconnectCustomer($username);
|
return Radius::disconnectCustomer($username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
@ -21,6 +21,7 @@ switch ($action) {
|
|||||||
case 'nas-add':
|
case 'nas-add':
|
||||||
$ui->assign('_system_menu', 'network');
|
$ui->assign('_system_menu', 'network');
|
||||||
$ui->assign('_title', "Network Access Server");
|
$ui->assign('_title', "Network Access Server");
|
||||||
|
$ui->assign('routers', ORM::for_table('tbl_routers')->find_many());
|
||||||
$ui->display('radius-nas-add.tpl');
|
$ui->display('radius-nas-add.tpl');
|
||||||
break;
|
break;
|
||||||
case 'nas-add-post':
|
case 'nas-add-post':
|
||||||
@ -32,6 +33,7 @@ switch ($action) {
|
|||||||
$server = _post('server', null);
|
$server = _post('server', null);
|
||||||
$community = _post('community', null);
|
$community = _post('community', null);
|
||||||
$description = _post('description');
|
$description = _post('description');
|
||||||
|
$routers = _post('routers');
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
|
||||||
if (Validator::Length($shortname, 30, 2) == false) {
|
if (Validator::Length($shortname, 30, 2) == false) {
|
||||||
@ -54,7 +56,7 @@ switch ($action) {
|
|||||||
$msg .= 'NAS IP Exists<br>';
|
$msg .= 'NAS IP Exists<br>';
|
||||||
}
|
}
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
$id = Radius::nasAdd($shortname, $nasname, $ports, $secret, $description, $type, $server, $community);
|
$id = Radius::nasAdd($shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community);
|
||||||
if ($id > 0) {
|
if ($id > 0) {
|
||||||
r2(U . 'radius/nas-list/', 's', "NAS Added");
|
r2(U . 'radius/nas-list/', 's', "NAS Added");
|
||||||
} else {
|
} else {
|
||||||
@ -74,6 +76,7 @@ switch ($action) {
|
|||||||
$d = ORM::for_table('nas', 'radius')->where_equal('shortname', _get('name'))->find_one();
|
$d = ORM::for_table('nas', 'radius')->where_equal('shortname', _get('name'))->find_one();
|
||||||
}
|
}
|
||||||
if ($d) {
|
if ($d) {
|
||||||
|
$ui->assign('routers', ORM::for_table('tbl_routers')->find_many());
|
||||||
$ui->assign('d', $d);
|
$ui->assign('d', $d);
|
||||||
$ui->display('radius-nas-edit.tpl');
|
$ui->display('radius-nas-edit.tpl');
|
||||||
} else {
|
} else {
|
||||||
@ -91,6 +94,7 @@ switch ($action) {
|
|||||||
$server = _post('server', null);
|
$server = _post('server', null);
|
||||||
$community = _post('community', null);
|
$community = _post('community', null);
|
||||||
$description = _post('description');
|
$description = _post('description');
|
||||||
|
$routers = _post('routers');
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
|
||||||
if (Validator::Length($shortname, 30, 2) == false) {
|
if (Validator::Length($shortname, 30, 2) == false) {
|
||||||
@ -109,7 +113,7 @@ switch ($action) {
|
|||||||
$type = null;
|
$type = null;
|
||||||
}
|
}
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
if (Radius::nasUpdate($id, $shortname, $nasname, $ports, $secret, $description, $type, $server, $community)) {
|
if (Radius::nasUpdate($id, $shortname, $nasname, $ports, $secret, $routers, $description, $type, $server, $community)) {
|
||||||
r2(U . 'radius/list/', 's', "NAS Saved");
|
r2(U . 'radius/list/', 's', "NAS Saved");
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'radius/nas-add', 'e', 'NAS NOT Exists');
|
r2(U . 'radius/nas-add', 'e', 'NAS NOT Exists');
|
||||||
|
@ -32,5 +32,8 @@
|
|||||||
],
|
],
|
||||||
"2023.10.1" : [
|
"2023.10.1" : [
|
||||||
"ALTER TABLE `tbl_plans` ADD `is_radius` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '1 is radius' AFTER `routers`; "
|
"ALTER TABLE `tbl_plans` ADD `is_radius` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '1 is radius' AFTER `routers`; "
|
||||||
|
],
|
||||||
|
"2023.10.24" : [
|
||||||
|
"ALTER TABLE `nas` ADD `routers` VARCHAR(32) NOT NULL DEFAULT '' AFTER `description`;"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -57,6 +57,18 @@
|
|||||||
<p class="help-block">{Lang::T('Explain Coverage of router')}</p>
|
<p class="help-block">{Lang::T('Explain Coverage of router')}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label"><a href="{$_url}routers/add">{$_L['Routers']}</a></label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<select id="routers" name="routers" class="form-control select2">
|
||||||
|
<option value="">No Router</option>
|
||||||
|
{foreach $routers as $rs}
|
||||||
|
<option value="{$rs['name']}">{$rs['name']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="help-block col-md-4">Assign NAS to Router</p>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-lg-offset-2 col-lg-10">
|
<div class="col-lg-offset-2 col-lg-10">
|
||||||
<button class="btn btn-primary waves-effect waves-light"
|
<button class="btn btn-primary waves-effect waves-light"
|
||||||
|
@ -57,6 +57,19 @@
|
|||||||
<p class="help-block">{Lang::T('Explain Coverage of router')}</p>
|
<p class="help-block">{Lang::T('Explain Coverage of router')}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label"><a href="{$_url}routers/add">{$_L['Routers']}</a></label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<select id="routers" name="routers" class="form-control select2">
|
||||||
|
<option value="">No Router</option>
|
||||||
|
{foreach $routers as $rs}
|
||||||
|
<option {if $rs['name'] == $d['routers']}selected{/if} value="{$rs['name']}">{$rs['name']}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="help-block col-md-4">Assign NAS to Router</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-gro
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-lg-offset-2 col-lg-10">
|
<div class="col-lg-offset-2 col-lg-10">
|
||||||
<button class="btn btn-primary waves-effect waves-light"
|
<button class="btn btn-primary waves-effect waves-light"
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<th>Port</th>
|
<th>Port</th>
|
||||||
<th>Server</th>
|
<th>Server</th>
|
||||||
<th>Community</th>
|
<th>Community</th>
|
||||||
|
<th>Routers</th>
|
||||||
<th>{$_L['Manage']}</th>
|
<th>{$_L['Manage']}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -51,6 +52,7 @@
|
|||||||
<td>{$ds['ports']}</td>
|
<td>{$ds['ports']}</td>
|
||||||
<td>{$ds['server']}</td>
|
<td>{$ds['server']}</td>
|
||||||
<td>{$ds['community']}</td>
|
<td>{$ds['community']}</td>
|
||||||
|
<td>{$ds['routers']}</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="{$_url}radius/nas-edit/{$ds['id']}" class="btn btn-info btn-xs">{$_L['Edit']}</a>
|
<a href="{$_url}radius/nas-edit/{$ds['id']}" class="btn btn-info btn-xs">{$_L['Edit']}</a>
|
||||||
<a href="{$_url}radius/nas-delete/{$ds['id']}" id="{$ds['id']}"
|
<a href="{$_url}radius/nas-delete/{$ds['id']}" id="{$ds['id']}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user