feat: استيراد كود سيرو إلى تريبز (سيرو @ecfe7568) — بلا تعديل
قرار المالك 2026-07-27: باك إند سيرو PHP هو المعتمد، وتطبيقاته المجرّبة ميدانياً تحل محل إعادة البناء المؤرشفة. سيرو نفسه لم يُمسّ. الخريطة: backend · payment_server · loction_server · ride_server · passenger_server · docker · dashboard · stress_test → الجذر siro_rider → apps/rider siro_driver → apps/driver siro_admin → dashboards/admin siro_service → dashboards/service android_bot → apps/android_bot socialBot → apps/socialBot نُسخ المتعقَّب في git سيرو فقط عبر `git archive` (3,198 ملفاً / ~169 م.ب) لا `cp -r` — فاستُثنيت مخلفات البناء تلقائياً. بلا أي تعديل محتوى عمداً: كل ما يلي يصير فرقاً مقروءاً مقابل المصدر. لم يُستورد وسببه: siromove.com (الموقع التسويقي يبقى marketing/ في تريبز، سيرو فيه 8 ملفات) · docs و planning (تريبز له docs/ الخاص) · deploy.sh (ليس نشراً على سيرفر بل `git add . && git push origin --all` — فخّ في مستودع آخر) · transit_dashboard (بانتظار قرار مصير backend-transit و dashboards/transit-web). ⚠️ لا يبني بعد — ثلاثة نواقص متوقعة ومقصودة: 1. `.env` و `lib/env/env.g.dart` غير متعقَّبين في سيرو (أسرار لكل مستأجر): كل تطبيق فلاتر يحتاج .env خاصاً ثم توليد env.g.dart بـ build_runner. 2. إعدادات Firebase (9 ملفات google-services.json و GoogleService-Info.plist) يستبعدها .gitignore تريبز — ولكل مستأجر مشروع Firebase خاص أصلاً. 3. apps/driver في سيرو يشير إلى `../../Intaleq/packages/get` خارج المستودع → يجب ضمّ الحزم داخله أسوة بـ apps/rider. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
9909d9b4c1
commit
4d8414c96b
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
// =================================================================
|
||||
// ملف: getUpdatedLocationForAdmin.php
|
||||
// =================================================================
|
||||
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
|
||||
header("Content-Type: application/json; charset=UTF-8");
|
||||
|
||||
// تفعيل إظهار الأخطاء لمعرفة مشكلة الكتابة
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
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') {
|
||||
$fileName = 'locations_day.json';
|
||||
$timeCondition = "DATE(created_at) = CURDATE()";
|
||||
} else {
|
||||
$fileName = 'locations_live.json';
|
||||
$freshSeconds = 1200;
|
||||
$timeCondition = "created_at >= NOW() - INTERVAL $freshSeconds SECOND";
|
||||
}
|
||||
|
||||
// تحديد المسار الكامل بدقة
|
||||
$savePath = __DIR__ . '/' . $fileName;
|
||||
|
||||
// === فحص صلاحيات الكتابة ===
|
||||
if (!is_writable(__DIR__)) {
|
||||
// إذا لم تكن هناك صلاحية، سنطبع الخطأ ونوقف التنفيذ
|
||||
echo json_encode([
|
||||
"status" => "error",
|
||||
"message" => "Permission Denied: Cannot write to directory. Please chmod 777 this folder.",
|
||||
"path" => __DIR__
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 1. جلب المواقع
|
||||
$sql_locations = "
|
||||
SELECT t.driver_id,
|
||||
t.latitude AS lat,
|
||||
t.longitude AS lon,
|
||||
t.heading,
|
||||
t.speed,
|
||||
t.created_at
|
||||
FROM car_tracks t
|
||||
INNER JOIN (
|
||||
SELECT driver_id, MAX(id) AS max_id
|
||||
FROM car_tracks
|
||||
WHERE $timeCondition
|
||||
GROUP BY driver_id
|
||||
) latest
|
||||
ON t.id = latest.max_id
|
||||
ORDER BY t.created_at DESC
|
||||
";
|
||||
$stmt = $con_tracking->prepare($sql_locations);
|
||||
$stmt->execute();
|
||||
$locations = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// 2. جلب بيانات السائقين
|
||||
$driver_ids = array_unique(array_column($locations, 'driver_id'));
|
||||
$drivers_info = [];
|
||||
|
||||
if (!empty($driver_ids)) {
|
||||
$placeholders = implode(',', array_fill(0, count($driver_ids), '?'));
|
||||
$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) {
|
||||
$drivers_info[$row['id']] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. الدمج
|
||||
$final_drivers = [];
|
||||
foreach ($locations as $loc) {
|
||||
$d_id = $loc['driver_id'];
|
||||
$merged = [
|
||||
'id' => $d_id,
|
||||
'lat' => $loc['lat'],
|
||||
'lon' => $loc['lon'],
|
||||
'heading' => $loc['heading'],
|
||||
'speed' => $loc['speed'],
|
||||
'name' => 'Unknown',
|
||||
'phone' => '',
|
||||
'completed' => 0,
|
||||
'cancelled' => 0
|
||||
];
|
||||
|
||||
if (isset($drivers_info[$d_id])) {
|
||||
$info = $drivers_info[$d_id];
|
||||
// فك التشفير البسيط (تأكد من عمل encryptionHelper)
|
||||
if (isset($encryptionHelper)) {
|
||||
try { $info['first_name'] = $encryptionHelper->decryptData($info['first_name']); } catch(Exception $e){}
|
||||
try { $info['last_name'] = $encryptionHelper->decryptData($info['last_name']); } catch(Exception $e){}
|
||||
try { $info['phone'] = $encryptionHelper->decryptData($info['phone']); } catch(Exception $e){}
|
||||
}
|
||||
|
||||
$merged['name'] = trim(($info['first_name']??'') . ' ' . ($info['last_name']??''));
|
||||
$merged['phone'] = $info['phone'] ?? '';
|
||||
$merged['completed'] = $info['completed'] ?? 0;
|
||||
$merged['cancelled'] = $info['cancelled'] ?? 0;
|
||||
}
|
||||
$final_drivers[] = $merged;
|
||||
}
|
||||
|
||||
// 4. الحفظ
|
||||
$jsonContent = json_encode(['drivers' => $final_drivers, 'last_updated' => date('Y-m-d H:i:s')], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
// محاولة الحفظ
|
||||
if (file_put_contents($savePath, $jsonContent) !== false) {
|
||||
echo json_encode(["status" => "success", "message" => "File written successfully to $savePath"]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Failed to write file. Check permissions."]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(["status" => "error", "message" => "An internal error occurred"]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user