admin 11
This commit is contained in:
@@ -4,17 +4,47 @@ require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$phone = filterRequest("phone");
|
||||
|
||||
// Encrypt phone
|
||||
$encphone = $encryptionHelper->encryptData($phone);
|
||||
// تنظيف الرقم من أي مسافات أو رموز زائدة
|
||||
$phone = preg_replace('/[^0-9]/', '', $phone);
|
||||
|
||||
// احتمالات الرقم (بالصفر الدولي أو بدونه)
|
||||
$phoneVariants = [];
|
||||
$phoneVariants[] = $phone; // كما هو (مثلاً 0992952235)
|
||||
|
||||
if (str_starts_with($phone, '0')) {
|
||||
$phoneVariants[] = '963' . substr($phone, 1); // تحويل 09 إلى 9639
|
||||
} elseif (str_starts_with($phone, '963')) {
|
||||
$phoneVariants[] = '0' . substr($phone, 3); // تحويل 9639 إلى 09
|
||||
}
|
||||
|
||||
// Encrypt each variant to see if any match the encrypted column
|
||||
$encVariants = [];
|
||||
foreach ($phoneVariants as $v) {
|
||||
$encVariants[] = $encryptionHelper->encryptData($v);
|
||||
}
|
||||
|
||||
error_log("[GIFT_CHECK] Received Phone: " . $phone);
|
||||
error_log("[GIFT_CHECK] Encrypted Phone: " . $encphone);
|
||||
error_log("[GIFT_CHECK] Variants: " . implode(', ', $phoneVariants));
|
||||
|
||||
$sql = "SELECT * FROM `driver` WHERE phone = :encPhone OR phone = :rawPhone";
|
||||
// بناء استعلام يبحث عن كل الاحتمالات (المشفرة وغير المشفرة)
|
||||
$placeholders = [];
|
||||
$params = [];
|
||||
|
||||
foreach ($encVariants as $i => $ev) {
|
||||
$placeholders[] = "phone = :enc$i";
|
||||
$params[":enc$i"] = $ev;
|
||||
}
|
||||
foreach ($phoneVariants as $i => $pv) {
|
||||
$placeholders[] = "phone = :raw$i";
|
||||
$params[":raw$i"] = $pv;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM `driver` WHERE " . implode(" OR ", $placeholders);
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':encPhone', $encphone, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':rawPhone', $phone, PDO::PARAM_STR);
|
||||
foreach ($params as $key => $val) {
|
||||
$stmt->bindValue($key, $val);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
|
||||
23
debug_phone.php
Normal file
23
debug_phone.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/connect.php';
|
||||
|
||||
$searchPhone = '0992952235';
|
||||
echo "Searching for: $searchPhone\n";
|
||||
|
||||
$variants = [$searchPhone, '963' . substr($searchPhone, 1), '+963' . substr($searchPhone, 1)];
|
||||
|
||||
foreach ($variants as $v) {
|
||||
echo "Checking variant: $v\n";
|
||||
$enc = $encryptionHelper->encryptData($v);
|
||||
|
||||
$stmt = $con->prepare("SELECT id, phone, first_name FROM driver WHERE phone = ? OR phone = ?");
|
||||
$stmt->execute([$v, $enc]);
|
||||
$res = $stmt->fetch();
|
||||
|
||||
if ($res) {
|
||||
echo "FOUND! ID: {$res['id']}, Name: {$res['first_name']}, Phone in DB: {$res['phone']}\n";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
echo "NOT FOUND in driver table.\n";
|
||||
@@ -13,6 +13,10 @@ error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
try {
|
||||
// البدء بالاتصال بقواعد البيانات المطلوبة
|
||||
$con_tracking = Database::get('tracking');
|
||||
$con_ride = Database::get('ride');
|
||||
// $con (main) تم تعريفه بالفعل في connect.php
|
||||
$mode = isset($_GET['mode']) && $_GET['mode'] == 'day' ? 'day' : 'live';
|
||||
|
||||
if ($mode == 'day') {
|
||||
@@ -66,10 +70,7 @@ try {
|
||||
|
||||
if (!empty($driver_ids)) {
|
||||
$placeholders = implode(',', array_fill(0, count($driver_ids), '?'));
|
||||
$sql_drivers = "SELECT id, first_name, last_name, phone,
|
||||
(SELECT COUNT(*) FROM ride WHERE driver_id = driver.id AND status = 'Completed') as completed,
|
||||
(SELECT COUNT(*) FROM ride WHERE driver_id = driver.id AND status = 'CancelFromDriverAfterApply') as cancelled
|
||||
FROM driver WHERE id IN ($placeholders)";
|
||||
$sql_drivers = "SELECT id, first_name, last_name, phone FROM driver WHERE id IN ($placeholders)";
|
||||
$stmt_drivers = $con->prepare($sql_drivers);
|
||||
$stmt_drivers->execute(array_values($driver_ids));
|
||||
foreach ($stmt_drivers->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
Reference in New Issue
Block a user