37684-vm/db/config.php
2026-03-01 00:58:25 +00:00

37 lines
1.4 KiB
PHP

<?php
// Generated by install.php or platform setup.
// Attempt to load current configuration
if (!defined('DB_HOST')) {
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_37684');
define('DB_USER', 'app_37684');
define('DB_PASS', '0e6af454-f0c3-4977-9e98-1a4682d0c995');
}
function db() {
static $pdo;
if (!$pdo) {
try {
// First, check if configuration is the default/placeholder which likely won't work elsewhere
if (DB_NAME === 'app_37684' && basename($_SERVER['PHP_SELF']) !== 'install.php' && !file_exists(__DIR__ . '/.install_lock')) {
// Potentially redirect if it's a new environment and we haven't locked it yet
// But safer to just try connection first.
}
$pdo = 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,
]);
} catch (PDOException $e) {
// If connection fails and we are not already on the install page, redirect to install.php
if (basename($_SERVER['PHP_SELF']) !== 'install.php' && !headers_sent()) {
header('Location: install.php');
exit;
}
throw $e;
}
}
return $pdo;
}