Files
intaleq/loction_server/siro/ride/location/save_behavior.php
T
Hamza-AyedandClaude Opus 5 92dc6b3641 chore: استيراد أولي من سيرو (ecfe7568) — بلا أي تعديل
نسخة كاملة من مستودع سيرو عند ecfe7568 لتكون أساس تطبيق «انطلق».
نُسخ المتعقَّب في git فقط (12,509 ملفاً / 302 م.ب) بـ git archive، لا
`cp -r` — فاستُثنيت تلقائياً مخلفات البناء (build · node_modules ·
.dart_tool · .gradle · Pods ≈ 10.7 غ.ب) وكل ما يستثنيه .gitignore.

هذا الكوميت **بلا أي تعديل عمداً** حتى يكون كل ما يليه فرقاً مقروءاً
مقابل سيرو الأصلي. سيرو نفسه لم يُمسّ.

⚠️ لا يبني بعد: `.env` و`lib/env/env.g.dart` غير متعقَّبين في سيرو (وهذا
صحيح — أسرار لكل مستأجر). كل تطبيق فلاتر هنا يحتاج .env خاصاً بانطلق ثم
توليد env.g.dart عبر build_runner. لا تُنسخ أسرار سيرو.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:10:29 +03:00

59 lines
1.9 KiB
PHP

<?php
include "../../connect.php";
// استلام البيانات من Flutter
$driver_id = filterRequest("driver_id");
$trip_id = filterRequest("trip_id");
$max_speed = filterRequest("max_speed");
$avg_speed = filterRequest("avg_speed");
$hard_brakes = filterRequest("hard_brakes");
$total_distance = filterRequest("total_distance");
$behavior_score = filterRequest("behavior_score");
// تحقق من القيم الأساسية
if (empty($driver_id) || empty($trip_id)) {
// Log the validation error
error_log("Driver Behavior Error: Missing driver_id ($driver_id) or trip_id ($trip_id)");
printFailure("Missing driver_id or trip_id");
exit();
}
try {
// إدخال البيانات في جدول driver_behavior
$stmt = $con->prepare("
INSERT INTO driver_behavior (
driver_id, trip_id, max_speed, avg_speed,
hard_brakes, total_distance, behavior_score
) VALUES (?, ?, ?, ?, ?, ?, ?)
");
$stmt->execute([
$driver_id,
$trip_id,
$max_speed,
$avg_speed,
$hard_brakes,
$total_distance,
$behavior_score
]);
// التحقق من نجاح العملية
if ($stmt->rowCount() > 0) {
printSuccess("Behavior data saved");
} else {
// Log that the query ran but no rows were inserted
error_log("Driver Behavior Warning: Insert executed but 0 rows affected for driver $driver_id");
printFailure("Failed to save data");
}
} catch (PDOException $e) {
// --- THIS IS THE TYPE ERROR LOG YOU ASKED FOR ---
// This records the exact SQL error (e.g., duplicate entry, foreign key fail) to your server log
error_log("Driver Behavior SQL Error: " . $e->getMessage());
// Return a generic error to the app (or $e->getMessage() if debugging)
printFailure("Database Error");
}
exit();
?>