<?php
require __DIR__ . "/required.php";
header("Content-Type: text/html; charset=utf-8");

require_once __DIR__ . "/pages.php";

$pageid = "home";
if (!is_empty($_GET['page'])) {
    $pg = strtolower($_GET['page']);
    $pg = preg_replace('/[^0-9a-z_]/', "", $pg);
    if (array_key_exists($pg, PAGES) && file_exists(__DIR__ . "/pages/" . $pg . ".php")) {
        $pageid = $pg;
    } else {
        $pageid = "404";
    }
}
?>
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Netsyms Business Accelerator</title>
<link href="assets/bootstrap.materia.min.css" rel="stylesheet" />
<link href="assets/material-color.min.css" rel="stylesheet" />
<link href="assets/app.css" rel="stylesheet" />
<link href="assets/fa-svg-with-js.css" rel="stylesheet">
<script nonce="<?php echo $SECURE_NONCE; ?>">
	FontAwesomeConfig = {autoAddCss: false}
</script>

<?php
    // Adjust as needed
    $navbar_breakpoint = "sm";
    // For mobile app
    echo "<script nonce=\"$SECURE_NONCE\">var navbar_breakpoint = \"$navbar_breakpoint\";</script>"
?>
<nav class="navbar navbar-expand-<?php echo $navbar_breakpoint; ?> navbar-dark bg-indigo fixed-top">
	<button class="navbar-toggler my-0 py-0" type="button" data-toggle="collapse" data-target="#navbar-collapse" aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle navigation">
		<span class="navbar-toggler-icon"></span>
	</button>
	<a class="navbar-brand py-0 mr-auto" href="index.php">
		<img src="assets/logo.svg" alt="" class="d-none d-<?php echo $navbar_breakpoint; ?>-inline brand-img py-0" />
		Business Accelerator
	</a>
	<div class="collapse navbar-collapse py-0" id="navbar-collapse">
		<div class="navbar-nav mr-auto py-0">
			<?php
            $curpagefound = false;
            foreach (PAGES as $id => $pg) {
                if ($pg['navbar'] === TRUE) {
                    if ($pageid == $id) {
                        $curpagefound = true;
                        ?>
                            <span class="nav-item py-<?php echo $navbar_breakpoint; ?>-0 active">
                        <?php } else { ?>
                            <span class="nav-item py-<?php echo $navbar_breakpoint; ?>-0">
                        <?php } ?>
                            <a class="nav-link py-<?php echo $navbar_breakpoint; ?>-0" href="index.php?page=<?php echo $id; ?>">
		                        <?php
				                    if (isset($pg['icon'])) {
				                    ?><i class="<?php echo $pg['icon']; ?> fa-fw"></i> <?php
				                    }
				                    echo $pg['title'];
		                        ?>
                            </a>
                        </span>
                        <?php
                        }
                    }
                    ?>
		</div>
		<div class="navbar-nav ml-auto py-0" id="navbar-right">
			<span class="nav-item py-md-0">
				<a class="nav-link py-md-0" href="https://support.netsyms.com">
					<i class="fas fa-life-ring fa-fw"></i> Get Support
				</a>
			</span>
		</div>
	</div>
</nav>

<div class="container" id="main-content">
<div>
<?php
	include_once __DIR__ . '/pages/' . $pageid . ".php";
?>
</div>
	<div class="footer">
		<?php echo FOOTER_TEXT; ?><br />
		Copyright &copy; <?php echo date('Y'); ?> <?php echo COPYRIGHT_NAME; ?>
	</div>
</div>

<script nonce="<?php echo $SECURE_NONCE; ?>" src="assets/fontawesome-all.min.js"></script>
