<?php

// File: dashboard_awal/redirect-kab-semarang.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 = 'kab_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;

}



// Set authorization flag for Kabupaten

$_SESSION['allow_kabupaten_access'] = true;

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



// Redirect ke cabang_lomba_kab

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

exit;

?>
