co já vím

Co-authored-by: Bruno Rybársky <bruno@brn.systems>
This commit is contained in:
Richard Mikloš 2024-01-20 18:55:42 +01:00
parent 0bd68c257f
commit a1f5af75bd
5 changed files with 44 additions and 6 deletions

@ -1,3 +1,5 @@
<?php <?php
require_once 'secrets/mysql.php'; require_once 'secrets/mysql.php';
$page_dir = "pages";
$template_dir = "templates";
?> ?>

@ -12,11 +12,31 @@ if (!isset($_SESSION['user_id'])) {
$result = mysqli_query($mysqli, $query); $result = mysqli_query($mysqli, $query);
$user = mysqli_fetch_assoc($result); $user = mysqli_fetch_assoc($result);
// Include the appropriate HTML based on user's status
if ($user['isAdmin'] == 1) { $page = basename($_SERVER['QUERY_STRING']);
include 'pages/index_admin.html'; // Custom HTML for Admin $nav = file_get_contents("$template_dir/navigation.html");
} else {
include 'pages/index_user.html'; // Custom HTML for regular user if(empty($page)){
if ($user['isAdmin'] == 1) {
$page = 'index_admin'; // Custom HTML for Admin
} else {
$page = 'index_user'; // Custom HTML for regular user
}
} }
$page_file = "$page_dir/$page.html";
if (!file_exists($page_file)) {
$page_file = "$template_dir/404.html";
}
ob_start();
include $page_file;
$page_data = ob_get_clean();
$page_data = str_replace("__NAV_TEMPLATE__", $nav, $page_data);
echo $page_data;
} }
?> ?>

@ -7,6 +7,16 @@
<link rel="stylesheet" href="../styles/pages/style.css"> <link rel="stylesheet" href="../styles/pages/style.css">
<link rel="stylesheet" href="../styles/global.css"> <link rel="stylesheet" href="../styles/global.css">
</head> </head>
<nav>
<ul>
<li><a href=""><i class="ri-settings-4-fill"></i></a></li>
<div class="links">
<li><a href=""></a></li>
<li><a href=""></a></li>
<li><a href=""></a></li>
</div>
</ul>
</nav>
<body> <body>
<h2>Welcome</h2> <h2>Welcome</h2>
<?php <?php

@ -1,12 +1,17 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register</title> <title>Register</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/remixicon/4.1.0/remixicon.css"
integrity="sha512-dUOcWaHA4sUKJgO7lxAQ0ugZiWjiDraYNeNJeRKGOIpEq4vroj1DpKcS3jP0K4Js4v6bXk31AAxAxaYt3Oi9xw=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="../styles/pages/register.css"> <link rel="stylesheet" href="../styles/pages/register.css">
<link rel="stylesheet" href="../styles/global.css"> <link rel="stylesheet" href="../styles/global.css">
</head> </head>
<body> <body>
<h2>Register</h2> <h2>Register</h2>
<form action="../register.php" method="post"> <form action="../register.php" method="post">
@ -17,4 +22,5 @@
<a href="/">Already have an account?</a> <a href="/">Already have an account?</a>
</form> </form>
</body> </body>
</html> </html>