mirror of
https://github.com/hotspotbilling/phpnuxbill.git
synced 2025-08-04 10:15:03 +02:00
Persiapan Radius Mode
This commit is contained in:
parent
19f79680ff
commit
464f41ef16
10 changed files with 919 additions and 832 deletions
|
@ -102,78 +102,80 @@ switch ($action) {
|
|||
|
||||
if ($type == 'Hotspot') {
|
||||
if ($b) {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
}
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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 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";
|
||||
$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'])
|
||||
->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;
|
||||
|
@ -203,68 +205,70 @@ switch ($action) {
|
|||
$t->type = "Hotspot";
|
||||
$t->save();
|
||||
} else {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
}
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
}
|
||||
|
||||
/* 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";
|
||||
/* 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'])
|
||||
->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();
|
||||
|
@ -301,32 +305,34 @@ switch ($action) {
|
|||
} else {
|
||||
|
||||
if ($b) {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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(
|
||||
'/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'])
|
||||
);
|
||||
}
|
||||
$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->username = $c['username'];
|
||||
|
@ -355,20 +361,22 @@ switch ($action) {
|
|||
$t->type = "PPPOE";
|
||||
$t->save();
|
||||
} else {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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('/ppp/secret/add');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $c['username'])
|
||||
->setArgument('service', 'pppoe')
|
||||
->setArgument('profile', $p['name_plan'])
|
||||
->setArgument('password', $c['password'])
|
||||
);
|
||||
}
|
||||
$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->customer_id = $id_customer;
|
||||
|
@ -465,42 +473,46 @@ switch ($action) {
|
|||
$mikrotik = Router::_info($d['routers']);
|
||||
if ($d) {
|
||||
if ($d['type'] == 'Hotspot') {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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 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)
|
||||
);
|
||||
}
|
||||
$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();
|
||||
} else {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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(
|
||||
'/ppp secret print .proplist=name',
|
||||
RouterOS\Query::where('name', $d['username'])
|
||||
);
|
||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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(
|
||||
'/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)
|
||||
);
|
||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
||||
$client(
|
||||
$removeRequest
|
||||
->setArgument('numbers', $userName)
|
||||
);
|
||||
}
|
||||
$d->delete();
|
||||
}
|
||||
r2(U . 'prepaid/list', 's', $_L['Delete_Successfully']);
|
||||
|
@ -738,77 +750,79 @@ switch ($action) {
|
|||
if ($v1) {
|
||||
if ($v1['type'] == 'Hotspot') {
|
||||
if ($b) {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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 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";
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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 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'])
|
||||
->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;
|
||||
|
@ -838,67 +852,69 @@ switch ($action) {
|
|||
$t->type = "Hotspot";
|
||||
$t->save();
|
||||
} else {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
}
|
||||
/* 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";
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
}
|
||||
/* 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'])
|
||||
->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();
|
||||
|
@ -940,32 +956,34 @@ switch ($action) {
|
|||
"\nPrice: ".$p['price']);
|
||||
} else {
|
||||
if ($b) {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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(
|
||||
'/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'])
|
||||
);
|
||||
}
|
||||
$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->username = $c['username'];
|
||||
|
@ -994,20 +1012,22 @@ switch ($action) {
|
|||
$t->type = "PPPOE";
|
||||
$t->save();
|
||||
} else {
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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());
|
||||
if(!$_c['radius_mode']){
|
||||
try {
|
||||
$iport = explode(":", $mikrotik['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('/ppp/secret/add');
|
||||
$client->sendSync(
|
||||
$addRequest
|
||||
->setArgument('name', $c['username'])
|
||||
->setArgument('service', 'pppoe')
|
||||
->setArgument('profile', $p['name_plan'])
|
||||
->setArgument('password', $c['password'])
|
||||
);
|
||||
}
|
||||
$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->customer_id = $user;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue