<?php
// Application configuration
define('APP_NAME', 'UpTours - Gestion Hajj & Omra');
define('APP_VERSION', '1.0.0');
define('APP_URL', '/uptours');
define('APP_ROOT', dirname(__DIR__));
define('UPLOAD_DIR', APP_ROOT . '/uploads/');
define('DOCUMENTS_DIR', APP_ROOT . '/uploads/documents/');
define('PHOTOS_DIR', APP_ROOT . '/uploads/photos/');

// Session configuration
ini_set('session.cookie_httponly', 1);
ini_set('session.use_strict_mode', 1);
session_start();

// Error reporting
error_reporting(E_ALL);
ini_set('display_errors', 0);
ini_set('log_errors', 1);

// Timezone
date_default_timezone_set('Africa/Casablanca');

// Prevent caching for dynamic pages
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

// Create upload directories
$dirs = [UPLOAD_DIR, DOCUMENTS_DIR, PHOTOS_DIR];
foreach ($dirs as $dir) {
    if (!is_dir($dir)) {
        mkdir($dir, 0755, true);
    }
}

// Autoload helpers
require_once __DIR__ . '/database.php';
require_once APP_ROOT . '/includes/functions.php';
require_once APP_ROOT . '/includes/auth.php';

// Start output buffering to prevent header errors
ob_start();
