<?php
session_start();
header('Content-Type: text/html; charset=utf-8');

// Database configuration
define('DB_HOST', 'sql305.infinityfree.com');
define('DB_USER', 'if0_40375409');
define('DB_PASS', 'pDPSp6KEQfub');
define('DB_NAME', 'if0_40375409_aws');

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

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

// Set charset to UTF-8 for Arabic support
$conn->set_charset("utf8");

// Check if captain is logged in
function checkCaptainAuth() {
    if (!isset($_SESSION['captain_id'])) {
        header('Location: login.php');
        exit();
    }
}
?>