blob: 76ca52307b8d26ce505a65f4bcdebc010ea830c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/../lib/utils.php';
function generate_alert(string $redirect, string|null $message, int $code = 200, mixed $data = null)
{
if (IS_JSON_REQUEST) {
json_response($data, $message, $code);
} else if (isset($message)) {
header("Location: $redirect" . (str_contains($redirect, "?") ? "&" : "?") . "es=$code&er=" . urlencode($message));
} else {
header("Location: $redirect");
}
}
function display_alert()
{
if (!isset($_GET["es"], $_GET["er"])) {
return;
}
$status = $_GET["es"];
$reason = urldecode($_GET['er']);
$ok = substr($status, 0, 1) == '2';
echo '' ?>
<section class="box alert<?= !$ok ? ' red' : '' ?>">
<p><?= $reason ?></p>
</section>
<?php ;
}
|