Fix is_radius

This commit is contained in:
Ibnu Maksum
2023-10-04 16:11:55 +07:00
parent 087c5ab515
commit b2a99def98
7 changed files with 38 additions and 31 deletions

View File

@ -6,8 +6,7 @@ class Mikrotik
{
public static function info($name)
{
$d = ORM::for_table('tbl_routers')->where('name', $name)->find_one();
return $d;
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
}
public static function getClient($ip, $user, $pass)

View File

@ -138,8 +138,14 @@ class Radius
public static function planDelete($plan_id){
// Delete Plan
Radius::getTablePackage()->where_equal('plan_id', "plan_".$plan_id)->delete_many();
// Delete User Plan
Radius::getTableUserPackage()->where_equal('groupname', "plan_".$plan_id)->delete_many();
// Reset User Plan
$c = Radius::getTableUserPackage()->where_equal('groupname', "plan_".$plan_id)->findMany();
if ($c) {
foreach($c as $u){
$u->groupname = '';
$u->save();
}
}
}
public static function customerChangeUsername($from, $to){
@ -159,13 +165,13 @@ class Radius
}
}
public static function customerDeactivate($customer){
public static function customerDeactivate($username){
global $radius_pass;
$r = Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Cleartext-Password')->findOne();
$r = Radius::getTableCustomer()->where_equal('username', $username)->whereEqual('attribute', 'Cleartext-Password')->findOne();
if($r){
// no need to delete, because it will make ID got higher
// we just change the password
$r->value = md5(time().$customer['username'].$radius_pass);
$r->value = md5(time().$username.$radius_pass);
$r->save();
}
}