asdfgasfg
This commit is contained in:
parent
fc9971a884
commit
ba03dd7cd8
59
index.php
59
index.php
@ -2,51 +2,46 @@
|
|||||||
session_start();
|
session_start();
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
|
$paths_to_check = array();
|
||||||
|
$paths_to_check[] = "pages/global";
|
||||||
|
|
||||||
|
|
||||||
|
$page = basename($_SERVER['QUERY_STRING']);
|
||||||
|
$nav = file_get_contents("$template_dir/navigation.html");
|
||||||
|
|
||||||
|
if(empty($page)){
|
||||||
|
$page = 'index';
|
||||||
|
}
|
||||||
|
|
||||||
// Check if user is logged in
|
// Check if user is logged in
|
||||||
if (!isset($_SESSION['user_id'])) {
|
if (isset($_SESSION['user_id'])) {
|
||||||
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']);
|
|
||||||
$nav = file_get_contents("$template_dir/navigation.html");
|
|
||||||
|
|
||||||
$paths_to_check = array();
|
|
||||||
|
|
||||||
$paths_to_check[] = "pages/global";
|
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
foreach($paths_to_check as $page_dir){
|
foreach($paths_to_check as $page_dir){
|
||||||
$page_file_tmp = "$page_dir/$page.html";
|
$page_file_tmp = "$page_dir/$page.html";
|
||||||
if(file_exists($page_file_tmp)){
|
if(file_exists($page_file_tmp)){
|
||||||
$page_file = $page_file_tmp;
|
$page_file = $page_file_tmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ob_start();
|
|
||||||
include $page_file;
|
|
||||||
$page_data = ob_get_clean();
|
|
||||||
|
|
||||||
$page_data = str_replace("__NAV_TEMPLATE__", $nav, $page_data);
|
|
||||||
|
|
||||||
echo $page_data;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
ob_start();
|
||||||
|
include $page_file;
|
||||||
|
$page_data = ob_get_clean();
|
||||||
|
|
||||||
|
$page_data = str_replace("__NAV_TEMPLATE__", $nav, $page_data);
|
||||||
|
|
||||||
|
echo $page_data;
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user