<?php
// config/config.php

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

// Set default timezone
date_default_timezone_set('Africa/Lagos');

// Environment settings
define('APP_NAME', 'Dar Al-Fikr International Online Academy');

// Dynamically determine base APP_URL for XAMPP (e.g. http://localhost/alfaruq) or CLI
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost:8000';
$scriptDir = isset($_SERVER['SCRIPT_NAME']) ? rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\') : '';
define('APP_URL', $protocol . '://' . $host . $scriptDir);

// Database configuration
define('DB_DRIVER', 'sqlite'); // 'sqlite' or 'mysql'
define('DB_SQLITE_PATH', __DIR__ . '/../database/database.sqlite');

define('DB_HOST', '127.0.0.1');
define('DB_PORT', '3306');
define('DB_NAME', 'alfaruq_academy');
define('DB_USER', 'root');
define('DB_PASS', '');

// Paystack Configuration
define('PAYSTACK_PUBLIC_KEY', getenv('PAYSTACK_PUBLIC_KEY') ?: 'pk_test_demo_dar_al_fikr');
define('PAYSTACK_SECRET_KEY', getenv('PAYSTACK_SECRET_KEY') ?: 'sk_test_demo_dar_al_fikr');

// Error reporting (display errors in dev, log in prod)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Security Headers
if (!headers_sent()) {
    header('X-Content-Type-Options: nosniff');
    header('X-Frame-Options: SAMEORIGIN');
    header('X-XSS-Protection: 1; mode=block');
}
