Update: 2026-07-25 18:40:38

This commit is contained in:
Hamza-Ayed
2026-07-25 18:40:38 +03:00
parent 4bbc687c15
commit 8d3e63d1c7
9 changed files with 58 additions and 65 deletions
+1 -6
View File
@@ -43,10 +43,5 @@ foreach ($dailyRides as &$row) {
$row['current_month_rides_count'] = $monthRides['current_month_rides_count']; $row['current_month_rides_count'] = $monthRides['current_month_rides_count'];
} }
// Return result jsonSuccess($dailyRides ?: []);
if ($dailyRides) {
jsonSuccess($dailyRides);
} else {
jsonError("No records found");
}
?> ?>
+28 -34
View File
@@ -3,46 +3,40 @@
require_once __DIR__ . '/../../connect.php'; require_once __DIR__ . '/../../connect.php';
$sql = "SELECT $sql = "SELECT
COUNT(`car_locations`.driver_id) AS driver_count, COUNT(r.id) AS driver_count,
driver.id, d.id,
driver.phone, d.phone,
driver.name_arabic, d.first_name,
MAX(dt.token) AS token d.last_name,
FROM d.name_arabic
`car_locations` FROM driver d
LEFT JOIN driver ON driver.id = car_locations.driver_id LEFT JOIN ride r ON d.id = r.driver_id AND LOWER(r.status) IN ('finished','completed')
LEFT JOIN driverToken dt ON dt.captain_id = driver.id GROUP BY d.id, d.phone, d.first_name, d.last_name, d.name_arabic
WHERE ORDER BY driver_count DESC
`car_locations`.created_at > TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY)) LIMIT 20";
GROUP BY
driver.id
ORDER BY
driver_count DESC
LIMIT 19;
";
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->execute(); $stmt->execute();
if ($stmt->rowCount() > 0) { $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// فك التشفير للحقول الحساسة // فك التشفير للحقول الحساسة
foreach ($rows as &$row) { foreach ($rows as &$row) {
if (!empty($row['phone'])) { if (!empty($row['phone'])) {
$row['phone'] = $encryptionHelper->decryptData($row['phone']); $row['phone'] = $encryptionHelper->decryptData($row['phone']) ?: $row['phone'];
} }
if (!empty($row['name_arabic'])) { if (!empty($row['first_name'])) {
$row['name_arabic'] = $encryptionHelper->decryptData($row['name_arabic']); $row['first_name'] = $encryptionHelper->decryptData($row['first_name']) ?: $row['first_name'];
} }
if (!empty($row['token'])) { if (!empty($row['last_name'])) {
$row['token'] = $encryptionHelper->decryptData($row['token']); $row['last_name'] = $encryptionHelper->decryptData($row['last_name']) ?: $row['last_name'];
} }
if (!empty($row['name_arabic'])) {
$row['name_arabic'] = $encryptionHelper->decryptData($row['name_arabic']) ?: $row['name_arabic'];
} }
jsonSuccess($rows);
} else {
jsonError($message = "No recent driver location activity found");
} }
unset($row);
jsonSuccess($rows);
?> ?>
+1 -8
View File
@@ -18,12 +18,5 @@ $stmt->execute();
// Fetch all records as an associative array // Fetch all records as an associative array
$employee_data = $stmt->fetchAll(PDO::FETCH_ASSOC); $employee_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Check if any records were retrieved jsonSuccess($employee_data ?: []);
if ($employee_data) {
// If records were found, print the data as JSON
jsonSuccess($data = $employee_data);
} else {
// If no records were found, print a failure message
jsonError($message = "No employee records found");
}
?> ?>
@@ -2,7 +2,6 @@
// Admin/v2/quality/blacklist_manager.php // Admin/v2/quality/blacklist_manager.php
require_once __DIR__ . '/../../../connect.php'; require_once __DIR__ . '/../../../connect.php';
require_once __DIR__ . '/../../../encrypt_decrypt.php'; require_once __DIR__ . '/../../../encrypt_decrypt.php';
require_once __DIR__ . '/../security/audit_logs_helper.php'; // إذا كان متاحاً، وإلا سننفذ الإدخال مباشرة
if ($role !== 'admin' && $role !== 'super_admin') { if ($role !== 'admin' && $role !== 'super_admin') {
jsonError("Unauthorized", 403); jsonError("Unauthorized", 403);
+16 -1
View File
@@ -10,7 +10,22 @@ if ($role !== 'admin' && $role !== 'super_admin') {
$driver_id = filterRequest('driver_id'); $driver_id = filterRequest('driver_id');
if (!$driver_id) { if (!$driver_id) {
jsonError("Missing driver_id", 400); try {
$stmt = $con->prepare("SELECT id, first_name, last_name, phone, status FROM driver ORDER BY id DESC LIMIT 20");
$stmt->execute();
$drivers = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($drivers as &$d) {
if (!empty($d['first_name'])) $d['first_name'] = $encryptionHelper->decryptData($d['first_name']) ?: $d['first_name'];
if (!empty($d['last_name'])) $d['last_name'] = $encryptionHelper->decryptData($d['last_name']) ?: $d['last_name'];
if (!empty($d['phone'])) $d['phone'] = $encryptionHelper->decryptData($d['phone']) ?: $d['phone'];
}
unset($d);
jsonSuccess($drivers);
exit;
} catch (Throwable $e) {
jsonSuccess([]);
exit;
}
} }
try { try {
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
require_once __DIR__ . '/../../../connect.php'; require_once __DIR__ . '/../../connect.php';
// 🔥 [Fix Broken Access Control] كان يتحقق من صلاحية التوكن فقط — أي مستخدم // 🔥 [Fix Broken Access Control] كان يتحقق من صلاحية التوكن فقط — أي مستخدم
// مسجّل دخول (راكب/سائق آخر) كان يقدر يجلب بيانات أي سائق مفكوكة التشفير // مسجّل دخول (راكب/سائق آخر) كان يقدر يجلب بيانات أي سائق مفكوكة التشفير
+1 -1
View File
@@ -1,5 +1,5 @@
<?php <?php
require_once __DIR__ . '/../../../connect.php'; require_once __DIR__ . '/../../connect.php';
// 🔥 [Fix Broken Access Control] كان يتحقق من صلاحية التوكن فقط بدون التحقق // 🔥 [Fix Broken Access Control] كان يتحقق من صلاحية التوكن فقط بدون التحقق
// من الدور — أي توكن صالح (حتى راكب) كان يقدر يسحب قائمة السائقين المعلّقين // من الدور — أي توكن صالح (حتى راكب) كان يقدر يسحب قائمة السائقين المعلّقين
+1 -7
View File
@@ -8,11 +8,5 @@ $stmt = $con->prepare($sql);
$stmt->execute(); $stmt->execute();
$passenger_data = $stmt->fetchAll(PDO::FETCH_ASSOC); $passenger_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($passenger_data) { jsonSuccess($passenger_data ?: []);
// Print the passenger data as JSON
jsonSuccess($data = $passenger_data);
} else {
// Print a failure message
jsonError($message = "No passenger data found");
}
?> ?>
+9 -6
View File
@@ -507,13 +507,10 @@
'Contact': 'معلومات الاتصال', 'Contact': 'معلومات الاتصال',
'Click any row to open the full profile': 'اضغط على أي سطر لفتح الملف الشخصي الكامل', 'Click any row to open the full profile': 'اضغط على أي سطر لفتح الملف الشخصي الكامل',
'Search by passenger ID, phone or email': 'البحث برقم الراكب، الهاتف، أو البريد الإلكتروني', 'Search by passenger ID, phone or email': 'البحث برقم الراكب، الهاتف، أو البريد الإلكتروني',
'Search by captain ID, phone or email': 'البحث برقم الكابتن، الهاتف، أو البريد الإلكتروني',
'Search rides by phone number': 'البحث في الرحلات برقم الهاتف', 'Search rides by phone number': 'البحث في الرحلات برقم الهاتف',
'Yes': 'نعم', 'Yes': 'نعم',
'No': 'لا', 'No': 'لا',
'Click any row to open the full profile': 'اضغط على أي سطر لفتح الملف الشخصي الكامل',
'Search rides by phone number': 'بحث في الرحلات برقم الهاتف',
'Search by captain ID, phone or email': 'بحث بمعرّف الكابتن أو البريد الإلكتروني أو الهاتف',
'Search by passenger ID, phone or email': 'بحث بمعرّف الراكب أو البريد الإلكتروني أو الهاتف',
// API error messages // API error messages
' — the endpoint returned HTML, check the API base URL': ' — الـ API أرجع HTML، تحقق من عنوان الخادم', ' — the endpoint returned HTML, check the API base URL': ' — الـ API أرجع HTML، تحقق من عنوان الخادم',
'Session rejected by the server': 'الخادم رفض الجلسة', 'Session rejected by the server': 'الخادم رفض الجلسة',
@@ -3389,12 +3386,18 @@
} }
function humanize(key) { function humanize(key) {
const s = String(key) if (!key) return '';
const rawKey = String(key).trim();
if (lang === 'ar' && AR[rawKey]) return AR[rawKey];
const s = rawKey
.replace(/[_-]+/g, ' ') .replace(/[_-]+/g, ' ')
.replace(/([a-z])([A-Z])/g, '$1 $2') .replace(/([a-z])([A-Z])/g, '$1 $2')
.replace(/\b\w/g, (m) => m.toUpperCase()) .replace(/\b\w/g, (m) => m.toUpperCase())
.trim(); .trim();
return t(key) || t(s) || s;
if (lang === 'ar' && AR[s]) return AR[s];
return s;
} }
function msgNode(text) { function msgNode(text) {