Burst Limit

This commit is contained in:
Ibnu Maksum 2024-02-19 18:03:40 +07:00
parent 91c90f05f8
commit cfb81596ae
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
8 changed files with 130 additions and 53 deletions

View file

@ -203,6 +203,8 @@ ALTER TABLE `tbl_users` CHANGE `user_type` `user_type` ENUM('SuperAdmin','Admin'
ALTER TABLE `tbl_users` CHANGE `password` `password` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;
ALTER TABLE `tbl_users` ADD `phone` VARCHAR(32) NOT NULL DEFAULT '' AFTER `password`, ADD `email` VARCHAR(128) NOT NULL DEFAULT '' AFTER `phone`, ADD `city` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kota' AFTER `email`, ADD `subdistrict` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kecamatan' AFTER `city`, ADD `ward` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'kelurahan' AFTER `subdistrict`;
ALTER TABLE `tbl_customers` ADD `created_by` INT NOT NULL DEFAULT '0' AFTER `auto_renewal`;
ALTER TABLE `tbl_plans` ADD `list_expired` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'address list' AFTER `pool_expired`;
ALTER TABLE `tbl_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `rate_up_unit`;
ALTER TABLE `tbl_appconfig`
ADD PRIMARY KEY (`id`);

View file

@ -67,6 +67,7 @@ switch ($action) {
$rate_down_unit = _post('rate_down_unit');
$rate_up = _post('rate_up');
$rate_up_unit = _post('rate_up_unit');
$burst = _post('burst');
run_hook('add_bandwidth'); #HOOK
$msg = '';
if(Validator::Length($name,16,4) == false){
@ -88,6 +89,7 @@ switch ($action) {
$d->rate_down_unit = $rate_down_unit;
$d->rate_up = $rate_up;
$d->rate_up_unit = $rate_up_unit;
$d->burst = $burst;
$d->save();
r2(U . 'bandwidth/list', 's', Lang::T('Data Created Successfully'));
@ -102,6 +104,7 @@ switch ($action) {
$rate_down_unit = _post('rate_down_unit');
$rate_up = _post('rate_up');
$rate_up_unit = _post('rate_up_unit');
$burst = _post('burst');
run_hook('edit_bandwidth'); #HOOK
$msg = '';
if(Validator::Length($name,16,4) == false){
@ -128,6 +131,7 @@ switch ($action) {
$d->rate_down_unit = $rate_down_unit;
$d->rate_up = $rate_up;
$d->rate_up_unit = $rate_up_unit;
$d->burst = $burst;
$d->save();
r2(U . 'bandwidth/list', 's', Lang::T('Data Updated Successfully'));

View file

@ -173,7 +173,7 @@ switch ($action) {
Mikrotik::removeHotspotPlan($client, $d['name_plan']);
} catch (Exception $e) {
//ignore exception, it means router has already deleted
} catch(Throwable $e){
} catch (Throwable $e) {
//ignore exception, it means router has already deleted
}
}
@ -200,6 +200,7 @@ switch ($action) {
$validity_unit = _post('validity_unit');
$routers = _post('routers');
$pool_expired = _post('pool_expired');
$list_expired = _post('list_expired');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');
@ -243,6 +244,7 @@ switch ($action) {
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
$rate = trim($rate . " " . $b['burst']);
$d = ORM::for_table('tbl_plans')->create();
$d->name_plan = $name;
@ -264,8 +266,9 @@ switch ($action) {
} else {
$d->is_radius = 0;
$d->routers = $routers;
$d->pool_expired = $pool_expired;
}
$d->pool_expired = $pool_expired;
$d->list_expired = $list_expired;
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();
@ -305,6 +308,7 @@ switch ($action) {
$validity = _post('validity');
$validity_unit = _post('validity_unit');
$pool_expired = _post('pool_expired');
$list_expired = _post('list_expired');
$enabled = _post('enabled');
$allow_purchase = _post('allow_purchase');
$routers = _post('routers');
@ -343,6 +347,8 @@ switch ($action) {
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
$rate = trim($rate . " " . $b['burst']);
if ($d['is_radius']) {
Radius::planUpSert($id, $radiusRate);
} else {
@ -367,6 +373,7 @@ switch ($action) {
$d->validity_unit = $validity_unit;
$d->shared_users = $sharedusers;
$d->pool_expired = $pool_expired;
$d->list_expired = $list_expired;
$d->enabled = $enabled;
$d->allow_purchase = $allow_purchase;
$d->save();
@ -443,7 +450,7 @@ switch ($action) {
Mikrotik::removePpoePlan($client, $d['name_plan']);
} catch (Exception $e) {
//ignore exception, it means router has already deleted
} catch(Throwable $e){
} catch (Throwable $e) {
//ignore exception, it means router has already deleted
}
}
@ -506,6 +513,7 @@ switch ($action) {
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
$rate = trim($rate . " " . $b['burst']);
$d = ORM::for_table('tbl_plans')->create();
$d->type = 'PPPOE';
@ -593,6 +601,7 @@ switch ($action) {
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown;
$rate = trim($rate . " " . $b['burst']);
if ($d['is_radius']) {
Radius::planUpSert($id, $radiusRate, $pool);

View file

@ -413,5 +413,9 @@
"Ward": "Ward",
"Credentials": "Credentials",
"Agent": "Agent",
"This_Token_will_act_as_SuperAdmin_Admin": "This Token will act as SuperAdmin\/Admin"
"This_Token_will_act_as_SuperAdmin_Admin": "This Token will act as SuperAdmin\/Admin",
"Login": "Login",
"Expired_Action": "Expired Action",
"Expired_Address_List_Name": "Expired Address List Name",
"Address_List": "Address List"
}

View file

@ -58,5 +58,9 @@
],
"2024.2.19": [
"CREATE TABLE `tbl_customers_fields` (`id` INT PRIMARY KEY AUTO_INCREMENT, `customer_id` INT NOT NULL, `field_name` VARCHAR(255) NOT NULL, `field_value` VARCHAR(255) NOT NULL, FOREIGN KEY (customer_id) REFERENCES tbl_customers(id));"
],
"2024.2.20" : [
"ALTER TABLE `tbl_plans` ADD `list_expired` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'address list' AFTER `pool_expired`;",
"ALTER TABLE `tbl_bandwidth` ADD `burst` VARCHAR(128) NOT NULL DEFAULT '' AFTER `rate_up_unit`;"
]
}

View file

@ -1,19 +1,19 @@
{include file="sections/header.tpl"}
<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">{Lang::T('Add New Bandwidth')}</div>
<div class="panel-body">
<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">{Lang::T('Add New Bandwidth')}</div>
<div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}bandwidth/add-post">
<div class="form-group">
<form class="form-horizontal" method="post" role="form" action="{$_url}bandwidth/add-post">
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Bandwidth Name')}</label>
<div class="col-md-6">
<input type="text" class="form-control" id="name" name="name">
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Rate Download')}</label>
<div class="col-md-4">
<input type="text" class="form-control" id="rate_down" name="rate_down">
@ -24,8 +24,8 @@
<option value="Mbps">Mbps</option>
</select>
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Rate Upload')}</label>
<div class="col-md-4">
<input type="text" class="form-control" id="rate_up" name="rate_up">
@ -36,19 +36,25 @@
<option value="Mbps">Mbps</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Burst Limit</label>
<div class="col-md-6">
<input type="text" class="form-control" id="burst" name="burst" placeholder="[Burst/Limit] [Burst/Threshold] [Burst/Time] [Priority] [Limit/At]">
</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">{Lang::T('Submit')}</button>
<button class="btn btn-primary waves-effect waves-light"
type="submit">{Lang::T('Submit')}</button>
Or <a href="{$_url}bandwidth/list">{Lang::T('Cancel')}</a>
</div>
</div>
</form>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
{include file="sections/footer.tpl"}

View file

@ -1,55 +1,67 @@
{include file="sections/header.tpl"}
<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">{Lang::T('Edit Bandwidth')}</div>
<div class="panel-body">
<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">{Lang::T('Edit Bandwidth')}</div>
<div class="panel-body">
<form class="form-horizontal" method="post" role="form" action="{$_url}bandwidth/edit-post" >
<input type="hidden" name="id" value="{$d['id']}">
<div class="form-group">
<form class="form-horizontal" method="post" role="form" action="{$_url}bandwidth/edit-post">
<input type="hidden" name="id" value="{$d['id']}">
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Bandwidth Name')}</label>
<div class="col-md-6">
<input type="text" class="form-control" id="name" name="name" value="{$d['name_bw']}">
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Rate Download')}</label>
<div class="col-md-4">
<input type="text" class="form-control" id="rate_down" name="rate_down" value="{$d['rate_down']}">
<input type="text" class="form-control" id="rate_down" name="rate_down"
value="{$d['rate_down']}">
</div>
<div class="col-md-2">
<select class="form-control" id="rate_down_unit" name="rate_down_unit">
<option value="Kbps" {if $d['rate_down_unit'] eq 'Kbps'}selected="selected" {/if}>Kbps</option>
<option value="Mbps" {if $d['rate_down_unit'] eq 'Mbps'}selected="selected" {/if}>Mbps</option>
<option value="Kbps" {if $d['rate_down_unit'] eq 'Kbps'}selected="selected" {/if}>Kbps
</option>
<option value="Mbps" {if $d['rate_down_unit'] eq 'Mbps'}selected="selected" {/if}>Mbps
</option>
</select>
</div>
</div>
<div class="form-group">
</div>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Rate Upload')}</label>
<div class="col-md-4">
<input type="text" class="form-control" id="rate_up" name="rate_up" value="{$d['rate_up']}">
</div>
<div class="col-md-2">
<select class="form-control" id="rate_up_unit" name="rate_up_unit">
<option value="Kbps" {if $d['rate_up_unit'] eq 'Kbps'}selected="selected" {/if}>Kbps</option>
<option value="Mbps" {if $d['rate_up_unit'] eq 'Mbps'}selected="selected" {/if}>Mbps</option>
<option value="Kbps" {if $d['rate_up_unit'] eq 'Kbps'}selected="selected" {/if}>Kbps
</option>
<option value="Mbps" {if $d['rate_up_unit'] eq 'Mbps'}selected="selected" {/if}>Mbps
</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Burst Limit</label>
<div class="col-md-6">
<input type="text" class="form-control" id="burst" name="burst" value="{$d['burst']}" placeholder="[Burst/Limit] [Burst/Threshold] [Burst/Time] [Priority] [Limit/At]">
</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">{Lang::T('Submit')}</button>
<button class="btn btn-primary waves-effect waves-light"
type="submit">{Lang::T('Submit')}</button>
Or <a href="{$_url}bandwidth/list">{Lang::T('Cancel')}</a>
</div>
</div>
</form>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{include file="sections/footer.tpl"}

View file

@ -148,6 +148,19 @@
</div>
</span>
<div class="form-group">
<label class="col-md-2 control-label">{Lang::T('Expired Action')}</label>
<div class="col-md-10">
<label><input type="radio" onclick="setExp(1)" checked name="exp_act" value="pool"> IP
Pool</label>
&nbsp;&nbsp;
<label><input type="radio" onclick="setExp(2)" name="exp_act" value="list"> Address
List</label>
&nbsp;&nbsp;
<label><input type="radio" onclick="setExp(0)" name="exp_act" value="none">
None</label>
</div>
</div>
<div class="form-group" id="ipPool">
<label class="col-md-2 control-label"><a
href="{$_url}pool/add">{Lang::T('Expired IP Pool')}</a></label>
<div class="col-md-6">
@ -156,6 +169,12 @@
</select>
</div>
</div>
<div class="form-group hidden" id="AddressList">
<label class="col-md-2 control-label">{Lang::T('Address List')}</label>
<div class="col-md-6">
<input type="text" class="form-control" name="list_expired" id="list_expired">
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button class="btn btn-success waves-effect waves-light"
@ -189,6 +208,23 @@
$("#routerChoose").removeClass('hidden');
}
}
function setExp(vl) {
if (vl == 1) {
$('#list_expired').val('');
$('#ipPool').removeClass('hidden');
$('#AddressList').addClass('hidden');
} else if (vl == 2) {
$('#pool_expired').prop('selectedIndex', 0);
$('#ipPool').addClass('hidden');
$('#AddressList').removeClass('hidden');
} else {
$('#pool_expired').prop('selectedIndex', 0);
$('#list_expired').val('');
$('#ipPool').addClass('hidden');
$('#AddressList').addClass('hidden');
}
}
</script>
{/literal}
{/if}