check if pppoe IP or Username has been used by other customer
This commit is contained in:
parent
0bb1f8ffa0
commit
7172cfbb79
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||
* by https://t.me/ibnux
|
||||
@ -18,9 +19,9 @@ $ui->assign('_admin', $admin);
|
||||
switch ($action) {
|
||||
case 'pool':
|
||||
$routers = _get('routers');
|
||||
if(empty($routers)){
|
||||
if (empty($routers)) {
|
||||
$d = ORM::for_table('tbl_pool')->find_many();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_pool')->where('routers', $routers)->find_many();
|
||||
}
|
||||
$ui->assign('routers', $routers);
|
||||
@ -34,20 +35,45 @@ switch ($action) {
|
||||
|
||||
$ui->display('autoload-server.tpl');
|
||||
break;
|
||||
|
||||
case 'pppoe_ip_used':
|
||||
if (!empty(_get('ip'))) {
|
||||
$cs = ORM::for_table('tbl_customers')
|
||||
->select("username")
|
||||
->where_not_equal('id', _get('id'))
|
||||
->where("pppoe_ip", _get('ip'))
|
||||
->findArray();
|
||||
if (count($cs) > 0) {
|
||||
$c = array_column($cs, 'username');
|
||||
die(Lang::T("IP has been used by") . ' : ' . implode(", ", $c));
|
||||
}
|
||||
}
|
||||
die();
|
||||
case 'pppoe_username_used':
|
||||
if (!empty(_get('u'))) {
|
||||
$cs = ORM::for_table('tbl_customers')
|
||||
->select("username")
|
||||
->where_not_equal('id', _get('id'))
|
||||
->where("pppoe_username", _get('u'))
|
||||
->findArray();
|
||||
if (count($cs) > 0) {
|
||||
$c = array_column($cs, 'username');
|
||||
die(Lang::T("Username has been used by") . ' : ' . implode(", ", $c));
|
||||
}
|
||||
}
|
||||
die();
|
||||
case 'plan':
|
||||
$server = _post('server');
|
||||
$jenis = _post('jenis');
|
||||
if(in_array($admin['user_type'], array('SuperAdmin', 'Admin'))){
|
||||
if($server=='radius'){
|
||||
if (in_array($admin['user_type'], array('SuperAdmin', 'Admin'))) {
|
||||
if ($server == 'radius') {
|
||||
$d = ORM::for_table('tbl_plans')->where('is_radius', 1)->where('type', $jenis)->find_many();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_plans')->where('routers', $server)->where('type', $jenis)->find_many();
|
||||
}
|
||||
}else{
|
||||
if($server=='radius'){
|
||||
} else {
|
||||
if ($server == 'radius') {
|
||||
$d = ORM::for_table('tbl_plans')->where('is_radius', 1)->where('type', $jenis)->where('enabled', '1')->find_many();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_plans')->where('routers', $server)->where('type', $jenis)->where('enabled', '1')->find_many();
|
||||
}
|
||||
}
|
||||
@ -59,9 +85,9 @@ switch ($action) {
|
||||
$d = ORM::for_table('tbl_user_recharges')->where('customer_id', $routes['2'])->findOne();
|
||||
if ($d) {
|
||||
if ($d['status'] == 'on') {
|
||||
die('<span class="label label-success" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">'.$d['namebp'].'</span>');
|
||||
die('<span class="label label-success" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . '</span>');
|
||||
} else {
|
||||
die('<span class="label label-danger" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">'.$d['namebp'].'</span>');
|
||||
die('<span class="label label-danger" title="Expired ' . Lang::dateAndTimeFormat($d['expiration'], $d['time']) . '">' . $d['namebp'] . '</span>');
|
||||
}
|
||||
} else {
|
||||
die('<span class="label label-danger">•</span>');
|
||||
|
@ -96,9 +96,9 @@
|
||||
<div class="panel-heading">PPPOE</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
|
||||
<label class="col-md-3 control-label">{Lang::T('Username')} <span class="label label-danger" id="warning_username"></span></label>
|
||||
<div class="col-md-9">
|
||||
<input type="username" class="form-control" id="pppoe_username" name="pppoe_username">
|
||||
<input type="username" class="form-control" id="pppoe_username" name="pppoe_username" onkeyup="checkUsername(this, '0')">
|
||||
<span class="help-block">{Lang::T('Not Working for freeradius')}</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -110,9 +110,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">Local IP</label>
|
||||
<label class="col-md-3 control-label">Local IP <span class="label label-danger" id="warning_ip"></span></label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" id="pppoe_ip" name="pppoe_ip">
|
||||
<input type="text" class="form-control" id="pppoe_ip" name="pppoe_ip" onkeyup="checkIP(this, '0')">
|
||||
<span class="help-block">{Lang::T('Not Working for freeradius')}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -119,11 +119,11 @@
|
||||
<div class="panel-heading">PPPOE</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{Lang::T('Username')}</label>
|
||||
<label class="col-md-3 control-label">{Lang::T('Username')} <span class="label label-danger" id="warning_username"></span></label>
|
||||
<div class="col-md-9">
|
||||
<input type="username" class="form-control" id="pppoe_username" name="pppoe_username"
|
||||
value="{$d['pppoe_username']}">
|
||||
<span class="help-block">{Lang::T('Not Working for freeradius')}</span>
|
||||
onkeyup="checkUsername(this, {$d['id']})" value="{$d['pppoe_username']}">
|
||||
<span class="help-block">{Lang::T('Not Working with Freeradius Mysql')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -135,11 +135,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">Local IP</label>
|
||||
<label class="col-md-3 control-label">Local IP <span class="label label-danger" id="warning_ip"></span></label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" id="pppoe_ip" name="pppoe_ip"
|
||||
value="{$d['pppoe_ip']}">
|
||||
<span class="help-block">{Lang::T('Not Working for freeradius')}</span>
|
||||
onkeyup="checkIP(this, {$d['id']})" value="{$d['pppoe_ip']}">
|
||||
<span class="help-block">{Lang::T('Not Working with Freeradius Mysql')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="help-block">
|
||||
|
@ -101,6 +101,7 @@
|
||||
<th>{Lang::T('Contact')}</th>
|
||||
<th>{Lang::T('Package')}</th>
|
||||
<th>{Lang::T('Service Type')}</th>
|
||||
<th>PPPOE</th>
|
||||
<th>{Lang::T('Status')}</th>
|
||||
<th>{Lang::T('Created On')}</th>
|
||||
<th>{Lang::T('Manage')}</th>
|
||||
@ -135,6 +136,11 @@
|
||||
<span class="label label-default">•</span>
|
||||
</td>
|
||||
<td>{$ds['service_type']}</td>
|
||||
<td>
|
||||
{$ds['pppoe_username']}
|
||||
{if !empty($ds['pppoe_username']) && !empty($ds['pppoe_ip'])}:{/if}
|
||||
{$ds['pppoe_ip']}
|
||||
</td>
|
||||
<td>{Lang::T($ds['status'])}</td>
|
||||
<td>{Lang::dateTimeFormat($ds['created_at'])}</td>
|
||||
<td align="center">
|
||||
|
@ -37,6 +37,22 @@ $(document).ready(function () {
|
||||
$("#Hotspot").prop("checked", true).change();
|
||||
|
||||
|
||||
function checkIP(f, id) {
|
||||
if (f.value.length > 6) {
|
||||
$.get('./?_route=autoload/pppoe_ip_used&ip=' + f.value + '&id=' + id, function(data) {
|
||||
$("#warning_ip").html(data)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function checkUsername(f, id) {
|
||||
if (f.value.length > 1) {
|
||||
$.get('./?_route=autoload/pppoe_username_used&u=' + f.value + '&id=' + id, function(data) {
|
||||
$("#warning_username").html(data)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//auto load pool - pppoe plan
|
||||
var htmlobjek;
|
||||
$(document).ready(function(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user