<?php

// File: dashboard_awal/redirect-kota.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_semarang'";

$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;

}



// Simply set a flag that we've gone through the proper channel

$_SESSION['allow_kota_access'] = true;

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



// Redirect to competition page

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

exit;

?>