This commit is contained in:
Ibnu Maksum 2023-09-18 16:45:08 +07:00
parent e64f27bc63
commit b3057bd59e
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
4 changed files with 163 additions and 7 deletions

View File

@ -102,11 +102,11 @@ try {
}
}
if (!empty($radius_user)) {
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'rad');
ORM::configure('username', $radius_user, 'rad');
ORM::configure('password', $radius_pass, 'rad');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'rad');
ORM::configure('return_result_sets', true, 'rad');
ORM::configure("mysql:host=$radius_host;dbname=$radius_name", null, 'radius');
ORM::configure('username', $radius_user, 'radius');
ORM::configure('password', $radius_pass, 'radius');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'radius');
ORM::configure('return_result_sets', true, 'radius');
}
} catch (Exception $e) {
$ui = new Smarty();

View File

@ -37,8 +37,6 @@ document.addEventListener("DOMContentLoaded", function(event) {
</script>
EOT;
require_once 'system/autoload/PEAR2/Autoload.php';
switch ($action) {
case 'sync':
set_time_limit(-1);

View File

@ -0,0 +1,84 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
**/
_admin();
$ui->assign('_title', $_L['Plugin Manager']);
$ui->assign('_system_menu', 'settings');
$action = $routes['1'];
$admin = Admin::_info();
$ui->assign('_admin', $admin);
if ($admin['user_type'] != 'Admin') {
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
}
switch ($action) {
case 'nas-list':
$ui->assign('_system_menu', 'network');
$ui->assign('_title', "Network Access Server");
$nas = ORM::for_table('nas', 'radius')->find_many();
$ui->assign('nas', $nas);
$ui->display('radius-nas.tpl');
case 'nas-add':
$ui->assign('_system_menu', 'network');
$ui->assign('_title', "Network Access Server");
$ui->display('radius-nas-add.tpl');
case 'nas-add-post':
$shortname = _post('shortname');
$nasname = _post('nasname');
$secret = _post('secret');
$ports = _post('ports', null);
$type = _post('type', 'other');
$server = _post('server', null);
$community = _post('community', null);
$description = _post('description');
$msg = '';
if (Validator::Length($shortname, 30, 2) == false) {
$msg .= 'Name should be between 3 to 30 characters' . '<br>';
}
if (empty($ports)) {
$ports = null;
}
if (empty($server)) {
$server = null;
}
if (empty($community)) {
$community = null;
}
if (empty($type)) {
$type = null;
}
$d = ORM::for_table('nas', 'radius')->where('nasname', $nasname)->find_one();
if ($d) {
$msg .= 'NAS IP Exists<br>';
}
if ($msg == '') {
$b = ORM::for_table('nas', 'radius')->create();
$b->nasname = $nasname;
$b->shortname = $shortname;
$b->secret = $secret;
$b->ports = $ports;
$b->type = $type;
$b->server = $server;
$b->community = $community;
$b->description = $description;
$b->save();
$id = $b->id();
if($id>0){
r2(U . 'radius/nas-edit/'.$id, 's', "NAS Added");
}else{
r2(U . 'radius/nas-add/', 'e', "NAS Added Failed");
}
}else{
r2(U . 'radius/nas-add', 'e', $msg);
}
default:
$ui->display('a404.tpl');
}

74
ui/ui/radius-nas-add.tpl Normal file
View File

@ -0,0 +1,74 @@
{include file="sections/header.tpl"}
<!-- routers-add -->
<div class="row">
<div class="col-sm-12 col-md-12">
<div class="panel panel-primary panel-hovered panel-stacked mb30">
<div class="panel-heading">Radius - Add NAS</div>
<div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}radius/nas-add-post">
<div class="form-group">
<label class="col-md-2 control-label">{$_L['Router_Name']}</label>
<div class="col-md-6">
<input type="text" required class="form-control" id="shortname" name="shortname" maxlength="32">
<p class="help-block">{Lang::T('Name of Area that router operated')}</p>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{$_L['IP_Address']}</label>
<div class="col-md-6">
<input type="text" placeholder="192.168.88.1" required class="form-control" id="nasname"
name="nasname" maxlength="128">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Secret</label>
<div class="col-md-6">
<input type="password" class="form-control" id="secret" name="secret" required
onmouseleave="this.type = 'password'" onmouseenter="this.type = 'text'" maxlength="60">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Ports</label>
<div class="col-md-2">
<input type="text" class="form-control" id="ports" name="ports" placeholder="null">
</div>
<label class="col-md-2 control-label">Type</label>
<div class="col-md-2">
<input type="text" class="form-control" id="type" name="type" value="other" required
placeholder="other">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Server</label>
<div class="col-md-2">
<input type="text" class="form-control" id="server" name="server" placeholder="null">
</div>
<label class="col-md-2 control-label">Community</label>
<div class="col-md-2">
<input type="text" class="form-control" id="community" name="community" placeholder="null">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{$_L['Description']}</label>
<div class="col-md-6">
<textarea class="form-control" id="description" name="description"></textarea>
<p class="help-block">{Lang::T('Explain Coverage of router')}</p>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button class="btn btn-primary waves-effect waves-light"
type="submit">{$_L['Save']}</button>
Or <a href="{$_url}radius/nas-list">{$_L['Cancel']}</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
{include file="sections/footer.tpl"}