<?php
// Detect environment: local XAMPP vs live cPanel server
$is_local = (strpos($_SERVER['HTTP_HOST'] ?? '', 'localhost') !== false || PHP_SAPI === 'cli');

if ($is_local) {
    // --- Local XAMPP credentials ---
    $host     = 'localhost';
    $dbname   = 'ojt';
    $username = 'root';
    $password = '';
} else {
    // --- Live cPanel credentials ---
    $host     = 'localhost';
    $dbname   = 'nroinet_guardtour';
    $username = 'nroinet_guardtour';
    $password = 'fQZ@wkcRNY8mp7^Y';
}

// Set default timezone (e.g., Asia/Manila for UTC+8)
date_default_timezone_set('Asia/Manila');

// Create connection
$conn = new mysqli($host, $username, $password, $dbname);

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

// Ensure MySQL session also matches the PHP timezone
$conn->query("SET time_zone = '+08:00'");

// Secret key for JWT signing.
define('JWT_SECRET_KEY', 'guard_tour_super_secret_key_2026!');
?>
