add radius expiration

This commit is contained in:
Ibnu Maksum 2023-10-12 13:42:52 +07:00
parent 77f21ece61
commit e19423471f
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
3 changed files with 15 additions and 10 deletions

View File

@ -99,7 +99,7 @@ class Package
if ($p['type'] == 'Hotspot') { if ($p['type'] == 'Hotspot') {
if ($b) { if ($b) {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
@ -158,7 +158,7 @@ class Package
$t->save(); $t->save();
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
@ -207,7 +207,7 @@ class Package
if ($b) { if ($b) {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
@ -267,7 +267,7 @@ class Package
$t->save(); $t->save();
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p, "$date_exp $time");
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
@ -351,7 +351,7 @@ class Package
if ($p['type'] == 'Hotspot') { if ($p['type'] == 'Hotspot') {
if ($b) { if ($b) {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']);
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);
@ -362,7 +362,7 @@ class Package
} }
} else { } else {
if ($p['is_radius']) { if ($p['is_radius']) {
Radius::customerAddPlan($c, $p); Radius::customerAddPlan($c, $p, $b['expiration'].''.$b['time']);
}else{ }else{
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
Mikrotik::removeHotspotUser($client, $c['username']); Mikrotik::removeHotspotUser($client, $c['username']);

View File

@ -132,7 +132,7 @@ class Radius
/** /**
* When add a plan to Customer, use this * When add a plan to Customer, use this
*/ */
public static function customerAddPlan($customer, $plan) public static function customerAddPlan($customer, $plan, $expired = null, $quota = null)
{ {
if (Radius::customerUpsert($customer, $plan)) { if (Radius::customerUpsert($customer, $plan)) {
$p = Radius::getTableUserPackage()->where_equal('username', $customer['username'])->findOne(); $p = Radius::getTableUserPackage()->where_equal('username', $customer['username'])->findOne();
@ -147,6 +147,11 @@ class Radius
$p->priority = 1; $p->priority = 1;
return $p->save(); return $p->save();
} }
//expired
if ($plan['type'] == 'HOTSPOT') {
}
Radius::upsertCustomer($customer['username'], 'expiration', date('d M Y H:i:s', strtotime($expired)));
} }
return false; return false;
} }