Move http status pages to this repository
This commit is contained in:
parent
ad98060f9e
commit
d342537a59
24 changed files with 347 additions and 8 deletions
15
http-errors/400.html
Normal file
15
http-errors/400.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bad request · HTTP 400</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Bad request</h1>
|
||||
<p>
|
||||
The request is malformed.
|
||||
</p>
|
||||
<small>HTTP <code>400</code></small>
|
||||
</body>
|
||||
</html>
|
15
http-errors/403.html
Normal file
15
http-errors/403.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Access forbidden · HTTP 403</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Access forbidden</h1>
|
||||
<p>
|
||||
The server refused to process the request for security reasons.
|
||||
</p>
|
||||
<small>HTTP <code>403</code></small>
|
||||
</body>
|
||||
</html>
|
19
http-errors/404.en.html
Normal file
19
http-errors/404.en.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>File not found · HTTP 404</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>File not found</h1>
|
||||
<p>
|
||||
The server did not find anything at the requested address.
|
||||
</p>
|
||||
<ul>
|
||||
<li>The file may have been moved or deleted.</li>
|
||||
<li>Perhaps the address was mistyped.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>404</code></small>
|
||||
</body>
|
||||
</html>
|
19
http-errors/404.fr.html
Normal file
19
http-errors/404.fr.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Fichier introuvable · HTTP 404</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Fichier introuvable</h1>
|
||||
<p>
|
||||
Le serveur n'a rien trouvé à l'adresse demandée.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Le fichier a pu être déplacé ou supprimé.</li>
|
||||
<li>L'adresse a peut-être été mal saisie.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>404</code></small>
|
||||
</body>
|
||||
</html>
|
5
http-errors/404.php
Normal file
5
http-errors/404.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
require 'lib.php';
|
||||
|
||||
echo file_get_contents('404.' . $locale . '.html');
|
15
http-errors/405.html
Normal file
15
http-errors/405.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Method Not Allowed · HTTP 405</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Method Not Allowed</h1>
|
||||
<p>
|
||||
The request method is not supported for this resource.
|
||||
</p>
|
||||
<small>HTTP <code>405</code></small>
|
||||
</body>
|
||||
</html>
|
15
http-errors/410.html
Normal file
15
http-errors/410.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Gone · HTTP 410</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Gone</h1>
|
||||
<p>
|
||||
The requested resource is not available anymore.
|
||||
</p>
|
||||
<small>HTTP <code>410</code></small>
|
||||
</body>
|
||||
</html>
|
15
http-errors/418.html
Normal file
15
http-errors/418.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>I'm a teapot · HTTP 418</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>I'm a teapot</h1>
|
||||
<p>
|
||||
Your coffee cannot be brewed because this server is a teapot.
|
||||
</p>
|
||||
<small>HTTP <code>418</code></small>
|
||||
</body>
|
||||
</html>
|
19
http-errors/500.en.html
Normal file
19
http-errors/500.en.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Server error · HTTP 500</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Server error</h1>
|
||||
<p>
|
||||
The server encountered an error and is unable to satisfy your request.
|
||||
</p>
|
||||
<ul>
|
||||
<li>This error is probably temporary.</li>
|
||||
<li>If it isn't, you can try to contact an administrator.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>500</code></small>
|
||||
</body>
|
||||
</html>
|
19
http-errors/500.fr.html
Normal file
19
http-errors/500.fr.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Erreur du serveur · HTTP 500</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Erreur du serveur</h1>
|
||||
<p>
|
||||
Le serveur a rencontré une erreur et ne peut pas répondre à cette requête.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Cette erreur est probablement temporaire.</li>
|
||||
<li>Si ce n'est pas le cas, vous pouvez contacter ane administrataire.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>500</code></small>
|
||||
</body>
|
||||
</html>
|
5
http-errors/500.php
Normal file
5
http-errors/500.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
require 'lib.php';
|
||||
|
||||
echo file_get_contents('500.' . $locale . '.html');
|
19
http-errors/502.html
Normal file
19
http-errors/502.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bad gateway · HTTP 502</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Bad gateway</h1>
|
||||
<p>
|
||||
The backend server encountered an error and is unable to satisfy your request.
|
||||
</p>
|
||||
<ul>
|
||||
<li>This error is probably temporary.</li>
|
||||
<li>If it isn't, you can try to contact an administrator.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>502</code></small>
|
||||
</body>
|
||||
</html>
|
19
http-errors/503.en.html
Normal file
19
http-errors/503.en.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Service unavailable · HTTP 503</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Service unavailable</h1>
|
||||
<p>
|
||||
The server cannot handle the request, because it is overloaded or down for maintenance.
|
||||
</p>
|
||||
<ul>
|
||||
<li>This error is probably temporary.</li>
|
||||
<li>If it isn't, you can try to contact an administrator.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>503</code></small>
|
||||
</body>
|
||||
</html>
|
19
http-errors/503.fr.html
Normal file
19
http-errors/503.fr.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Service indisponible · HTTP 503</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Service indisponible</h1>
|
||||
<p>
|
||||
Le serveur ne peut pas répondre à cette requête, car il est surchargé ou en cours de maintenance.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Cette erreur est probablement temporaire.</li>
|
||||
<li>Si ce n'est pas le cas, vous pouvez contacter ane administrataire.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>503</code></small>
|
||||
</body>
|
||||
</html>
|
5
http-errors/503.php
Normal file
5
http-errors/503.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
require 'lib.php';
|
||||
|
||||
echo file_get_contents('503.' . $locale . '.html');
|
19
http-errors/504.html
Normal file
19
http-errors/504.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Gateway timeout · HTTP 504</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Gateway timeout</h1>
|
||||
<p>
|
||||
The backend server did not send a timely response.
|
||||
</p>
|
||||
<ul>
|
||||
<li>This error is probably temporary.</li>
|
||||
<li>If it isn't, you can try to contact an administrator.</li>
|
||||
</ul>
|
||||
<small>HTTP <code>504</code></small>
|
||||
</body>
|
||||
</html>
|
15
http-errors/default-domain.html
Normal file
15
http-errors/default-domain.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Broken site</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Broken site</h1>
|
||||
<p>
|
||||
The site you're trying to reach is misconfigured. This domain seems to be pointing to this server, but this server is not aware of a site using this domain.
|
||||
</p>
|
||||
<small>HTTP <code>404</code></small>
|
||||
</body>
|
||||
</html>
|
15
http-errors/default-ip.html
Normal file
15
http-errors/default-ip.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Nothing here</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Nothing here</h1>
|
||||
<p>
|
||||
You reached the default site of this server directly using its IP address. There's nothing for you here.
|
||||
</p>
|
||||
<small>HTTP <code>404</code></small>
|
||||
</body>
|
||||
</html>
|
8
http-errors/index.php
Normal file
8
http-errors/index.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
http_response_code(404);
|
||||
|
||||
if (filter_var(str_replace(['[', ']'], '', $_SERVER['HTTP_HOST']), FILTER_VALIDATE_IP))
|
||||
echo file_get_contents('default-ip.html');
|
||||
else
|
||||
echo file_get_contents('default-domain.html');
|
10
http-errors/lib.php
Normal file
10
http-errors/lib.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
$locale = 'en';
|
||||
foreach (explode(',', preg_replace('/[A-Z0-9]|q=|;|-|\./', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '') as $client_locale)) {
|
||||
if (in_array($client_locale, ['en', 'fr'], true)) {
|
||||
$locale = $client_locale;
|
||||
break;
|
||||
}
|
||||
}
|
||||
header('Content-Language: ' . $locale);
|
23
http-errors/unsecure.en.html
Normal file
23
http-errors/unsecure.en.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>TLS required</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>TLS required</h1>
|
||||
<p>
|
||||
This site does not accept HTTP requests without TLS.
|
||||
</p>
|
||||
<h2>What happened?</h2>
|
||||
<p>
|
||||
You made a request using HTTP without TLS to the server, which refused this for privacy and security reasons, as unsecure HTTP connections can be watched and modified by any device on the way.
|
||||
</p>
|
||||
<h2>How to solve this?</h2>
|
||||
<p>
|
||||
You can replace the URI scheme <code>http</code> by <code>https</code> to tell your client to make the request using TLS.
|
||||
</p>
|
||||
<code>HTTP 403</code>
|
||||
</body>
|
||||
</html>
|
23
http-errors/unsecure.fr.html
Normal file
23
http-errors/unsecure.fr.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Nécessite TLS</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Nécessite TLS</h1>
|
||||
<p>
|
||||
Ce site n'accepte pas les connexions HTTP sans TLS.
|
||||
</p>
|
||||
<h2>Que s'est-il passé ?</h2>
|
||||
<p>
|
||||
Vous avez envoyé une requête HTTP sans TLS au serveur, qui l'a refusée pour des raisons de sécurité et de confidentialité.
|
||||
</p>
|
||||
<h2>Comment régler ce problème ?</h2>
|
||||
<p>
|
||||
Vous pouvez remplacer le schéma d'URI <code>http</code> par <code>https</code> pour indiquer à votre client de faire la requête avec TLS.
|
||||
</p>
|
||||
<code>HTTP 403</code>
|
||||
</body>
|
||||
</html>
|
7
http-errors/unsecure.php
Normal file
7
http-errors/unsecure.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
http_response_code(403);
|
||||
|
||||
require 'lib.php';
|
||||
|
||||
require 'unsecure.' . $locale . '.html';
|
12
router.php
12
router.php
|
@ -4,14 +4,10 @@ define('CONF', parse_ini_file(__DIR__ . '/config.ini', true, INI_SCANNER_TYPED))
|
|||
define('DB', new PDO('sqlite:' . CONF['common']['root_path'] . '/db/servnest.db'));
|
||||
|
||||
$locale = 'en';
|
||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
$client_locales = explode(',', preg_replace('/[A-Z0-9]|q=|;|-|\./', '', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
|
||||
$available_locales = array_diff(scandir('locales'), ['..', '.']);
|
||||
foreach ($client_locales as $client_locale) {
|
||||
if (in_array($client_locale, $available_locales)) {
|
||||
$locale = $client_locale;
|
||||
break;
|
||||
}
|
||||
foreach (explode(',', preg_replace('/[A-Z0-9]|q=|;|-|\./', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '') as $client_locale)) {
|
||||
if (in_array($client_locale, array_diff(scandir('locales'), ['..', '.']), true)) {
|
||||
$locale = $client_locale;
|
||||
break;
|
||||
}
|
||||
}
|
||||
define('LOCALE', $locale);
|
||||
|
|
Loading…
Reference in a new issue