48 lines
799 B
PHP
48 lines
799 B
PHP
<?php
|
|
|
|
unset($error);
|
|
|
|
if (isset($_GET['page'])) {
|
|
$page = $_GET['page'];
|
|
} elseif (isset($_POST['page'])) {
|
|
$page = $_POST['page'];
|
|
} else {
|
|
$page = 'front';
|
|
}
|
|
|
|
session_start();
|
|
|
|
if ( !isset($_SESSION['user_id']) && ($page !== 'login' && $page !== 'register') ) {
|
|
header('Location: index.php?page=login');
|
|
exit();
|
|
}
|
|
|
|
if ( isset($_SESSION['username']) ) {
|
|
$user = htmlspecialchars($_SESSION['username']);
|
|
}
|
|
|
|
if (isset($error)) {
|
|
echo "<div class=\"error\">Error: $error</div>";
|
|
}
|
|
|
|
$allowed_urls = [
|
|
'front',
|
|
'login',
|
|
'logout',
|
|
'register',
|
|
'profile',
|
|
'config',
|
|
];
|
|
|
|
include 'templates/header.php';
|
|
|
|
if (in_array($page, $allowed_urls)) {
|
|
include "pages/{$page}.php";
|
|
} else {
|
|
include 'pages/front.php';
|
|
}
|
|
|
|
include 'templates/footer.php';
|
|
|
|
?>
|