Modifications sur les pages d'erreur

This commit is contained in:
Yohann 2019-09-02 21:19:21 +02:00
parent 273bd05944
commit 946d261c71
8 changed files with 29 additions and 51 deletions

View File

@ -1,5 +1,5 @@
ErrorDocument 403 /tfjm/403.php ErrorDocument 403 /tfjm/server_files/403.php
ErrorDocument 404 /tfjm/404.php ErrorDocument 404 /tfjm/server_files/404.php
Options +FollowSymlinks Options +FollowSymlinks
Options -Indexes Options -Indexes

18
403.php
View File

@ -1,18 +0,0 @@
<?php
include_once "server_files/config.php";
include_once "server_files/header.php";
http_response_code(403);
?>
<h1>Vous n'êtes pas autorisé à accéder à cette page.</h1>
<?php
include "server_files/footer.php";
exit();
?>

18
404.php
View File

@ -1,18 +0,0 @@
<?php
include_once "server_files/config.php";
include_once "server_files/header.php";
http_response_code(404);
?>
<h1>Cette page n'existe pas.</h1>
<?php
include "server_files/footer.php";
exit();
?>

12
server_files/403.php Normal file
View File

@ -0,0 +1,12 @@
<?php
include_once "config.php";
include_once "header.php";
http_response_code(403);
echo "<h1>Vous n'êtes pas autorisé à accéder à cette page.</h1>";
include "footer.php";
exit();

12
server_files/404.php Normal file
View File

@ -0,0 +1,12 @@
<?php
include_once "config.php";
include_once "header.php";
http_response_code(404);
echo "<h1>Cette page n'existe pas.</h1>";
include "footer.php";
exit();

View File

@ -56,13 +56,3 @@ function echo_date($date = NULL, $with_time = false) {
return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date)); return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
} }
function error403() {
include "../403.php";
}
function error404() {
include "../404.php";
}
?>

View File

@ -11,7 +11,7 @@ if (isset($_POST["validate"])) {
$team_data = $DB->query("SELECT * FROM `teams` WHERE `trigram` = '$trigram' AND `year` = $YEAR;")->fetch(); $team_data = $DB->query("SELECT * FROM `teams` WHERE `trigram` = '$trigram' AND `year` = $YEAR;")->fetch();
if ($team_data === false) if ($team_data === false)
error404(); include "404.php";
$tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch(); $tournament_data = $DB->query("SELECT `name`, `date_start` FROM `tournaments` WHERE `id` = '" . $team_data["tournament"] . "' AND `year` = '$YEAR';")->fetch();

View File

@ -3,14 +3,14 @@
include "config.php"; include "config.php";
if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ORGANIZER" && $_SESSION["role"] != "ADMIN") { if (!isset($_SESSION["role"]) || $_SESSION["role"] != "ORGANIZER" && $_SESSION["role"] != "ADMIN") {
error403(); include "403.php";
} }
$id = $_GET["id"]; $id = $_GET["id"];
$user_data = $DB->query("SELECT * FROM `users` WHERE `id` = $id;")->fetch(); $user_data = $DB->query("SELECT * FROM `users` WHERE `id` = $id;")->fetch();
if ($user_data === false) { if ($user_data === false) {
error404(); include "404.php";
} }
$team_data = false; $team_data = false;