PPPOE don't set IP for expired Plan

This commit is contained in:
Ibnu Maksum 2024-09-26 09:43:12 +07:00
parent 0a9733b0b3
commit 44af731c4c
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -33,9 +33,10 @@ class MikrotikPppoe
$mikrotik = $this->info($plan['routers']); $mikrotik = $this->info($plan['routers']);
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$cid = self::getIdByCustomer($customer, $client); $cid = self::getIdByCustomer($customer, $client);
$isExp = ORM::for_table('tbl_plans')->select("id")->where('plan_expired', $plan['id'])->find_one();
if (empty($cid)) { if (empty($cid)) {
//customer not exists, add it //customer not exists, add it
$this->addPpoeUser($client, $plan, $customer); $this->addPpoeUser($client, $plan, $customer, $isExp);
}else{ }else{
$setRequest = new RouterOS\Request('/ppp/secret/set'); $setRequest = new RouterOS\Request('/ppp/secret/set');
$setRequest->setArgument('numbers', $cid); $setRequest->setArgument('numbers', $cid);
@ -50,7 +51,7 @@ class MikrotikPppoe
$setRequest->setArgument('name', $customer['username']); $setRequest->setArgument('name', $customer['username']);
} }
$unsetIP = false; $unsetIP = false;
if (!empty($customer['pppoe_ip'])){ if (!empty($customer['pppoe_ip']) && !$isExp){
$setRequest->setArgument('remote-address', $customer['pppoe_ip']); $setRequest->setArgument('remote-address', $customer['pppoe_ip']);
} else { } else {
$unsetIP = true; $unsetIP = true;
@ -331,7 +332,7 @@ class MikrotikPppoe
$client->sendSync($removeRequest); $client->sendSync($removeRequest);
} }
function addPpoeUser($client, $plan, $customer) function addPpoeUser($client, $plan, $customer, $isExp = false)
{ {
$setRequest = new RouterOS\Request('/ppp/secret/add'); $setRequest = new RouterOS\Request('/ppp/secret/add');
$setRequest->setArgument('service', 'pppoe'); $setRequest->setArgument('service', 'pppoe');
@ -347,7 +348,7 @@ class MikrotikPppoe
} else { } else {
$setRequest->setArgument('name', $customer['username']); $setRequest->setArgument('name', $customer['username']);
} }
if (!empty($customer['pppoe_ip'])) { if (!empty($customer['pppoe_ip']) && !$isExp) {
$setRequest->setArgument('remote-address', $customer['pppoe_ip']); $setRequest->setArgument('remote-address', $customer['pppoe_ip']);
} }
$client->sendSync($setRequest); $client->sendSync($setRequest);