Persiapan Radius Mode
This commit is contained in:
parent
19f79680ff
commit
464f41ef16
@ -40,32 +40,33 @@ switch ($action) {
|
|||||||
if ($c){
|
if ($c){
|
||||||
$mikrotik = Router::_info($c['routers']);
|
$mikrotik = Router::_info($c['routers']);
|
||||||
if($c['type'] == 'Hotspot'){
|
if($c['type'] == 'Hotspot'){
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
$iport = explode(":",$mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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 = new RouterOS\Request('/ip/hotspot/user/print');
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
||||||
$setRequest->setArgument('numbers', $id);
|
$setRequest->setArgument('numbers', $id);
|
||||||
$setRequest->setArgument('password', $npass);
|
$setRequest->setArgument('password', $npass);
|
||||||
$client->sendSync($setRequest);
|
$client->sendSync($setRequest);
|
||||||
|
|
||||||
//remove hotspot active
|
//remove hotspot active
|
||||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
$onlineRequest->setArgument('.proplist', '.id');
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $user['username']));
|
$onlineRequest->setQuery(RouterOS\Query::where('user', $user['username']));
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
|
|
||||||
|
$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();
|
||||||
|
|
||||||
@ -75,32 +76,33 @@ switch ($action) {
|
|||||||
r2(U.'login');
|
r2(U.'login');
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
$iport = explode(":",$mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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 = new RouterOS\Request('/ppp/secret/print');
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
$printRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
$setRequest = new RouterOS\Request('/ppp/secret/set');
|
||||||
$setRequest->setArgument('numbers', $id);
|
$setRequest->setArgument('numbers', $id);
|
||||||
$setRequest->setArgument('password', $npass);
|
$setRequest->setArgument('password', $npass);
|
||||||
$client->sendSync($setRequest);
|
$client->sendSync($setRequest);
|
||||||
|
|
||||||
//remove pppoe active
|
//remove pppoe active
|
||||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
$onlineRequest->setArgument('.proplist', '.id');
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
$onlineRequest->setQuery(RouterOS\Query::where('name', $user['username']));
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
|
||||||
$removeRequest->setArgument('numbers', $id);
|
|
||||||
$client->sendSync($removeRequest);
|
|
||||||
|
|
||||||
|
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
||||||
|
$removeRequest->setArgument('numbers', $id);
|
||||||
|
$client->sendSync($removeRequest);
|
||||||
|
}
|
||||||
$d->password = $npass;
|
$d->password = $npass;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
|
||||||
|
@ -61,56 +61,59 @@ switch ($action) {
|
|||||||
if ($c) {
|
if ($c) {
|
||||||
$mikrotik = Router::_info($c['routers']);
|
$mikrotik = Router::_info($c['routers']);
|
||||||
if ($c['type'] == 'Hotspot') {
|
if ($c['type'] == 'Hotspot') {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
} 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);
|
||||||
}
|
}
|
||||||
$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']){
|
||||||
|
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');
|
||||||
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
|
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
try {
|
$setRequest = new RouterOS\Request('/ppp/secret/remove');
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
$setRequest->setArgument('numbers', $id);
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$client->sendSync($setRequest);
|
||||||
} catch (Exception $e) {
|
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
//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);
|
||||||
}
|
}
|
||||||
$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 {
|
||||||
$d->delete();
|
$d->delete();
|
||||||
@ -218,60 +221,64 @@ switch ($action) {
|
|||||||
if ($c) {
|
if ($c) {
|
||||||
$mikrotik = Router::_info($c['routers']);
|
$mikrotik = Router::_info($c['routers']);
|
||||||
if ($c['type'] == 'Hotspot') {
|
if ($c['type'] == 'Hotspot') {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
} 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);
|
||||||
}
|
}
|
||||||
$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 {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>" . $e->getMessage());
|
} 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);
|
||||||
}
|
}
|
||||||
$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;
|
||||||
$d->save();
|
$d->save();
|
||||||
|
@ -59,22 +59,24 @@ switch ($action) {
|
|||||||
$d = ORM::for_table('tbl_pool')->find_one($id);
|
$d = ORM::for_table('tbl_pool')->find_one($id);
|
||||||
$mikrotik = Router::_info($d['routers']);
|
$mikrotik = Router::_info($d['routers']);
|
||||||
if($d){
|
if($d){
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
$iport = explode(":",$mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$printRequest = new RouterOS\Request(
|
}
|
||||||
'/ip pool print .proplist=name',
|
$printRequest = new RouterOS\Request(
|
||||||
RouterOS\Query::where('name', $d['pool_name'])
|
'/ip pool print .proplist=name',
|
||||||
);
|
RouterOS\Query::where('name', $d['pool_name'])
|
||||||
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
);
|
||||||
|
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/pool/remove');
|
$removeRequest = new RouterOS\Request('/ip/pool/remove');
|
||||||
$client($removeRequest
|
$client($removeRequest
|
||||||
->setArgument('numbers', $poolName)
|
->setArgument('numbers', $poolName)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
@ -101,17 +103,19 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Router::_info($routers);
|
||||||
if($msg == ''){
|
if($msg == ''){
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
$iport = explode(":",$mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$addRequest = new RouterOS\Request('/ip/pool/add');
|
}
|
||||||
$client->sendSync($addRequest
|
$addRequest = new RouterOS\Request('/ip/pool/add');
|
||||||
->setArgument('name', $name)
|
$client->sendSync($addRequest
|
||||||
->setArgument('ranges', $ip_address)
|
->setArgument('name', $name)
|
||||||
);
|
->setArgument('ranges', $ip_address)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$b = ORM::for_table('tbl_pool')->create();
|
$b = ORM::for_table('tbl_pool')->create();
|
||||||
$b->pool_name = $name;
|
$b->pool_name = $name;
|
||||||
@ -149,23 +153,25 @@ switch ($action) {
|
|||||||
|
|
||||||
$mikrotik = Router::_info($routers);
|
$mikrotik = Router::_info($routers);
|
||||||
if($msg == ''){
|
if($msg == ''){
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":",$mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
$iport = explode(":",$mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'],($iport[1])?$iport[1]:null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$printRequest = new RouterOS\Request(
|
}
|
||||||
'/ip pool print .proplist=name',
|
$printRequest = new RouterOS\Request(
|
||||||
RouterOS\Query::where('name', $name)
|
'/ip pool print .proplist=name',
|
||||||
);
|
RouterOS\Query::where('name', $name)
|
||||||
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
);
|
||||||
|
$poolName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/pool/set');
|
$setRequest = new RouterOS\Request('/ip/pool/set');
|
||||||
$client($setRequest
|
$client($setRequest
|
||||||
->setArgument('numbers', $poolName)
|
->setArgument('numbers', $poolName)
|
||||||
->setArgument('ranges', $ip_address)
|
->setArgument('ranges', $ip_address)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$d->pool_name = $name;
|
$d->pool_name = $name;
|
||||||
$d->range_ip = $ip_address;
|
$d->range_ip = $ip_address;
|
||||||
|
@ -102,78 +102,80 @@ switch ($action) {
|
|||||||
|
|
||||||
if ($type == 'Hotspot') {
|
if ($type == 'Hotspot') {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$printRequest = new RouterOS\Request(
|
$printRequest = new RouterOS\Request(
|
||||||
'/ip hotspot user print .proplist=name',
|
'/ip hotspot user print .proplist=name',
|
||||||
RouterOS\Query::where('name', $c['username'])
|
RouterOS\Query::where('name', $c['username'])
|
||||||
);
|
);
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
||||||
$client(
|
$client(
|
||||||
$removeRequest
|
$removeRequest
|
||||||
->setArgument('numbers', $userName)
|
->setArgument('numbers', $userName)
|
||||||
);
|
);
|
||||||
/* iBNuX Added:
|
/* iBNuX Added:
|
||||||
* Time limit to Mikrotik
|
* Time limit to Mikrotik
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
*/
|
*/
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
if ($p['typebp'] == "Limited") {
|
if ($p['typebp'] == "Limited") {
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
if ($p['time_unit'] == 'Hrs')
|
if ($p['time_unit'] == 'Hrs')
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
else
|
else
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
$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(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
->setArgument('name', $c['username'])
|
->setArgument('name', $c['username'])
|
||||||
->setArgument('profile', $p['name_plan'])
|
->setArgument('profile', $p['name_plan'])
|
||||||
->setArgument('password', $c['password'])
|
->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;
|
||||||
@ -203,68 +205,70 @@ switch ($action) {
|
|||||||
$t->type = "Hotspot";
|
$t->type = "Hotspot";
|
||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
/* iBNuX Added:
|
/* iBNuX Added:
|
||||||
* Time limit to Mikrotik
|
* Time limit to Mikrotik
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
*/
|
*/
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
if ($p['typebp'] == "Limited") {
|
if ($p['typebp'] == "Limited") {
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
if ($p['time_unit'] == 'Hrs')
|
if ($p['time_unit'] == 'Hrs')
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
else
|
else
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
$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(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
->setArgument('name', $c['username'])
|
->setArgument('name', $c['username'])
|
||||||
->setArgument('profile', $p['name_plan'])
|
->setArgument('profile', $p['name_plan'])
|
||||||
->setArgument('password', $c['password'])
|
->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();
|
||||||
@ -301,32 +305,34 @@ switch ($action) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ($b) {
|
if ($b) {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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->customer_id = $id_customer;
|
||||||
$b->username = $c['username'];
|
$b->username = $c['username'];
|
||||||
@ -355,20 +361,22 @@ switch ($action) {
|
|||||||
$t->type = "PPPOE";
|
$t->type = "PPPOE";
|
||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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 = ORM::for_table('tbl_user_recharges')->create();
|
||||||
$d->customer_id = $id_customer;
|
$d->customer_id = $id_customer;
|
||||||
@ -465,42 +473,46 @@ switch ($action) {
|
|||||||
$mikrotik = Router::_info($d['routers']);
|
$mikrotik = Router::_info($d['routers']);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
if ($d['type'] == 'Hotspot') {
|
if ($d['type'] == 'Hotspot') {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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();
|
$d->delete();
|
||||||
} else {
|
} else {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$printRequest = new RouterOS\Request(
|
}
|
||||||
'/ppp secret print .proplist=name',
|
$printRequest = new RouterOS\Request(
|
||||||
RouterOS\Query::where('name', $d['username'])
|
'/ppp secret print .proplist=name',
|
||||||
);
|
RouterOS\Query::where('name', $d['username'])
|
||||||
$userName = $client->sendSync($printRequest)->getProperty('name');
|
);
|
||||||
|
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
$removeRequest = new RouterOS\Request('/ppp/secret/remove');
|
||||||
$client(
|
$client(
|
||||||
$removeRequest
|
$removeRequest
|
||||||
->setArgument('numbers', $userName)
|
->setArgument('numbers', $userName)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
$d->delete();
|
$d->delete();
|
||||||
}
|
}
|
||||||
r2(U . 'prepaid/list', 's', $_L['Delete_Successfully']);
|
r2(U . 'prepaid/list', 's', $_L['Delete_Successfully']);
|
||||||
@ -738,77 +750,79 @@ switch ($action) {
|
|||||||
if ($v1) {
|
if ($v1) {
|
||||||
if ($v1['type'] == 'Hotspot') {
|
if ($v1['type'] == 'Hotspot') {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$printRequest = new RouterOS\Request(
|
}
|
||||||
'/ip hotspot user print .proplist=name',
|
$printRequest = new RouterOS\Request(
|
||||||
RouterOS\Query::where('name', $c['username'])
|
'/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');
|
$userName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
$client(
|
$removeRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
||||||
$removeRequest
|
$client(
|
||||||
->setArgument('numbers', $userName)
|
$removeRequest
|
||||||
);
|
->setArgument('numbers', $userName)
|
||||||
/* iBNuX Added:
|
);
|
||||||
* Time limit to Mikrotik
|
/* iBNuX Added:
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
* Time limit to Mikrotik
|
||||||
*/
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
*/
|
||||||
if ($p['typebp'] == "Limited") {
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
if ($p['typebp'] == "Limited") {
|
||||||
if ($p['time_unit'] == 'Hrs')
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
if ($p['time_unit'] == 'Hrs')
|
||||||
else
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":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(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
->setArgument('name', $c['username'])
|
->setArgument('name', $c['username'])
|
||||||
->setArgument('profile', $p['name_plan'])
|
->setArgument('profile', $p['name_plan'])
|
||||||
->setArgument('password', $c['password'])
|
->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;
|
||||||
@ -838,67 +852,69 @@ switch ($action) {
|
|||||||
$t->type = "Hotspot";
|
$t->type = "Hotspot";
|
||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
/* iBNuX Added:
|
}
|
||||||
* Time limit to Mikrotik
|
/* iBNuX Added:
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
* Time limit to Mikrotik
|
||||||
*/
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
*/
|
||||||
if ($p['typebp'] == "Limited") {
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
if ($p['typebp'] == "Limited") {
|
||||||
if ($p['time_unit'] == 'Hrs')
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
if ($p['time_unit'] == 'Hrs')
|
||||||
else
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":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(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
->setArgument('name', $c['username'])
|
->setArgument('name', $c['username'])
|
||||||
->setArgument('profile', $p['name_plan'])
|
->setArgument('profile', $p['name_plan'])
|
||||||
->setArgument('password', $c['password'])
|
->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();
|
||||||
@ -940,32 +956,34 @@ switch ($action) {
|
|||||||
"\nPrice: ".$p['price']);
|
"\nPrice: ".$p['price']);
|
||||||
} else {
|
} else {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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->customer_id = $user;
|
||||||
$b->username = $c['username'];
|
$b->username = $c['username'];
|
||||||
@ -994,20 +1012,22 @@ switch ($action) {
|
|||||||
$t->type = "PPPOE";
|
$t->type = "PPPOE";
|
||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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 = ORM::for_table('tbl_user_recharges')->create();
|
||||||
$d->customer_id = $user;
|
$d->customer_id = $user;
|
||||||
|
@ -83,11 +83,13 @@ switch ($action) {
|
|||||||
$msg .= $_L['Router_already_exist']. '<br>';
|
$msg .= $_L['Router_already_exist']. '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $ip_address);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $ip_address);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
|
||||||
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
|
} catch (Exception $e) {
|
||||||
|
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($msg == ''){
|
if($msg == ''){
|
||||||
@ -145,11 +147,13 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $ip_address);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $ip_address);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
|
||||||
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
|
} catch (Exception $e) {
|
||||||
|
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,24 +68,26 @@ switch ($action) {
|
|||||||
|
|
||||||
$d = ORM::for_table('tbl_plans')->find_one($id);
|
$d = ORM::for_table('tbl_plans')->find_one($id);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
$mikrotik = Router::_info($d['routers']);
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$mikrotik = Router::_info($d['routers']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$printRequest = new RouterOS\Request(
|
}
|
||||||
'/ip hotspot user profile print .proplist=name',
|
$printRequest = new RouterOS\Request(
|
||||||
RouterOS\Query::where('name', $d['name_plan'])
|
'/ip hotspot user profile print .proplist=name',
|
||||||
);
|
RouterOS\Query::where('name', $d['name_plan'])
|
||||||
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
);
|
||||||
|
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
|
$removeRequest = new RouterOS\Request('/ip/hotspot/user/profile/remove');
|
||||||
$client(
|
$client(
|
||||||
$removeRequest
|
$removeRequest
|
||||||
->setArgument('numbers', $profileName)
|
->setArgument('numbers', $profileName)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$d->delete();
|
$d->delete();
|
||||||
|
|
||||||
@ -138,20 +140,22 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
$mikrotik = Router::_info($routers);
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$mikrotik = Router::_info($routers);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$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();
|
||||||
$d->name_plan = $name;
|
$d->name_plan = $name;
|
||||||
@ -224,26 +228,28 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
$mikrotik = Router::_info($routers);
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$mikrotik = Router::_info($routers);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$printRequest = new RouterOS\Request(
|
}
|
||||||
'/ip hotspot user profile print .proplist=name',
|
$printRequest = new RouterOS\Request(
|
||||||
RouterOS\Query::where('name', $name)
|
'/ip hotspot user profile print .proplist=name',
|
||||||
);
|
RouterOS\Query::where('name', $name)
|
||||||
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
);
|
||||||
|
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/profile/set');
|
||||||
$client(
|
$client(
|
||||||
$setRequest
|
$setRequest
|
||||||
->setArgument('numbers', $profileName)
|
->setArgument('numbers', $profileName)
|
||||||
->setArgument('shared-users', $sharedusers)
|
->setArgument('shared-users', $sharedusers)
|
||||||
->setArgument('rate-limit', $rate)
|
->setArgument('rate-limit', $rate)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$d->name_plan = $name;
|
$d->name_plan = $name;
|
||||||
$d->id_bw = $id_bw;
|
$d->id_bw = $id_bw;
|
||||||
@ -317,25 +323,26 @@ switch ($action) {
|
|||||||
|
|
||||||
$d = ORM::for_table('tbl_plans')->find_one($id);
|
$d = ORM::for_table('tbl_plans')->find_one($id);
|
||||||
if ($d) {
|
if ($d) {
|
||||||
$mikrotik = Router::_info($d['routers']);
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$mikrotik = Router::_info($d['routers']);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$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();
|
||||||
|
|
||||||
r2(U . 'services/pppoe', 's', $_L['Delete_Successfully']);
|
r2(U . 'services/pppoe', 's', $_L['Delete_Successfully']);
|
||||||
@ -381,21 +388,23 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
$mikrotik = Router::_info($routers);
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$mikrotik = Router::_info($routers);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$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();
|
||||||
$d->type = 'PPPOE';
|
$d->type = 'PPPOE';
|
||||||
@ -455,27 +464,29 @@ switch ($action) {
|
|||||||
}
|
}
|
||||||
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
|
||||||
|
|
||||||
$mikrotik = Router::_info($routers);
|
if(!$_c['radius_mode']){
|
||||||
try {
|
$mikrotik = Router::_info($routers);
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
$printRequest = new RouterOS\Request(
|
}
|
||||||
'/ppp profile print .proplist=name',
|
$printRequest = new RouterOS\Request(
|
||||||
RouterOS\Query::where('name', $name)
|
'/ppp profile print .proplist=name',
|
||||||
);
|
RouterOS\Query::where('name', $name)
|
||||||
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
);
|
||||||
|
$profileName = $client->sendSync($printRequest)->getProperty('name');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
$setRequest = new RouterOS\Request('/ppp/profile/set');
|
||||||
$client(
|
$client(
|
||||||
$setRequest
|
$setRequest
|
||||||
->setArgument('numbers', $profileName)
|
->setArgument('numbers', $profileName)
|
||||||
->setArgument('local-address', $pool)
|
->setArgument('local-address', $pool)
|
||||||
->setArgument('remote-address', $pool)
|
->setArgument('remote-address', $pool)
|
||||||
->setArgument('rate-limit', $rate)
|
->setArgument('rate-limit', $rate)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$d->name_plan = $name;
|
$d->name_plan = $name;
|
||||||
$d->id_bw = $id_bw;
|
$d->id_bw = $id_bw;
|
||||||
|
@ -206,6 +206,7 @@ switch ($action) {
|
|||||||
$wa_url = _post('wa_url');
|
$wa_url = _post('wa_url');
|
||||||
$address = _post('address');
|
$address = _post('address');
|
||||||
$tawkto = _post('tawkto');
|
$tawkto = _post('tawkto');
|
||||||
|
$radius_mode = _post('radius_mode')*1;
|
||||||
$payment_gateway = _post('payment_gateway');
|
$payment_gateway = _post('payment_gateway');
|
||||||
if ($company == '') {
|
if ($company == '') {
|
||||||
r2(U . 'settings/app', 'e', $_L['All_field_is_required']);
|
r2(U . 'settings/app', 'e', $_L['All_field_is_required']);
|
||||||
@ -289,6 +290,17 @@ switch ($action) {
|
|||||||
$d->save();
|
$d->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$d = ORM::for_table('tbl_appconfig')->where('setting', 'radius_mode')->find_one();
|
||||||
|
if($d){
|
||||||
|
$d->value = $radius_mode;
|
||||||
|
$d->save();
|
||||||
|
}else{
|
||||||
|
$d = ORM::for_table('tbl_appconfig')->create();
|
||||||
|
$d->setting = 'radius_mode';
|
||||||
|
$d->value = $radius_mode;
|
||||||
|
$d->save();
|
||||||
|
}
|
||||||
|
|
||||||
$note = _post('note');
|
$note = _post('note');
|
||||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'note')->find_one();
|
$d = ORM::for_table('tbl_appconfig')->where('setting', 'note')->find_one();
|
||||||
$d->value = $note;
|
$d->value = $note;
|
||||||
|
@ -52,78 +52,79 @@ switch ($action) {
|
|||||||
if ($v1) {
|
if ($v1) {
|
||||||
if ($v1['type'] == 'Hotspot') {
|
if ($v1['type'] == 'Hotspot') {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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 = new RouterOS\Request('/ip/hotspot/user/print');
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/remove');
|
||||||
$setRequest->setArgument('numbers', $id);
|
$setRequest->setArgument('numbers', $id);
|
||||||
$client->sendSync($setRequest);
|
$client->sendSync($setRequest);
|
||||||
|
|
||||||
/* iBNuX Added:
|
/* iBNuX Added:
|
||||||
* Time limit to Mikrotik
|
* Time limit to Mikrotik
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
*/
|
*/
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
if ($p['typebp'] == "Limited") {
|
if ($p['typebp'] == "Limited") {
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
if ($p['time_unit'] == 'Hrs')
|
if ($p['time_unit'] == 'Hrs')
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
else
|
else
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":00";
|
$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(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
->setArgument('name', $c['username'])
|
->setArgument('name', $c['username'])
|
||||||
->setArgument('profile', $p['name_plan'])
|
->setArgument('profile', $p['name_plan'])
|
||||||
->setArgument('password', $c['password'])
|
->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'];
|
||||||
$b->plan_id = $v1['id_plan'];
|
$b->plan_id = $v1['id_plan'];
|
||||||
@ -151,67 +152,69 @@ switch ($action) {
|
|||||||
$t->type = "Hotspot";
|
$t->type = "Hotspot";
|
||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
/* iBNuX Added:
|
}
|
||||||
* Time limit to Mikrotik
|
/* iBNuX Added:
|
||||||
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
* Time limit to Mikrotik
|
||||||
*/
|
* 'Time_Limit', 'Data_Limit', 'Both_Limit'
|
||||||
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
*/
|
||||||
if ($p['typebp'] == "Limited") {
|
$addRequest = new RouterOS\Request('/ip/hotspot/user/add');
|
||||||
if ($p['limit_type'] == "Time_Limit") {
|
if ($p['typebp'] == "Limited") {
|
||||||
if ($p['time_unit'] == 'Hrs')
|
if ($p['limit_type'] == "Time_Limit") {
|
||||||
$timelimit = $p['time_limit'] . ":00:00";
|
if ($p['time_unit'] == 'Hrs')
|
||||||
else
|
$timelimit = $p['time_limit'] . ":00:00";
|
||||||
$timelimit = "00:" . $p['time_limit'] . ":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(
|
$client->sendSync(
|
||||||
$addRequest
|
$addRequest
|
||||||
->setArgument('name', $c['username'])
|
->setArgument('name', $c['username'])
|
||||||
->setArgument('profile', $p['name_plan'])
|
->setArgument('profile', $p['name_plan'])
|
||||||
->setArgument('password', $c['password'])
|
->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();
|
||||||
@ -253,29 +256,31 @@ switch ($action) {
|
|||||||
"\nPrice: ".$p['price']);
|
"\nPrice: ".$p['price']);
|
||||||
} else {
|
} else {
|
||||||
if ($b) {
|
if ($b) {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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'])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$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'];
|
||||||
$b->username = $c['username'];
|
$b->username = $c['username'];
|
||||||
@ -304,20 +309,22 @@ switch ($action) {
|
|||||||
$t->type = "PPPOE";
|
$t->type = "PPPOE";
|
||||||
$t->save();
|
$t->save();
|
||||||
} else {
|
} else {
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":", $mikrotik['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
$iport = explode(":", $mikrotik['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $mikrotik['username'], $mikrotik['password'], ($iport[1]) ? $iport[1] : null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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 = ORM::for_table('tbl_user_recharges')->create();
|
||||||
$d->customer_id = $user['id'];
|
$d->customer_id = $user['id'];
|
||||||
|
@ -34,38 +34,39 @@ foreach ($d as $ds){
|
|||||||
$c = ORM::for_table('tbl_customers')->where('id',$ds['customer_id'])->find_one();
|
$c = ORM::for_table('tbl_customers')->where('id',$ds['customer_id'])->find_one();
|
||||||
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
||||||
|
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":",$m['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
|
$iport = explode(":",$m['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} catch (Exception $e) {
|
||||||
}
|
die("Unable to connect to the router.<br>".$e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
$printRequest = new RouterOS\Request('/ip/hotspot/user/print');
|
||||||
$printRequest->setArgument('.proplist', '.id');
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
$setRequest = new RouterOS\Request('/ip/hotspot/user/set');
|
||||||
$setRequest->setArgument('numbers', $id);
|
$setRequest->setArgument('numbers', $id);
|
||||||
$setRequest->setArgument('limit-uptime', '00:00:05');
|
$setRequest->setArgument('limit-uptime', '00:00:05');
|
||||||
$client->sendSync($setRequest);
|
$client->sendSync($setRequest);
|
||||||
|
|
||||||
//remove hotspot active
|
//remove hotspot active
|
||||||
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
$onlineRequest = new RouterOS\Request('/ip/hotspot/active/print');
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
$onlineRequest->setArgument('.proplist', '.id');
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('user', $c['username']));
|
$onlineRequest->setQuery(RouterOS\Query::where('user', $c['username']));
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
|
||||||
$removeRequest->setArgument('numbers', $id);
|
$removeRequest->setArgument('numbers', $id);
|
||||||
$client->sendSync($removeRequest);
|
$client->sendSync($removeRequest);
|
||||||
|
}
|
||||||
|
|
||||||
//update database user dengan status off
|
//update database user dengan status off
|
||||||
$u->status = 'off';
|
$u->status = 'off';
|
||||||
$u->save();
|
$u->save();
|
||||||
}else
|
}else echo " : ACTIVE \r\n";
|
||||||
echo " : ACTIVE \r\n";
|
|
||||||
}else{
|
}else{
|
||||||
$date_now = strtotime(date("Y-m-d H:i:s"));
|
$date_now = strtotime(date("Y-m-d H:i:s"));
|
||||||
$expiration = strtotime($ds['expiration'].' '.$ds['time']);
|
$expiration = strtotime($ds['expiration'].' '.$ds['time']);
|
||||||
@ -76,30 +77,32 @@ foreach ($d as $ds){
|
|||||||
$c = ORM::for_table('tbl_customers')->where('id',$ds['customer_id'])->find_one();
|
$c = ORM::for_table('tbl_customers')->where('id',$ds['customer_id'])->find_one();
|
||||||
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
$m = ORM::for_table('tbl_routers')->where('name',$ds['routers'])->find_one();
|
||||||
|
|
||||||
try {
|
if(!$_c['radius_mode']){
|
||||||
$iport = explode(":",$m['ip_address']);
|
try {
|
||||||
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
|
$iport = explode(":",$m['ip_address']);
|
||||||
} catch (Exception $e) {
|
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
|
||||||
die("Unable to connect to the router.<br>".$e->getMessage());
|
} 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 = new RouterOS\Request('/ppp/secret/print');
|
||||||
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
$printRequest->setArgument('.proplist', '.id');
|
||||||
$id = $client->sendSync($printRequest)->getProperty('.id');
|
$printRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
||||||
|
$id = $client->sendSync($printRequest)->getProperty('.id');
|
||||||
|
|
||||||
$setRequest = new RouterOS\Request('/ppp/secret/disable');
|
$setRequest = new RouterOS\Request('/ppp/secret/disable');
|
||||||
$setRequest->setArgument('numbers', $id);
|
$setRequest->setArgument('numbers', $id);
|
||||||
$client->sendSync($setRequest);
|
$client->sendSync($setRequest);
|
||||||
|
|
||||||
//remove hotspot active
|
//remove hotspot active
|
||||||
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
$onlineRequest = new RouterOS\Request('/ppp/active/print');
|
||||||
$onlineRequest->setArgument('.proplist', '.id');
|
$onlineRequest->setArgument('.proplist', '.id');
|
||||||
$onlineRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
$onlineRequest->setQuery(RouterOS\Query::where('name', $c['username']));
|
||||||
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
$id = $client->sendSync($onlineRequest)->getProperty('.id');
|
||||||
|
|
||||||
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
$removeRequest = new RouterOS\Request('/ppp/active/remove');
|
||||||
$removeRequest->setArgument('numbers', $id);
|
$removeRequest->setArgument('numbers', $id);
|
||||||
$client->sendSync($removeRequest);
|
$client->sendSync($removeRequest);
|
||||||
|
}
|
||||||
|
|
||||||
$u->status = 'off';
|
$u->status = 'off';
|
||||||
$u->save();
|
$u->save();
|
||||||
|
@ -33,10 +33,25 @@
|
|||||||
<option value="none">None</option>
|
<option value="none">None</option>
|
||||||
<option value="xendit" {if $_c['payment_gateway'] eq 'xendit'}selected="selected" {/if}>Xendit</option>
|
<option value="xendit" {if $_c['payment_gateway'] eq 'xendit'}selected="selected" {/if}>Xendit</option>
|
||||||
<option value="midtrans" {if $_c['payment_gateway'] eq 'midtrans'}selected="selected" {/if}>Midtrans</option>
|
<option value="midtrans" {if $_c['payment_gateway'] eq 'midtrans'}selected="selected" {/if}>Midtrans</option>
|
||||||
|
<option value="tripay" {if $_c['payment_gateway'] eq 'tripay'}selected="selected" {/if}>Tripay</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-md-2 control-label">Radius Mode?</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<select name="radius_mode" id="radius_mode" class="form-control">
|
||||||
|
<option value="0">No</option>
|
||||||
|
<option value="1" {if $_c['radius_mode']}selected="selected" {/if}>Yes</option>
|
||||||
|
</select>
|
||||||
|
<p class="help-block">Still on Testing.</p>
|
||||||
|
<p class="help-block">Changing from Radius will not add existing user to Mikrotik Hotspot.</p>
|
||||||
|
<p class="help-block">With Radius user can use Hotspot or PPOE.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="panel-heading">Telegram Notification</div>
|
<div class="panel-heading">Telegram Notification</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user