Change to devices
This commit is contained in:
parent
c21c7689a8
commit
8ea853c617
@ -8,6 +8,8 @@
|
|||||||
use PHPMailer\PHPMailer\PHPMailer;
|
use PHPMailer\PHPMailer\PHPMailer;
|
||||||
use PHPMailer\PHPMailer\Exception;
|
use PHPMailer\PHPMailer\Exception;
|
||||||
use PHPMailer\PHPMailer\SMTP;
|
use PHPMailer\PHPMailer\SMTP;
|
||||||
|
use PEAR2\Net\RouterOS;
|
||||||
|
|
||||||
require $root_path . 'system/autoload/mail/Exception.php';
|
require $root_path . 'system/autoload/mail/Exception.php';
|
||||||
require $root_path . 'system/autoload/mail/PHPMailer.php';
|
require $root_path . 'system/autoload/mail/PHPMailer.php';
|
||||||
require $root_path . 'system/autoload/mail/SMTP.php';
|
require $root_path . 'system/autoload/mail/SMTP.php';
|
||||||
@ -37,10 +39,8 @@ class Message
|
|||||||
if (strlen($txt) > 160) {
|
if (strlen($txt) > 160) {
|
||||||
$txts = str_split($txt, 160);
|
$txts = str_split($txt, 160);
|
||||||
try {
|
try {
|
||||||
$mikrotik = Mikrotik::info($config['sms_url']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
foreach ($txts as $txt) {
|
foreach ($txts as $txt) {
|
||||||
Mikrotik::sendSMS($client, $phone, $txt);
|
self::sendSMS($config['sms_url'], $phone, $txt);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// ignore, add to logs
|
// ignore, add to logs
|
||||||
@ -48,9 +48,7 @@ class Message
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
$mikrotik = Mikrotik::info($config['sms_url']);
|
self::sendSMS($config['sms_url'], $phone, $txt);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::sendSMS($client, $phone, $txt);
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// ignore, add to logs
|
// ignore, add to logs
|
||||||
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
_log("Failed to send SMS using Mikrotik.\n" . $e->getMessage(), 'SMS', 0);
|
||||||
@ -64,6 +62,24 @@ class Message
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function MikrotikSendSMS($router_name, $to, $message)
|
||||||
|
{
|
||||||
|
global $_app_stage, $client_m;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(!isset($client_m)){
|
||||||
|
$mikrotik = ORM::for_table('tbl_routers')->where('name', $router_name)->find_one();
|
||||||
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
|
$client_m = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
|
}
|
||||||
|
$smsRequest = new RouterOS\Request('/tool sms send');
|
||||||
|
$smsRequest
|
||||||
|
->setArgument('phone-number', $to)
|
||||||
|
->setArgument('message', $message);
|
||||||
|
$client_m->sendSync($smsRequest);
|
||||||
|
}
|
||||||
|
|
||||||
public static function sendWhatsapp($phone, $txt)
|
public static function sendWhatsapp($phone, $txt)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -1,562 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
|
||||||
* by https://t.me/ibnux
|
|
||||||
**/
|
|
||||||
|
|
||||||
use PEAR2\Net\RouterOS;
|
|
||||||
|
|
||||||
class Mikrotik
|
|
||||||
{
|
|
||||||
public static function info($name)
|
|
||||||
{
|
|
||||||
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getClient($ip, $user, $pass)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$iport = explode(":", $ip);
|
|
||||||
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function isUserLogin($client, $username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot active print',
|
|
||||||
RouterOS\Query::where('user', $username)
|
|
||||||
);
|
|
||||||
return $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function logMeIn($client, $user, $pass, $ip, $mac)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/active/login');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('user', $user)
|
|
||||||
->setArgument('password', $pass)
|
|
||||||
->setArgument('ip', $ip)
|
|
||||||
->setArgument('mac-address', $mac)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function logMeOut($client, $user)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot active print',
|
|
||||||
RouterOS\Query::where('user', $user)
|
|
||||||
);
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $id)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function addHotspotPlan($client, $name, $sharedusers, $rate)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $name)
|
|
||||||
->setArgument('shared-users', $sharedusers)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setHotspotPlan($client, $name, $sharedusers, $rate)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
if (empty($profileID)) {
|
|
||||||
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
|
|
||||||
} else {
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
|
||||||
$client->sendSync(
|
|
||||||
$setRequest
|
|
||||||
->setArgument('numbers', $profileID)
|
|
||||||
->setArgument('shared-users', $sharedusers)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setHotspotExpiredPlan($client, $name, $pool)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
if (empty($profileID)) {
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $name)
|
|
||||||
->setArgument('shared-users', 3)
|
|
||||||
->setArgument('address-pool', $pool)
|
|
||||||
->setArgument('rate-limit', '512K/512K')
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
|
||||||
$client->sendSync(
|
|
||||||
$setRequest
|
|
||||||
->setArgument('numbers', $profileID)
|
|
||||||
->setArgument('shared-users', 3)
|
|
||||||
->setArgument('address-pool', $pool)
|
|
||||||
->setArgument('rate-limit', '512K/512K')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removeHotspotPlan($client, $name)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $profileID)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removeHotspotUser($client, $username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $username)
|
|
||||||
);
|
|
||||||
$userID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userID)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function addHotspotUser($client, $plan, $customer)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($plan['typebp'] == "Limited") {
|
|
||||||
if ($plan['limit_type'] == "Time_Limit") {
|
|
||||||
if ($plan['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $plan['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $plan['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $customer['username'])
|
|
||||||
->setArgument('profile', $plan['name_plan'])
|
|
||||||
->setArgument('password', $customer['password'])
|
|
||||||
->setArgument('comment', $customer['fullname'])
|
|
||||||
->setArgument('email', $customer['email'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($plan['limit_type'] == "Data_Limit") {
|
|
||||||
if ($plan['data_unit'] == 'GB')
|
|
||||||
$datalimit = $plan['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $plan['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $customer['username'])
|
|
||||||
->setArgument('profile', $plan['name_plan'])
|
|
||||||
->setArgument('password', $customer['password'])
|
|
||||||
->setArgument('comment', $customer['fullname'])
|
|
||||||
->setArgument('email', $customer['email'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($plan['limit_type'] == "Both_Limit") {
|
|
||||||
if ($plan['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $plan['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $plan['time_limit'] . ":00";
|
|
||||||
if ($plan['data_unit'] == 'GB')
|
|
||||||
$datalimit = $plan['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $plan['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $customer['username'])
|
|
||||||
->setArgument('profile', $plan['name_plan'])
|
|
||||||
->setArgument('password', $customer['password'])
|
|
||||||
->setArgument('comment', $customer['fullname'])
|
|
||||||
->setArgument('email', $customer['email'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $customer['username'])
|
|
||||||
->setArgument('profile', $plan['name_plan'])
|
|
||||||
->setArgument('comment', $customer['fullname'])
|
|
||||||
->setArgument('email', $customer['email'])
|
|
||||||
->setArgument('password', $customer['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setHotspotUser($client, $user, $pass)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('password', $pass);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setHotspotUserPackage($client, $user, $plan)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('profile', $plan);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removeHotspotActiveUser($client, $username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $username));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removePpoeUser($client, $username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
//$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $username));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function addPpoeUser($client, $plan, $customer)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
if (!empty($customer['pppoe_password'])) {
|
|
||||||
$pass = $customer['pppoe_password'];
|
|
||||||
} else {
|
|
||||||
$pass = $customer['password'];
|
|
||||||
}
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $customer['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $plan['name_plan'])
|
|
||||||
->setArgument('comment', $customer['fullname'] . ' | ' . $customer['email'])
|
|
||||||
->setArgument('password', $pass)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setPpoeUser($client, $user, $pass)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('password', $pass);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setPpoeUserPlan($client, $user, $plan)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('profile', $plan);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removePpoeActive($client, $username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $username));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removePool($client, $name)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip pool print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$poolID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/pool/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $poolID)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function addPool($client, $name, $ip_address)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/pool/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $name)
|
|
||||||
->setArgument('ranges', $ip_address)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setPool($client, $name, $ip_address)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip pool print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$poolID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
if (empty($poolID)) {
|
|
||||||
self::addPool($client, $name, $ip_address);
|
|
||||||
} else {
|
|
||||||
$setRequest = new RouterOS\Request('/ip/pool/set');
|
|
||||||
$client->sendSync(
|
|
||||||
$setRequest
|
|
||||||
->setArgument('numbers', $poolID)
|
|
||||||
->setArgument('ranges', $ip_address)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static function addPpoePlan($client, $name, $pool, $rate)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/profile/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $name)
|
|
||||||
->setArgument('local-address', $pool)
|
|
||||||
->setArgument('remote-address', $pool)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setPpoePlan($client, $name, $pool, $rate)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
if (empty($profileID)) {
|
|
||||||
self::addPpoePlan($client, $name, $pool, $rate);
|
|
||||||
} else {
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
|
||||||
$client->sendSync(
|
|
||||||
$setRequest
|
|
||||||
->setArgument('numbers', $profileID)
|
|
||||||
->setArgument('local-address', $pool)
|
|
||||||
->setArgument('remote-address', $pool)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removePpoePlan($client, $name)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/profile/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $profileID)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function sendSMS($client, $to, $message)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$smsRequest = new RouterOS\Request('/tool sms send');
|
|
||||||
$smsRequest
|
|
||||||
->setArgument('phone-number', $to)
|
|
||||||
->setArgument('message', $message);
|
|
||||||
$client->sendSync($smsRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getIpHotspotUser($client, $username){
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot active print',
|
|
||||||
RouterOS\Query::where('user', $username)
|
|
||||||
);
|
|
||||||
return $client->sendSync($printRequest)->getProperty('address');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function addIpToAddressList($client, $ip, $listName, $comment = '')
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/firewall/address-list/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('address', $ip)
|
|
||||||
->setArgument('comment', $comment)
|
|
||||||
->setArgument('list', $listName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function removeIpFromAddressList($client, $ip)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip firewall address-list print .proplist=.id',
|
|
||||||
RouterOS\Query::where('address', $ip)
|
|
||||||
);
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/firewall/address-list/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $id)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -221,10 +221,10 @@ class Package
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($isChangePlan || $b['status'] == 'off') {
|
if ($isChangePlan || $b['status'] == 'off') {
|
||||||
$dvc = $DEVICE_PATH . DIRECTORY_SEPARATOR . $p['device'] . '.php';
|
$dvc = Package::getDevice($p);
|
||||||
if (file_exists($dvc)) {
|
if (file_exists($dvc)) {
|
||||||
include $dvc;
|
require_once $dvc;
|
||||||
new $p['device']->connect_customer($c, $p);
|
new $p['device']->add_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
new Exception(Lang::T("Devices Not Found"));
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
}
|
}
|
||||||
@ -303,11 +303,11 @@ class Package
|
|||||||
"\nPrice: " . Lang::moneyFormat($p['price'] + $add_cost) .
|
"\nPrice: " . Lang::moneyFormat($p['price'] + $add_cost) .
|
||||||
"\nNote:\n" . $note);
|
"\nNote:\n" . $note);
|
||||||
} else {
|
} else {
|
||||||
// plan not exists
|
// active plan not exists
|
||||||
$dvc = $DEVICE_PATH . DIRECTORY_SEPARATOR . $p['device'] . '.php';
|
$dvc = Package::getDevice($p);
|
||||||
if (file_exists($dvc)) {
|
if (file_exists($dvc)) {
|
||||||
include $dvc;
|
require_once $dvc;
|
||||||
new $p['device']->connect_customer($c, $p);
|
new $p['device']->add_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
new Exception(Lang::T("Devices Not Found"));
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
}
|
}
|
||||||
@ -412,86 +412,13 @@ class Package
|
|||||||
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one();
|
||||||
$b = ORM::for_table('tbl_user_recharges')->find_one($from_id);
|
$b = ORM::for_table('tbl_user_recharges')->find_one($from_id);
|
||||||
|
|
||||||
$dvc = $DEVICE_PATH . DIRECTORY_SEPARATOR . $p['device'] . '.php';
|
$dvc = Package::getDevice($p);
|
||||||
if (file_exists($dvc)) {
|
if (file_exists($dvc)) {
|
||||||
include $dvc;
|
require_once $dvc;
|
||||||
new $p['device']->change_customer($b, $c, $p);
|
new $p['device']->change_customer($b, $c, $p);
|
||||||
} else {
|
} else {
|
||||||
new Exception(Lang::T("Devices Not Found"));
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($p['routers'] == $b['routers'] && $b['routers'] != 'radius') {
|
|
||||||
// $mikrotik = Mikrotik::info($p['routers']);
|
|
||||||
// } else {
|
|
||||||
// $mikrotik = Mikrotik::info($b['routers']);
|
|
||||||
// }
|
|
||||||
// // delete first
|
|
||||||
// if ($p['type'] == 'Hotspot') {
|
|
||||||
// if ($b) {
|
|
||||||
// if (!$p['is_radius']) {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::removeHotspotUser($client, $c['username']);
|
|
||||||
// Mikrotik::removeHotspotActiveUser($client, $c['username']);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (!$p['is_radius']) {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::removeHotspotUser($client, $c['username']);
|
|
||||||
// Mikrotik::removeHotspotActiveUser($client, $c['username']);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if ($b) {
|
|
||||||
// if (!$p['is_radius']) {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::removePpoeUser($client, $c['username']);
|
|
||||||
// Mikrotik::removePpoeActive($client, $c['username']);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (!$p['is_radius']) {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::removePpoeUser($client, $c['username']);
|
|
||||||
// Mikrotik::removePpoeActive($client, $c['username']);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // call the next mikrotik
|
|
||||||
// if ($p['routers'] != $b['routers'] && $p['routers'] != 'radius') {
|
|
||||||
// $mikrotik = Mikrotik::info($p['routers']);
|
|
||||||
// }
|
|
||||||
// if ($p['type'] == 'Hotspot') {
|
|
||||||
// if ($b) {
|
|
||||||
// if ($p['is_radius']) {
|
|
||||||
// Radius::customerAddPlan($c, $p, $b['expiration'] . '' . $b['time']);
|
|
||||||
// } else {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::addHotspotUser($client, $p, $c);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if ($p['is_radius']) {
|
|
||||||
// Radius::customerAddPlan($c, $p, $b['expiration'] . '' . $b['time']);
|
|
||||||
// } else {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::addHotspotUser($client, $p, $c);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if ($b) {
|
|
||||||
// if ($p['is_radius']) {
|
|
||||||
// Radius::customerAddPlan($c, $p);
|
|
||||||
// } else {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::addPpoeUser($client, $p, $c);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if ($p['is_radius']) {
|
|
||||||
// Radius::customerAddPlan($c, $p);
|
|
||||||
// } else {
|
|
||||||
// $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
// Mikrotik::addPpoeUser($client, $p, $c);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -620,4 +547,25 @@ class Package
|
|||||||
$tax = $price * $tax_rate_decimal;
|
$tax = $price * $tax_rate_decimal;
|
||||||
return $tax;
|
return $tax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getDevice($plan)
|
||||||
|
{
|
||||||
|
global $DEVICE_PATH;
|
||||||
|
if (!empty($plan['device'])) {
|
||||||
|
return $DEVICE_PATH . DIRECTORY_SEPARATOR . $plan['device'] . '.php';
|
||||||
|
}
|
||||||
|
if ($plan['is_radius'] == 1) {
|
||||||
|
$plan->device = 'Radius';
|
||||||
|
$plan->save();
|
||||||
|
return $DEVICE_PATH . DIRECTORY_SEPARATOR . 'Radius' . '.php';
|
||||||
|
}
|
||||||
|
if ($plan['type'] == 'PPPOE') {
|
||||||
|
$plan->device = 'MikrotikPppoe';
|
||||||
|
$plan->save();
|
||||||
|
return $DEVICE_PATH . DIRECTORY_SEPARATOR . 'MikrotikPppoe' . '.php';
|
||||||
|
}
|
||||||
|
$plan->device = 'MikrotikHotspot';
|
||||||
|
$plan->save();
|
||||||
|
return $DEVICE_PATH . DIRECTORY_SEPARATOR . 'MikrotikHotspot' . '.php';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,350 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
|
||||||
* by https://t.me/ibnux
|
|
||||||
**/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Radius Class
|
|
||||||
* based https://gist.github.com/nasirhafeez/6669b24aab0bda545f60f9da5ed14f25
|
|
||||||
*/
|
|
||||||
class Radius
|
|
||||||
{
|
|
||||||
|
|
||||||
public static function getClient()
|
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
if (empty($config['radius_client'])) {
|
|
||||||
if (function_exists("shell_exec")) {
|
|
||||||
shell_exec('which radclient');
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$config['radius_client'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTableNas()
|
|
||||||
{
|
|
||||||
return ORM::for_table('nas', 'radius');
|
|
||||||
}
|
|
||||||
public static function getTableAcct()
|
|
||||||
{
|
|
||||||
return ORM::for_table('radacct', 'radius');
|
|
||||||
}
|
|
||||||
public static function getTableCustomer()
|
|
||||||
{
|
|
||||||
return ORM::for_table('radcheck', 'radius');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTableCustomerAttr()
|
|
||||||
{
|
|
||||||
return ORM::for_table('radreply', 'radius');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTablePackage()
|
|
||||||
{
|
|
||||||
return ORM::for_table('radgroupreply', 'radius');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTableUserPackage()
|
|
||||||
{
|
|
||||||
return ORM::for_table('radusergroup', 'radius');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function nasAdd($name, $ip, $ports, $secret, $routers = "", $description = "", $type = 'other', $server = null, $community = null)
|
|
||||||
{
|
|
||||||
$n = Radius::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->routers = $routers;
|
|
||||||
$n->save();
|
|
||||||
return $n->id();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function nasUpdate($id, $name, $ip, $ports, $secret, $routers = "", $description = "", $type = 'other', $server = null, $community = null)
|
|
||||||
{
|
|
||||||
$n = Radius::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->routers = $routers;
|
|
||||||
return $n->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function planUpSert($plan_id, $rate, $pool = null)
|
|
||||||
{
|
|
||||||
$rates = explode('/', $rate);
|
|
||||||
##burst fixed
|
|
||||||
if (strpos($rate, ' ')) {
|
|
||||||
$ratos = $rates[0] . '/' . $rates[1] . ' ' . $rates[2] . '/' . $rates[3] . '/' . $rates[4] . '/' . $rates[5] . '/' . $rates[6];
|
|
||||||
} else {
|
|
||||||
$ratos = $rates[0] . '/' . $rates[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
Radius::upsertPackage($plan_id, 'Ascend-Data-Rate', $rates[1], ':=');
|
|
||||||
Radius::upsertPackage($plan_id, 'Ascend-Xmit-Rate', $rates[0], ':=');
|
|
||||||
Radius::upsertPackage($plan_id, 'Mikrotik-Rate-Limit', $ratos, ':=');
|
|
||||||
// if ($pool != null) {
|
|
||||||
// Radius::upsertPackage($plan_id, 'Framed-Pool', $pool, ':=');
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function planDelete($plan_id)
|
|
||||||
{
|
|
||||||
// Delete Plan
|
|
||||||
Radius::getTablePackage()->where_equal('plan_id', "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)
|
|
||||||
{
|
|
||||||
$c = Radius::getTableCustomer()->where_equal('username', $from)->findMany();
|
|
||||||
if ($c) {
|
|
||||||
foreach ($c as $u) {
|
|
||||||
$u->username = $to;
|
|
||||||
$u->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$c = Radius::getTableUserPackage()->where_equal('username', $from)->findMany();
|
|
||||||
if ($c) {
|
|
||||||
foreach ($c as $u) {
|
|
||||||
$u->username = $to;
|
|
||||||
$u->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function customerDeactivate($username, $radiusDisconnect = true)
|
|
||||||
{ {
|
|
||||||
global $radius_pass;
|
|
||||||
$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() . $username . $radius_pass);
|
|
||||||
$r->save();
|
|
||||||
if ($radiusDisconnect)
|
|
||||||
return Radius::disconnectCustomer($username);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function customerDelete($username)
|
|
||||||
{
|
|
||||||
Radius::getTableCustomer()->where_equal('username', $username)->delete_many();
|
|
||||||
Radius::getTableUserPackage()->where_equal('username', $username)->delete_many();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* When add a plan to Customer, use this
|
|
||||||
*/
|
|
||||||
public static function customerAddPlan($customer, $plan, $expired = null)
|
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
if (Radius::customerUpsert($customer, $plan)) {
|
|
||||||
$p = Radius::getTableUserPackage()->where_equal('username', $customer['username'])->findOne();
|
|
||||||
if ($p) {
|
|
||||||
// if exists
|
|
||||||
Radius::delAtribute(Radius::getTableCustomer(), 'Max-All-Session', 'username', $customer['username']);
|
|
||||||
//Radius::delAtribute(Radius::getTableCustomer(), 'Max-Volume', 'username', $customer['username']);
|
|
||||||
Radius::delAtribute(Radius::getTableCustomer(), 'Max-Data', 'username', $customer['username']);
|
|
||||||
$p->groupname = "plan_" . $plan['id'];
|
|
||||||
$p->save();
|
|
||||||
} else {
|
|
||||||
$p = Radius::getTableUserPackage()->create();
|
|
||||||
$p->username = $customer['username'];
|
|
||||||
$p->groupname = "plan_" . $plan['id'];
|
|
||||||
$p->priority = 1;
|
|
||||||
$p->save();
|
|
||||||
}
|
|
||||||
if ($plan['type'] == 'Hotspot' && $plan['typebp'] == "Limited") {
|
|
||||||
if ($plan['limit_type'] == "Time_Limit") {
|
|
||||||
if ($plan['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $plan['time_limit'] * 60 * 60;
|
|
||||||
else
|
|
||||||
$timelimit = $plan['time_limit'] * 60;
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Max-All-Session', $timelimit);
|
|
||||||
//Radius::upsertCustomer($customer['username'], 'Expire-After', $timelimit);
|
|
||||||
} else if ($plan['limit_type'] == "Data_Limit") {
|
|
||||||
if ($plan['data_unit'] == 'GB')
|
|
||||||
$datalimit = $plan['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $plan['data_limit'] . "000000";
|
|
||||||
//Radius::upsertCustomer($customer['username'], 'Max-Volume', $datalimit);
|
|
||||||
// Mikrotik Spesific
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Max-Data', $datalimit);
|
|
||||||
//Radius::upsertCustomer($customer['username'], 'Mikrotik-Total-Limit', $datalimit);
|
|
||||||
} else if ($plan['limit_type'] == "Both_Limit") {
|
|
||||||
if ($plan['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $plan['time_limit'] * 60 * 60;
|
|
||||||
else
|
|
||||||
$timelimit = $plan['time_limit'] * 60;
|
|
||||||
if ($plan['data_unit'] == 'GB')
|
|
||||||
$datalimit = $plan['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $plan['data_limit'] . "000000";
|
|
||||||
//Radius::upsertCustomer($customer['username'], 'Max-Volume', $datalimit);
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Max-All-Session', $timelimit);
|
|
||||||
// Mikrotik Spesific
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Max-Data', $datalimit);
|
|
||||||
//Radius::upsertCustomer($customer['username'], 'Mikrotik-Total-Limit', $datalimit);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//Radius::delAtribute(Radius::getTableCustomer(), 'Max-Volume', 'username', $customer['username']);
|
|
||||||
Radius::delAtribute(Radius::getTableCustomer(), 'Max-All-Session', 'username', $customer['username']);
|
|
||||||
Radius::delAtribute(Radius::getTableCustomer(), 'Max-Data', 'username', $customer['username']);
|
|
||||||
}
|
|
||||||
|
|
||||||
Radius::disconnectCustomer($customer['username']);
|
|
||||||
Radius::getTableAcct()->where_equal('username', $customer['username'])->delete_many();
|
|
||||||
|
|
||||||
|
|
||||||
// expired user
|
|
||||||
if ($expired != null) {
|
|
||||||
//Radius::upsertCustomer($customer['username'], 'access-period', strtotime($expired) - time());
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Max-All-Session', strtotime($expired) - time());
|
|
||||||
//Radius::upsertCustomer($customer['username'], 'expiration', date('d M Y H:i:s', strtotime($expired)));
|
|
||||||
// Mikrotik Spesific
|
|
||||||
Radius::upsertCustomer(
|
|
||||||
$customer['username'],
|
|
||||||
'WISPr-Session-Terminate-Time',
|
|
||||||
date('Y-m-d', strtotime($expired)) . 'T' . date('H:i:s', strtotime($expired)) . Timezone::getTimeOffset($config['timezone'])
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Radius::delAtribute(Radius::getTableCustomer(), 'Max-All-Session', 'username', $customer['username']);
|
|
||||||
//Radius::delAtribute(Radius::getTableCustomer(), 'access-period', 'username', $customer['username']);
|
|
||||||
//Radius::delAtribute(Radius::getTableCustomer(), 'expiration', 'username', $customer['username']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($plan['type'] == 'PPPOE') {
|
|
||||||
Radius::upsertCustomerAttr($customer['username'], 'Framed-Pool', $plan['pool'], ':=');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function customerUpsert($customer, $plan)
|
|
||||||
{
|
|
||||||
if ($plan['type'] == 'PPPOE') {
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Cleartext-Password', (empty($customer['pppoe_password'])) ? $customer['password'] : $customer['pppoe_password']);
|
|
||||||
} else {
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Cleartext-Password', $customer['password']);
|
|
||||||
}
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Simultaneous-Use', ($plan['type'] == 'PPPOE') ? 1 : $plan['shared_users']);
|
|
||||||
// Mikrotik Spesific
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Port-Limit', ($plan['type'] == 'PPPOE') ? 1 : $plan['shared_users']);
|
|
||||||
Radius::upsertCustomer($customer['username'], 'Mikrotik-Wireless-Comment', $customer['fullname']);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function delAtribute($tabel, $attribute, $key, $value)
|
|
||||||
{
|
|
||||||
$r = $tabel->where_equal($key, $value)->whereEqual('attribute', $attribute)->findOne();
|
|
||||||
if ($r) $r->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To insert or update existing plan
|
|
||||||
*/
|
|
||||||
private static function upsertPackage($plan_id, $attr, $value, $op = ':=')
|
|
||||||
{
|
|
||||||
$r = Radius::getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', $attr)->find_one();
|
|
||||||
if (!$r) {
|
|
||||||
$r = Radius::getTablePackage()->create();
|
|
||||||
$r->groupname = "plan_" . $plan_id;
|
|
||||||
$r->plan_id = $plan_id;
|
|
||||||
}
|
|
||||||
$r->attribute = $attr;
|
|
||||||
$r->op = $op;
|
|
||||||
$r->value = $value;
|
|
||||||
return $r->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To insert or update existing customer
|
|
||||||
*/
|
|
||||||
public static function upsertCustomer($username, $attr, $value, $op = ':=')
|
|
||||||
{
|
|
||||||
$r = Radius::getTableCustomer()->where_equal('username', $username)->whereEqual('attribute', $attr)->find_one();
|
|
||||||
if (!$r) {
|
|
||||||
$r = Radius::getTableCustomer()->create();
|
|
||||||
$r->username = $username;
|
|
||||||
}
|
|
||||||
$r->attribute = $attr;
|
|
||||||
$r->op = $op;
|
|
||||||
$r->value = $value;
|
|
||||||
return $r->save();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* To insert or update existing customer Attribute
|
|
||||||
*/
|
|
||||||
public static function upsertCustomerAttr($username, $attr, $value, $op = ':=')
|
|
||||||
{
|
|
||||||
$r = Radius::getTableCustomerAttr()->where_equal('username', $username)->whereEqual('attribute', $attr)->find_one();
|
|
||||||
if (!$r) {
|
|
||||||
$r = Radius::getTableCustomerAttr()->create();
|
|
||||||
$r->username = $username;
|
|
||||||
}
|
|
||||||
$r->attribute = $attr;
|
|
||||||
$r->op = $op;
|
|
||||||
$r->value = $value;
|
|
||||||
return $r->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function disconnectCustomer($username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Fix loop to all Nas but still detecting Hotspot Multylogin from other Nas
|
|
||||||
*/
|
|
||||||
$act = ORM::for_table('radacct')->where_raw("acctstoptime IS NULL")->where('username', $username)->find_one();
|
|
||||||
$nas = Radius::getTableNas()->where('nasname', $act['nasipaddress'])->find_many();
|
|
||||||
$count = count($nas) * 15;
|
|
||||||
set_time_limit($count);
|
|
||||||
$result = [];
|
|
||||||
foreach ($nas as $n) {
|
|
||||||
$port = 3799;
|
|
||||||
if (!empty($n['ports'])) {
|
|
||||||
$port = $n['ports'];
|
|
||||||
}
|
|
||||||
$result[] = $n['nasname'] . ': ' . @shell_exec("echo 'User-Name = $username,Framed-IP-Address = " . $act['framedipaddress'] . "' | radclient -x " . trim($n['nasname']) . ":$port disconnect '" . $n['secret'] . "'");
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -41,22 +41,14 @@ switch ($action) {
|
|||||||
|
|
||||||
$c = ORM::for_table('tbl_user_recharges')->where('username', $user['username'])->find_one();
|
$c = ORM::for_table('tbl_user_recharges')->where('username', $user['username'])->find_one();
|
||||||
if ($c) {
|
if ($c) {
|
||||||
|
// if has active plan, change the password to devices
|
||||||
$p = ORM::for_table('tbl_plans')->where('id', $c['plan_id'])->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $c['plan_id'])->find_one();
|
||||||
if ($p['is_radius']) {
|
$dvc = Package::getDevice($p);
|
||||||
if ($c['type'] == 'Hotspot' || ($c['type'] == 'PPPOE' && empty($d['pppoe_password']))) {
|
if (file_exists($dvc)) {
|
||||||
Radius::customerUpsert($d, $p);
|
require_once $dvc;
|
||||||
}
|
new $p['device']->remove_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($c['routers']);
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
if ($c['type'] == 'Hotspot') {
|
|
||||||
Mikrotik::setHotspotUser($client, $c['username'], $npass);
|
|
||||||
Mikrotik::removeHotspotActiveUser($client, $user['username']);
|
|
||||||
} else if (empty($d['pppoe_password'])) {
|
|
||||||
// only change when pppoe_password empty
|
|
||||||
Mikrotik::setPpoeUser($client, $c['username'], $npass);
|
|
||||||
Mikrotik::removePpoeActive($client, $user['username']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$d->password = $npass;
|
$d->password = $npass;
|
||||||
|
@ -212,18 +212,13 @@ switch ($action) {
|
|||||||
if ($b) {
|
if ($b) {
|
||||||
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->find_one();
|
||||||
if ($p) {
|
if ($p) {
|
||||||
if ($p['is_radius']) {
|
$p = ORM::for_table('tbl_plans')->where('id', $c['plan_id'])->find_one();
|
||||||
Radius::customerDeactivate($b['username']);
|
$dvc = Package::getDevice($p);
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->change_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($b['routers']);
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
if ($b['type'] == 'Hotspot') {
|
|
||||||
Mikrotik::removeHotspotUser($client, $b['username']);
|
|
||||||
Mikrotik::removeHotspotActiveUser($client, $b['username']);
|
|
||||||
} else if ($b['type'] == 'PPPOE') {
|
|
||||||
Mikrotik::removePpoeUser($client, $b['username']);
|
|
||||||
Mikrotik::removePpoeActive($client, $b['username']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$b->status = 'off';
|
$b->status = 'off';
|
||||||
$b->expiration = date('Y-m-d');
|
$b->expiration = date('Y-m-d');
|
||||||
@ -246,16 +241,12 @@ switch ($action) {
|
|||||||
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->where('enabled', '1')->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $b['plan_id'])->where('enabled', '1')->find_one();
|
||||||
if ($p) {
|
if ($p) {
|
||||||
$routers[] = $b['routers'];
|
$routers[] = $b['routers'];
|
||||||
if ($p['is_radius']) {
|
$dvc = Package::getDevice($p);
|
||||||
Radius::customerAddPlan($c, $p, $p['expiration'] . ' ' . $p['time']);
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->add_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($b['routers']);
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
if ($b['type'] == 'Hotspot') {
|
|
||||||
Mikrotik::addHotspotUser($client, $p, $c);
|
|
||||||
} else if ($b['type'] == 'PPPOE') {
|
|
||||||
Mikrotik::addPpoeUser($client, $p, $c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,43 +328,25 @@ switch ($action) {
|
|||||||
$c = ORM::for_table('tbl_user_recharges')->where('username', $d['username'])->find_one();
|
$c = ORM::for_table('tbl_user_recharges')->where('username', $d['username'])->find_one();
|
||||||
if ($c) {
|
if ($c) {
|
||||||
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
|
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
|
||||||
if ($p['is_radius']) {
|
if($p){
|
||||||
Radius::customerDelete($d['username']);
|
$dvc = Package::getDevice($p);
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->remove_customer($d, $p);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($c['routers']);
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
if ($c['type'] == 'Hotspot') {
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::removeHotspotUser($client, $d['username']);
|
|
||||||
Mikrotik::removeHotspotActiveUser($client, $d['username']);
|
|
||||||
} else {
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::removePpoeUser($client, $d['username']);
|
|
||||||
Mikrotik::removePpoeActive($client, $d['username']);
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
$d->delete();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$c->delete();
|
$c->delete();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
$d->delete();
|
$d->delete();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
if ($c)
|
|
||||||
$c->delete();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
r2(U . 'customers/list', 's', Lang::T('User deleted Successfully'));
|
r2(U . 'customers/list', 's', Lang::T('User deleted Successfully'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -595,26 +568,13 @@ switch ($action) {
|
|||||||
$c->username = $username;
|
$c->username = $username;
|
||||||
$c->save();
|
$c->save();
|
||||||
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
|
$p = ORM::for_table('tbl_plans')->find_one($c['plan_id']);
|
||||||
if ($p['is_radius']) {
|
$dvc = Package::getDevice($p);
|
||||||
if ($userDiff) {
|
if (file_exists($dvc)) {
|
||||||
Radius::customerChangeUsername($oldusername, $username);
|
require_once $dvc;
|
||||||
}
|
new $p['device']->remove_customer($d, $p);
|
||||||
Radius::customerAddPlan($d, $p, $p['expiration'] . ' ' . $p['time']);
|
new $p['device']->add_customer($d, $p);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($c['routers']);
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
if ($c['type'] == 'Hotspot') {
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::setHotspotUser($client, $c['username'], $password);
|
|
||||||
Mikrotik::removeHotspotActiveUser($client, $d['username']);
|
|
||||||
} else {
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
if (!empty($d['pppoe_password'])) {
|
|
||||||
Mikrotik::setPpoeUser($client, $c['username'], $d['pppoe_password']);
|
|
||||||
} else {
|
|
||||||
Mikrotik::setPpoeUser($client, $c['username'], $password);
|
|
||||||
}
|
|
||||||
Mikrotik::removePpoeActive($client, $d['username']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,26 +154,15 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($tur['status'] != 'on') {
|
if ($tur['status'] != 'on') {
|
||||||
if ($tur['routers'] != 'radius') {
|
|
||||||
$mikrotik = Mikrotik::info($tur['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
$router = $tur['routers'];
|
|
||||||
}
|
|
||||||
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
|
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
|
||||||
if (!$p) {
|
$dvc = Package::getDevice($p);
|
||||||
r2(U . 'home', '3', "Plan Not Found");
|
if (file_exists($dvc)) {
|
||||||
}
|
require_once $dvc;
|
||||||
if ($tur['routers'] == 'radius') {
|
new $p['device']->add_customer($user, $p);
|
||||||
Radius::customerAddPlan($user, $p, $tur['expiration'] . ' ' . $tur['time']);
|
|
||||||
} else {
|
} else {
|
||||||
if ($tur['type'] == 'Hotspot') {
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
Mikrotik::removeHotspotUser($client, $user['username']);
|
|
||||||
Mikrotik::addHotspotUser($client, $p, $user);
|
|
||||||
} else if ($tur['type'] == 'PPPOE') {
|
|
||||||
Mikrotik::removePpoeUser($client, $user['username']);
|
|
||||||
Mikrotik::addPpoeUser($client, $p, $user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make customer cannot extend again
|
// make customer cannot extend again
|
||||||
$days = $config['extend_days'];
|
$days = $config['extend_days'];
|
||||||
$expiration = date('Y-m-d', strtotime(" +$days day"));
|
$expiration = date('Y-m-d', strtotime(" +$days day"));
|
||||||
@ -198,22 +187,12 @@ if (isset($_GET['recharge']) && !empty($_GET['recharge'])) {
|
|||||||
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['deactivate'])->where('username', $user['username'])->findOne();
|
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['deactivate'])->where('username', $user['username'])->findOne();
|
||||||
if ($bill) {
|
if ($bill) {
|
||||||
$p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one();
|
||||||
if ($p['is_radius']) {
|
$dvc = Package::getDevice($p);
|
||||||
Radius::customerDeactivate($user['username']);
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->remove_customer($user, $p);
|
||||||
} else {
|
} else {
|
||||||
try {
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
$mikrotik = Mikrotik::info($bill['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
if ($bill['type'] == 'Hotspot') {
|
|
||||||
Mikrotik::removeHotspotUser($client, $bill['username']);
|
|
||||||
Mikrotik::removeHotspotActiveUser($client, $bill['username']);
|
|
||||||
} else if ($bill['type'] == 'PPPOE') {
|
|
||||||
Mikrotik::removePpoeUser($client, $bill['username']);
|
|
||||||
Mikrotik::removePpoeActive($client, $bill['username']);
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
//ignore it maybe mikrotik has been deleted
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$bill->status = 'off';
|
$bill->status = 'off';
|
||||||
$bill->expiration = date('Y-m-d');
|
$bill->expiration = date('Y-m-d');
|
||||||
@ -231,17 +210,20 @@ if (!empty($_SESSION['nux-mac']) && !empty($_SESSION['nux-ip'])) {
|
|||||||
$ui->assign('nux_mac', $_SESSION['nux-mac']);
|
$ui->assign('nux_mac', $_SESSION['nux-mac']);
|
||||||
$ui->assign('nux_ip', $_SESSION['nux-ip']);
|
$ui->assign('nux_ip', $_SESSION['nux-ip']);
|
||||||
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['id'])->where('username', $user['username'])->findOne();
|
$bill = ORM::for_table('tbl_user_recharges')->where('id', $_GET['id'])->where('username', $user['username'])->findOne();
|
||||||
|
$p = ORM::for_table('tbl_plans')->where('id', $bill['plan_id'])->find_one();
|
||||||
|
$dvc = Package::getDevice($p);
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
if ($_GET['mikrotik'] == 'login') {
|
if ($_GET['mikrotik'] == 'login') {
|
||||||
$m = Mikrotik::info($bill['routers']);
|
new $p['device']->connect_customer($user, $_SESSION['nux-ip'], $_SESSION['nux-mac'], $bill['routers']);
|
||||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
|
||||||
Mikrotik::logMeIn($c, $user['username'], $user['password'], $_SESSION['nux-ip'], $_SESSION['nux-mac']);
|
|
||||||
r2(U . 'home', 's', Lang::T('Login Request successfully'));
|
r2(U . 'home', 's', Lang::T('Login Request successfully'));
|
||||||
} else if ($_GET['mikrotik'] == 'logout') {
|
} else if ($_GET['mikrotik'] == 'logout') {
|
||||||
$m = Mikrotik::info($bill['routers']);
|
new $p['device']->disconnect_customer($user, $bill['routers']);
|
||||||
$c = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
|
||||||
Mikrotik::logMeOut($c, $user['username']);
|
|
||||||
r2(U . 'home', 's', Lang::T('Logout Request successfully'));
|
r2(U . 'home', 's', Lang::T('Logout Request successfully'));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ui->assign('unpaid', ORM::for_table('tbl_payment_gateway')
|
$ui->assign('unpaid', ORM::for_table('tbl_payment_gateway')
|
||||||
|
@ -41,21 +41,14 @@ switch ($action) {
|
|||||||
$log = '';
|
$log = '';
|
||||||
$router = '';
|
$router = '';
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
if ($router != $plan['routers'] && $plan['routers'] != 'radius') {
|
|
||||||
$mikrotik = Mikrotik::info($plan['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
$router = $plan['routers'];
|
|
||||||
}
|
|
||||||
$p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']);
|
$p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']);
|
||||||
$c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']);
|
$c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']);
|
||||||
if ($plan['routers'] == 'radius') {
|
$dvc = Package::getDevice($plan);
|
||||||
Radius::customerAddPlan($c, $p, $plan['expiration'] . ' ' . $plan['time']);
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->add_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
if ($plan['type'] == 'Hotspot') {
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
Mikrotik::addHotspotUser($client, $p, $c);
|
|
||||||
} else if ($plan['type'] == 'PPPOE') {
|
|
||||||
Mikrotik::addPpoeUser($client, $p, $c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]<br>";
|
$log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]<br>";
|
||||||
}
|
}
|
||||||
@ -265,19 +258,11 @@ switch ($action) {
|
|||||||
if ($d) {
|
if ($d) {
|
||||||
run_hook('delete_customer_active_plan'); #HOOK
|
run_hook('delete_customer_active_plan'); #HOOK
|
||||||
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
|
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
|
||||||
if ($p['is_radius']) {
|
if (file_exists($dvc)) {
|
||||||
Radius::customerDeactivate($d['username']);
|
require_once $dvc;
|
||||||
|
new $p['device']->remove_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
if ($d['type'] == 'Hotspot') {
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::removeHotspotUser($client, $d['username']);
|
|
||||||
Mikrotik::removeHotspotActiveUser($client, $d['username']);
|
|
||||||
} else {
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::removePpoeUser($client, $d['username']);
|
|
||||||
Mikrotik::removePpoeActive($client, $d['username']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
_log('[' . $admin['username'] . ']: ' . 'Delete Plan for Customer ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']);
|
_log('[' . $admin['username'] . ']: ' . 'Delete Plan for Customer ' . $c['username'] . ' [' . $in['plan_name'] . '][' . Lang::moneyFormat($in['price']) . ']', $admin['user_type'], $admin['id']);
|
||||||
@ -786,25 +771,14 @@ switch ($action) {
|
|||||||
$tur->status = "on";
|
$tur->status = "on";
|
||||||
$tur->save();
|
$tur->save();
|
||||||
App::setToken($stoken, $id);
|
App::setToken($stoken, $id);
|
||||||
if ($tur['routers'] != 'radius') {
|
|
||||||
$mikrotik = Mikrotik::info($tur['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
$router = $tur['routers'];
|
|
||||||
}
|
|
||||||
$p = ORM::for_table('tbl_plans')->findOne($tur['plan_id']);
|
|
||||||
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
|
$c = ORM::for_table('tbl_customers')->findOne($tur['customer_id']);
|
||||||
if ($tur['routers'] == 'radius') {
|
$p = ORM::for_table('tbl_plans')->find_one($d['plan_id']);
|
||||||
Radius::customerAddPlan($c, $p, $tur['expiration'] . ' ' . $tur['time']);
|
$dvc = Package::getDevice($p);
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->add_customer($c, $p);
|
||||||
} else {
|
} else {
|
||||||
if ($tur['type'] == 'Hotspot') {
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
Mikrotik::removeHotspotUser($client, $c['username']);
|
|
||||||
Mikrotik::removeHotspotActiveUser($client, $c['username']);
|
|
||||||
Mikrotik::addHotspotUser($client, $p, $c);
|
|
||||||
} else if ($tur['type'] == 'PPPOE') {
|
|
||||||
Mikrotik::removePpoeUser($client, $c['username']);
|
|
||||||
Mikrotik::removePpoeActive($client, $c['username']);
|
|
||||||
Mikrotik::addPpoeUser($client, $p, $c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_log("$admin[fullname] extend Customer $tur[customer_id] $tur[username] for $days days", $admin['user_type'], $admin['id']);
|
_log("$admin[fullname] extend Customer $tur[customer_id] $tur[username] for $days days", $admin['user_type'], $admin['id']);
|
||||||
r2(U . 'plan', 's', "Extend until $expiration");
|
r2(U . 'plan', 's', "Extend until $expiration");
|
||||||
|
@ -13,9 +13,10 @@ $action = $routes['1'];
|
|||||||
$ui->assign('_admin', $admin);
|
$ui->assign('_admin', $admin);
|
||||||
|
|
||||||
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) {
|
||||||
_alert(Lang::T('You do not have permission to access this page'),'danger', "dashboard");
|
_alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once $DEVICE_PATH . DIRECTORY_SEPARATOR . "MikrotikPppoe.php";
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'list':
|
case 'list':
|
||||||
@ -60,15 +61,7 @@ switch ($action) {
|
|||||||
$d = ORM::for_table('tbl_pool')->find_one($id);
|
$d = ORM::for_table('tbl_pool')->find_one($id);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
if ($d['routers'] != 'radius') {
|
if ($d['routers'] != 'radius') {
|
||||||
try {
|
(new MikrotikPppoe())->remove_pool($d);
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::removePool($client, $d['pool_name']);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
//ignore exception, it means router has already deleted
|
|
||||||
} catch(Throwable $e){
|
|
||||||
//ignore exception, it means router has already deleted
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
@ -81,9 +74,7 @@ switch ($action) {
|
|||||||
$log = '';
|
$log = '';
|
||||||
foreach ($pools as $pool) {
|
foreach ($pools as $pool) {
|
||||||
if ($pool['routers'] != 'radius') {
|
if ($pool['routers'] != 'radius') {
|
||||||
$mikrotik = Mikrotik::info($pool['routers']);
|
(new MikrotikPppoe())->update_pool($pool, $pool);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::addPool($client, $pool['pool_name'], $pool['range_ip']);
|
|
||||||
$log .= 'DONE: ' . $pool['pool_name'] . ': ' . $pool['range_ip'] . '<br>';
|
$log .= 'DONE: ' . $pool['pool_name'] . ': ' . $pool['range_ip'] . '<br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,9 +99,7 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
if ($routers != 'radius') {
|
if ($routers != 'radius') {
|
||||||
$mikrotik = Mikrotik::info($routers);
|
(new MikrotikPppoe())->add_pool($pool);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::addPool($client, $name, $ip_address);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b = ORM::for_table('tbl_pool')->create();
|
$b = ORM::for_table('tbl_pool')->create();
|
||||||
@ -138,22 +127,20 @@ switch ($action) {
|
|||||||
|
|
||||||
$id = _post('id');
|
$id = _post('id');
|
||||||
$d = ORM::for_table('tbl_pool')->find_one($id);
|
$d = ORM::for_table('tbl_pool')->find_one($id);
|
||||||
if ($d) {
|
$old = ORM::for_table('tbl_pool')->find_one($id);
|
||||||
} else {
|
if (!$d) {
|
||||||
$msg .= Lang::T('Data Not Found') . '<br>';
|
$msg .= Lang::T('Data Not Found') . '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
if ($routers != 'radius') {
|
|
||||||
$mikrotik = Mikrotik::info($routers);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::setPool($client, $d['pool_name'], $ip_address);
|
|
||||||
}
|
|
||||||
|
|
||||||
$d->range_ip = $ip_address;
|
$d->range_ip = $ip_address;
|
||||||
$d->routers = $routers;
|
$d->routers = $routers;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
|
if ($routers != 'radius') {
|
||||||
|
(new MikrotikPppoe())->update_pool($old, $d);
|
||||||
|
}
|
||||||
|
|
||||||
r2(U . 'pool/list', 's', Lang::T('Data Updated Successfully'));
|
r2(U . 'pool/list', 's', Lang::T('Data Updated Successfully'));
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'pool/edit/' . $id, 'e', $msg);
|
r2(U . 'pool/edit/' . $id, 'e', $msg);
|
||||||
|
@ -27,43 +27,20 @@ switch ($action) {
|
|||||||
$log = '';
|
$log = '';
|
||||||
$router = '';
|
$router = '';
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
if ($plan['is_radius']) {
|
$dvc = Package::getDevice($plan);
|
||||||
if ($b['rate_down_unit'] == 'Kbps') {
|
if (file_exists($dvc)) {
|
||||||
$raddown = '000';
|
require_once $dvc;
|
||||||
} else {
|
new $p['device']->add_plan($plan);
|
||||||
$raddown = '000000';
|
|
||||||
}
|
|
||||||
if ($b['rate_up_unit'] == 'Kbps') {
|
|
||||||
$radup = '000';
|
|
||||||
} else {
|
|
||||||
$radup = '000000';
|
|
||||||
}
|
|
||||||
$radiusRate = $plan['rate_up'] . $radup . '/' . $plan['rate_down'] . $raddown . '/' . $plan['burst'];
|
|
||||||
Radius::planUpSert($plan['id'], $radiusRate);
|
|
||||||
$log .= "DONE : Radius $plan[name_plan], $plan[shared_users], $radiusRate<br>";
|
|
||||||
} else {
|
|
||||||
if ($router != $plan['routers']) {
|
|
||||||
$mikrotik = Mikrotik::info($plan['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
$router = $plan['routers'];
|
|
||||||
}
|
|
||||||
if ($plan['rate_down_unit'] == 'Kbps') {
|
|
||||||
$unitdown = 'K';
|
|
||||||
} else {
|
|
||||||
$unitdown = 'M';
|
|
||||||
}
|
|
||||||
if ($plan['rate_up_unit'] == 'Kbps') {
|
|
||||||
$unitup = 'K';
|
|
||||||
} else {
|
|
||||||
$unitup = 'M';
|
|
||||||
}
|
|
||||||
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
|
||||||
Mikrotik::addHotspotPlan($client, $plan['name_plan'], $plan['shared_users'], $rate);
|
|
||||||
$log .= "DONE : $plan[name_plan], $plan[shared_users], $rate<br>";
|
|
||||||
if (!empty($plan['pool_expired'])) {
|
if (!empty($plan['pool_expired'])) {
|
||||||
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired']);
|
$plan->name_plan = 'EXPIRED NUXBILL ' . $pool_expired;
|
||||||
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]<br>";
|
$plan->rate_down_unit = "Kbps";
|
||||||
|
$plan->rate_up_unit == 'Kbps';
|
||||||
|
$plan->rate_up = '512';
|
||||||
|
$plan->rate_down = '512';
|
||||||
|
new $p['device']->add_plan($plan);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r2(U . 'services/hotspot', 's', $log);
|
r2(U . 'services/hotspot', 's', $log);
|
||||||
@ -72,43 +49,20 @@ switch ($action) {
|
|||||||
$log = '';
|
$log = '';
|
||||||
$router = '';
|
$router = '';
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
if ($plan['is_radius']) {
|
$dvc = Package::getDevice($plan);
|
||||||
if ($b['rate_down_unit'] == 'Kbps') {
|
if (file_exists($dvc)) {
|
||||||
$raddown = '000';
|
require_once $dvc;
|
||||||
} else {
|
new $p['device']->add_plan($plan);
|
||||||
$raddown = '000000';
|
|
||||||
}
|
|
||||||
if ($b['rate_up_unit'] == 'Kbps') {
|
|
||||||
$radup = '000';
|
|
||||||
} else {
|
|
||||||
$radup = '000000';
|
|
||||||
}
|
|
||||||
$radiusRate = $plan['rate_up'] . $radup . '/' . $plan['rate_down'] . $raddown . '/' . $plan['burst'];
|
|
||||||
Radius::planUpSert($plan['id'], $radiusRate, $plan['pool']);
|
|
||||||
$log .= "DONE : RADIUS $plan[name_plan], $plan[pool], $rate<br>";
|
|
||||||
} else {
|
|
||||||
if ($router != $plan['routers']) {
|
|
||||||
$mikrotik = Mikrotik::info($plan['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
$router = $plan['routers'];
|
|
||||||
}
|
|
||||||
if ($plan['rate_down_unit'] == 'Kbps') {
|
|
||||||
$unitdown = 'K';
|
|
||||||
} else {
|
|
||||||
$unitdown = 'M';
|
|
||||||
}
|
|
||||||
if ($plan['rate_up_unit'] == 'Kbps') {
|
|
||||||
$unitup = 'K';
|
|
||||||
} else {
|
|
||||||
$unitup = 'M';
|
|
||||||
}
|
|
||||||
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
|
||||||
Mikrotik::addPpoePlan($client, $plan['name_plan'], $plan['pool'], $rate);
|
|
||||||
$log .= "DONE : $plan[name_plan], $plan[pool], $rate<br>";
|
|
||||||
if (!empty($plan['pool_expired'])) {
|
if (!empty($plan['pool_expired'])) {
|
||||||
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired'], '512K/512K');
|
$plan->name_plan = 'EXPIRED NUXBILL ' . $pool_expired;
|
||||||
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]<br>";
|
$plan->rate_down_unit = "Kbps";
|
||||||
|
$plan->rate_up_unit == 'Kbps';
|
||||||
|
$plan->rate_up = '512';
|
||||||
|
$plan->rate_down = '512';
|
||||||
|
new $p['device']->add_plan($plan);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r2(U . 'services/pppoe', 's', $log);
|
r2(U . 'services/pppoe', 's', $log);
|
||||||
@ -162,20 +116,13 @@ switch ($action) {
|
|||||||
$d = ORM::for_table('tbl_plans')->find_one($id);
|
$d = ORM::for_table('tbl_plans')->find_one($id);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
run_hook('delete_plan'); #HOOK
|
run_hook('delete_plan'); #HOOK
|
||||||
if ($d['is_radius']) {
|
$dvc = Package::getDevice($d);
|
||||||
Radius::planDelete($d['id']);
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->remove_plan($d);
|
||||||
} else {
|
} else {
|
||||||
try {
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::removeHotspotPlan($client, $d['name_plan']);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
//ignore exception, it means router has already deleted
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
//ignore exception, it means router has already deleted
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
r2(U . 'services/hotspot', 's', Lang::T('Data Deleted Successfully'));
|
r2(U . 'services/hotspot', 's', Lang::T('Data Deleted Successfully'));
|
||||||
@ -272,20 +219,23 @@ switch ($action) {
|
|||||||
$d->enabled = $enabled;
|
$d->enabled = $enabled;
|
||||||
$d->prepaid = $prepaid;
|
$d->prepaid = $prepaid;
|
||||||
$d->save();
|
$d->save();
|
||||||
$plan_id = $d->id();
|
|
||||||
|
|
||||||
if ($d['is_radius']) {
|
$dvc = Package::getDevice($d);
|
||||||
Radius::planUpSert($plan_id, $radiusRate);
|
if (file_exists($dvc)) {
|
||||||
} else {
|
require_once $dvc;
|
||||||
$mikrotik = Mikrotik::info($routers);
|
new $p['device']->add_plan($d);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
|
|
||||||
if (!empty($pool_expired)) {
|
if (!empty($pool_expired)) {
|
||||||
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired);
|
$d->name_plan = 'EXPIRED NUXBILL ' . $pool_expired;
|
||||||
|
$d->rate_down_unit = "Kbps";
|
||||||
|
$d->rate_up_unit == 'Kbps';
|
||||||
|
$d->rate_up = '512';
|
||||||
|
$d->rate_down = '512';
|
||||||
|
new $p['device']->add_plan($d);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
r2(U . 'services/hotspot', 's', Lang::T('Data Created Successfully'));
|
r2(U . 'services/hotspot', 's', Lang::T('Data Created Successfully'));
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'services/add', 'e', $msg);
|
r2(U . 'services/add', 'e', $msg);
|
||||||
@ -324,6 +274,7 @@ switch ($action) {
|
|||||||
$msg .= Lang::T('All field is required') . '<br>';
|
$msg .= Lang::T('All field is required') . '<br>';
|
||||||
}
|
}
|
||||||
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
|
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
|
||||||
|
$old = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
|
||||||
if ($d) {
|
if ($d) {
|
||||||
} else {
|
} else {
|
||||||
$msg .= Lang::T('Data Not Found') . '<br>';
|
$msg .= Lang::T('Data Not Found') . '<br>';
|
||||||
@ -350,16 +301,6 @@ switch ($action) {
|
|||||||
|
|
||||||
$rate = trim($rate . " " . $b['burst']);
|
$rate = trim($rate . " " . $b['burst']);
|
||||||
|
|
||||||
if ($d['is_radius']) {
|
|
||||||
Radius::planUpSert($id, $radiusRate);
|
|
||||||
} else {
|
|
||||||
$mikrotik = Mikrotik::info($routers);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate);
|
|
||||||
if (!empty($pool_expired)) {
|
|
||||||
Mikrotik::setHotspotExpiredPlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$d->name_plan = $name;
|
$d->name_plan = $name;
|
||||||
$d->id_bw = $id_bw;
|
$d->id_bw = $id_bw;
|
||||||
$d->price = $price; // Set price with or without tax based on configuration
|
$d->price = $price; // Set price with or without tax based on configuration
|
||||||
@ -379,6 +320,23 @@ switch ($action) {
|
|||||||
$d->prepaid = $prepaid;
|
$d->prepaid = $prepaid;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
|
$dvc = Package::getDevice($d);
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $d['device']->update_plan($old, $d);
|
||||||
|
if (!empty($pool_expired)) {
|
||||||
|
$old->name_plan = 'EXPIRED NUXBILL ' . $old['pool_expired'];
|
||||||
|
$d->name_plan = 'EXPIRED NUXBILL ' . $pool_expired;
|
||||||
|
$d->rate_down_unit = "Kbps";
|
||||||
|
$d->rate_up_unit == 'Kbps';
|
||||||
|
$d->rate_up = '512';
|
||||||
|
$d->rate_down = '512';
|
||||||
|
new $d['device']->update_plan($old, $d);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
|
}
|
||||||
|
|
||||||
r2(U . 'services/hotspot', 's', Lang::T('Data Updated Successfully'));
|
r2(U . 'services/hotspot', 's', Lang::T('Data Updated Successfully'));
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'services/edit/' . $id, 'e', $msg);
|
r2(U . 'services/edit/' . $id, 'e', $msg);
|
||||||
@ -441,18 +399,13 @@ switch ($action) {
|
|||||||
$d = ORM::for_table('tbl_plans')->find_one($id);
|
$d = ORM::for_table('tbl_plans')->find_one($id);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
run_hook('delete_ppoe'); #HOOK
|
run_hook('delete_ppoe'); #HOOK
|
||||||
if ($d['is_radius']) {
|
|
||||||
Radius::planDelete($d['id']);
|
$dvc = Package::getDevice($d);
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $p['device']->remove_plan($d);
|
||||||
} else {
|
} else {
|
||||||
try {
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::removePpoePlan($client, $d['name_plan']);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
//ignore exception, it means router has already deleted
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
//ignore exception, it means router has already deleted
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
@ -537,17 +490,21 @@ switch ($action) {
|
|||||||
$d->enabled = $enabled;
|
$d->enabled = $enabled;
|
||||||
$d->prepaid = $prepaid;
|
$d->prepaid = $prepaid;
|
||||||
$d->save();
|
$d->save();
|
||||||
$plan_id = $d->id();
|
|
||||||
|
|
||||||
if ($d['is_radius']) {
|
$dvc = Package::getDevice($d);
|
||||||
Radius::planUpSert($plan_id, $radiusRate, $pool);
|
if (file_exists($dvc)) {
|
||||||
} else {
|
require_once $dvc;
|
||||||
$mikrotik = Mikrotik::info($routers);
|
new $p['device']->add_plan($d);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::addPpoePlan($client, $name, $pool, $rate);
|
|
||||||
if (!empty($pool_expired)) {
|
if (!empty($pool_expired)) {
|
||||||
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired, '512K/512K');
|
$d->name_plan = 'EXPIRED NUXBILL ' . $pool_expired;
|
||||||
|
$d->rate_down_unit = "Kbps";
|
||||||
|
$d->rate_up_unit == 'Kbps';
|
||||||
|
$d->rate_up = '512';
|
||||||
|
$d->rate_down = '512';
|
||||||
|
new $p['device']->add_plan($d);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
r2(U . 'services/pppoe', 's', Lang::T('Data Created Successfully'));
|
r2(U . 'services/pppoe', 's', Lang::T('Data Created Successfully'));
|
||||||
@ -583,6 +540,7 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
|
$d = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
|
||||||
|
$old = ORM::for_table('tbl_plans')->where('id', $id)->find_one();
|
||||||
if ($d) {
|
if ($d) {
|
||||||
} else {
|
} else {
|
||||||
$msg .= Lang::T('Data Not Found') . '<br>';
|
$msg .= Lang::T('Data Not Found') . '<br>';
|
||||||
@ -608,16 +566,6 @@ switch ($action) {
|
|||||||
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown . '/' . $b['burst'];
|
$radiusRate = $b['rate_up'] . $radup . '/' . $b['rate_down'] . $raddown . '/' . $b['burst'];
|
||||||
$rate = trim($rate . " " . $b['burst']);
|
$rate = trim($rate . " " . $b['burst']);
|
||||||
|
|
||||||
if ($d['is_radius']) {
|
|
||||||
Radius::planUpSert($id, $radiusRate, $pool);
|
|
||||||
} else {
|
|
||||||
$mikrotik = Mikrotik::info($routers);
|
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
|
||||||
Mikrotik::setPpoePlan($client, $name, $pool, $rate);
|
|
||||||
if (!empty($pool_expired)) {
|
|
||||||
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $pool_expired, $pool_expired, '512K/512K');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$d->name_plan = $name;
|
$d->name_plan = $name;
|
||||||
$d->id_bw = $id_bw;
|
$d->id_bw = $id_bw;
|
||||||
$d->price = $price;
|
$d->price = $price;
|
||||||
@ -632,6 +580,23 @@ switch ($action) {
|
|||||||
$d->prepaid = $prepaid;
|
$d->prepaid = $prepaid;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
|
$dvc = Package::getDevice($d);
|
||||||
|
if (file_exists($dvc)) {
|
||||||
|
require_once $dvc;
|
||||||
|
new $d['device']->update_plan($old, $d);
|
||||||
|
if (!empty($pool_expired)) {
|
||||||
|
$old->name_plan = 'EXPIRED NUXBILL ' . $old['pool_expired'];
|
||||||
|
$d->name_plan = 'EXPIRED NUXBILL ' . $pool_expired;
|
||||||
|
$d->rate_down_unit = "Kbps";
|
||||||
|
$d->rate_up_unit == 'Kbps';
|
||||||
|
$d->rate_up = '512';
|
||||||
|
$d->rate_down = '512';
|
||||||
|
new $d['device']->update_plan($old, $d);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
new Exception(Lang::T("Devices Not Found"));
|
||||||
|
}
|
||||||
|
|
||||||
r2(U . 'services/pppoe', 's', Lang::T('Data Updated Successfully'));
|
r2(U . 'services/pppoe', 's', Lang::T('Data Updated Successfully'));
|
||||||
} else {
|
} else {
|
||||||
r2(U . 'services/pppoe-edit/' . $id, 'e', $msg);
|
r2(U . 'services/pppoe-edit/' . $id, 'e', $msg);
|
||||||
|
@ -32,33 +32,14 @@ foreach ($d as $ds) {
|
|||||||
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();
|
$u = ORM::for_table('tbl_user_recharges')->where('id', $ds['id'])->find_one();
|
||||||
$c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one();
|
$c = ORM::for_table('tbl_customers')->where('id', $ds['customer_id'])->find_one();
|
||||||
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
|
||||||
$dvc = $DEVICE_PATH . DIRECTORY_SEPARATOR . $p['device'].'.php';
|
$dvc = Package::getDevice($p);
|
||||||
if(file_exists($dvc)){
|
if (file_exists($dvc)) {
|
||||||
include $dvc;
|
require_once $dvc;
|
||||||
new $p['device']->disconnect_customer($ds['routers'], $c, $p);
|
new $p['device']->remove_customer($ds['routers'], $c, $p);
|
||||||
}else{
|
} else {
|
||||||
echo "Cron error Devices $p[device] not found, cannot disconnect $c[username]";
|
echo "Cron error Devices $p[device] not found, cannot disconnect $c[username]";
|
||||||
Message::sendTelegram("Cron error Devices $p[device] not found, cannot disconnect $c[username]");
|
Message::sendTelegram("Cron error Devices $p[device] not found, cannot disconnect $c[username]");
|
||||||
}
|
}
|
||||||
// if ($p['is_radius']) {
|
|
||||||
// if (empty($p['pool_expired'])) {
|
|
||||||
// print_r(Radius::customerDeactivate($c['username']));
|
|
||||||
// } else {
|
|
||||||
// Radius::upsertCustomerAttr($c['username'], 'Framed-Pool', $p['pool_expired'], ':=');
|
|
||||||
// print_r(Radius::disconnectCustomer($c['username']));
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// $client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
|
||||||
// if (!empty($p['pool_expired'])) {
|
|
||||||
// Mikrotik::setHotspotUserPackage($client, $c['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']);
|
|
||||||
// // }if (!empty($p['list_expired'])) {
|
|
||||||
// // $ip = Mikrotik::getIpHotspotUser($client, $ds['username']);
|
|
||||||
// // Mikrotik::addIpToAddressList($client, $ip, $p['list_expired'], $c['username']);
|
|
||||||
// } else {
|
|
||||||
// Mikrotik::removeHotspotUser($client, $c['username']);
|
|
||||||
// }
|
|
||||||
// Mikrotik::removeHotspotActiveUser($client, $c['username']);
|
|
||||||
// }
|
|
||||||
echo Message::sendPackageNotification($c, $u['namebp'], $p['price'], $textExpired, $config['user_notification_expired']) . "\n";
|
echo Message::sendPackageNotification($c, $u['namebp'], $p['price'], $textExpired, $config['user_notification_expired']) . "\n";
|
||||||
//update database user dengan status off
|
//update database user dengan status off
|
||||||
$u->status = 'off';
|
$u->status = 'off';
|
||||||
@ -91,7 +72,7 @@ foreach ($d as $ds) {
|
|||||||
} else {
|
} else {
|
||||||
echo "no renewall | balance $config[enable_balance] auto_renewal $c[auto_renewal]\n";
|
echo "no renewall | balance $config[enable_balance] auto_renewal $c[auto_renewal]\n";
|
||||||
}
|
}
|
||||||
} else{
|
} else {
|
||||||
echo " : ACTIVE \r\n";
|
echo " : ACTIVE \r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,46 +13,46 @@ use PEAR2\Net\RouterOS;
|
|||||||
class MikrotikHotspot
|
class MikrotikHotspot
|
||||||
{
|
{
|
||||||
|
|
||||||
function connect_customer($customer, $plan)
|
function add_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removeHotspotUser($client, $customer['username']);
|
$this->removeHotspotUser($client, $customer['username']);
|
||||||
Mikrotik::removeHotspotActiveUser($client, $customer['username']);
|
$this->removeHotspotActiveUser($client, $customer['username']);
|
||||||
Mikrotik::addHotspotUser($client, $plan, $customer);
|
$this->addHotspotUser($client, $plan, $customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function disconnect_customer($customer, $plan)
|
function remove_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
if (!empty($p['pool_expired'])) {
|
if (!empty($plan['pool_expired'])) {
|
||||||
Mikrotik::setHotspotUserPackage($client, $customer['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']);
|
$this->setHotspotUserPackage($client, $customer['username'], 'EXPIRED NUXBILL ' . $plan['pool_expired']);
|
||||||
} else {
|
} else {
|
||||||
Mikrotik::removeHotspotUser($client, $customer['username']);
|
$this->removeHotspotUser($client, $customer['username']);
|
||||||
}
|
}
|
||||||
Mikrotik::removeHotspotActiveUser($client, $customer['username']);
|
$this->removeHotspotActiveUser($client, $customer['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_customer($tur, $customer, $plan)
|
function change_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removeHotspotUser($client, $customer['username']);
|
$this->removeHotspotUser($client, $customer['username']);
|
||||||
Mikrotik::removeHotspotActiveUser($client, $customer['username']);
|
$this->removeHotspotActiveUser($client, $customer['username']);
|
||||||
Mikrotik::addHotspotUser($client, $plan, $customer);
|
$this->addHotspotUser($client, $plan, $customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_plan($plan)
|
function add_plan($plan)
|
||||||
@ -62,7 +62,7 @@ class MikrotikHotspot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
if ($plan['rate_down_unit'] == 'Kbps') {
|
if ($plan['rate_down_unit'] == 'Kbps') {
|
||||||
$unitdown = 'K';
|
$unitdown = 'K';
|
||||||
} else {
|
} else {
|
||||||
@ -83,6 +83,60 @@ class MikrotikHotspot
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function online_customer($customer, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$mikrotik = $this->info($router_name);
|
||||||
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip hotspot active print',
|
||||||
|
RouterOS\Query::where('user', $customer['username'])
|
||||||
|
);
|
||||||
|
return $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
}
|
||||||
|
|
||||||
|
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$mikrotik = $this->info($router_name);
|
||||||
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
$addRequest = new RouterOS\Request('/ip/hotspot/active/login');
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('user', $customer['username'])
|
||||||
|
->setArgument('password', $customer['password'])
|
||||||
|
->setArgument('ip', $ip)
|
||||||
|
->setArgument('mac-address', $mac_address)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function disconnect_customer($customer, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$mikrotik = $this->info($router_name);
|
||||||
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip hotspot active print',
|
||||||
|
RouterOS\Query::where('user', $customer['username'])
|
||||||
|
);
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
||||||
|
$client->sendSync(
|
||||||
|
$removeRequest
|
||||||
|
->setArgument('numbers', $id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function update_plan($old_plan, $new_plan)
|
function update_plan($old_plan, $new_plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
@ -90,7 +144,16 @@ class MikrotikHotspot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($new_plan['routers']);
|
$mikrotik = $this->info($new_plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip hotspot user profile print .proplist=.id',
|
||||||
|
RouterOS\Query::where('name', $old_plan['name_plan'])
|
||||||
|
);
|
||||||
|
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
if (empty($profileID)) {
|
||||||
|
$this->add_plan($new_plan);
|
||||||
|
} else {
|
||||||
if ($new_plan['rate_down_unit'] == 'Kbps') {
|
if ($new_plan['rate_down_unit'] == 'Kbps') {
|
||||||
$unitdown = 'K';
|
$unitdown = 'K';
|
||||||
} else {
|
} else {
|
||||||
@ -102,14 +165,6 @@ class MikrotikHotspot
|
|||||||
$unitup = 'M';
|
$unitup = 'M';
|
||||||
}
|
}
|
||||||
$rate = $new_plan['rate_up'] . $unitup . "/" . $new_plan['rate_down'] . $unitdown;
|
$rate = $new_plan['rate_up'] . $unitup . "/" . $new_plan['rate_down'] . $unitdown;
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $old_plan['name_plan'])
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
if (empty($profileID)) {
|
|
||||||
Mikrotik::addHotspotPlan($client, $new_plan['name_plan'], $new_plan['shared_users'], $rate);
|
|
||||||
} else {
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
||||||
$client->sendSync(
|
$client->sendSync(
|
||||||
$setRequest
|
$setRequest
|
||||||
@ -128,7 +183,7 @@ class MikrotikHotspot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$printRequest = new RouterOS\Request(
|
$printRequest = new RouterOS\Request(
|
||||||
'/ip hotspot user profile print .proplist=.id',
|
'/ip hotspot user profile print .proplist=.id',
|
||||||
RouterOS\Query::where('name', $plan['name_plan'])
|
RouterOS\Query::where('name', $plan['name_plan'])
|
||||||
@ -141,18 +196,6 @@ class MikrotikHotspot
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_pool($pool){
|
|
||||||
// Hotspot no need pool
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_pool($old_pool, $new_pool){
|
|
||||||
// Hotspot no need pool
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_pool($pool){
|
|
||||||
// Hotspot no need pool
|
|
||||||
}
|
|
||||||
|
|
||||||
function info($name)
|
function info($name)
|
||||||
{
|
{
|
||||||
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
|
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
|
||||||
@ -168,53 +211,6 @@ class MikrotikHotspot
|
|||||||
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUserLogin($client, $username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot active print',
|
|
||||||
RouterOS\Query::where('user', $username)
|
|
||||||
);
|
|
||||||
return $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMeIn($client, $user, $pass, $ip, $mac)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/active/login');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('user', $user)
|
|
||||||
->setArgument('password', $pass)
|
|
||||||
->setArgument('ip', $ip)
|
|
||||||
->setArgument('mac-address', $mac)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMeOut($client, $user)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot active print',
|
|
||||||
RouterOS\Query::where('user', $user)
|
|
||||||
);
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $id)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeHotspotUser($client, $username)
|
function removeHotspotUser($client, $username)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
@ -351,19 +347,6 @@ class MikrotikHotspot
|
|||||||
$client->sendSync($removeRequest);
|
$client->sendSync($removeRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendSMS($client, $to, $message)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$smsRequest = new RouterOS\Request('/tool sms send');
|
|
||||||
$smsRequest
|
|
||||||
->setArgument('phone-number', $to)
|
|
||||||
->setArgument('message', $message);
|
|
||||||
$client->sendSync($smsRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIpHotspotUser($client, $username)
|
function getIpHotspotUser($client, $username)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
|
@ -10,73 +10,49 @@
|
|||||||
|
|
||||||
use PEAR2\Net\RouterOS;
|
use PEAR2\Net\RouterOS;
|
||||||
|
|
||||||
class MikrotikHotspot
|
class MikrotikPppoe
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
function add_customer($customer, $plan)
|
||||||
* Establishes a connection between a MikroTik router and a customer.
|
|
||||||
*
|
|
||||||
* This function takes two parameters: $routers and $customer.
|
|
||||||
*
|
|
||||||
* @param array $routers An array containing information about the MikroTik routers.
|
|
||||||
* This can include IP addresses or connection details.
|
|
||||||
* @param mixed $customer An object or array representing a specific customer.
|
|
||||||
* This can contain relevant information about the customer,
|
|
||||||
* such as their username or account details.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function connect_customer($customer, $plan)
|
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removePpoeUser($client, $customer['username']);
|
$this->removePpoeUser($client, $customer['username']);
|
||||||
Mikrotik::removePpoeActive($client, $customer['username']);
|
$this->removePpoeActive($client, $customer['username']);
|
||||||
Mikrotik::addPpoeUser($client, $plan, $customer);
|
$this->addPpoeUser($client, $plan, $customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function remove_customer($customer, $plan)
|
||||||
* Disconnects a customer from a MikroTik router.
|
|
||||||
*
|
|
||||||
* This function takes two parameters: $routers and $customer.
|
|
||||||
*
|
|
||||||
* @param array $routers An array containing information about the MikroTik routers.
|
|
||||||
* This can include IP addresses or connection details.
|
|
||||||
* @param mixed $customer An object or array representing a specific customer.
|
|
||||||
* This can contain relevant information about the customer,
|
|
||||||
* such as their username or account details.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function disconnect_customer($customer, $plan)
|
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
if (!empty($p['pool_expired'])) {
|
if (!empty($plan['pool_expired'])) {
|
||||||
Mikrotik::setPpoeUserPlan($client, $customer['username'], 'EXPIRED NUXBILL ' . $p['pool_expired']);
|
$this->setPpoeUserPlan($client, $customer['username'], 'EXPIRED NUXBILL ' . $plan['pool_expired']);
|
||||||
} else {
|
} else {
|
||||||
Mikrotik::removePpoeUser($client, $customer['username']);
|
$this->removePpoeUser($client, $customer['username']);
|
||||||
}
|
}
|
||||||
Mikrotik::removePpoeActive($client, $customer['username']);
|
$this->removePpoeActive($client, $customer['username']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_customer($tur, $customer, $plan)
|
function change_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removePpoeUser($client, $customer['username']);
|
$this->removePpoeUser($client, $customer['username']);
|
||||||
Mikrotik::removePpoeActive($client, $customer['username']);
|
$this->removePpoeActive($client, $customer['username']);
|
||||||
Mikrotik::addPpoeUser($client, $plan, $customer);
|
$this->addPpoeUser($client, $plan, $customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +63,10 @@ class MikrotikHotspot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
|
|
||||||
|
//Add Pool
|
||||||
|
|
||||||
if ($plan['rate_down_unit'] == 'Kbps') {
|
if ($plan['rate_down_unit'] == 'Kbps') {
|
||||||
$unitdown = 'K';
|
$unitdown = 'K';
|
||||||
} else {
|
} else {
|
||||||
@ -99,48 +78,51 @@ class MikrotikHotspot
|
|||||||
$unitup = 'M';
|
$unitup = 'M';
|
||||||
}
|
}
|
||||||
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
|
$addRequest = new RouterOS\Request('/ppp/profile/add');
|
||||||
$client->sendSync(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
->setArgument('name', $plan['name_plan'])
|
->setArgument('name', $plan['name_plan'])
|
||||||
->setArgument('shared-users', $plan['shared_users'])
|
->setArgument('local-address', $plan['pool'])
|
||||||
|
->setArgument('remote-address', $plan['pool'])
|
||||||
->setArgument('rate-limit', $rate)
|
->setArgument('rate-limit', $rate)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_plan($old_name, $plan)
|
function update_plan($old_name, $new_plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($new_plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
if ($plan['rate_down_unit'] == 'Kbps') {
|
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ppp profile print .proplist=.id',
|
||||||
|
RouterOS\Query::where('name', $old_name['name_plan'])
|
||||||
|
);
|
||||||
|
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
if (empty($profileID)) {
|
||||||
|
$this->add_plan($new_plan);
|
||||||
|
} else {
|
||||||
|
if ($new_plan['rate_down_unit'] == 'Kbps') {
|
||||||
$unitdown = 'K';
|
$unitdown = 'K';
|
||||||
} else {
|
} else {
|
||||||
$unitdown = 'M';
|
$unitdown = 'M';
|
||||||
}
|
}
|
||||||
if ($plan['rate_up_unit'] == 'Kbps') {
|
if ($new_plan['rate_up_unit'] == 'Kbps') {
|
||||||
$unitup = 'K';
|
$unitup = 'K';
|
||||||
} else {
|
} else {
|
||||||
$unitup = 'M';
|
$unitup = 'M';
|
||||||
}
|
}
|
||||||
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
$rate = $new_plan['rate_up'] . $unitup . "/" . $new_plan['rate_down'] . $unitdown;
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user profile print .proplist=.id',
|
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
||||||
RouterOS\Query::where('name', $old_name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
if (empty($profileID)) {
|
|
||||||
Mikrotik::addHotspotPlan($client, $plan['name_plan'], $plan['shared_users'], $rate);
|
|
||||||
} else {
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
|
||||||
$client->sendSync(
|
$client->sendSync(
|
||||||
$setRequest
|
$setRequest
|
||||||
->setArgument('numbers', $profileID)
|
->setArgument('numbers', $profileID)
|
||||||
->setArgument('name', $plan['name_plan'])
|
->setArgument('local-address', $new_plan['pool'])
|
||||||
->setArgument('shared-users', $plan['shared_users'])
|
->setArgument('remote-address', $new_plan['pool'])
|
||||||
->setArgument('rate-limit', $rate)
|
->setArgument('rate-limit', $rate)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -153,13 +135,14 @@ class MikrotikHotspot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($plan['routers']);
|
$mikrotik = $this->info($plan['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$printRequest = new RouterOS\Request(
|
$printRequest = new RouterOS\Request(
|
||||||
'/ip hotspot user profile print .proplist=.id',
|
'/ppp profile print .proplist=.id',
|
||||||
RouterOS\Query::where('name', $plan['name_plan'])
|
RouterOS\Query::where('name', $plan['name_plan'])
|
||||||
);
|
);
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
|
|
||||||
|
$removeRequest = new RouterOS\Request('/ppp/profile/remove');
|
||||||
$client->sendSync(
|
$client->sendSync(
|
||||||
$removeRequest
|
$removeRequest
|
||||||
->setArgument('numbers', $profileID)
|
->setArgument('numbers', $profileID)
|
||||||
@ -172,7 +155,7 @@ class MikrotikHotspot
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($pool['routers']);
|
$mikrotik = $this->info($pool['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$addRequest = new RouterOS\Request('/ip/pool/add');
|
$addRequest = new RouterOS\Request('/ip/pool/add');
|
||||||
$client->sendSync(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
@ -187,7 +170,7 @@ class MikrotikHotspot
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($new_pool['routers']);
|
$mikrotik = $this->info($new_pool['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$printRequest = new RouterOS\Request(
|
$printRequest = new RouterOS\Request(
|
||||||
'/ip pool print .proplist=.id',
|
'/ip pool print .proplist=.id',
|
||||||
RouterOS\Query::where('name', $old_pool['pool_name'])
|
RouterOS\Query::where('name', $old_pool['pool_name'])
|
||||||
@ -212,7 +195,7 @@ class MikrotikHotspot
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$mikrotik = $this->info($pool['routers']);
|
$mikrotik = $this->info($pool['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = $this->getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$printRequest = new RouterOS\Request(
|
$printRequest = new RouterOS\Request(
|
||||||
'/ip pool print .proplist=.id',
|
'/ip pool print .proplist=.id',
|
||||||
RouterOS\Query::where('name', $pool['pool_name'])
|
RouterOS\Query::where('name', $pool['pool_name'])
|
||||||
@ -225,6 +208,22 @@ class MikrotikHotspot
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function disconnect_customer($customer, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function info($name)
|
function info($name)
|
||||||
{
|
{
|
||||||
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
|
return ORM::for_table('tbl_routers')->where('name', $name)->find_one();
|
||||||
@ -240,34 +239,6 @@ class MikrotikHotspot
|
|||||||
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUserLogin($client, $username)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot active print',
|
|
||||||
RouterOS\Query::where('user', $username)
|
|
||||||
);
|
|
||||||
return $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
}
|
|
||||||
|
|
||||||
function logMeIn($client, $user, $pass, $ip, $mac)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/active/login');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('user', $user)
|
|
||||||
->setArgument('password', $pass)
|
|
||||||
->setArgument('ip', $ip)
|
|
||||||
->setArgument('mac-address', $mac)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
function removePpoeUser($client, $username)
|
function removePpoeUser($client, $username)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
@ -355,79 +326,6 @@ class MikrotikHotspot
|
|||||||
$client->sendSync($removeRequest);
|
$client->sendSync($removeRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPpoePlan($client, $name, $pool, $rate)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/profile/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $name)
|
|
||||||
->setArgument('local-address', $pool)
|
|
||||||
->setArgument('remote-address', $pool)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setPpoePlan($client, $name, $pool, $rate)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
if (empty($profileID)) {
|
|
||||||
self::addPpoePlan($client, $name, $pool, $rate);
|
|
||||||
} else {
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
|
||||||
$client->sendSync(
|
|
||||||
$setRequest
|
|
||||||
->setArgument('numbers', $profileID)
|
|
||||||
->setArgument('local-address', $pool)
|
|
||||||
->setArgument('remote-address', $pool)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function removePpoePlan($client, $name)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp profile print .proplist=.id',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileID = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/profile/remove');
|
|
||||||
$client->sendSync(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $profileID)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendSMS($client, $to, $message)
|
|
||||||
{
|
|
||||||
global $_app_stage;
|
|
||||||
if ($_app_stage == 'demo') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$smsRequest = new RouterOS\Request('/tool sms send');
|
|
||||||
$smsRequest
|
|
||||||
->setArgument('phone-number', $to)
|
|
||||||
->setArgument('message', $message);
|
|
||||||
$client->sendSync($smsRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIpHotspotUser($client, $username)
|
function getIpHotspotUser($client, $username)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
|
@ -1,37 +1,417 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||||
|
* by https://t.me/ibnux
|
||||||
|
*
|
||||||
|
* This is Core, don't modification except you want to contribute
|
||||||
|
* better create new plugin
|
||||||
|
**/
|
||||||
|
|
||||||
class Radius {
|
class Radius {
|
||||||
|
|
||||||
/**
|
function add_customer($customer, $plan)
|
||||||
* Establishes a connection between a MikroTik router and a customer.
|
{
|
||||||
*
|
global $b;
|
||||||
* This function takes two parameters: $routers and $customer.
|
$this->customerAddPlan($customer, $plan, $b['expiration'] . '' . $b['time']);
|
||||||
*
|
}
|
||||||
* @param array $routers An array containing information about the MikroTik routers.
|
|
||||||
* This can include IP addresses or connection details.
|
|
||||||
* @param mixed $customer An object or array representing a specific customer.
|
|
||||||
* This can contain relevant information about the customer,
|
|
||||||
* such as their username or account details.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function connect_customer($routers, $customer){
|
|
||||||
|
|
||||||
|
function remove_customer($customer, $plan)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (empty($plan['pool_expired'])) {
|
||||||
|
$this->customerDeactivate($customer['username']);
|
||||||
|
} else {
|
||||||
|
$this->upsertCustomerAttr($customer['username'], 'Framed-Pool', $plan['pool_expired'], ':=');
|
||||||
|
$this->disconnectCustomer($customer['username']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function change_customer($customer, $plan)
|
||||||
|
{
|
||||||
|
$this->customerUpsert($customer, $plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_plan($plan)
|
||||||
|
{
|
||||||
|
if ($plan['rate_down_unit'] == 'Kbps') {
|
||||||
|
$unitdown = 'K';
|
||||||
|
} else {
|
||||||
|
$unitdown = 'M';
|
||||||
|
}
|
||||||
|
if ($plan['rate_up_unit'] == 'Kbps') {
|
||||||
|
$unitup = 'K';
|
||||||
|
} else {
|
||||||
|
$unitup = 'M';
|
||||||
|
}
|
||||||
|
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
||||||
|
|
||||||
|
$rates = explode('/', $rate);
|
||||||
|
##burst fixed
|
||||||
|
if (strpos($rate, ' ')) {
|
||||||
|
$ratos = $rates[0] . '/' . $rates[1] . ' ' . $rates[2] . '/' . $rates[3] . '/' . $rates[4] . '/' . $rates[5] . '/' . $rates[6];
|
||||||
|
} else {
|
||||||
|
$ratos = $rates[0] . '/' . $rates[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->upsertPackage($plan['id'], 'Ascend-Data-Rate', $rates[1], ':=');
|
||||||
|
$this->upsertPackage($plan['id'], 'Ascend-Xmit-Rate', $rates[0], ':=');
|
||||||
|
$this->upsertPackage($plan['id'], 'Mikrotik-Rate-Limit', $ratos, ':=');
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_plan($old_name, $plan)
|
||||||
|
{
|
||||||
|
$this->add_plan($plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_plan($plan)
|
||||||
|
{
|
||||||
|
// Delete Plan
|
||||||
|
$this->getTablePackage()->where_equal('plan_id', "plan_" . $plan['id'])->delete_many();
|
||||||
|
// Reset User Plan
|
||||||
|
$c = $this->getTableUserPackage()->where_equal('groupname', "plan_" . $plan['id'])->findMany();
|
||||||
|
if ($c) {
|
||||||
|
foreach ($c as $u) {
|
||||||
|
$u->groupname = '';
|
||||||
|
$u->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function online_customer($customer, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function disconnect_customer($customer, $router_name)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTableNas()
|
||||||
|
{
|
||||||
|
return ORM::for_table('nas', 'radius');
|
||||||
|
}
|
||||||
|
public function getTableAcct()
|
||||||
|
{
|
||||||
|
return ORM::for_table('radacct', 'radius');
|
||||||
|
}
|
||||||
|
public function getTableCustomer()
|
||||||
|
{
|
||||||
|
return ORM::for_table('radcheck', 'radius');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTableCustomerAttr()
|
||||||
|
{
|
||||||
|
return ORM::for_table('radreply', 'radius');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTablePackage()
|
||||||
|
{
|
||||||
|
return ORM::for_table('radgroupreply', 'radius');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTableUserPackage()
|
||||||
|
{
|
||||||
|
return ORM::for_table('radusergroup', 'radius');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nasAdd($name, $ip, $ports, $secret, $routers = "", $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->routers = $routers;
|
||||||
|
$n->save();
|
||||||
|
return $n->id();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nasUpdate($id, $name, $ip, $ports, $secret, $routers = "", $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->routers = $routers;
|
||||||
|
return $n->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function planUpSert($plan_id, $rate, $pool = null)
|
||||||
|
{
|
||||||
|
$rates = explode('/', $rate);
|
||||||
|
##burst fixed
|
||||||
|
if (strpos($rate, ' ')) {
|
||||||
|
$ratos = $rates[0] . '/' . $rates[1] . ' ' . $rates[2] . '/' . $rates[3] . '/' . $rates[4] . '/' . $rates[5] . '/' . $rates[6];
|
||||||
|
} else {
|
||||||
|
$ratos = $rates[0] . '/' . $rates[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->upsertPackage($plan_id, 'Ascend-Data-Rate', $rates[1], ':=');
|
||||||
|
$this->upsertPackage($plan_id, 'Ascend-Xmit-Rate', $rates[0], ':=');
|
||||||
|
$this->upsertPackage($plan_id, 'Mikrotik-Rate-Limit', $ratos, ':=');
|
||||||
|
// if ($pool != null) {
|
||||||
|
// $this->upsertPackage($plan_id, 'Framed-Pool', $pool, ':=');
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public function customerChangeUsername($from, $to)
|
||||||
|
{
|
||||||
|
$c = $this->getTableCustomer()->where_equal('username', $from)->findMany();
|
||||||
|
if ($c) {
|
||||||
|
foreach ($c as $u) {
|
||||||
|
$u->username = $to;
|
||||||
|
$u->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$c = $this->getTableUserPackage()->where_equal('username', $from)->findMany();
|
||||||
|
if ($c) {
|
||||||
|
foreach ($c as $u) {
|
||||||
|
$u->username = $to;
|
||||||
|
$u->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function customerDeactivate($username, $radiusDisconnect = true)
|
||||||
|
{ {
|
||||||
|
global $radius_pass;
|
||||||
|
$r = $this->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() . $username . $radius_pass);
|
||||||
|
$r->save();
|
||||||
|
if ($radiusDisconnect)
|
||||||
|
return $this->disconnectCustomer($username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function customerDelete($username)
|
||||||
|
{
|
||||||
|
$this->getTableCustomer()->where_equal('username', $username)->delete_many();
|
||||||
|
$this->getTableUserPackage()->where_equal('username', $username)->delete_many();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects a customer from a MikroTik router.
|
* When add a plan to Customer, use this
|
||||||
*
|
|
||||||
* This function takes two parameters: $routers and $customer.
|
|
||||||
*
|
|
||||||
* @param array $routers An array containing information about the MikroTik routers.
|
|
||||||
* This can include IP addresses or connection details.
|
|
||||||
* @param mixed $customer An object or array representing a specific customer.
|
|
||||||
* This can contain relevant information about the customer,
|
|
||||||
* such as their username or account details.
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
function disconnect_customer($routers, $customer){
|
public function customerAddPlan($customer, $plan, $expired = null)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
if ($this->customerUpsert($customer, $plan)) {
|
||||||
|
$p = $this->getTableUserPackage()->where_equal('username', $customer['username'])->findOne();
|
||||||
|
if ($p) {
|
||||||
|
// if exists
|
||||||
|
$this->delAtribute($this->getTableCustomer(), 'Max-All-Session', 'username', $customer['username']);
|
||||||
|
//$this->delAtribute($this->getTableCustomer(), 'Max-Volume', 'username', $customer['username']);
|
||||||
|
$this->delAtribute($this->getTableCustomer(), 'Max-Data', 'username', $customer['username']);
|
||||||
|
$p->groupname = "plan_" . $plan['id'];
|
||||||
|
$p->save();
|
||||||
|
} else {
|
||||||
|
$p = $this->getTableUserPackage()->create();
|
||||||
|
$p->username = $customer['username'];
|
||||||
|
$p->groupname = "plan_" . $plan['id'];
|
||||||
|
$p->priority = 1;
|
||||||
|
$p->save();
|
||||||
|
}
|
||||||
|
if ($plan['type'] == 'Hotspot' && $plan['typebp'] == "Limited") {
|
||||||
|
if ($plan['limit_type'] == "Time_Limit") {
|
||||||
|
if ($plan['time_unit'] == 'Hrs')
|
||||||
|
$timelimit = $plan['time_limit'] * 60 * 60;
|
||||||
|
else
|
||||||
|
$timelimit = $plan['time_limit'] * 60;
|
||||||
|
$this->upsertCustomer($customer['username'], 'Max-All-Session', $timelimit);
|
||||||
|
//$this->upsertCustomer($customer['username'], 'Expire-After', $timelimit);
|
||||||
|
} else if ($plan['limit_type'] == "Data_Limit") {
|
||||||
|
if ($plan['data_unit'] == 'GB')
|
||||||
|
$datalimit = $plan['data_limit'] . "000000000";
|
||||||
|
else
|
||||||
|
$datalimit = $plan['data_limit'] . "000000";
|
||||||
|
//$this->upsertCustomer($customer['username'], 'Max-Volume', $datalimit);
|
||||||
|
// Mikrotik Spesific
|
||||||
|
$this->upsertCustomer($customer['username'], 'Max-Data', $datalimit);
|
||||||
|
//$this->upsertCustomer($customer['username'], 'Mikrotik-Total-Limit', $datalimit);
|
||||||
|
} else if ($plan['limit_type'] == "Both_Limit") {
|
||||||
|
if ($plan['time_unit'] == 'Hrs')
|
||||||
|
$timelimit = $plan['time_limit'] * 60 * 60;
|
||||||
|
else
|
||||||
|
$timelimit = $plan['time_limit'] * 60;
|
||||||
|
if ($plan['data_unit'] == 'GB')
|
||||||
|
$datalimit = $plan['data_limit'] . "000000000";
|
||||||
|
else
|
||||||
|
$datalimit = $plan['data_limit'] . "000000";
|
||||||
|
//$this->upsertCustomer($customer['username'], 'Max-Volume', $datalimit);
|
||||||
|
$this->upsertCustomer($customer['username'], 'Max-All-Session', $timelimit);
|
||||||
|
// Mikrotik Spesific
|
||||||
|
$this->upsertCustomer($customer['username'], 'Max-Data', $datalimit);
|
||||||
|
//$this->upsertCustomer($customer['username'], 'Mikrotik-Total-Limit', $datalimit);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//$this->delAtribute($this->getTableCustomer(), 'Max-Volume', 'username', $customer['username']);
|
||||||
|
$this->delAtribute($this->getTableCustomer(), 'Max-All-Session', 'username', $customer['username']);
|
||||||
|
$this->delAtribute($this->getTableCustomer(), 'Max-Data', 'username', $customer['username']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->disconnectCustomer($customer['username']);
|
||||||
|
$this->getTableAcct()->where_equal('username', $customer['username'])->delete_many();
|
||||||
|
|
||||||
|
|
||||||
|
// expired user
|
||||||
|
if ($expired != null) {
|
||||||
|
//$this->upsertCustomer($customer['username'], 'access-period', strtotime($expired) - time());
|
||||||
|
$this->upsertCustomer($customer['username'], 'Max-All-Session', strtotime($expired) - time());
|
||||||
|
//$this->upsertCustomer($customer['username'], 'expiration', date('d M Y H:i:s', strtotime($expired)));
|
||||||
|
// Mikrotik Spesific
|
||||||
|
$this->upsertCustomer(
|
||||||
|
$customer['username'],
|
||||||
|
'WISPr-Session-Terminate-Time',
|
||||||
|
date('Y-m-d', strtotime($expired)) . 'T' . date('H:i:s', strtotime($expired)) . Timezone::getTimeOffset($config['timezone'])
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->delAtribute($this->getTableCustomer(), 'Max-All-Session', 'username', $customer['username']);
|
||||||
|
//$this->delAtribute($this->getTableCustomer(), 'access-period', 'username', $customer['username']);
|
||||||
|
//$this->delAtribute($this->getTableCustomer(), 'expiration', 'username', $customer['username']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($plan['type'] == 'PPPOE') {
|
||||||
|
$this->upsertCustomerAttr($customer['username'], 'Framed-Pool', $plan['pool'], ':=');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function customerUpsert($customer, $plan)
|
||||||
|
{
|
||||||
|
if ($plan['type'] == 'PPPOE') {
|
||||||
|
$this->upsertCustomer($customer['username'], 'Cleartext-Password', (empty($customer['pppoe_password'])) ? $customer['password'] : $customer['pppoe_password']);
|
||||||
|
} else {
|
||||||
|
$this->upsertCustomer($customer['username'], 'Cleartext-Password', $customer['password']);
|
||||||
|
}
|
||||||
|
$this->upsertCustomer($customer['username'], 'Simultaneous-Use', ($plan['type'] == 'PPPOE') ? 1 : $plan['shared_users']);
|
||||||
|
// Mikrotik Spesific
|
||||||
|
$this->upsertCustomer($customer['username'], 'Port-Limit', ($plan['type'] == 'PPPOE') ? 1 : $plan['shared_users']);
|
||||||
|
$this->upsertCustomer($customer['username'], 'Mikrotik-Wireless-Comment', $customer['fullname']);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function delAtribute($tabel, $attribute, $key, $value)
|
||||||
|
{
|
||||||
|
$r = $tabel->where_equal($key, $value)->whereEqual('attribute', $attribute)->findOne();
|
||||||
|
if ($r) $r->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To insert or update existing plan
|
||||||
|
*/
|
||||||
|
private function upsertPackage($plan_id, $attr, $value, $op = ':=')
|
||||||
|
{
|
||||||
|
$r = $this->getTablePackage()->where_equal('plan_id', $plan_id)->whereEqual('attribute', $attr)->find_one();
|
||||||
|
if (!$r) {
|
||||||
|
$r = $this->getTablePackage()->create();
|
||||||
|
$r->groupname = "plan_" . $plan_id;
|
||||||
|
$r->plan_id = $plan_id;
|
||||||
|
}
|
||||||
|
$r->attribute = $attr;
|
||||||
|
$r->op = $op;
|
||||||
|
$r->value = $value;
|
||||||
|
return $r->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To insert or update existing customer
|
||||||
|
*/
|
||||||
|
public function upsertCustomer($username, $attr, $value, $op = ':=')
|
||||||
|
{
|
||||||
|
$r = $this->getTableCustomer()->where_equal('username', $username)->whereEqual('attribute', $attr)->find_one();
|
||||||
|
if (!$r) {
|
||||||
|
$r = $this->getTableCustomer()->create();
|
||||||
|
$r->username = $username;
|
||||||
|
}
|
||||||
|
$r->attribute = $attr;
|
||||||
|
$r->op = $op;
|
||||||
|
$r->value = $value;
|
||||||
|
return $r->save();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* To insert or update existing customer Attribute
|
||||||
|
*/
|
||||||
|
public function upsertCustomerAttr($username, $attr, $value, $op = ':=')
|
||||||
|
{
|
||||||
|
$r = $this->getTableCustomerAttr()->where_equal('username', $username)->whereEqual('attribute', $attr)->find_one();
|
||||||
|
if (!$r) {
|
||||||
|
$r = $this->getTableCustomerAttr()->create();
|
||||||
|
$r->username = $username;
|
||||||
|
}
|
||||||
|
$r->attribute = $attr;
|
||||||
|
$r->op = $op;
|
||||||
|
$r->value = $value;
|
||||||
|
return $r->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disconnectCustomer($username)
|
||||||
|
{
|
||||||
|
global $_app_stage;
|
||||||
|
if ($_app_stage == 'demo') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Fix loop to all Nas but still detecting Hotspot Multylogin from other Nas
|
||||||
|
*/
|
||||||
|
$act = ORM::for_table('radacct')->where_raw("acctstoptime IS NULL")->where('username', $username)->find_one();
|
||||||
|
$nas = $this->getTableNas()->where('nasname', $act['nasipaddress'])->find_many();
|
||||||
|
$count = count($nas) * 15;
|
||||||
|
set_time_limit($count);
|
||||||
|
$result = [];
|
||||||
|
foreach ($nas as $n) {
|
||||||
|
$port = 3799;
|
||||||
|
if (!empty($n['ports'])) {
|
||||||
|
$port = $n['ports'];
|
||||||
|
}
|
||||||
|
$result[] = $n['nasname'] . ': ' . @shell_exec("echo 'User-Name = $username,Framed-IP-Address = " . $act['framedipaddress'] . "' | radclient -x " . trim($n['nasname']) . ":$port disconnect '" . $n['secret'] . "'");
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ just follow the template
|
|||||||
|
|
||||||
class FileName {
|
class FileName {
|
||||||
|
|
||||||
function connect_customer($customer, $plan)
|
function add_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
@ -15,7 +15,7 @@ class FileName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function disconnect_customer($customer, $plan)
|
function remove_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
@ -23,7 +23,7 @@ class FileName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_customer($tur, $customer, $plan)
|
function change_customer($customer, $plan)
|
||||||
{
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
@ -55,25 +55,29 @@ class FileName {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_pool($pool){
|
function online_customer($customer, $router_name)
|
||||||
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_pool($old_pool, $new_pool){
|
function connect_customer($customer, $ip, $mac_address, $router_name)
|
||||||
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_pool($pool){
|
function disconnect_customer($customer, $router_name)
|
||||||
|
{
|
||||||
global $_app_stage;
|
global $_app_stage;
|
||||||
if ($_app_stage == 'demo') {
|
if ($_app_stage == 'demo') {
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
@ -102,5 +102,9 @@
|
|||||||
],
|
],
|
||||||
"2024.5.20" : [
|
"2024.5.20" : [
|
||||||
"ALTER TABLE `tbl_customers` ADD `city` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `address`, ADD `district` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `city`, ADD `state` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `district`, ADD `zip` VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `state`;"
|
"ALTER TABLE `tbl_customers` ADD `city` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `address`, ADD `district` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `city`, ADD `state` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `district`, ADD `zip` VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci AFTER `state`;"
|
||||||
|
],
|
||||||
|
"2024.6.5" : [
|
||||||
|
"ALTER TABLE `tbl_plans` ADD `price_old` VARCHAR(40) NOT NULL DEFAULT '' AFTER `price`;",
|
||||||
|
"ALTER TABLE `tbl_plans` ADD `device` VARCHAR(32) NOT NULL DEFAULT '' AFTER `plan_type`;"
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user