Fix rad_acct
This commit is contained in:
parent
0fae434c1b
commit
ced0d487e7
17
radius.php
17
radius.php
@ -264,7 +264,7 @@ try {
|
|||||||
}
|
}
|
||||||
header("HTTP/1.1 200 ok");
|
header("HTTP/1.1 200 ok");
|
||||||
$d = ORM::for_table('rad_acct')
|
$d = ORM::for_table('rad_acct')
|
||||||
->whereRaw("BINARY `code` = '$username'")
|
->whereRaw("BINARY `username` = '$username'")
|
||||||
->where('acctstatustype', _post('acctStatusType'))
|
->where('acctstatustype', _post('acctStatusType'))
|
||||||
->findOne();
|
->findOne();
|
||||||
if (!$d) {
|
if (!$d) {
|
||||||
@ -275,7 +275,7 @@ try {
|
|||||||
if (_post('acctStatusType') == 'Stop') {
|
if (_post('acctStatusType') == 'Stop') {
|
||||||
// log in the Start only
|
// log in the Start only
|
||||||
$start = ORM::for_table('rad_acct')
|
$start = ORM::for_table('rad_acct')
|
||||||
->whereRaw("BINARY `code` = '$username'")
|
->whereRaw("BINARY `username` = '$username'")
|
||||||
->where('acctstatustype', 'Start')
|
->where('acctstatustype', 'Start')
|
||||||
->findOne();
|
->findOne();
|
||||||
if (!$start) {
|
if (!$start) {
|
||||||
@ -288,6 +288,17 @@ try {
|
|||||||
$start->acctOutputOctets = 0;
|
$start->acctOutputOctets = 0;
|
||||||
$start->acctInputOctets = 0;
|
$start->acctInputOctets = 0;
|
||||||
}
|
}
|
||||||
|
$start->acctsessionid = _post('acctSessionId');
|
||||||
|
$start->username = $username;
|
||||||
|
$start->realm = _post('realm');
|
||||||
|
$start->nasipaddress = _post('nasip');
|
||||||
|
$start->nasid = _post('nasid');
|
||||||
|
$start->nasportid = _post('nasPortId');
|
||||||
|
$start->nasporttype = _post('nasPortType');
|
||||||
|
$start->framedipaddress = _post('framedIPAddress');
|
||||||
|
$start->acctstatustype = _post('acctStatusType');
|
||||||
|
$start->macaddr = _post('macAddr');
|
||||||
|
$start->dateAdded = date('Y-m-d H:i:s');
|
||||||
$start->save();
|
$start->save();
|
||||||
$d->acctOutputOctets = 0;
|
$d->acctOutputOctets = 0;
|
||||||
$d->acctInputOctets = 0;
|
$d->acctInputOctets = 0;
|
||||||
@ -392,7 +403,7 @@ function process_radiust_rest($tur, $code)
|
|||||||
|
|
||||||
if ($plan['typebp'] == "Limited") {
|
if ($plan['typebp'] == "Limited") {
|
||||||
if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") {
|
if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") {
|
||||||
$raddact = ORM::for_table('rad_acct')->whereRaw("BINARY `code` = '$tur[username]'")->where('acctstatustype', 'Start')->find_one();
|
$raddact = ORM::for_table('rad_acct')->whereRaw("BINARY `username` = '$tur[username]'")->where('acctstatustype', 'Start')->find_one();
|
||||||
$totalUsage = intval($raddact['acctOutputOctets']) + intval($raddact['acctInputOctets']);
|
$totalUsage = intval($raddact['acctOutputOctets']) + intval($raddact['acctInputOctets']);
|
||||||
$attrs['reply:Mikrotik-Total-Limit'] = Text::convertDataUnit($plan['data_limit'], $plan['data_unit']) - $totalUsage;
|
$attrs['reply:Mikrotik-Total-Limit'] = Text::convertDataUnit($plan['data_limit'], $plan['data_unit']) - $totalUsage;
|
||||||
if ($attrs['reply:Mikrotik-Total-Limit'] < 0) {
|
if ($attrs['reply:Mikrotik-Total-Limit'] < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user