nostolgagram/config.php
2026-06-24 21:39:10 +01:00

62 lines
No EOL
2.2 KiB
PHP

<?php
/**
* NostolgaGram Configuration Hub v1.0
* Architecture: InfinityFree Core Matrix + Cloudinary CDN Processing
*/
// 1. Universal Security and Client Handshake Headers
// Crucial for allowing old Android clients to connect without CORS errors
header('Content-Type: application/json; charset=utf-8');
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, DELETE");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
// Handle preflight OPTIONS requests instantly before they reach feature files
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
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. 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');
// 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."
]));
}
}