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,65 @@
|
||||
<?php
|
||||
// ride_server/intaleq/connect.php
|
||||
// Bootstrap for standalone REST endpoints under ride_server/intaleq/.
|
||||
// Modeled on loction_server/siro/connect.php (the JWT-enforcing variant).
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/load_env.php';
|
||||
|
||||
// .env path mirrors ride_server/passenger_socket.php's own already-deployed
|
||||
// convention on this box — confirm/adjust with ops at deploy time.
|
||||
$env_file = file_exists(__DIR__ . '/../ride-keys/.env')
|
||||
? __DIR__ . '/../ride-keys/.env'
|
||||
: (file_exists('/home/intaleq-rides/env/.env') ? '/home/intaleq-rides/env/.env' : '');
|
||||
if (!empty($env_file)) {
|
||||
loadEnvironment($env_file);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/functions.php';
|
||||
|
||||
// --- CORS + JSON headers ---
|
||||
header("Access-Control-Allow-Origin: https://intaleqapp.com");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization");
|
||||
header('Content-Type: application/json');
|
||||
|
||||
date_default_timezone_set('Asia/Amman');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- JWT auth — enforced. This endpoint returns ride status tied to a
|
||||
// specific passenger/driver, and backend's connect.php enforces JWT for the
|
||||
// same call today; dropping auth here would be a regression. ---
|
||||
$decodedToken = authenticateJWT();
|
||||
$user_id = $decodedToken->sub ?? $decodedToken->user_id ?? null;
|
||||
|
||||
// --- DB connection: same physical database backend's Database::get('main')
|
||||
// resolves to (confirmed distinct from Database::get('ride') — the getRideStatus
|
||||
// endpoint this replaces has always read from 'main', so the fallback query
|
||||
// below stays on 'main' too, for zero behavior change vs. today). Env var
|
||||
// names match backend/core/Database/Database.php's 'main' entry exactly;
|
||||
// falling back to loction_server's simpler names only if ops sets this box
|
||||
// up differently. Actual values must be confirmed/provisioned by ops. ---
|
||||
$dbname = getenv('DB_PRIMARY_NAME_V2') ?: getenv('dbname');
|
||||
$dbhost = getenv('DB_PRIMARY_HOST_V2') ?: 'localhost';
|
||||
$dbuser = getenv('DB_PRIMARY_USER_V2') ?: getenv('USER');
|
||||
$dbpass = getenv('DB_PRIMARY_PASS_V2') ?: getenv('PASS');
|
||||
|
||||
try {
|
||||
$dsn = "mysql:host=$dbhost;dbname=$dbname;charset=utf8mb4";
|
||||
$con = new PDO($dsn, $dbuser, $dbpass, [
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8",
|
||||
PDO::ATTR_TIMEOUT => 5,
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
error_log("[ride_server/connect] DB connection failed: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['status' => 'failure', 'message' => 'A database error occurred.']);
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user