Persiapan Radius Mode

This commit is contained in:
Ibnu Maksum 2022-09-07 16:11:35 +07:00
parent 19f79680ff
commit 464f41ef16
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
10 changed files with 919 additions and 832 deletions

View File

@ -40,6 +40,7 @@ switch ($action) {
if ($c){
$mikrotik = Router::_info($c['routers']);
if($c['type'] == 'Hotspot'){
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);
@ -65,7 +66,7 @@ switch ($action) {
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
$d->password = $npass;
$d->save();
@ -75,6 +76,7 @@ switch ($action) {
r2(U.'login');
}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);
@ -100,7 +102,7 @@ switch ($action) {
$removeRequest = new RouterOS\Request('/ppp/active/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
$d->password = $npass;
$d->save();

View File

@ -61,6 +61,7 @@ switch ($action) {
if ($c) {
$mikrotik = Router::_info($c['routers']);
if ($c['type'] == 'Hotspot') {
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);
@ -85,8 +86,9 @@ switch ($action) {
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
} 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);
@ -112,6 +114,7 @@ switch ($action) {
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
}
try {
$d->delete();
} catch (Exception $e) {
@ -218,6 +221,7 @@ switch ($action) {
if ($c) {
$mikrotik = Router::_info($c['routers']);
if ($c['type'] == 'Hotspot') {
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);
@ -243,10 +247,12 @@ switch ($action) {
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
$d->password = $password;
$d->save();
} 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);
@ -272,6 +278,7 @@ switch ($action) {
$removeRequest = new RouterOS\Request('/ppp/active/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
$d->password = $password;
$d->save();

View File

@ -59,6 +59,7 @@ switch ($action) {
$d = ORM::for_table('tbl_pool')->find_one($id);
$mikrotik = Router::_info($d['routers']);
if($d){
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);
@ -75,6 +76,7 @@ switch ($action) {
$client($removeRequest
->setArgument('numbers', $poolName)
);
}
$d->delete();
@ -101,6 +103,7 @@ switch ($action) {
}
$mikrotik = Router::_info($routers);
if($msg == ''){
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);
@ -112,6 +115,7 @@ switch ($action) {
->setArgument('name', $name)
->setArgument('ranges', $ip_address)
);
}
$b = ORM::for_table('tbl_pool')->create();
$b->pool_name = $name;
@ -149,6 +153,7 @@ switch ($action) {
$mikrotik = Router::_info($routers);
if($msg == ''){
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);
@ -166,6 +171,7 @@ switch ($action) {
->setArgument('numbers', $poolName)
->setArgument('ranges', $ip_address)
);
}
$d->pool_name = $name;
$d->range_ip = $ip_address;

View File

@ -102,6 +102,7 @@ switch ($action) {
if ($type == 'Hotspot') {
if ($b) {
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);
@ -175,6 +176,7 @@ switch ($action) {
->setArgument('password', $c['password'])
);
}
}
$b->customer_id = $id_customer;
$b->username = $c['username'];
@ -203,6 +205,7 @@ switch ($action) {
$t->type = "Hotspot";
$t->save();
} 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);
@ -266,6 +269,7 @@ switch ($action) {
->setArgument('password', $c['password'])
);
}
}
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $id_customer;
@ -301,6 +305,7 @@ switch ($action) {
} else {
if ($b) {
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);
@ -327,6 +332,7 @@ switch ($action) {
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
}
$b->customer_id = $id_customer;
$b->username = $c['username'];
@ -355,6 +361,7 @@ switch ($action) {
$t->type = "PPPOE";
$t->save();
} 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);
@ -369,6 +376,7 @@ switch ($action) {
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
}
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $id_customer;
@ -465,6 +473,7 @@ switch ($action) {
$mikrotik = Router::_info($d['routers']);
if ($d) {
if ($d['type'] == 'Hotspot') {
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);
@ -481,9 +490,11 @@ switch ($action) {
$removeRequest
->setArgument('numbers', $userName)
);
}
$d->delete();
} 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);
@ -501,6 +512,7 @@ switch ($action) {
$removeRequest
->setArgument('numbers', $userName)
);
}
$d->delete();
}
r2(U . 'prepaid/list', 's', $_L['Delete_Successfully']);
@ -738,6 +750,7 @@ switch ($action) {
if ($v1) {
if ($v1['type'] == 'Hotspot') {
if ($b) {
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);
@ -810,6 +823,7 @@ switch ($action) {
->setArgument('password', $c['password'])
);
}
}
$b->customer_id = $user;
$b->username = $c['username'];
@ -838,6 +852,7 @@ switch ($action) {
$t->type = "Hotspot";
$t->save();
} 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);
@ -900,6 +915,7 @@ switch ($action) {
->setArgument('password', $c['password'])
);
}
}
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $user;
@ -940,6 +956,7 @@ switch ($action) {
"\nPrice: ".$p['price']);
} else {
if ($b) {
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);
@ -966,6 +983,7 @@ switch ($action) {
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
}
$b->customer_id = $user;
$b->username = $c['username'];
@ -994,6 +1012,7 @@ switch ($action) {
$t->type = "PPPOE";
$t->save();
} 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);
@ -1008,6 +1027,7 @@ switch ($action) {
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
}
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $user;

