24 lines
761 B
PHP
24 lines
761 B
PHP
<?php
|
|
|
|
// When the user requests something unexpected
|
|
function userError($msg) {
|
|
http_response_code(403);
|
|
echo "<p><strong>Erreur utilisataire</strong> : <em>" . $msg . "</em></p>";
|
|
closeHTML();
|
|
}
|
|
|
|
// When the system did something unexpected
|
|
function serverError($msg) {
|
|
http_response_code(500);
|
|
error_log("Niver internal error: " . strip_tags($msg));
|
|
echo "<p><strong>Server error</strong>: The server encountered an error: <em>" . $msg . "</em></p>";
|
|
closeHTML();
|
|
}
|
|
|
|
// For use in pages that first display a form and then process it
|
|
function switchToFormProcess($requireLogin = true) {
|
|
if (empty($_POST))
|
|
closeHTML();
|
|
if ($requireLogin AND !isset($_SESSION['username']))
|
|
userError("Vous devez être connecté·e pour effectuer cette action.");
|
|
}
|