<?php
/**
 * Database Configuration
 * 
 * This file contains the database connection setup for the application
 */

// Database Configuration
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'interior_db');

// Create connection
$connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

// Check connection
if ($connection->connect_error) {
    die("Connection failed: " . $connection->connect_error);
}

// Set charset to utf8
$connection->set_charset("utf8");

// Optional: Set timezone
date_default_timezone_set('UTC');

// Skip maintenance mode check for API endpoints
$scriptName = basename($_SERVER['SCRIPT_NAME'] ?? '');
$requestUri = $_SERVER['REQUEST_URI'] ?? '';
if (!(str_contains($requestUri, '/api/') || str_contains($scriptName, 'api'))) {
    require_once __DIR__ . '/maintenance.php';
    enforce_maintenance_mode($connection);
}

?>
