From 9dbad9cd51a03d328496caeaa563d4574bcad20d Mon Sep 17 00:00:00 2001 From: Ahyan Z Date: Thu, 25 Jun 2026 17:02:33 +0100 Subject: [PATCH] Update config.php --- config.php | 113 +++++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/config.php b/config.php index b1f9d6c..4f538aa 100644 --- a/config.php +++ b/config.php @@ -1,62 +1,65 @@ PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ] + ); +} catch (PDOException $e) { + // If the database connection drops, immediately return a clean JSON error response + // so the patched Instagram 6.20.2 client app doesn't crash or hang. + header('Content-Type: application/json'); + http_response_code(500); + echo json_encode([ + "error" => "Secure cloud database connection error.", + "status" => "fail" + ]); + exit(); } -// 2. Database Connectivity Profiles -// Swap these placeholders with your actual keys from your InfinityFree Client Area -define('DB_HOST', 'sql112.infinityfree.com'); -define('DB_USER', 'if0_42261255'); -define('DB_PASS', '8d1WbfEonq'); -define('DB_NAME', 'if0_42261255_nostolgagram'); +// ==================================================================== +// 3. MEDIA UPLOAD & STORAGE CONFIGURATION (Cloudinary) +// ==================================================================== +// Pull your raw cloudinary:// URL string directly from Vercel's Environment Variables +$cloudinary_env = getenv('CLOUDINARY_URL') ?: 'cloudinary://LOCAL_MOCK_KEY_FOR_TESTING'; -// 3. Cloudinary Edge CDN Credentials -// Swap with your actual cloud account name. The preset matches your unsigned configuration. -define('CLOUDINARY_CLOUD_NAME', 'dnkm8pijh'); -define('CLOUDINARY_UPLOAD_PRESET', 'nostolgagram'); +// Define it as a global constant so your existing media/upload scripts run unchanged +define('CLOUDINARY_URL', $cloudinary_env); -// 4. Global Managed Database Connection Gateway (PDO) -// This function can be safely executed by any file in your directory tree. -function getDB() { - static $dbInstance = null; - - // Reuse existing connection if already established during the request lifecycle - if ($dbInstance !== null) { - return $dbInstance; - } - - try { - $dbInstance = new PDO( - "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=utf8mb4", - DB_USER, - DB_PASS, - [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::ATTR_EMULATE_PREPARES => false, - ] - ); - return $dbInstance; - } catch (PDOException $e) { - // Return structured JSON instead of raw PHP syntax blocks if the database drops - http_response_code(500); - die(json_encode([ - "status" => "fail", - "message" => "Database node offline." - ])); - } -} \ No newline at end of file + +// ==================================================================== +// 4. API UTILITY FUNCTIONS (Optional helper block for your endpoints) +// ==================================================================== +/** + * Standardized function to echo clean JSON responses back to the Instagram app + */ +function sendJsonResponse($data, $status_code = 200) { + header('Content-Type: application/json'); + http_response_code($status_code); + echo json_encode($data); + exit(); +}