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,87 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../connect.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
uploadLog("🚀 [EgyptDocuments/uploadEgyptidFront.php] Egyptian ID front upload started.");
|
||||
|
||||
$rawDriverID = filterRequest("driverID");
|
||||
if (empty($rawDriverID)) {
|
||||
uploadLog("❌ Missing driverID parameter.", 'ERROR');
|
||||
jsonError("driverID is required.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// منع path traversal
|
||||
$driverID = basename($rawDriverID);
|
||||
|
||||
if (isset($_FILES['image'])) {
|
||||
uploadLog('$_FILES[\'image\'] metadata', 'INFO', [
|
||||
'name' => $_FILES['image']['name'] ?? 'unknown',
|
||||
'type' => $_FILES['image']['type'] ?? 'unknown',
|
||||
'size' => $_FILES['image']['size'] ?? 0,
|
||||
'upload_error_code' => $_FILES['image']['error'] ?? UPLOAD_ERR_OK
|
||||
]);
|
||||
} else {
|
||||
uploadLog("No 'image' file was sent in the request.", 'WARNING');
|
||||
}
|
||||
|
||||
if (!isset($_FILES['image']) || $_FILES['image']['error'] !== UPLOAD_ERR_OK) {
|
||||
$err = $_FILES['image']['error'] ?? 'missing_file';
|
||||
uploadLog("❌ File upload validation failed. Code: $err", 'ERROR');
|
||||
jsonError("Image upload failed");
|
||||
exit;
|
||||
}
|
||||
|
||||
$image_file = $_FILES['image'];
|
||||
$allowed_extensions = ['jpg', 'jpeg', 'png'];
|
||||
|
||||
$image_name = $image_file['name'];
|
||||
$image_size = $image_file['size'];
|
||||
$image_extension = strtolower(pathinfo($image_name, PATHINFO_EXTENSION));
|
||||
|
||||
if (!in_array($image_extension, $allowed_extensions, true)) {
|
||||
uploadLog("❌ Invalid image format extension: .$image_extension", 'ERROR');
|
||||
jsonError("Invalid image format");
|
||||
exit;
|
||||
}
|
||||
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mime_type = finfo_file($finfo, $image_file['tmp_name']);
|
||||
finfo_close($finfo);
|
||||
|
||||
$allowed_mime_types = ['image/jpeg', 'image/png', 'image/jpg'];
|
||||
if (!in_array($mime_type, $allowed_mime_types, true)) {
|
||||
uploadLog("❌ Invalid MIME type: $mime_type", 'ERROR');
|
||||
jsonError("Invalid image format (MIME mismatch)");
|
||||
exit;
|
||||
}
|
||||
|
||||
$new_filename = $driverID . '.' . $image_extension;
|
||||
|
||||
$target_dir = __DIR__ . "/egypt/idFront/";
|
||||
if (!is_dir($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_file = $target_dir . $new_filename;
|
||||
|
||||
if (!move_uploaded_file($image_file['tmp_name'], $target_file)) {
|
||||
uploadLog("❌ Failed to save image to target file: $target_file", 'ERROR');
|
||||
jsonError("Failed to save image");
|
||||
exit;
|
||||
}
|
||||
|
||||
// استخدام النطاق من البيئة بدلاً من Host header
|
||||
$domain = getenv('APP_DOMAIN') ?: 'api.siromove.com';
|
||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https" : "http";
|
||||
$image_url = "$protocol://$domain/siro/EgyptDocuments/egypt/idFront/" . $new_filename;
|
||||
|
||||
uploadLog("✅ Egypt ID front uploaded successfully. URL: $image_url");
|
||||
|
||||
printSuccess([
|
||||
"status" => "success",
|
||||
"url" => $image_url,
|
||||
"file_link" => $image_url,
|
||||
"image_url" => $image_url
|
||||
]);
|
||||
Reference in New Issue
Block a user