fix(public) better structure
This commit is contained in:
2
components/structure/footer.php
Normal file
2
components/structure/footer.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||||
<script src="https://kit.fontawesome.com/440009238d.js" crossorigin="anonymous"></script>
|
||||
14
components/structure/header.php
Normal file
14
components/structure/header.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Subway schedules</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||
<?php
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
echo '<link href="assets/css/login.css" rel="stylesheet">';
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body style="display:block;">
|
||||
34
components/structure/main.php
Normal file
34
components/structure/main.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include __DIR__ . '/../../config.php';
|
||||
|
||||
$page = basename($_SERVER['PHP_SELF']);
|
||||
if (!isset($_SESSION['user_id']) && $page !== 'login.php' && $page !== 'register.php') {
|
||||
header("Location: login.php");
|
||||
exit();
|
||||
} else if (isset($_SESSION['user_id']) && ($page === 'login.php' || $page === 'register.php')) {
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
include 'header.php';
|
||||
include 'navbar.php';
|
||||
include __DIR__ . '/../../services/db.php';
|
||||
|
||||
?>
|
||||
|
||||
<main class="container mt-4">
|
||||
<?php include $content; ?>
|
||||
</main>
|
||||
|
||||
<?php include 'footer.php'; ?>
|
||||
|
||||
<script>
|
||||
window.addEventListener('load', function() {
|
||||
document.body.style.display = 'block';
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
37
components/structure/navbar.php
Normal file
37
components/structure/navbar.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php if (isset($_SESSION['user_id'])) : ?>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img src="assets/logo/dark.png" alt="" width="64">
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo ($_SERVER['REQUEST_URI'] == '/') ? 'active' : ''; ?>" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo ($_SERVER['REQUEST_URI'] == '/navigate.php') ? 'active' : ''; ?>" href="/navigate.php">Discover</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php echo ($_SERVER['REQUEST_URI'] == '/account.php') ? 'active' : ''; ?>" href="/account.php">Account</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/logout.php"><i class="fa fa-sign-out"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="d-flex">
|
||||
<?php if(isset($_SESSION['is_admin']) && $_SESSION['is_admin']): ?>
|
||||
<a class="btn btn-primary" href="/admin.php">Admin</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user