|
| 1 | +<?php |
| 2 | +$defaultMessages = [ |
| 3 | + 400 => 'Bad Request', |
| 4 | + 401 => 'Unauthorized', |
| 5 | + 403 => 'Forbidden', |
| 6 | + 404 => 'Not Found', |
| 7 | + 405 => 'Method Not Allowed', |
| 8 | + 408 => 'Request Timeout', |
| 9 | + 422 => 'Unprocessable Entity', |
| 10 | + 429 => 'Too Many Requests', |
| 11 | + 500 => 'Internal Server Error', |
| 12 | + 502 => 'Bad Gateway', |
| 13 | + 503 => 'Service Unavailable', |
| 14 | + 504 => 'Gateway Timeout', |
| 15 | +]; |
| 16 | + |
| 17 | +$code = $status ?? 500; |
| 18 | +$messageText = $defaultMessages[$code] ?? 'An unexpected error occurred'; |
| 19 | +?> |
| 20 | + |
1 | 21 | <!DOCTYPE html> |
2 | 22 | <html lang="en"> |
3 | 23 |
|
4 | 24 | <head> |
5 | 25 | <meta charset="UTF-8"> |
6 | 26 | <title> |
7 | 27 | <?= htmlspecialchars($status) ?> |
8 | | - — <?= htmlspecialchars($message ?: 'An unexpected error occurred') ?> |
| 28 | + — <?= htmlspecialchars($messageText) ?> |
9 | 29 | </title> |
10 | 30 | <style> |
11 | 31 | :root { |
|
34 | 54 | font-size: 52px; |
35 | 55 | margin-bottom: 10px; |
36 | 56 | color: #007bff; |
37 | | - /* Codemonster blue */ |
38 | 57 | } |
39 | 58 |
|
40 | 59 | h2 { |
41 | 60 | font-size: 22px; |
42 | 61 | color: #334155; |
43 | | - /* slate-700 */ |
44 | 62 | margin-bottom: 12px; |
45 | 63 | } |
46 | 64 |
|
47 | 65 | p { |
48 | 66 | color: #64748b; |
49 | | - /* slate-500 */ |
50 | 67 | font-size: 16px; |
51 | 68 | } |
52 | 69 |
|
53 | 70 | footer { |
54 | 71 | margin-top: 24px; |
55 | 72 | color: #94a3b8; |
56 | | - /* slate-400 */ |
57 | 73 | font-size: 13px; |
58 | 74 | } |
59 | 75 |
|
60 | | - /* 🌙 Dark theme */ |
61 | 76 | @media (prefers-color-scheme: dark) { |
62 | 77 | body { |
63 | 78 | background: #0a192f; |
64 | | - /* deep navy blue */ |
65 | 79 | color: #e2e8f0; |
66 | 80 | } |
67 | 81 |
|
68 | 82 | h1 { |
69 | 83 | color: #339cff; |
70 | | - /* lighter Codemonster blue */ |
71 | 84 | } |
72 | 85 |
|
73 | 86 | h2 { |
|
86 | 99 | </head> |
87 | 100 |
|
88 | 101 | <body> |
89 | | - <?php |
90 | | - $defaultMessages = [ |
91 | | - 400 => 'Bad Request', |
92 | | - 401 => 'Unauthorized', |
93 | | - 403 => 'Forbidden', |
94 | | - 404 => 'Not Found', |
95 | | - 405 => 'Method Not Allowed', |
96 | | - 408 => 'Request Timeout', |
97 | | - 422 => 'Unprocessable Entity', |
98 | | - 429 => 'Too Many Requests', |
99 | | - 500 => 'Internal Server Error', |
100 | | - 502 => 'Bad Gateway', |
101 | | - 503 => 'Service Unavailable', |
102 | | - 504 => 'Gateway Timeout', |
103 | | - ]; |
104 | | - |
105 | | - $code = $status ?? 500; |
106 | | - $messageText = $message |
107 | | - ?: ($defaultMessages[$code] ?? 'An unexpected error occurred'); |
108 | | - ?> |
109 | | - |
110 | 102 | <div class="container"> |
111 | 103 | <h1><?= htmlspecialchars($code) ?></h1> |
112 | 104 | <h2><?= htmlspecialchars($messageText) ?></h2> |
113 | 105 | <p>Sorry, something went wrong while processing your request.</p> |
114 | | - <footer>Codemonster Annabel</footer> |
| 106 | + <footer>Codemonster Errors</footer> |
115 | 107 | </div> |
116 | 108 | </body> |
117 | 109 |
|
|
0 commit comments