vela vecí nove more

This commit is contained in:
Richard Mikloš 2024-01-20 19:04:39 +01:00
parent a1f5af75bd
commit dcefd7944a
5 changed files with 19 additions and 9 deletions

@ -16,18 +16,28 @@ if (!isset($_SESSION['user_id'])) {
$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");
if(empty($page)){ $paths_to_check = array();
if ($user['isAdmin'] == 1) {
$page = 'index_admin'; // Custom HTML for Admin $paths_to_check[] = "pages/global";
} else {
$page = 'index_user'; // Custom HTML for regular user if ($user['isAdmin'] == 1) {
} $paths_to_check[] = "pages/admin";
} }
$page_file = "$page_dir/$page.html"; $paths_to_check[] = "pages/user";
if (!file_exists($page_file)) { if(empty($page)){
$page_file = "$template_dir/404.html"; $page = 'index';
}
$page_file = "$template_dir/404.html";
foreach($paths_to_check as $page_dir){
$page_file_tmp = "$page_dir/$page.html";
if(file_exists($page_file_tmp)){
$page_file = $page_file_tmp;
break;
}
} }
ob_start(); ob_start();
include $page_file; include $page_file;