From fd2c9b08e0761ac053d7d68b683c0bab6473c3ea Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Mon, 28 Aug 2023 08:45:35 +0700 Subject: [PATCH] add NAS update NAS --- system/autoload/Radius.php | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/system/autoload/Radius.php b/system/autoload/Radius.php index d251b358..b7ac259f 100644 --- a/system/autoload/Radius.php +++ b/system/autoload/Radius.php @@ -2,4 +2,50 @@ class Radius { + public function getTableNas(){ + return ORM::for_table('nas', 'radius'); + } + + public function getTableCustomer(){ + return ORM::for_table('radcheck', 'radius'); + } + + public function getTablePackage(){ + return ORM::for_table('radgroupreply', 'radius'); + } + + public function getTableUserPackage(){ + return ORM::for_table('radusergroup', 'radius'); + } + + public function addNas($name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){ + $n = $this->getTableNas()->create(); + $n->nasname = $ip; + $n->shortname = $name; + $n->type = $type; + $n->ports = $ports; + $n->secret = $secret; + $n->description = $description; + $n->server = $server; + $n->community = $community; + $n->save(); + return $n->id(); + } + public function updateNas($id, $name, $ip, $ports, $secret, $description = "",$type = 'other', $server= null, $community= null){ + $n = $this->getTableNas()->find_one($id); + if(empty($n)){ + return false; + } + $n->nasname = $ip; + $n->shortname = $name; + $n->type = $type; + $n->ports = $ports; + $n->secret = $secret; + $n->description = $description; + $n->server = $server; + $n->community = $community; + $n->save(); + return true; + } + }