Files
Siro/backend/ride/driver_scam/get.php
Hamza-Ayed 72eeb24cd7 Fix #18: Exception leak remediation across 87 PHP files
- Replaced all client-facing $e->getMessage() with generic error messages
- Added error_log() with filename prefix to all catch blocks
- Covered jsonError(), echo, and json_encode() response patterns
- Also fixed 2 remaining display_errors=1 and add_invoice.php leak
- Script-assisted fix for 75 files, manual fix for 12 remaining edge cases
2026-06-17 07:48:31 +03:00

49 lines
1.3 KiB
PHP

<?php
require_once __DIR__ . '/../../connect.php';
$driverID = filterRequest("driverID");
// Safety check: ensure driverID is not empty to prevent SQL errors
if (!$driverID) {
jsonError("Driver ID is required");
exit();
}
$sql = "SELECT
DATE(driver_ride_scam.dateCreated) AS date,
CAST(COUNT(driver_ride_scam.id) AS CHAR) AS count
FROM
driver_ride_scam
LEFT JOIN
ride ON ride.id = driver_ride_scam.rideID
AND ride.status = 'Cancel'
WHERE
driver_ride_scam.driverID = :driverID
AND driver_ride_scam.dateCreated >= CURDATE()
AND driver_ride_scam.dateCreated < DATE_ADD(CURDATE(), INTERVAL 1 DAY)
GROUP BY
DATE(driver_ride_scam.dateCreated)
ORDER BY
date DESC";
try {
$stmt = $con->prepare($sql);
$stmt->bindParam(':driverID', $driverID);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!empty($rows)) {
// --- FIX IS HERE ---
// Your Flutter app looks for d['message'].
// We manually create the array with the key "message" to match your app.
echo json_encode(array("status" => "success", "message" => $rows));
} else {
jsonError("No ride scam record found");
}
} catch (PDOException $e) {
error_log("[get.php] " . $e->getMessage());
jsonError("An internal error occurred. Please try again later.");
}
?>