sync plan
This commit is contained in:
parent
bc763b476e
commit
700e861197
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
|
||||||
* by https://t.me/ibnux
|
* by https://t.me/ibnux
|
||||||
@ -28,6 +29,19 @@ switch ($action) {
|
|||||||
$router = '';
|
$router = '';
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
if ($plan['is_radius']) {
|
if ($plan['is_radius']) {
|
||||||
|
if ($b['rate_down_unit'] == 'Kbps') {
|
||||||
|
$raddown = '000';
|
||||||
|
} else {
|
||||||
|
$raddown = '000000';
|
||||||
|
}
|
||||||
|
if ($b['rate_up_unit'] == 'Kbps') {
|
||||||
|
$radup = '000';
|
||||||
|
} else {
|
||||||
|
$radup = '000000';
|
||||||
|
}
|
||||||
|
$radiusRate = $plan['rate_up'] . $radup . '/' . $plan['rate_down'] . $raddown;
|
||||||
|
Radius::planUpSert($plan['id'], $radiusRate);
|
||||||
|
$log .= "DONE : Radius $plan[name_plan], $plan[shared_users], $radiusRate<br>";
|
||||||
} else {
|
} else {
|
||||||
if ($router != $plan['routers']) {
|
if ($router != $plan['routers']) {
|
||||||
$mikrotik = Mikrotik::info($plan['routers']);
|
$mikrotik = Mikrotik::info($plan['routers']);
|
||||||
@ -59,27 +73,43 @@ switch ($action) {
|
|||||||
$log = '';
|
$log = '';
|
||||||
$router = '';
|
$router = '';
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
if ($router != $plan['routers']) {
|
if ($plan['is_radius']) {
|
||||||
$mikrotik = Mikrotik::info($plan['routers']);
|
if ($b['rate_down_unit'] == 'Kbps') {
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$raddown = '000';
|
||||||
$router = $plan['routers'];
|
} else {
|
||||||
}
|
$raddown = '000000';
|
||||||
if ($plan['rate_down_unit'] == 'Kbps') {
|
}
|
||||||
$unitdown = 'K';
|
if ($b['rate_up_unit'] == 'Kbps') {
|
||||||
|
$radup = '000';
|
||||||
|
} else {
|
||||||
|
$radup = '000000';
|
||||||
|
}
|
||||||
|
$radiusRate = $plan['rate_up'] . $radup . '/' . $plan['rate_down'] . $raddown;
|
||||||
|
Radius::planUpSert($plan['id'], $radiusRate, $plan['pool']);
|
||||||
|
$log .= "DONE : RADIUS $plan[name_plan], $plan[pool], $rate<br>";
|
||||||
} else {
|
} else {
|
||||||
$unitdown = 'M';
|
if ($router != $plan['routers']) {
|
||||||
}
|
$mikrotik = Mikrotik::info($plan['routers']);
|
||||||
if ($plan['rate_up_unit'] == 'Kbps') {
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
$unitup = 'K';
|
$router = $plan['routers'];
|
||||||
} else {
|
}
|
||||||
$unitup = 'M';
|
if ($plan['rate_down_unit'] == 'Kbps') {
|
||||||
}
|
$unitdown = 'K';
|
||||||
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
} else {
|
||||||
Mikrotik::addPpoePlan($client, $plan['name_plan'], $plan['pool'], $rate);
|
$unitdown = 'M';
|
||||||
$log .= "DONE : $plan[name_plan], $plan[pool], $rate<br>";
|
}
|
||||||
if (!empty($plan['pool_expired'])) {
|
if ($plan['rate_up_unit'] == 'Kbps') {
|
||||||
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired'], '512K/512K');
|
$unitup = 'K';
|
||||||
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]<br>";
|
} else {
|
||||||
|
$unitup = 'M';
|
||||||
|
}
|
||||||
|
$rate = $plan['rate_up'] . $unitup . "/" . $plan['rate_down'] . $unitdown;
|
||||||
|
Mikrotik::addPpoePlan($client, $plan['name_plan'], $plan['pool'], $rate);
|
||||||
|
$log .= "DONE : $plan[name_plan], $plan[pool], $rate<br>";
|
||||||
|
if (!empty($plan['pool_expired'])) {
|
||||||
|
Mikrotik::setPpoePlan($client, 'EXPIRED NUXBILL ' . $plan['pool_expired'], $plan['pool_expired'], '512K/512K');
|
||||||
|
$log .= "DONE Expired : EXPIRED NUXBILL $plan[pool_expired]<br>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r2(U . 'services/pppoe', 's', $log);
|
r2(U . 'services/pppoe', 's', $log);
|
||||||
@ -136,7 +166,7 @@ switch ($action) {
|
|||||||
run_hook('delete_plan'); #HOOK
|
run_hook('delete_plan'); #HOOK
|
||||||
if ($d['is_radius']) {
|
if ($d['is_radius']) {
|
||||||
Radius::planDelete($d['id']);
|
Radius::planDelete($d['id']);
|
||||||
}else{
|
} else {
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removeHotspotPlan($client, $d['name_plan']);
|
Mikrotik::removeHotspotPlan($client, $d['name_plan']);
|
||||||
@ -396,7 +426,7 @@ switch ($action) {
|
|||||||
run_hook('delete_ppoe'); #HOOK
|
run_hook('delete_ppoe'); #HOOK
|
||||||
if ($d['is_radius']) {
|
if ($d['is_radius']) {
|
||||||
Radius::planDelete($d['id']);
|
Radius::planDelete($d['id']);
|
||||||
}else{
|
} else {
|
||||||
$mikrotik = Mikrotik::info($d['routers']);
|
$mikrotik = Mikrotik::info($d['routers']);
|
||||||
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
|
||||||
Mikrotik::removePpoePlan($client, $d['name_plan']);
|
Mikrotik::removePpoePlan($client, $d['name_plan']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user