asdfgasfg

This commit is contained in:
Richard Mikloš 2024-01-20 19:10:12 +01:00
parent fc9971a884
commit ba03dd7cd8

@ -2,32 +2,30 @@
session_start(); session_start();
require_once 'config.php'; require_once 'config.php';
// Check if user is logged in $paths_to_check = array();
if (!isset($_SESSION['user_id'])) { $paths_to_check[] = "pages/global";
include 'login.php';
} else {
// Fetch user details
$user_id = $_SESSION['user_id'];
$query = "SELECT * FROM users WHERE id = $user_id";
$result = mysqli_query($mysqli, $query);
$user = mysqli_fetch_assoc($result);
$page = basename($_SERVER['QUERY_STRING']); $page = basename($_SERVER['QUERY_STRING']);
$nav = file_get_contents("$template_dir/navigation.html"); $nav = file_get_contents("$template_dir/navigation.html");
$paths_to_check = array(); if(empty($page)){
$page = 'index';
$paths_to_check[] = "pages/global"; }
// Check if user is logged in
if (isset($_SESSION['user_id'])) {
if ($user['isAdmin'] == 1) { if ($user['isAdmin'] == 1) {
$paths_to_check[] = "pages/admin"; $paths_to_check[] = "pages/admin";
} }
$paths_to_check[] = "pages/user"; $paths_to_check[] = "pages/user";
if(empty($page)){ // Fetch user details
$page = 'index'; $user_id = $_SESSION['user_id'];
$query = "SELECT * FROM users WHERE id = $user_id";
$result = mysqli_query($mysqli, $query);
$user = mysqli_fetch_assoc($result);
} }
$page_file = "$template_dir/404.html"; $page_file = "$template_dir/404.html";
@ -46,7 +44,4 @@ if (!isset($_SESSION['user_id'])) {
$page_data = str_replace("__NAV_TEMPLATE__", $nav, $page_data); $page_data = str_replace("__NAV_TEMPLATE__", $nav, $page_data);
echo $page_data; echo $page_data;
}
?> ?>