<?php
    if(session_status() == PHP_SESSION_NONE) {
        session_start();
    }
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Kajetans Stuff</title>

        <link rel="icon" href="favicon.png">
        <meta name="viewport" content="width=device-width, maximum-scale=1.0"/>

        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/style.css" rel="stylesheet">
        <link href="css/snuviscript.css" rel="stylesheet">
        <link href="css/brainfuck.css" rel="stylesheet">

        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
        <script src="js/bootstrap.min.js"></script>
    </head>
    <body id="body">
        <nav id="navbar" class="navbar navbar-expand-md">
            <div class="navbar-brand">Kajetans Stuff</div>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#bar" aria-controls="bar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="bar">
                <ul class="navbar-nav ml-auto">
                    <li class="nav-item"><a class="nav-link" href="index.php?section=home">Home</a></li>
                    <li class='nav-item dropdown'>
                        <a class='nav-link dropdown-toggle' href='#' id='snuvi_dropdown' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
                            SnuviScript
                        </a>
                        <div class='dropdown-menu nav_drop' aria-labelledby='snuvi_dropdown'>
                            <a class='dropdown-item nav_drop_item' href='index.php?section=snuvi_core'>Core</a>
                            <a class='dropdown-item nav_drop_item' href='index.php?section=snuvi_supersnuvi'>Super Snuvi</a>
                            <a class='dropdown-item nav_drop_item' href='index.php?section=snuvi_minecraft'>Minecraft</a>
                        </div>
                    </li>
                    <li class="nav-item"><a class="nav-link" href="index.php?section=brainfuck">Brainfuck</a></li>
                    <li class="nav-item"><a class="nav-link" href="index.php?section=fruits">Fruits</a></li>
                    <li class="nav-item"><a class="nav-link" href="index.php?section=endlerbrecer">Endlerbrecer</a></li>
                </ul>
            </div>
        </nav>    
        <main class="container">
            <?php
            if(isset($_GET["section"])) {
                switch ($_GET["section"]) {
                    case "snuvi_core":
                        include "snuvi_core.php";
                        break;
                    case "snuvi_minecraft":
                        include "snuvi_minecraft.php";
                        break;
                    case "snuvi_supersnuvi":
                        include "snuvi_supersnuvi.php";
                        break;
                    case "brainfuck":
                        include "brainfuck.php";
                        break;
                    case "login":
                        include "login.php";
                        break;
                    case "logout":
                        include "logout.php";
                        break;
                    case "fruits":
                        include "fruits.php";
                        break;
                    case "endlerbrecer":
                        include "endlerbrecer.php";
                        break;
                    case "home":
                    default:
                        include "home.php";
                        break;
                }
            } else {
                include "home.php";
            }
            ?>
        </main>
        <footer>
            <span class="footerPipe">Made by Kajetan</span>
            <?php
                if(isset($_SESSION["user"])) {
                    echo "<a class='login' href='index.php?section=logout'>Logout</a>";
                } else {
                    echo "<a class='login' href='index.php?section=login'>Login</a>";
                }
            ?>
        </footer>
    </body>
</html>
