forked from kevinowino869/mitrobill
Change Local-Ip PPPoE to Remote-IP
Change Local-Ip PPPoE to Remote-IP in customer page and ignor attribute if empty
This commit is contained in:
parent
53512cfa58
commit
84bc680f40
@ -10,14 +10,14 @@
|
||||
|
||||
use PEAR2\Net\RouterOS;
|
||||
|
||||
class MikrotikPppoe
|
||||
class MikrotikPppoeCustom
|
||||
{
|
||||
// show Description
|
||||
function description()
|
||||
{
|
||||
return [
|
||||
'title' => 'Mikrotik PPPOE',
|
||||
'description' => 'To handle connection between PHPNuxBill with Mikrotik PPPOE',
|
||||
'description' => 'To handle connection between PHPNuxBill with Mikrotik PPPOE using Custom Username, IP and Password',
|
||||
'author' => 'ibnux',
|
||||
'url' => [
|
||||
'Github' => 'https://github.com/hotspotbilling/phpnuxbill/',
|
||||
@ -39,14 +39,28 @@ class MikrotikPppoe
|
||||
}else{
|
||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
||||
$setRequest->setArgument('numbers', $cid);
|
||||
if (!empty($customer['pppoe_password'])) {
|
||||
$setRequest->setArgument('password', $customer['pppoe_password']);
|
||||
} else {
|
||||
$setRequest->setArgument('password', $customer['password']);
|
||||
}
|
||||
if (!empty($customer['pppoe_username'])) {
|
||||
$setRequest->setArgument('name', $customer['pppoe_username']);
|
||||
} else {
|
||||
$setRequest->setArgument('name', $customer['username']);
|
||||
}
|
||||
if (!empty($customer['pppoe_ip'])) {
|
||||
$setRequest->setArgument('remote-address', $customer['pppoe_ip']);
|
||||
}
|
||||
$setRequest->setArgument('profile', $plan['name_plan']);
|
||||
$setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id'])));
|
||||
$client->sendSync($setRequest);
|
||||
//disconnect then
|
||||
if(isset($isChangePlan) && $isChangePlan){
|
||||
$this->removePpoeActive($client, $customer['username']);
|
||||
if (!empty($customer['pppoe_username'])) {
|
||||
$this->removePpoeActive($client, $customer['pppoe_username']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,11 +74,20 @@ class MikrotikPppoe
|
||||
if($p){
|
||||
$this->add_customer($customer, $p);
|
||||
$this->removePpoeActive($client, $customer['username']);
|
||||
if (!empty($customer['pppoe_username'])) {
|
||||
$this->removePpoeActive($client, $customer['pppoe_username']);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->removePpoeActive($client, $customer['username']);
|
||||
$this->removePpoeUser($client, $customer['username']);
|
||||
if (!empty($customer['pppoe_username'])) {
|
||||
$this->removePpoeUser($client, $customer['pppoe_username']);
|
||||
}
|
||||
$this->removePpoeActive($client, $customer['username']);
|
||||
if (!empty($customer['pppoe_username'])) {
|
||||
$this->removePpoeActive($client, $customer['pppoe_username']);
|
||||
}
|
||||
}
|
||||
|
||||
// customer change username
|
||||
@ -125,7 +148,15 @@ class MikrotikPppoe
|
||||
function getIdByCustomer($customer, $client){
|
||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $customer['username']));
|
||||
return $client->sendSync($printRequest)->getProperty('.id');
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
if(empty($id)){
|
||||
if (!empty($customer['pppoe_username'])) {
|
||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $customer['pppoe_username']));
|
||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||
}
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
function update_plan($old_name, $new_plan)
|
||||
@ -294,8 +325,19 @@ class MikrotikPppoe
|
||||
$setRequest->setArgument('service', 'pppoe');
|
||||
$setRequest->setArgument('profile', $plan['name_plan']);
|
||||
$setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'] . ' | ' . implode(', ', User::getBillNames($customer['id'])));
|
||||
if (!empty($customer['pppoe_password'])) {
|
||||
$setRequest->setArgument('password', $customer['pppoe_password']);
|
||||
} else {
|
||||
$setRequest->setArgument('password', $customer['password']);
|
||||
}
|
||||
if (!empty($customer['pppoe_username'])) {
|
||||
$setRequest->setArgument('name', $customer['pppoe_username']);
|
||||
} else {
|
||||
$setRequest->setArgument('name', $customer['username']);
|
||||
}
|
||||
if (!empty($customer['pppoe_ip'])) {
|
||||
$setRequest->setArgument('remote-address', $customer['pppoe_ip']);
|
||||
}
|
||||
$client->sendSync($setRequest);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">Local IP <span class="label label-danger" id="warning_ip"></span></label>
|
||||
<label class="col-md-3 control-label">Remote 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" onkeyup="checkIP(this, '0')">
|
||||
<span class="help-block">{Lang::T('Not Working for freeradius')}</span>
|
||||
|
@ -135,7 +135,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">Local IP <span class="label label-danger" id="warning_ip"></span></label>
|
||||
<label class="col-md-3 control-label">Remote 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"
|
||||
onkeyup="checkIP(this, {$d['id']})" value="{$d['pppoe_ip']}">
|
||||
|
@ -56,7 +56,7 @@
|
||||
{/if}
|
||||
{if $d['pppoe_ip'] != ''}
|
||||
<li class="list-group-item">
|
||||
<b>PPPOE Local IP</b> <span class="pull-right">{$d['pppoe_ip']}</span>
|
||||
<b>PPPOE Remote IP</b> <span class="pull-right">{$d['pppoe_ip']}</span>
|
||||
</li>
|
||||
{/if}
|
||||
<!--Customers Attributes view start -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user