<?php
// ============================
// GANTI SESUAI DATA KAMU
// ============================
$npm    = "202343501608";
$nama   = "Ninda Rambu Ndai Ngana";
$kelas  = "Y6K";

// Daftar menu: 'Label' => 'nama_file_di_folder_includes'
$menu = [
    "Hello World"               => "helloworld",
    "Biodata"                   => "biodata",
    "Variabel"                => "variable",
    "Object"                  => "variable_object",
    "Konstanta"                => "constant",
    "Operator Aritmetika"      => "operator_aritmatika",
    "Operator Perbandingan"    => "operator_pembanding",
    "Operator String"          => "operator_string",
    "Kondisi If"                => "if",
    "Kondisi Elseif"            => "if_elseif",
    "Kondisi Switch"             => "switch",
    "While Loop"                 => "while",
    "Do While Loop"              => "do_while",
    "For Loop"                    => "for",
    "Foreach Loop"                => "foreach",
    "Method Get"                   => "method_get",
    "Method Post"                  => "method_post",
    "Form Post"                    => "form_post",
    "Action Post"                  => "action_post",
    "Latihan Biodata"              => "latihan_biodata",
    "Latihan Konversi Nilai"       => "latihan_konversi_nilai",
    "Latihan Tabel"                => "latihan_tabel",
    ];

// Ambil halaman aktif dari URL (?page=xxx), default: biodata
$page = isset($_GET['page']) ? $_GET['page'] : 'biodata';

// Validasi: hanya boleh buka file yang memang ada di daftar menu (biar aman)
$valid = in_array($page, $menu);
$file  = __DIR__ . "/includes/" . $page . ".php";
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <title><?php echo $nama; ?> - Tugas Pemrograman Web</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

    <!-- HEADER HITAM -->
    <div class="topbar">
        <?php echo $npm; ?> - <?php echo $nama; ?>
    </div>

    <div class="wrapper">

        <!-- SIDEBAR MENU -->
        <div class="sidebar">
            <?php foreach ($menu as $label => $slug): ?>
                <a href="?page=<?php echo $slug; ?>"
                class="<?php echo ($slug === $page) ? 'aktif' : ''; ?>">
                    <?php echo $label; ?>
                </a>
            <?php endforeach; ?>
        </div>

        <!-- KOTAK FOTO -->
        <div class="foto-box">
            <img src="fotoku.jpeg" alt="Foto"
                onerror="this.style.display='none'; this.parentNode.innerHTML='Foto';">
        </div>

        <!-- KONTEN UTAMA -->
        <div class="content">
            <?php
        if ($valid && file_exists($file)) {
            include $file; } else {
            echo "Nama: " . $nama . "<br>";
            echo "NPM: " . $npm . "<br>";
            echo "Kelas: " . $kelas;
        }
            ?>
        </div>

    </div>

</body>
</html>