show error stacktrace

This commit is contained in:
Ibnu Maksum 2023-10-12 15:47:45 +07:00
parent 7e00feb02f
commit 95097e4512
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
5 changed files with 29 additions and 21 deletions

View File

@ -130,8 +130,9 @@ class Radius
// we just change the password
$r->value = md5(time() . $username . $radius_pass);
$r->save();
Radius::disconnectCustomer($username);
return Radius::disconnectCustomer($username);
}
return '';
}
public static function customerDelete($username)
@ -158,7 +159,7 @@ class Radius
$p->priority = 1;
$p->save();
}
if ($plan['type'] == 'HOTSPOT' && $plan['typebp'] == "Limited") {
if ($plan['type'] == 'Hotspot' && $plan['typebp'] == "Limited") {
if ($plan['limit_type'] == "Time_Limit") {
if ($plan['time_unit'] == 'Hrs')
$timelimit = $plan['time_limit'] * 60 * 60;
@ -184,14 +185,17 @@ class Radius
Radius::upsertCustomer($customer['username'], 'Expire-After', $timelimit);
}
} else {
Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Max-Volume')->delete();
Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Expire-After')->delete();
$r = Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Max-Volume')->findOne();
if($r) $r->delete();
$r = Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'Expire-After')->findOne();
if($r) $r->delete();
}
// expired user
if ($expired != null) {
Radius::upsertCustomer($customer['username'], 'expiration', date('d M Y H:i:s', strtotime($expired)));
} else {
Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'expiration')->delete();
$r = Radius::getTableCustomer()->where_equal('username', $customer['username'])->whereEqual('attribute', 'expiration')->findOne();
if($r) $r->delete();
}
return true;
}
@ -206,7 +210,7 @@ class Radius
Radius::upsertCustomer($customer['username'], 'Cleartext-Password', $customer['password']);
}
Radius::upsertCustomer($customer['username'], 'Simultaneous-Use', ($plan['type'] == 'PPPOE') ? 1 : $plan['shared_users']);
return false;
return true;
}
/**
@ -246,12 +250,14 @@ class Radius
$nas = Radius::getTableNas()->findMany();
$count = count($nas)*15;
set_time_limit($count);
$result = [];
foreach ($nas as $n){
$port = 3799;
if(!empty($n['ports'])){
$port = $n['ports'];
}
shell_exec("echo 'User-Name = $username' | ".Radius::getClient()." ".trim($n['nasname']).":$port disconnect '".$n['secret']."'");
$result[] = $n['nasname'].': '.shell_exec("echo 'User-Name = $username' | ".Radius::getClient()." ".trim($n['nasname']).":$port disconnect '".$n['secret']."'");
}
return $result;
}
}

View File

@ -338,7 +338,7 @@ try {
}
} catch (Exception $e) {
$ui->assign("error_title", "PHPNuxBill Crash");
$ui->assign("error_message", $e->getMessage());
$ui->assign("error_message", $e->getMessage().'<br><pre>'.$e->getTraceAsString().'</pre>');
$ui->display('router-error.tpl');
die();
}

View File

@ -1,8 +1,11 @@
<?php
/**
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* PHP Mikrotik Billing (https://github.com/hotspotbilling/phpnuxbill/)
* by @ibnux
**/
_auth();
$ui->assign('_title', $_L['My_Account']);
$ui->assign('_system_menu', 'accounts');
@ -11,10 +14,6 @@ $action = $routes['1'];
$user = User::_info();
$ui->assign('_user', $user);
use PEAR2\Net\RouterOS;
require_once 'system/autoload/PEAR2/Autoload.php';
switch ($action) {
case 'change-password':

View File

@ -41,21 +41,24 @@ switch ($action) {
case 'sync':
set_time_limit(-1);
$plans = ORM::for_table('tbl_user_recharges')->where('status', 'on')->find_many();
echo count($plans);
$log = '';
$router = '';
foreach ($plans as $plan) {
if ($router != $plan['routers']) {
if ($router != $plan['routers'] && $plan['routers'] != 'radius') {
$mikrotik = Mikrotik::info($plan['routers']);
$client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']);
$router = $plan['routers'];
}
$p = ORM::for_table('tbl_plans')->findOne($plan['plan_id']);
$c = ORM::for_table('tbl_customers')->findOne($plan['customer_id']);
if ($plan['type'] == 'Hotspot') {
Mikrotik::addHotspotUser($client, $p, $c);
} else if ($plan['type'] == 'PPPOE') {
Mikrotik::addPpoeUser($client, $p, $c);
if($plan['routers'] == 'radius'){
Radius::customerAddPlan($c, $p, $plans['expiration'].' '.$plans['time']);
}else{
if ($plan['type'] == 'Hotspot') {
Mikrotik::addHotspotUser($client, $p, $c);
} else if ($plan['type'] == 'PPPOE') {
Mikrotik::addPpoeUser($client, $p, $c);
}
}
$log .= "DONE : $plan[username], $plan[namebp], $plan[type], $plan[routers]<br>";
}

View File

@ -101,7 +101,7 @@ foreach ($d as $ds) {
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
if ($p['is_radius']) {
Radius::customerDeactivate($c['username']);
echo Radius::customerDeactivate($c['username']);
}else{
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
if (!empty($p['pool_expired'])) {
@ -150,7 +150,7 @@ foreach ($d as $ds) {
$p = ORM::for_table('tbl_plans')->where('id', $u['plan_id'])->find_one();
if ($p['is_radius']) {
Radius::customerDeactivate($c['username']);
echo Radius::customerDeactivate($c['username']);
}else{
$client = Mikrotik::getClient($m['ip_address'], $m['username'], $m['password']);
if (!empty($p['pool_expired'])) {