by mac and nasid
This commit is contained in:
parent
357b7932e9
commit
b1e145f0dc
21
radius.php
21
radius.php
@ -274,7 +274,7 @@ try {
|
||||
}
|
||||
header("HTTP/1.1 200 ok");
|
||||
$d = ORM::for_table('rad_acct')
|
||||
->whereRaw("BINARY username = '$username' AND acctsessionid = '"._post('acctSessionId')."'")
|
||||
->whereRaw("BINARY username = '$username' AND macaddr = '"._post('macAddr')."' AND nasid = '"._post('nasid')."'")
|
||||
->findOne();
|
||||
if (!$d) {
|
||||
$d = ORM::for_table('rad_acct')->create();
|
||||
@ -296,16 +296,16 @@ try {
|
||||
$d->nasportid = _post('nasPortId');
|
||||
$d->nasporttype = _post('nasPortType');
|
||||
$d->framedipaddress = _post('framedIPAddress');
|
||||
if (_post('acctStatusType') == 'Start') {
|
||||
$d->acctstatustype = 'Interim-Update';
|
||||
} else {
|
||||
if(in_array(_post('acctStatusType'), ['Start', 'Stop'])){
|
||||
$d->acctstatustype = _post('acctStatusType');
|
||||
}
|
||||
$d->macaddr = _post('macAddr');
|
||||
$d->dateAdded = date('Y-m-d H:i:s');
|
||||
// pastikan data akunting yang disimpan memang customer aktif phpnuxbill
|
||||
$tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username' AND `status` = 'on' AND `routers` = 'radius'")->find_one();
|
||||
if($tur){
|
||||
$d->save();
|
||||
if (_post('acctStatusType') == 'Start') {
|
||||
$tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username' AND `status` = 'on' AND `routers` = 'radius'")->find_one();
|
||||
$plan = ORM::for_table('tbl_plans')->where('id', $tur['plan_id'])->find_one();
|
||||
if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") {
|
||||
$totalUsage = $d['acctOutputOctets'] + $d['acctInputOctets'];
|
||||
@ -316,6 +316,7 @@ try {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
show_radius_result([
|
||||
"control:Auth-Type" => "Accept",
|
||||
"reply:Reply-Message" => 'Saved'
|
||||
@ -347,10 +348,12 @@ function process_radiust_rest($tur, $code)
|
||||
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
|
||||
// Count User Onlines
|
||||
$USRon = ORM::for_table('rad_acct')
|
||||
->whereRaw("BINARY username = '".$tur['username']."'")
|
||||
->where("acctStatusType", 'Interim-Update')
|
||||
->count();
|
||||
if ($USRon >= $plan['shared_users'] && $plan['type'] == 'Hotspot') {
|
||||
->whereRaw("BINARY username = '".$tur['username']."' AND acctStatusType = 'Start'")
|
||||
->find_array();
|
||||
// get all the IP
|
||||
$ips = array_column($USRon, 'framedipaddress');
|
||||
// check if user reach shared_users limit but IP is not in the list active
|
||||
if (count($USRon) >= $plan['shared_users'] && $plan['type'] == 'Hotspot' && !in_array(_post('framedIPAddress'), $ips)) {
|
||||
show_radius_result(["control:Auth-Type" => "Accept", 'Reply-Message' => 'You are already logged in - access denied ('.$USRon.')'], 401);
|
||||
}
|
||||
if ($bw['rate_down_unit'] == 'Kbps') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user