<?php
// ============================================================
// config.php - FortiGate Dashboard Configuration
// Ubah sesuai cPanel database Anda
// ============================================================

define('DB_HOST', 'localhost');
define('DB_NAME', 'caracuanbiz_fortidash');   // ganti dengan nama database cPanel
define('DB_USER', 'caracuanbiz_fortidash');   // ganti dengan user database cPanel
define('DB_PASS', 'Libra_1995');   // ganti dengan password database

define('ADMIN_PASSWORD', 'Jisamsu@234'); // password admin panel
define('SESSION_NAME', 'fg_dashboard');
define('APP_VERSION', '1.0');
define('APP_TITLE', 'FortiGate Dashboard — mermaid-mrl');

// Trial: berapa lama akun trial bisa akses (dalam jam)
define('TRIAL_DURATION_HOURS', 24);

// Aktifkan/nonaktifkan registrasi mandiri oleh user
define('ALLOW_SELF_REGISTER', true);

ini_set('session.cookie_httponly', 1);
ini_set('session.use_strict_mode', 1);
ini_set('session.cookie_path', '/');
ini_set('session.cookie_samesite', 'Lax');
// Pastikan session save path writable
$_sess_path = sys_get_temp_dir();
if (is_writable($_sess_path)) ini_set('session.save_path', $_sess_path);

function getDB(): PDO {
    static $pdo = null;
    if ($pdo === null) {
        $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]
        );
    }
    return $pdo;
}
