add acctinputoctets acctoutputoctets
This commit is contained in:
parent
da3ef535a2
commit
8c00496a5b
@ -221,6 +221,8 @@ CREATE TABLE `rad_acct` (
|
||||
`nasportid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`nasporttype` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`framedipaddress` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
|
||||
`acctinputoctets` BIGINT NOT NULL DEFAULT '0',
|
||||
`acctoutputoctets` BIGINT NOT NULL DEFAULT '0',
|
||||
`acctstatustype` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
|
||||
`macaddr` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`dateAdded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
|
57
radius.php
57
radius.php
@ -68,31 +68,31 @@ try {
|
||||
$username = _req('username');
|
||||
$password = _req('password');
|
||||
$isVoucher = ($username == $password);
|
||||
$real = _req('CHAPassword');
|
||||
$challenge = _req('CHAPchallenge');
|
||||
if (!empty($real)) { //aktif hanya kalo chappasword ada isinya
|
||||
$dd = ORM::for_table('tbl_customers')->select('password')->where('username', $username)->find_one();
|
||||
$pwd = $dd['password']; //ambil password text
|
||||
$challenger = hex2bin(substr($challenge, 2)); //buang 0x
|
||||
$realr = substr($real, 2); //buang 0x lagi
|
||||
$chapid = substr($realr, 0, 2); //ambil chap-id dari chap-pass
|
||||
$chapidr = hex2bin($chapid); //konvert chap-id
|
||||
$result = $chapidr . $pwd . $challenger; //mix semua
|
||||
$response = $chapid.md5($result); //enkripsi lagi hasilnya trus di mix sama chap id
|
||||
if ($response != $realr) { //begal kalo hasil gak sama
|
||||
show_radius_result(['Reply-Message' => 'Username or Password is wrong'], 401);
|
||||
}
|
||||
|
||||
//if ($response == $realr) { echo 'ok betul 100'; }else{ echo 'salah'; } // untuk keperluan debug
|
||||
} else { //kalo chappassword kosong brrti eksekusi yg ini
|
||||
$real = _req('CHAPassword');
|
||||
$challenge = _req('CHAPchallenge');
|
||||
if (!empty($real)) { //aktif hanya kalo chappasword ada isinya
|
||||
$dd = ORM::for_table('tbl_customers')->select('password')->where('username', $username)->find_one();
|
||||
$pwd = $dd['password']; //ambil password text
|
||||
$challenger = hex2bin(substr($challenge, 2)); //buang 0x
|
||||
$realr = substr($real, 2); //buang 0x lagi
|
||||
$chapid = substr($realr, 0, 2); //ambil chap-id dari chap-pass
|
||||
$chapidr = hex2bin($chapid); //konvert chap-id
|
||||
$result = $chapidr . $pwd . $challenger; //mix semua
|
||||
$response = $chapid . md5($result); //enkripsi lagi hasilnya trus di mix sama chap id
|
||||
if ($response != $realr) { //begal kalo hasil gak sama
|
||||
show_radius_result(['Reply-Message' => 'Username or Password is wrong'], 401);
|
||||
}
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
show_radius_result([
|
||||
"control:Auth-Type" => "Reject",
|
||||
"reply:Reply-Message" => 'Login invalid......'
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
//if ($response == $realr) { echo 'ok betul 100'; }else{ echo 'salah'; } // untuk keperluan debug
|
||||
} else { //kalo chappassword kosong brrti eksekusi yg ini
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
show_radius_result([
|
||||
"control:Auth-Type" => "Reject",
|
||||
"reply:Reply-Message" => 'Login invalid......'
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
$tur = ORM::for_table('tbl_user_recharges')->where('username', $username)->find_one();
|
||||
if ($tur) {
|
||||
if (!$isVoucher) {
|
||||
@ -151,6 +151,15 @@ try {
|
||||
if (!$d) {
|
||||
$d = ORM::for_table('rad_acct')->create();
|
||||
}
|
||||
$acctOutputOctets = _post('acctOutputOctets');
|
||||
$acctInputOctets = _post('acctInputOctets');
|
||||
if ($acctOutputOctets !== false && $acctInputOctets !== false) {
|
||||
$d->acctOutputOctets += $acctOutputOctets;
|
||||
$d->acctInputOctets += $acctInputOctets;
|
||||
}else{
|
||||
$d->acctOutputOctets = 0;
|
||||
$d->acctInputOctets = 0;
|
||||
}
|
||||
$d->acctsessionid = _post('acctSessionId');
|
||||
$d->username = $username;
|
||||
$d->realm = _post('realm');
|
||||
|
@ -144,5 +144,9 @@
|
||||
"2024.8.5.1" : [
|
||||
"ALTER TABLE `tbl_routers` ADD `coordinates` VARCHAR(50) NOT NULL DEFAULT '' AFTER `description`;",
|
||||
"ALTER TABLE `tbl_routers` ADD `coverage` VARCHAR(8) NOT NULL DEFAULT '0' AFTER `coordinates`;"
|
||||
],
|
||||
"2024.8.6" : [
|
||||
"ALTER TABLE `rad_acct` ADD `acctinputoctets` BIGINT NOT NULL DEFAULT '0' AFTER `framedipaddress`;",
|
||||
"ALTER TABLE `rad_acct` ADD `acctoutputoctets` BIGINT NOT NULL DEFAULT '0' AFTER `acctinputoctets`;"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user