Enable disable router and plan

This commit is contained in:
Ibnu Maksum 2022-09-08 10:43:46 +07:00
parent 464f41ef16
commit 4fa341d854
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
14 changed files with 332 additions and 227 deletions

View File

@ -69,6 +69,7 @@ switch ($action) {
$username = _post('username'); $username = _post('username');
$password = _post('password'); $password = _post('password');
$description = _post('description'); $description = _post('description');
$enabled = _post('enabled')*1;
$msg = ''; $msg = '';
if(Validator::Length($name,30,4) == false){ if(Validator::Length($name,30,4) == false){
@ -99,6 +100,7 @@ switch ($action) {
$d->username = $username; $d->username = $username;
$d->password = $password; $d->password = $password;
$d->description = $description; $d->description = $description;
$d->enabled = $enabled;
$d->save(); $d->save();
r2(U . 'routers/list', 's', $_L['Created_Successfully']); r2(U . 'routers/list', 's', $_L['Created_Successfully']);
@ -114,7 +116,7 @@ switch ($action) {
$username = _post('username'); $username = _post('username');
$password = _post('password'); $password = _post('password');
$description = _post('description'); $description = _post('description');
$enabled = $_POST['enabled']*1;
$msg = ''; $msg = '';
if(Validator::Length($name,30,4) == false){ if(Validator::Length($name,30,4) == false){
$msg .= 'Name should be between 5 to 30 characters'. '<br>'; $msg .= 'Name should be between 5 to 30 characters'. '<br>';
@ -163,7 +165,9 @@ switch ($action) {
$d->username = $username; $d->username = $username;
$d->password = $password; $d->password = $password;
$d->description = $description; $d->description = $description;
$d->enabled = $enabled;
$d->save(); $d->save();
if($name!=$oldname){
$p = ORM::for_table('tbl_plans')->where('routers',$oldname)->find_result_set(); $p = ORM::for_table('tbl_plans')->where('routers',$oldname)->find_result_set();
$p->set('routers',$name); $p->set('routers',$name);
$p->save(); $p->save();
@ -182,6 +186,7 @@ switch ($action) {
$p = ORM::for_table('tbl_voucher')->where('routers',$oldname)->find_result_set(); $p = ORM::for_table('tbl_voucher')->where('routers',$oldname)->find_result_set();
$p->set('routers',$name); $p->set('routers',$name);
$p->save(); $p->save();
}
r2(U . 'routers/list', 's', $_L['Updated_Successfully']); r2(U . 'routers/list', 's', $_L['Updated_Successfully']);
}else{ }else{
r2(U . 'routers/edit/'.$id, 'e', $msg); r2(U . 'routers/edit/'.$id, 'e', $msg);

View File

@ -109,6 +109,7 @@ switch ($action) {
$validity = _post('validity'); $validity = _post('validity');
$validity_unit = _post('validity_unit'); $validity_unit = _post('validity_unit');
$routers = _post('routers'); $routers = _post('routers');
$enabled = _post('enabled')*1;
$msg = ''; $msg = '';
if (Validator::UnsignedNumber($validity) == false) { if (Validator::UnsignedNumber($validity) == false) {
@ -172,6 +173,7 @@ switch ($action) {
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->shared_users = $sharedusers; $d->shared_users = $sharedusers;
$d->routers = $routers; $d->routers = $routers;
$d->enabled = $enabled;
$d->save(); $d->save();
r2(U . 'services/hotspot', 's', $_L['Created_Successfully']); r2(U . 'services/hotspot', 's', $_L['Created_Successfully']);
@ -196,6 +198,7 @@ switch ($action) {
$validity = _post('validity'); $validity = _post('validity');
$validity_unit = _post('validity_unit'); $validity_unit = _post('validity_unit');
$routers = _post('routers'); $routers = _post('routers');
$enabled = _post('enabled')*1;
$msg = ''; $msg = '';
if (Validator::UnsignedNumber($validity) == false) { if (Validator::UnsignedNumber($validity) == false) {
@ -264,6 +267,7 @@ switch ($action) {
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->shared_users = $sharedusers; $d->shared_users = $sharedusers;
$d->routers = $routers; $d->routers = $routers;
$d->enabled = $enabled;
$d->save(); $d->save();
r2(U . 'services/hotspot', 's', $_L['Updated_Successfully']); r2(U . 'services/hotspot', 's', $_L['Updated_Successfully']);
@ -357,6 +361,7 @@ switch ($action) {
$validity_unit = _post('validity_unit'); $validity_unit = _post('validity_unit');
$routers = _post('routers'); $routers = _post('routers');
$pool = _post('pool_name'); $pool = _post('pool_name');
$enabled = _post('enabled')*1;
$msg = ''; $msg = '';
if (Validator::UnsignedNumber($validity) == false) { if (Validator::UnsignedNumber($validity) == false) {
@ -415,6 +420,7 @@ switch ($action) {
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->routers = $routers; $d->routers = $routers;
$d->pool = $pool; $d->pool = $pool;
$d->enabled = $enabled;
$d->save(); $d->save();
r2(U . 'services/pppoe', 's', $_L['Created_Successfully']); r2(U . 'services/pppoe', 's', $_L['Created_Successfully']);
@ -432,6 +438,7 @@ switch ($action) {
$validity_unit = _post('validity_unit'); $validity_unit = _post('validity_unit');
$routers = _post('routers'); $routers = _post('routers');
$pool = _post('pool_name'); $pool = _post('pool_name');
$enabled = _post('enabled')*1;
$msg = ''; $msg = '';
if (Validator::UnsignedNumber($validity) == false) { if (Validator::UnsignedNumber($validity) == false) {
@ -495,6 +502,7 @@ switch ($action) {
$d->validity_unit = $validity_unit; $d->validity_unit = $validity_unit;
$d->routers = $routers; $d->routers = $routers;
$d->pool = $pool; $d->pool = $pool;
$d->enabled = $enabled;
$d->save(); $d->save();
r2(U . 'services/pppoe', 's', $_L['Updated_Successfully']); r2(U . 'services/pppoe', 's', $_L['Updated_Successfully']);

View File

@ -254,3 +254,5 @@ $_L['Explain_Coverage_of_router'] = 'Jelaskan Cakupan wilayah hotspot';
$_L['Name_of_Area_that_router_operated'] = 'Nama Lokasi/Wilayah Router beroperasi'; $_L['Name_of_Area_that_router_operated'] = 'Nama Lokasi/Wilayah Router beroperasi';
$_L['Payment_Notification_URL_Recurring_Notification_URL_Pay_Account_Notification_URL'] = 'Payment Notification URL, Recurring Notification URL, Pay Account Notification URL'; $_L['Payment_Notification_URL_Recurring_Notification_URL_Pay_Account_Notification_URL'] = 'Payment Notification URL, Recurring Notification URL, Pay Account Notification URL';
$_L['Finish_Redirect_URL_Unfinish_Redirect_URL_Error_Redirect_URL'] = 'Finish Redirect URL, Unfinish Redirect URL, Error Redirect URL'; $_L['Finish_Redirect_URL_Unfinish_Redirect_URL_Error_Redirect_URL'] = 'Finish Redirect URL, Unfinish Redirect URL, Error Redirect URL';
$_L['Status'] = 'Status';
$_L['Status'] = 'Status';

26
system/radius.php Normal file
View File

@ -0,0 +1,26 @@
<?php
/**
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
**/
if(php_sapi_name() !== 'cli'){
die("RUN ON COMMAND LINE ONLY BY RADIUS ENGINE");
}
require('config.php');
require('orm.php');
use PEAR2\Net\RouterOS;
require_once 'autoload/PEAR2/Autoload.php';
ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('return_result_sets', true);
ORM::configure('logging', true);
$result = ORM::for_table('tbl_appconfig')->find_many();
foreach($result as $value){
$config[$value['setting']]=$value['value'];
}
date_default_timezone_set($config['timezone']);

View File

@ -5,8 +5,18 @@
<div class="panel panel-default panel-hovered panel-stacked mb30"> <div class="panel panel-default panel-hovered panel-stacked mb30">
<div class="panel-heading">{$_L['Add_Plan']}</div> <div class="panel-heading">{$_L['Add_Plan']}</div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}services/add-post" > <form class="form-horizontal" method="post" role="form" action="{$_url}services/add-post" >
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" checked name="enabled" value="1"> Enable
</label>
<label class="radio-inline">
<input type="radio" name="enabled" value="0"> Disable
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label> <label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
<div class="col-md-6"> <div class="col-md-6">
@ -116,7 +126,6 @@
</div> </div>
</div> </div>
</form> </form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -5,9 +5,19 @@
<div class="panel panel-default panel-hovered panel-stacked mb30"> <div class="panel panel-default 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">
<label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" {if $d['enabled'] == 1}checked{/if} name="enabled" value="1"> Enable
</label>
<label class="radio-inline">
<input type="radio" {if $d['enabled'] == 0}checked{/if} name="enabled" value="0"> Disable
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label> <label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
<div class="col-md-6"> <div class="col-md-6">

View File

@ -23,7 +23,7 @@
<a href="{$_url}services/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Plan']}</a> <a href="{$_url}services/add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Plan']}</a>
</div>&nbsp; </div>&nbsp;
</div> </div>
<div class="table-responsive">
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead> <thead>
<tr> <tr>
@ -40,7 +40,7 @@
</thead> </thead>
<tbody> <tbody>
{foreach $d as $ds} {foreach $d as $ds}
<tr> <tr {if $ds['enabled'] != 1}class="danger" title="disabled"{/if}>
<td>{$ds['name_plan']}</td> <td>{$ds['name_plan']}</td>
<td>{$ds['typebp']}</td> <td>{$ds['typebp']}</td>
<td>{$ds['name_bw']}</td> <td>{$ds['name_bw']}</td>
@ -50,13 +50,13 @@
<td>{$ds['validity']} {$ds['validity_unit']}</td> <td>{$ds['validity']} {$ds['validity_unit']}</td>
<td>{$ds['routers']}</td> <td>{$ds['routers']}</td>
<td> <td>
<a href="{$_url}services/edit/{$ds['id']}" class="btn btn-warning btn-sm">{$_L['Edit']}</a> <a href="{$_url}services/edit/{$ds['id']}" class="btn btn-info btn-sm btn-block">{$_L['Edit']}</a>
<a href="{$_url}services/delete/{$ds['id']}" id="{$ds['id']}" class="btn btn-danger btn-sm cdelete">{$_L['Delete']}</a>
</td> </td>
</tr> </tr>
{/foreach} {/foreach}
</tbody> </tbody>
</table> </table>
</div>
{$paginator['contents']} {$paginator['contents']}
</div> </div>

View File

@ -6,6 +6,17 @@
<div class="panel-heading">{$_L['Add_Plan']}</div> <div class="panel-heading">{$_L['Add_Plan']}</div>
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}services/pppoe-add-post" > <form class="form-horizontal" method="post" role="form" action="{$_url}services/pppoe-add-post" >
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" checked name="enabled" value="1"> Enable
</label>
<label class="radio-inline">
<input type="radio" name="enabled" value="0"> Disable
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label> <label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
<div class="col-md-6"> <div class="col-md-6">

View File

@ -7,6 +7,17 @@
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}services/edit-pppoe-post"> <form class="form-horizontal" method="post" role="form" action="{$_url}services/edit-pppoe-post">
<input type="hidden" name="id" value="{$d['id']}"> <input type="hidden" name="id" value="{$d['id']}">
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" {if $d['enabled'] == 1}checked{/if} name="enabled" value="1"> Enable
</label>
<label class="radio-inline">
<input type="radio" {if $d['enabled'] == 0}checked{/if} name="enabled" value="0"> Disable
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['Plan_Name']}</label> <label class="col-md-2 control-label">{$_L['Plan_Name']}</label>
<div class="col-md-6"> <div class="col-md-6">

View File

@ -23,7 +23,7 @@
<a href="{$_url}services/pppoe-add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Plan']}</a> <a href="{$_url}services/pppoe-add" class="btn btn-primary btn-block waves-effect"><i class="ion ion-android-add"> </i> {$_L['New_Plan']}</a>
</div>&nbsp; </div>&nbsp;
</div> </div>
<div class="table-responsive">
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead> <thead>
<tr> <tr>
@ -38,7 +38,7 @@
</thead> </thead>
<tbody> <tbody>
{foreach $d as $ds} {foreach $d as $ds}
<tr> <tr {if $ds['enabled'] != 1}class="danger" title="disabled"{/if}>
<td>{$ds['name_plan']}</td> <td>{$ds['name_plan']}</td>
<td>{$ds['name_bw']}</td> <td>{$ds['name_bw']}</td>
<td>{$ds['price']}</td> <td>{$ds['price']}</td>
@ -46,13 +46,13 @@
<td>{$ds['pool']}</td> <td>{$ds['pool']}</td>
<td>{$ds['routers']}</td> <td>{$ds['routers']}</td>
<td> <td>
<a href="{$_url}services/pppoe-edit/{$ds['id']}" class="btn btn-warning btn-sm">{$_L['Edit']}</a> <a href="{$_url}services/pppoe-edit/{$ds['id']}" class="btn btn-info btn-sm btn-block">{$_L['Edit']}</a>
<a href="{$_url}services/pppoe-delete/{$ds['id']}" id="{$ds['id']}" class="btn btn-danger btn-sm cdelete">{$_L['Delete']}</a>
</td> </td>
</tr> </tr>
{/foreach} {/foreach}
</tbody> </tbody>
</table> </table>
</div>
{$paginator['contents']} {$paginator['contents']}
</div> </div>
</div> </div>

View File

@ -7,6 +7,17 @@
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}routers/add-post" > <form class="form-horizontal" method="post" role="form" action="{$_url}routers/add-post" >
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" checked name="enabled" value="1"> Enable
</label>
<label class="radio-inline">
<input type="radio" name="enabled" value="0"> Disable
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['Router_Name']}</label> <label class="col-md-2 control-label">{$_L['Router_Name']}</label>
<div class="col-md-6"> <div class="col-md-6">

View File

@ -7,6 +7,17 @@
<div class="panel-body"> <div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}routers/edit-post" > <form class="form-horizontal" method="post" role="form" action="{$_url}routers/edit-post" >
<input type="hidden" name="id" value="{$d['id']}"> <input type="hidden" name="id" value="{$d['id']}">
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Status')}</label>
<div class="col-md-10">
<label class="radio-inline warning">
<input type="radio" {if $d['enabled'] == 1}checked{/if} name="enabled" value="1"> Enable
</label>
<label class="radio-inline">
<input type="radio" {if $d['enabled'] == 0}checked{/if} name="enabled" value="0"> Disable
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{$_L['Router_Name']}</label> <label class="col-md-2 control-label">{$_L['Router_Name']}</label>
<div class="col-md-6"> <div class="col-md-6">
@ -39,7 +50,6 @@
<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"> <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" type="submit">{$_L['Save']}</button> <button class="btn btn-primary waves-effect waves-light" type="submit">{$_L['Save']}</button>

View File

@ -32,19 +32,20 @@
<th>{$_L['IP_Address']}</th> <th>{$_L['IP_Address']}</th>
<th>{$_L['Username']}</th> <th>{$_L['Username']}</th>
<th>{$_L['Description']}</th> <th>{$_L['Description']}</th>
<th>{Lang::T('Status')}</th>
<th>{$_L['Manage']}</th> <th>{$_L['Manage']}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach $d as $ds} {foreach $d as $ds}
<tr> <tr {if $ds['enabled'] != 1}class="danger" title="disabled"{/if}>
<td>{$ds['name']}</td> <td>{$ds['name']}</td>
<td>{$ds['ip_address']}</td> <td>{$ds['ip_address']}</td>
<td>{$ds['username']}</td> <td>{$ds['username']}</td>
<td>{$ds['description']}</td> <td>{$ds['description']}</td>
<td>{if $ds['enabled'] == 1}Enabled{else}Disabled{/if}</td>
<td> <td>
<a href="{$_url}routers/edit/{$ds['id']}" class="btn btn-warning btn-sm">{$_L['Edit']}</a> <a href="{$_url}routers/edit/{$ds['id']}" class="btn btn-info btn-sm btn-block">{$_L['Edit']}</a>
<a href="{$_url}routers/delete/{$ds['id']}" id="{$ds['id']}" class="btn btn-danger btn-sm cdelete">{$_L['Delete']}</a>
</td> </td>
</tr> </tr>
{/foreach} {/foreach}

View File

@ -12,8 +12,8 @@
{$router['description']} {$router['description']}
</div> </div>
{/if} {/if}
</div>
<div class="row"> <div class="panel-body row">
{foreach $plans as $plan} {foreach $plans as $plan}
{if $router['name'] eq $plan['routers']} {if $router['name'] eq $plan['routers']}
<div class="col-sm-3"> <div class="col-sm-3">
@ -41,6 +41,7 @@
{/if} {/if}
{/foreach} {/foreach}
</div> </div>
</div>
{/foreach} {/foreach}
</div> </div>
</div> </div>