gymrooster_php/html/index.php

33 lines
1.2 KiB
PHP
Executable File

<?php
include __DIR__ . '/../php/auth.php';
ob_start();
$url = $_SERVER['REQUEST_URI'];
$url = preg_replace('/\?.+\=.+/m', '', $url);
if ($url === '/' && !isAuthorized()) {
include __DIR__ . '/../templates/index.html.php';
} elseif ($url === '/' && isAuthorized()) {
header('Location: /dashboard');
} elseif ($url === '/login' && $_SERVER['REQUEST_METHOD'] === "GET" && !isAuthorized()) {
include __DIR__ . '/../templates/login.html.php';
} elseif ($url === '/login' && $_SERVER['REQUEST_METHOD'] === "GET" && isAuthorized()) {
header('Location: /dashboard');
} elseif ($url === '/login' && $_SERVER['REQUEST_METHOD'] === "POST") {
include __DIR__ . '/../php/login.php';
} elseif ($url === '/update' && $_SERVER['REQUEST_METHOD'] === "POST" && isAuthorized()) {
include __DIR__ . '/../php/update.php';
} elseif ($url === '/dashboard' && isAuthorized()) {
include __DIR__ . '/../templates/dashboard.html.php';
} elseif ($url === '/logout') {
include __DIR__ . '/../php/logout.php';
} elseif ($url === '/delete' && isAuthorized()) {
include __DIR__ . '/../php/delete.php';
}
$output = ob_get_clean();
include __DIR__ . '/../templates/layout.html.php';