fix whereRaw

This commit is contained in:
iBNu Maksum 2024-12-22 12:23:49 +07:00
parent 27c736fa69
commit 7c547c967e
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -42,7 +42,7 @@ try {
$CHAPchallenge = _req('CHAPchallenge'); $CHAPchallenge = _req('CHAPchallenge');
$isCHAP = false; $isCHAP = false;
if (!empty($CHAPassword)) { if (!empty($CHAPassword)) {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
@ -68,7 +68,7 @@ try {
} }
} }
} else { } else {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY `pppoe_username` = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY pppoe_username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
@ -111,7 +111,7 @@ try {
$username = Text::alphanumeric($username, "-_.,"); $username = Text::alphanumeric($username, "-_.,");
$d = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username'")->find_one(); $d = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username'")->find_one();
} else { } else {
$d = ORM::for_table('tbl_customers')->whereRaw("BINARY username = '$username'")->find_one(); $d = ORM::for_table('tbl_customers')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($d['password'] != $password) { if ($d['password'] != $password) {
if ($d['pppoe_password'] != $password) { if ($d['pppoe_password'] != $password) {
unset($d); unset($d);
@ -136,7 +136,7 @@ try {
$CHAPchallenge = _req('CHAPchallenge'); $CHAPchallenge = _req('CHAPchallenge');
$isCHAP = false; $isCHAP = false;
if (!empty($CHAPassword)) { if (!empty($CHAPassword)) {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
@ -162,7 +162,7 @@ try {
} }
} }
} else { } else {
$c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY `pppoe_username` = '$username'")->find_one(); $c = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY pppoe_username = '$username' AND status = 'Active'")->find_one();
if ($c) { if ($c) {
if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) { if (Password::chap_verify($c['password'], $CHAPassword, $CHAPchallenge)) {
$password = $c['password']; $password = $c['password'];
@ -204,7 +204,7 @@ try {
$tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username'")->find_one(); $tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username'")->find_one();
if ($tur) { if ($tur) {
if (!$isVoucher && !$isCHAP) { if (!$isVoucher && !$isCHAP) {
$d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username'")->find_one(); $d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY username = '$username' AND status = 'Active'")->find_one();
if ($d) { if ($d) {
if ($d['password'] != $password) { if ($d['password'] != $password) {
if ($d['pppoe_password'] != $password) { if ($d['pppoe_password'] != $password) {
@ -212,7 +212,7 @@ try {
} }
} }
} else { } else {
$d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY `pppoe_username` = '$username'")->find_one(); $d = ORM::for_table('tbl_customers')->select('password')->select('pppoe_password')->whereRaw("BINARY pppoe_username = '$username' AND status = 'Active'")->find_one();
if ($d) { if ($d) {
if ($d['password'] != $password) { if ($d['password'] != $password) {
if ($d['pppoe_password'] != $password) { if ($d['pppoe_password'] != $password) {
@ -226,7 +226,7 @@ try {
} else { } else {
if ($isVoucher) { if ($isVoucher) {
$username = Text::alphanumeric($username, "-_.,"); $username = Text::alphanumeric($username, "-_.,");
$v = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username'")->where('routers', 'radius')->find_one(); $v = ORM::for_table('tbl_voucher')->whereRaw("BINARY code = '$username' AND routers = 'radius'")->find_one();
if ($v) { if ($v) {
if ($v['status'] == 0) { if ($v['status'] == 0) {
if (Package::rechargeUser(0, $v['routers'], $v['id_plan'], "Voucher", $username)) { if (Package::rechargeUser(0, $v['routers'], $v['id_plan'], "Voucher", $username)) {
@ -264,8 +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 username = '$username'") ->whereRaw("BINARY username = '$username' AND acctsessionid = '"._post('acctsessionid')."'")
->where('acctsessionid', _post('acctsessionid'))
->findOne(); ->findOne();
if (!$d) { if (!$d) {
$d = ORM::for_table('rad_acct')->create(); $d = ORM::for_table('rad_acct')->create();
@ -292,7 +291,7 @@ try {
$d->dateAdded = date('Y-m-d H:i:s'); $d->dateAdded = date('Y-m-d H:i:s');
$d->save(); $d->save();
if (_post('acctStatusType') == 'Start') { if (_post('acctStatusType') == 'Start') {
$tur = ORM::for_table('tbl_user_recharges')->whereRaw("BINARY username = '$username'")->where('status', 'on')->where('routers', 'radius')->find_one(); $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(); $plan = ORM::for_table('tbl_plans')->where('id', $tur['plan_id'])->find_one();
if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") { if ($plan['limit_type'] == "Data_Limit" || $plan['limit_type'] == "Both_Limit") {
$totalUsage = $d['acctOutputOctets'] + $d['acctInputOctets']; $totalUsage = $d['acctOutputOctets'] + $d['acctInputOctets'];
@ -334,7 +333,7 @@ function process_radiust_rest($tur, $code)
$bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']); $bw = ORM::for_table("tbl_bandwidth")->find_one($plan['id_bw']);
// Count User Onlines // Count User Onlines
$USRon = ORM::for_table('rad_acct') $USRon = ORM::for_table('rad_acct')
->where('username', $tur['username']) ->whereRaw("BINARY username = '".$tur['username']."'")
->where("acctStatusType", 'Start') ->where("acctStatusType", 'Start')
->count(); ->count();
if ($USRon >= $plan['shared_users'] && $plan['type'] == 'Hotspot') { if ($USRon >= $plan['shared_users'] && $plan['type'] == 'Hotspot') {
@ -434,6 +433,5 @@ function show_radius_result($array, $code = 200)
header("HTTP/1.1 204 No Content"); header("HTTP/1.1 204 No Content");
die(); die();
} }
echo json_encode($array); die(json_encode($array));
die();
} }