View File

@ -83,12 +83,14 @@ switch ($action) {
$msg .= $_L['Router_already_exist']. '<br>';
}
if(!$_c['radius_mode']){
try {
$iport = explode(":", $ip_address);
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
}
}
if($msg == ''){
$d = ORM::for_table('tbl_routers')->create();
@ -145,12 +147,14 @@ switch ($action) {
}
if(!$_c['radius_mode']){
try {
$iport = explode(":", $ip_address);
$client = new RouterOS\Client($iport[0], $username, $password, ($iport[1]) ? $iport[1] : null);
} catch (Exception $e) {
$msg .= "Unable to connect to the router.<br>".$e->getMessage().'<br>';
}
}
if($msg == ''){

View File

@ -68,6 +68,7 @@ switch ($action) {
$d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) {
if(!$_c['radius_mode']){
$mikrotik = Router::_info($d['routers']);
try {
$iport = explode(":", $mikrotik['ip_address']);
@ -86,6 +87,7 @@ switch ($action) {
$removeRequest
->setArgument('numbers', $profileName)
);
}
$d->delete();
@ -138,6 +140,7 @@ switch ($action) {
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){
$mikrotik = Router::_info($routers);
try {
$iport = explode(":", $mikrotik['ip_address']);
@ -152,6 +155,7 @@ switch ($action) {
->setArgument('shared-users', $sharedusers)
->setArgument('rate-limit', $rate)
);
}
$d = ORM::for_table('tbl_plans')->create();
$d->name_plan = $name;
@ -224,6 +228,7 @@ switch ($action) {
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){
$mikrotik = Router::_info($routers);
try {
$iport = explode(":", $mikrotik['ip_address']);
@ -244,6 +249,7 @@ switch ($action) {
->setArgument('shared-users', $sharedusers)
->setArgument('rate-limit', $rate)
);
}
$d->name_plan = $name;
$d->id_bw = $id_bw;
@ -317,6 +323,7 @@ switch ($action) {
$d = ORM::for_table('tbl_plans')->find_one($id);
if ($d) {
if(!$_c['radius_mode']){
$mikrotik = Router::_info($d['routers']);
try {
$iport = explode(":", $mikrotik['ip_address']);
@ -335,7 +342,7 @@ switch ($action) {
$removeRequest
->setArgument('numbers', $profileName)
);
}
$d->delete();
r2(U . 'services/pppoe', 's', $_L['Delete_Successfully']);
@ -381,6 +388,7 @@ switch ($action) {
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){
$mikrotik = Router::_info($routers);
try {
$iport = explode(":", $mikrotik['ip_address']);
@ -396,6 +404,7 @@ switch ($action) {
->setArgument('remote-address', $pool)
->setArgument('rate-limit', $rate)
);
}
$d = ORM::for_table('tbl_plans')->create();
$d->type = 'PPPOE';
@ -455,6 +464,7 @@ switch ($action) {
}
$rate = $b['rate_up'] . $unitup . "/" . $b['rate_down'] . $unitdown;
if(!$_c['radius_mode']){
$mikrotik = Router::_info($routers);
try {
$iport = explode(":", $mikrotik['ip_address']);
@ -476,6 +486,7 @@ switch ($action) {
->setArgument('remote-address', $pool)
->setArgument('rate-limit', $rate)
);
}
$d->name_plan = $name;
$d->id_bw = $id_bw;

View File

@ -206,6 +206,7 @@ switch ($action) {
$wa_url = _post('wa_url');
$address = _post('address');
$tawkto = _post('tawkto');
$radius_mode = _post('radius_mode')*1;
$payment_gateway = _post('payment_gateway');
if ($company == '') {
r2(U . 'settings/app', 'e', $_L['All_field_is_required']);
@ -289,6 +290,17 @@ switch ($action) {
$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');
$d = ORM::for_table('tbl_appconfig')->where('setting', 'note')->find_one();
$d->value = $note;

View File

@ -52,6 +52,7 @@ switch ($action) {
if ($v1) {
if ($v1['type'] == 'Hotspot') {
if ($b) {
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);
@ -123,7 +124,7 @@ switch ($action) {
->setArgument('password', $c['password'])
);
}
}
$b->customer_id = $user['id'];
$b->username = $c['username'];
$b->plan_id = $v1['id_plan'];
@ -151,6 +152,7 @@ switch ($action) {
$t->type = "Hotspot";
$t->save();
} 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);
@ -213,6 +215,7 @@ switch ($action) {
->setArgument('password', $c['password'])
);
}
}
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $user['id'];
@ -253,6 +256,7 @@ switch ($action) {
"\nPrice: ".$p['price']);
} else {
if ($b) {
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);
@ -276,6 +280,7 @@ switch ($action) {
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
}
$b->customer_id = $user['id'];
$b->username = $c['username'];
@ -304,6 +309,7 @@ switch ($action) {
$t->type = "PPPOE";
$t->save();
} 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);
@ -318,6 +324,7 @@ switch ($action) {
->setArgument('profile', $p['name_plan'])
->setArgument('password', $c['password'])
);
}
$d = ORM::for_table('tbl_user_recharges')->create();
$d->customer_id = $user['id'];

View File

@ -34,6 +34,7 @@ foreach ($d as $ds){
$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();
if(!$_c['radius_mode']){
try {
$iport = explode(":",$m['ip_address']);
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
@ -60,12 +61,12 @@ foreach ($d as $ds){
$removeRequest = new RouterOS\Request('/ip/hotspot/active/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
//update database user dengan status off
$u->status = 'off';
$u->save();
}else
echo " : ACTIVE \r\n";
}else echo " : ACTIVE \r\n";
}else{
$date_now = strtotime(date("Y-m-d H:i:s"));
$expiration = strtotime($ds['expiration'].' '.$ds['time']);
@ -76,6 +77,7 @@ foreach ($d as $ds){
$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();
if(!$_c['radius_mode']){
try {
$iport = explode(":",$m['ip_address']);
$client = new RouterOS\Client($iport[0], $m['username'], $m['password'],($iport[1])?$iport[1]:null);
@ -100,6 +102,7 @@ foreach ($d as $ds){
$removeRequest = new RouterOS\Request('/ppp/active/remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
}
$u->status = 'off';
$u->save();

View File

@ -33,10 +33,25 @@
<option value="none">None</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="tripay" {if $_c['payment_gateway'] eq 'tripay'}selected="selected" {/if}>Tripay</option>
</select>
</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-body">
<div class="form-group">