<?php

// File: dashboard_awal/redirect-kota-salatiga.php

session_start();



// Check if the system is open for this region

require_once "../admin/config.php";

$conn = connectDB();



$sql = "SELECT status FROM status_lomba WHERE name = 'kota_salatiga'";

$result = $conn->query($sql);

$status = ($result && $result->num_rows > 0) ? $result->fetch_assoc()['status'] : 'open';



if ($status == 'closed') {

    // If closed, redirect to main dashboard

    header("Location: index.php?error=closed");

    exit;

}



// Set authorization flag for Kota

$_SESSION['allow_kota_access'] = true;

$_SESSION['last_activity'] = time();



// Redirect ke cabang_lomba_kota

header("Location: ../cabang_lomba_kota/index.php");

exit;

?>
