simplified Mikrotik Connection
This commit is contained in:
parent
e6f8826490
commit
ac813ca132
310
system/autoload/Mikrotik.php
Normal file
310
system/autoload/Mikrotik.php
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PEAR2\Net\RouterOS;
|
||||||
|
|
||||||
|
class Mikrotik
|
||||||
|
{
|
||||||
|
public static function info($name){
|
||||||
|
$d = ORM::for_table('tbl_routers')->where('name',$name)->find_one();
|
||||||
|
return $d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getClient($ip, $user, $pass)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$iport = explode(":", $ip);
|
||||||
|
return new RouterOS\Client($iport[0], $user, $pass, ($iport[1]) ? $iport[1] : null);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
die("Unable to connect to the router.<br>" . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addHotspotPlan($client, $name, $sharedusers, $rate){
|
||||||
|
$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){
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip hotspot user profile print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $name)
|
||||||
|
);
|
||||||
|
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
||||||
|
$client(
|
||||||
|
$setRequest
|
||||||
|
->setArgument('numbers', $profileName)
|
||||||
|
->setArgument('shared-users', $sharedusers)
|
||||||
|
->setArgument('rate-limit', $rate)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function removeHotspotPlan($client, $name){
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip hotspot user profile print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $name)
|
||||||
|
);
|
||||||
|
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
|
||||||
|
$client(
|
||||||
|
$removeRequest
|
||||||
|
->setArgument('numbers', $profileName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function removeHotspotUser($client, $username)
|
||||||
|
{
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip hotspot user print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $username)
|
||||||
|
);
|
||||||
|
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
||||||
|
$client(
|
||||||
|
$removeRequest
|
||||||
|
->setArgument('numbers', $userName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addHotspotUser($client, $plan, $customer)
|
||||||
|
{
|
||||||
|
$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('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('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('limit-uptime', $timelimit)
|
||||||
|
->setArgument('limit-bytes-total', $datalimit)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $customer['username'])
|
||||||
|
->setArgument('profile', $plan['name_plan'])
|
||||||
|
->setArgument('password', $customer['password'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setHotspotUser($client, $user, $pass, $nuser= 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 removeHotspotActiveUser($client, $username)
|
||||||
|
{
|
||||||
|
$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 setHotspotLimitUptime($client, $username)
|
||||||
|
{
|
||||||
|
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
||||||
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
|
$printRequest->setQuery(RouterOS\Query::where('name', $username));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
||||||
|
$setRequest->setArgument('numbers', $id);
|
||||||
|
$setRequest->setArgument('limit-uptime', '00:00:05');
|
||||||
|
$client->sendSync($setRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function removePpoeUser($client, $username)
|
||||||
|
{
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ppp secret print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $username)
|
||||||
|
);
|
||||||
|
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
||||||
|
$client(
|
||||||
|
$removeRequest
|
||||||
|
->setArgument('numbers', $userName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addPpoeUser($client, $plan, $customer)
|
||||||
|
{
|
||||||
|
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
||||||
|
$client->sendSync(
|
||||||
|
$addRequest
|
||||||
|
->setArgument('name', $customer['username'])
|
||||||
|
->setArgument('service', 'pppoe')
|
||||||
|
->setArgument('profile', $plan['name_plan'])
|
||||||
|
->setArgument('password', $customer['password'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setPpoeUser($client, $user, $pass, $nuser= null){
|
||||||
|
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||||
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
|
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
||||||
|
$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 disablePpoeUser($client, $username)
|
||||||
|
{
|
||||||
|
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
||||||
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
|
$printRequest->setQuery(RouterOS\Query::where('name', $username));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
|
$setRequest = new RouterOS\Request('/ppp/secret/disable');
|
||||||
|
$setRequest->setArgument('numbers', $id);
|
||||||
|
$client->sendSync($setRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function removePpoeActive($client, $username)
|
||||||
|
{
|
||||||
|
$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){
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip pool print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $name)
|
||||||
|
);
|
||||||
|
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$removeRequest = new RouterOS\Request('/ip/pool/remove');
|
||||||
|
$client($removeRequest
|
||||||
|
->setArgument('numbers', $poolName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addPool($client, $name, $ip_address){
|
||||||
|
$addRequest = new RouterOS\Request('/ip/pool/add');
|
||||||
|
$client->sendSync($addRequest
|
||||||
|
->setArgument('name', $name)
|
||||||
|
->setArgument('ranges', $ip_address)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setPool($client, $oldName, $name, $ip_address){
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ip pool print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $oldName)
|
||||||
|
);
|
||||||
|
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$setRequest = new RouterOS\Request('/ip/pool/set');
|
||||||
|
$client(
|
||||||
|
$setRequest
|
||||||
|
->setArgument('numbers', $name)
|
||||||
|
->setArgument('ranges', $ip_address)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function addPpoePlan($client, $name, $pool, $rate){
|
||||||
|
$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){
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ppp profile print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $name)
|
||||||
|
);
|
||||||
|
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
||||||
|
$client(
|
||||||
|
$setRequest
|
||||||
|
->setArgument('numbers', $profileName)
|
||||||
|
->setArgument('local-address', $pool)
|
||||||
|
->setArgument('remote-address', $pool)
|
||||||
|
->setArgument('rate-limit', $rate)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function removePpoePlan($client, $name){
|
||||||
|
$printRequest = new RouterOS\Request(
|
||||||
|
'/ppp profile print .proplist=name',
|
||||||
|
RouterOS\Query::where('name', $name)
|
||||||
|
);
|
||||||
|
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
|
$removeRequest = new RouterOS\Request('/ppp/profile/remove');
|
||||||
|
$client(
|
||||||
|
$removeRequest
|
||||||
|
->setArgument('numbers', $profileName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -32,7 +32,7 @@ class Package
|
|||||||
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $plan_id)->where('enabled', '1')->find_one();
|
||||||
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
||||||
|
|
||||||
$mikrotik = Router::_info($router_name);
|
$mikrotik = Mikrotik::info($router_name);
|
||||||
if ($p['validity_unit'] == 'Months') {
|
if ($p['validity_unit'] == 'Months') {
|
||||||
$date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month'));
|
$date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month'));
|
||||||
} else if ($p['validity_unit'] == 'Days') {
|
} else if ($p['validity_unit'] == 'Days') {
|
||||||
@ -50,79 +50,9 @@ class Package
|
|||||||
if ($p['type'] == 'Hotspot') {
|
if ($p['type'] == 'Hotspot') {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removeHotspotUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addHotspotUser($client,$p,$c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b->customer_id = $id_customer;
|
$b->customer_id = $id_customer;
|
||||||
@ -153,69 +83,8 @@ class Package
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addHotspotUser($client,$p,$c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
@ -255,32 +124,9 @@ class Package
|
|||||||
|
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removePpoeUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addPpoeUser($client,$p,$c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp secret print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b->customer_id = $id_customer;
|
$b->customer_id = $id_customer;
|
||||||
@ -311,20 +157,8 @@ class Package
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addPpoeUser($client,$p,$c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
|
@ -4,8 +4,5 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
Class Router{
|
Class Router{
|
||||||
public static function _info($name){
|
|
||||||
$d = ORM::for_table('tbl_routers')->where('name',$name)->find_one();
|
|
||||||
return $d;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -40,34 +40,12 @@ 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){
|
||||||
$mikrotik = Router::_info($c['routers']);
|
$mikrotik = Mikrotik::info($c['routers']);
|
||||||
if($c['type'] == 'Hotspot'){
|
if($c['type'] == 'Hotspot'){
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
Mikrotik::setHotspotUser($client,$c['username'],$npass);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
Mikrotik::removeHotspotActiveUser($client,$user['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('password', $npass);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove hotspot active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $user['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
$d->password = $npass;
|
$d->password = $npass;
|
||||||
$d->save();
|
$d->save();
|
||||||
@ -79,31 +57,9 @@ switch ($action) {
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
Mikrotik::setPpoeUser($client,$c['username'],$npass);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
Mikrotik::removePpoeActive($client,$user['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('password', $npass);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove pppoe active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
$d->password = $npass;
|
$d->password = $npass;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
@ -62,60 +62,18 @@ switch ($action) {
|
|||||||
if ($d) {
|
if ($d) {
|
||||||
$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) {
|
||||||
$mikrotik = Router::_info($c['routers']);
|
$mikrotik = Mikrotik::info($c['routers']);
|
||||||
if ($c['type'] == 'Hotspot') {
|
if ($c['type'] == 'Hotspot') {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removeHotspotUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::removeHotspotActiveUser($client,$user['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove hotspot active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $c['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removePpoeUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::removePpoeActive($client,$user['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove pppoe active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -222,65 +180,21 @@ switch ($action) {
|
|||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
$c = ORM::for_table('tbl_user_recharges')->where('username', $username)->find_one();
|
$c = ORM::for_table('tbl_user_recharges')->where('username', $username)->find_one();
|
||||||
if ($c) {
|
if ($c) {
|
||||||
$mikrotik = Router::_info($c['routers']);
|
$mikrotik = Mikrotik::info($c['routers']);
|
||||||
if ($c['type'] == 'Hotspot') {
|
if ($c['type'] == 'Hotspot') {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::setHotspotUser($client,$c['username'],$password);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::removeHotspotActiveUser($client,$user['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('password', $password);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove hotspot active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $c['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->password = $password;
|
$d->password = $password;
|
||||||
$d->save();
|
$d->save();
|
||||||
} else {
|
} else {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::setPpoeUser($client,$c['username'],$password);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::removePpoeActive($client,$user['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('password', $password);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove pppoe active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->password = $password;
|
$d->password = $password;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||||
**/
|
**/
|
||||||
@ -15,6 +16,7 @@ if($admin['user_type'] != 'Admin'){
|
|||||||
}
|
}
|
||||||
|
|
||||||
use PEAR2\Net\RouterOS;
|
use PEAR2\Net\RouterOS;
|
||||||
|
|
||||||
require_once 'system/autoload/PEAR2/Autoload.php';
|
require_once 'system/autoload/PEAR2/Autoload.php';
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
@ -59,27 +61,12 @@ switch ($action) {
|
|||||||
$id = $routes['2'];
|
$id = $routes['2'];
|
||||||
run_hook('delete_pool'); #HOOK
|
run_hook('delete_pool'); #HOOK
|
||||||
$d = ORM::for_table('tbl_pool')->find_one($id);
|
$d = ORM::for_table('tbl_pool')->find_one($id);
|
||||||
$mikrotik = Router::_info($d['routers']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
Mikrotik::removePool($client, $d['pool_name']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
}
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip pool print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $d['pool_name'])
|
|
||||||
);
|
|
||||||
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/pool/remove');
|
|
||||||
$client($removeRequest
|
|
||||||
->setArgument('numbers', $poolName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
r2(U . 'pool/list', 's', $_L['Delete_Successfully']);
|
r2(U . 'pool/list', 's', $_L['Delete_Successfully']);
|
||||||
@ -95,7 +82,7 @@ switch ($action) {
|
|||||||
if (Validator::Length($name, 30, 2) == false) {
|
if (Validator::Length($name, 30, 2) == false) {
|
||||||
$msg .= 'Name should be between 3 to 30 characters' . '<br>';
|
$msg .= 'Name should be between 3 to 30 characters' . '<br>';
|
||||||
}
|
}
|
||||||
if ($ip_address == '' OR $routers == ''){
|
if ($ip_address == '' or $routers == '') {
|
||||||
$msg .= $_L['All_field_is_required'] . '<br>';
|
$msg .= $_L['All_field_is_required'] . '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,20 +90,11 @@ switch ($action) {
|
|||||||
if ($d) {
|
if ($d) {
|
||||||
$msg .= $_L['Pool_already_exist'] . '<br>';
|
$msg .= $_L['Pool_already_exist'] . '<br>';
|
||||||
}
|
}
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Mikrotik::info($routers);
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
Mikrotik::removePool($client, $name, $ip_address);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/pool/add');
|
|
||||||
$client->sendSync($addRequest
|
|
||||||
->setArgument('name', $name)
|
|
||||||
->setArgument('ranges', $ip_address)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b = ORM::for_table('tbl_pool')->create();
|
$b = ORM::for_table('tbl_pool')->create();
|
||||||
@ -141,38 +119,22 @@ switch ($action) {
|
|||||||
if (Validator::Length($name, 30, 2) == false) {
|
if (Validator::Length($name, 30, 2) == false) {
|
||||||
$msg .= 'Name should be between 3 to 30 characters' . '<br>';
|
$msg .= 'Name should be between 3 to 30 characters' . '<br>';
|
||||||
}
|
}
|
||||||
if ($ip_address == '' OR $routers == ''){
|
if ($ip_address == '' or $routers == '') {
|
||||||
$msg .= $_L['All_field_is_required'] . '<br>';
|
$msg .= $_L['All_field_is_required'] . '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$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) {
|
if ($d) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$msg .= $_L['Data_Not_Found'] . '<br>';
|
$msg .= $_L['Data_Not_Found'] . '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Mikrotik::info($routers);
|
||||||
if ($msg == '') {
|
if ($msg == '') {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
Mikrotik::setPool($client, $name,$poolName, $ip_address);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip pool print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/pool/set');
|
|
||||||
$client($setRequest
|
|
||||||
->setArgument('numbers', $poolName)
|
|
||||||
->setArgument('ranges', $ip_address)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->pool_name = $name;
|
$d->pool_name = $name;
|
||||||
|
@ -86,7 +86,7 @@ switch ($action) {
|
|||||||
$p = ORM::for_table('tbl_plans')->where('id', $plan)->where('enabled', '1')->find_one();
|
$p = ORM::for_table('tbl_plans')->where('id', $plan)->where('enabled', '1')->find_one();
|
||||||
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
$b = ORM::for_table('tbl_user_recharges')->where('customer_id', $id_customer)->find_one();
|
||||||
|
|
||||||
$mikrotik = Router::_info($server);
|
$mikrotik = Mikrotik::info($server);
|
||||||
if($p['validity_unit']=='Months'){
|
if($p['validity_unit']=='Months'){
|
||||||
$date_exp = date("Y-m-d", strtotime('+'.$p['validity'].' month'));
|
$date_exp = date("Y-m-d", strtotime('+'.$p['validity'].' month'));
|
||||||
}else if($p['validity_unit']=='Days'){
|
}else if($p['validity_unit']=='Days'){
|
||||||
@ -104,79 +104,9 @@ switch ($action) {
|
|||||||
if ($type == 'Hotspot') {
|
if ($type == 'Hotspot') {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removeHotspotUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addHotspotUser($client,$p,$c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b->customer_id = $id_customer;
|
$b->customer_id = $id_customer;
|
||||||
@ -207,69 +137,8 @@ switch ($action) {
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addHotspotUser($client,$p,$c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
@ -307,32 +176,9 @@ switch ($action) {
|
|||||||
|
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removePpoeUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addPpoeUser($client,$p,$c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp secret print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b->customer_id = $id_customer;
|
$b->customer_id = $id_customer;
|
||||||
@ -363,20 +209,8 @@ switch ($action) {
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addPpoeUser($client,$p,$c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
@ -471,49 +305,20 @@ switch ($action) {
|
|||||||
$id = $routes['2'];
|
$id = $routes['2'];
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->find_one($id);
|
$d = ORM::for_table('tbl_user_recharges')->find_one($id);
|
||||||
$mikrotik = Router::_info($d['routers']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
run_hook('delete_customer_active_plan'); #HOOK
|
run_hook('delete_customer_active_plan'); #HOOK
|
||||||
if ($d['type'] == 'Hotspot') {
|
if ($d['type'] == 'Hotspot') {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removeHotspotUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $d['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
} else {
|
} else {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removePpoeUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp secret print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $d['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
}
|
}
|
||||||
@ -736,7 +541,7 @@ switch ($action) {
|
|||||||
$date_only = date("Y-m-d");
|
$date_only = date("Y-m-d");
|
||||||
$time = date("H:i:s");
|
$time = date("H:i:s");
|
||||||
|
|
||||||
$mikrotik = Router::_info($v1['routers']);
|
$mikrotik = Mikrotik::info($v1['routers']);
|
||||||
|
|
||||||
if($p['validity_unit']=='Months'){
|
if($p['validity_unit']=='Months'){
|
||||||
$date_exp = date("Y-m-d", strtotime('+'.$p['validity'].' month'));
|
$date_exp = date("Y-m-d", strtotime('+'.$p['validity'].' month'));
|
||||||
@ -756,78 +561,9 @@ switch ($action) {
|
|||||||
if ($v1['type'] == 'Hotspot') {
|
if ($v1['type'] == 'Hotspot') {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removeHotspotUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addHotspotUser($client,$p,$c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b->customer_id = $user;
|
$b->customer_id = $user;
|
||||||
@ -858,68 +594,8 @@ switch ($action) {
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addHotspotUser($client,$p,$c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
@ -962,32 +638,9 @@ switch ($action) {
|
|||||||
} else {
|
} else {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removePpoeUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addPpoeUser($client,$p,$c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp secret print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $c['username'])
|
|
||||||
);
|
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $userName)
|
|
||||||
);
|
|
||||||
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b->customer_id = $user;
|
$b->customer_id = $user;
|
||||||
@ -1018,20 +671,8 @@ switch ($action) {
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addPpoeUser($client,$p,$c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
|
@ -86,12 +86,7 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
Mikrotik::getClient($ip_address,$username,$password);
|
||||||
$iport = explode(":", $ip_address);
|
|
||||||
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($msg == ''){
|
if($msg == ''){
|
||||||
@ -152,12 +147,7 @@ switch ($action) {
|
|||||||
|
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
Mikrotik::getClient($ip_address,$username,$password);
|
||||||
$iport = explode(":", $ip_address);
|
|
||||||
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,24 +71,9 @@ switch ($action) {
|
|||||||
if ($d) {
|
if ($d) {
|
||||||
run_hook('delete_plan'); #HOOK
|
run_hook('delete_plan'); #HOOK
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
$mikrotik = Router::_info($d['routers']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removeHotspotPlan($client,$d['name_plan']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user profile print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $d['name_plan'])
|
|
||||||
);
|
|
||||||
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $profileName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
@ -146,20 +131,9 @@ switch ($action) {
|
|||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Mikrotik::info($routers);
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addHotspotPlan($client, $name, $sharedusers, $rate);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/profile/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $name)
|
|
||||||
->setArgument('shared-users', $sharedusers)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_plans')->create();
|
$d = ORM::for_table('tbl_plans')->create();
|
||||||
@ -236,26 +210,9 @@ switch ($action) {
|
|||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Mikrotik::info($routers);
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::setHotspotPlan($client, $name, $sharedusers, $rate);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ip hotspot user profile print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
|
||||||
$client(
|
|
||||||
$setRequest
|
|
||||||
->setArgument('numbers', $profileName)
|
|
||||||
->setArgument('shared-users', $sharedusers)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->name_plan = $name;
|
$d->name_plan = $name;
|
||||||
@ -334,24 +291,9 @@ switch ($action) {
|
|||||||
if ($d) {
|
if ($d) {
|
||||||
run_hook('delete_ppoe'); #HOOK
|
run_hook('delete_ppoe'); #HOOK
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
$mikrotik = Router::_info($d['routers']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removePpoePlan($client, $d['name_plan']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp profile print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $d['name_plan'])
|
|
||||||
);
|
|
||||||
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/profile/remove');
|
|
||||||
$client(
|
|
||||||
$removeRequest
|
|
||||||
->setArgument('numbers', $profileName)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
@ -400,21 +342,9 @@ switch ($action) {
|
|||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Mikrotik::info($routers);
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addPpoePlan($client, $name, $pool, $rate);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$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)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_plans')->create();
|
$d = ORM::for_table('tbl_plans')->create();
|
||||||
@ -478,27 +408,9 @@ switch ($action) {
|
|||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Mikrotik::info($routers);
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::setPpoePlan($client, $name, $pool, $rate);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request(
|
|
||||||
'/ppp profile print .proplist=name',
|
|
||||||
RouterOS\Query::where('name', $name)
|
|
||||||
);
|
|
||||||
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
|
||||||
$client(
|
|
||||||
$setRequest
|
|
||||||
->setArgument('numbers', $profileName)
|
|
||||||
->setArgument('local-address', $pool)
|
|
||||||
->setArgument('remote-address', $pool)
|
|
||||||
->setArgument('rate-limit', $rate)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d->name_plan = $name;
|
$d->name_plan = $name;
|
||||||
|
@ -35,7 +35,7 @@ switch ($action) {
|
|||||||
$date_only = date("Y-m-d");
|
$date_only = date("Y-m-d");
|
||||||
$time = date("H:i:s");
|
$time = date("H:i:s");
|
||||||
|
|
||||||
$mikrotik = Router::_info($v1['routers']);
|
$mikrotik = Mikrotik::info($v1['routers']);
|
||||||
if ($p['validity_unit'] == 'Months') {
|
if ($p['validity_unit'] == 'Months') {
|
||||||
$date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month'));
|
$date_exp = date("Y-m-d", strtotime('+' . $p['validity'] . ' month'));
|
||||||
} else if ($p['validity_unit'] == 'Days') {
|
} else if ($p['validity_unit'] == 'Days') {
|
||||||
@ -54,77 +54,9 @@ switch ($action) {
|
|||||||
if ($v1['type'] == 'Hotspot') {
|
if ($v1['type'] == 'Hotspot') {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removeHotspotUser($client, $c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addHotspotUser($client, $p, $c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$b->customer_id = $user['id'];
|
$b->customer_id = $user['id'];
|
||||||
$b->username = $c['username'];
|
$b->username = $c['username'];
|
||||||
@ -154,68 +86,8 @@ switch ($action) {
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addHotspotUser($client, $p, $c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
/* iBNuX Added:
|
|
||||||
* Time limit to Mikrotik
|
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
|
||||||
*/
|
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
|
||||||
if ($p['typebp'] == "Limited") {
|
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Data_Limit") {
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
} else if ($p['limit_type'] == "Both_Limit") {
|
|
||||||
if ($p['time_unit'] == 'Hrs')
|
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
|
||||||
else
|
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
|
||||||
if ($p['data_unit'] == 'GB')
|
|
||||||
$datalimit = $p['data_limit'] . "000000000";
|
|
||||||
else
|
|
||||||
$datalimit = $p['data_limit'] . "000000";
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
->setArgument('limit-uptime', $timelimit)
|
|
||||||
->setArgument('limit-bytes-total', $datalimit)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
@ -258,29 +130,9 @@ switch ($action) {
|
|||||||
} else {
|
} else {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::removePpoeUser($client, $c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
Mikrotik::addPpoeUser($client, $p, $c);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/remove');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$b->customer_id = $user['id'];
|
$b->customer_id = $user['id'];
|
||||||
@ -311,20 +163,8 @@ switch ($action) {
|
|||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
if (!$_c['radius_mode']) {
|
if (!$_c['radius_mode']) {
|
||||||
try {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
Mikrotik::addPpoeUser($client, $p, $c);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$addRequest = new RouterOS\Request('/ppp/secret/add');
|
|
||||||
$client->sendSync(
|
|
||||||
$addRequest
|
|
||||||
->setArgument('name', $c['username'])
|
|
||||||
->setArgument('service', 'pppoe')
|
|
||||||
->setArgument('profile', $p['name_plan'])
|
|
||||||
->setArgument('password', $c['password'])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = ORM::for_table('tbl_user_recharges')->create();
|
$d = ORM::for_table('tbl_user_recharges')->create();
|
||||||
|
@ -35,32 +35,9 @@ foreach ($d as $ds){
|
|||||||
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||||
$iport = explode(":",$m['ip_address']);
|
Mikrotik::setHotspotLimitUptime($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
|
Mikrotik::removeHotspotActiveUser($client,$c['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$setRequest->setArgument('limit-uptime', '00:00:05');
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove hotspot active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $c['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//update database user dengan status off
|
//update database user dengan status off
|
||||||
@ -78,30 +55,9 @@ foreach ($d as $ds){
|
|||||||
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
||||||
|
|
||||||
if(!$_c['radius_mode']){
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
|
||||||
$iport = explode(":",$m['ip_address']);
|
Mikrotik::disablePpoeUser($client,$c['username']);
|
||||||
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
|
Mikrotik::removePpoeActive($client,$c['username']);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
|
||||||
}
|
|
||||||
$printRequest = new RouterOS\Request('/ppp/secret/print');
|
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/disable');
|
|
||||||
$setRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($setRequest);
|
|
||||||
|
|
||||||
//remove hotspot active
|
|
||||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$u->status = 'off';
|
$u->status = 'off';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user