forked from kevinowino869/mitrobill
Radius Rest API
This commit is contained in:
@ -26,16 +26,25 @@ class Package
|
||||
$time_only = date("H:i:s");
|
||||
$time = date("H:i:s");
|
||||
$inv = "";
|
||||
$isVoucher = false;
|
||||
|
||||
if ($id_customer == '' or $router_name == '' or $plan_id == '') {
|
||||
return false;
|
||||
}
|
||||
if($channel == 'Voucher' && $id_customer = 0){
|
||||
$isVoucher = true;
|
||||
}
|
||||
|
||||
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
||||
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one();
|
||||
|
||||
if ($c['status'] != 'Active') {
|
||||
_alert(Lang::T('This account status') . ' : ' . Lang::T($c['status']), 'danger', "");
|
||||
if(!$isVoucher){
|
||||
$c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one();
|
||||
if ($c['status'] != 'Active') {
|
||||
_alert(Lang::T('This account status') . ' : ' . Lang::T($c['status']), 'danger', "");
|
||||
}
|
||||
}else{
|
||||
$c['username'] = $channel;
|
||||
$c['fullname'] = $gateway;
|
||||
}
|
||||
|
||||
$add_cost = 0;
|
||||
|
@ -31,9 +31,23 @@ class MikrotikPppoe
|
||||
{
|
||||
$mikrotik = $this->info($plan['routers']);
|
||||
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||
$this->removePpoeUser($client, $customer['username']);
|
||||
$this->removePpoeActive($client, $customer['username']);
|
||||
$this->addPpoeUser($client, $plan, $customer);
|
||||
//check if customer exists
|
||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||
$printRequest->setQuery(RouterOS\Query::where('name', $customer['username']));
|
||||
$cid = $client->sendSync($printRequest)->getProperty('.id');
|
||||
if (empty($cid)) {
|
||||
//customer not exists, add it
|
||||
$this->addPpoeUser($client, $plan, $customer);
|
||||
}else{
|
||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
||||
$setRequest->setArgument('numbers', $cid);
|
||||
$setRequest->setArgument('profile', $plan['name_plan']);
|
||||
$setRequest->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email']);
|
||||
$setRequest->setArgument('password', $customer['password']);
|
||||
$client->sendSync($setRequest);
|
||||
//disconnect then
|
||||
$this->removePpoeActive($client, $customer['username']);
|
||||
}
|
||||
}
|
||||
|
||||
function remove_customer($customer, $plan)
|
||||
@ -212,15 +226,6 @@ class MikrotikPppoe
|
||||
return $client->sendSync($printRequest)->getProperty('.id');
|
||||
}
|
||||
|
||||
|
||||
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||
{
|
||||
}
|
||||
|
||||
function disconnect_customer($customer, $router_name)
|
||||
{
|
||||
}
|
||||
|
||||
function info($name)
|
||||
{
|
||||
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
|
||||
|
@ -10,7 +10,7 @@ class RadiusRest {
|
||||
'description' => 'This devices will handle Radius Connection using Rest API',
|
||||
'author' => 'ibnu maksum',
|
||||
'url' => [
|
||||
'Wiki/Tutorial' => 'https://github.com/hotspotbilling/phpnuxbill/wiki/Radius-Rest',
|
||||
'Wiki Tutorial' => 'https://github.com/hotspotbilling/phpnuxbill/wiki/FreeRadius-Rest',
|
||||
'Telegram' => 'https://t.me/ibnux',
|
||||
'Donate' => 'https://paypal.me/ibnux'
|
||||
]
|
||||
|
@ -561,5 +561,6 @@
|
||||
"Please_wait_1015_seconds_before_sending_another_SMS": "Harap tunggu 1015 detik sebelum mengirim SMS lainnya",
|
||||
"Phone_number_updated_successfully": "Nomor telepon berhasil diperbarui",
|
||||
"You_cannot_use_your_current_phone_number": "Anda tidak dapat menggunakan nomor telepon Anda saat ini",
|
||||
"Devices": "Perangkat"
|
||||
"Devices": "Perangkat",
|
||||
"Voucher_Prefix": "Awalan Voucher"
|
||||
}
|
@ -120,5 +120,10 @@
|
||||
"2024.6.21" : [
|
||||
"ALTER TABLE `tbl_plans` ADD `on_login` TEXT NULL DEFAULT NULL AFTER `device`;",
|
||||
"ALTER TABLE `tbl_plans` ADD `on_logout` TEXT NULL DEFAULT NULL AFTER `on_login`;"
|
||||
],
|
||||
"2024.7.6" : [
|
||||
"CREATE TABLE IF NOT EXISTS `rad_acct` ( `id` bigint NOT NULL, `acctsessionid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `nasid` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `nasipaddress` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '', `nasportid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `nasporttype` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `framedipaddress` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',`acctstatustype` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `macaddr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `dateAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;",
|
||||
"ALTER TABLE `rad_acct` ADD PRIMARY KEY (`id`), ADD KEY `username` (`username`), ADD KEY `framedipaddress` (`framedipaddress`), ADD KEY `acctsessionid` (`acctsessionid`), ADD KEY `nasipaddress` (`nasipaddress`);",
|
||||
"ALTER TABLE `rad_acct` MODIFY `id` bigint NOT NULL AUTO_INCREMENT;"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user