connect($redisHost, $redisPort, 1.5)) { if ($redisPass) $redis->auth($redisPass); $redis->setOption(Redis::OPT_PREFIX, 'intaleq:'); } else { $redis = null; } } } catch (Exception $e) { error_log("[REDIS] Connection failed: " . $e->getMessage()); $redis = null; } // 5. تحميل الـ Services الأساسية require_once __DIR__ . '/Security/EncryptionHelper.php'; require_once __DIR__ . '/Database/Database.php'; require_once __DIR__ . '/Auth/RateLimiter.php'; require_once __DIR__ . '/Auth/JwtService.php'; // لا نحمّل OtpService و FcmService إلا عند الحاجة (Lazy) // 6. تهيئة Encryption Helper العام (للتوافقية) // يتم استخدام .enckey (32 بايت) لتشفير البيانات $encKey = trim(@file_get_contents('/home/intaleq-api/.enckey') ?: ''); if (!$encKey) { $encKey = getenv('ENC_KEY') ?: ''; } if (!$encKey || strlen($encKey) !== 32) { error_log("[FATAL] Encryption key (.enckey) is missing or invalid length (must be 32 bytes)."); http_response_code(500); exit(json_encode(['error' => 'Server configuration error: Encryption key issue'])); } $encryptionHelper = new EncryptionHelper($encKey);