-
Notifications
You must be signed in to change notification settings - Fork 2
/
error.php
42 lines (39 loc) · 1.22 KB
/
error.php
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
31
32
33
34
35
36
37
38
39
40
41
42
<?php
// FILEPATH: /mayurjobanputra/ChatGPT-wrapper-in-PHP-MySQL/error.php
// Get the error code from the query string
$errorCode = $_GET['error'] ?? '9999';
// Define an array of error codes and their corresponding messages
$errorMessages = [
'1000' => 'Error Code 1000. Administrator has been notified.',
'1001' => 'Error Code 1001. Administrator has been notified.',
'1002' => 'Error Code 1002. Administrator has been notified.',
'1003' => 'Error Code 1003. Administrator has been notified.',
'9999' => 'Hello Bot :)',
// Add more error codes and messages as needed
];
// Check if the error code exists in the array
if (array_key_exists($errorCode, $errorMessages)) {
// Display the error message
?>
<!DOCTYPE html>
<html>
<head>
<title>Error Page</title>
</head>
<body>
<?php
echo '<p class="errorcode">' . $errorMessages[$errorCode] . '</p>';
?>
</body>
</html>
<?php
} else {
// Display a generic error message
echo 'Hello BadBot! :)';
}
// Log errors to error.log file
if (isset($_GET['error'])) {
$errorLog = date('Y-m-d H:i:s') . ' - Error ' . $errorCode . PHP_EOL;
file_put_contents('error.log', $errorLog, FILE_APPEND);
}
?>