|
7 | 7 |
|
8 | 8 | class UnitySite
|
9 | 9 | {
|
10 |
| - public static function die() |
| 10 | + public static function die($x = null, $show_user = false) |
11 | 11 | {
|
12 |
| - if (CONFIG["site"]["allow_die"]) { |
13 |
| - die(); |
| 12 | + if (CONFIG["site"]["allow_die"] == false) { |
| 13 | + if (is_null($x)) { |
| 14 | + throw new NoDieException(); |
| 15 | + } else { |
| 16 | + throw new NoDieException($x); |
| 17 | + } |
14 | 18 | } else {
|
15 |
| - throw new NoDieException(); |
| 19 | + if (!is_null($x) and $show_user) { |
| 20 | + die($x); |
| 21 | + } else { |
| 22 | + die(); |
| 23 | + } |
16 | 24 | }
|
17 | 25 | }
|
18 | 26 |
|
@@ -99,23 +107,23 @@ public static function badRequest($message, $error = null, $data = null)
|
99 | 107 | $errorid = uniqid();
|
100 | 108 | self::errorLog("bad request", $message, $errorid, $error, $data);
|
101 | 109 | self::errorToUser("Invalid requested action or submitted data.", 400, $errorid);
|
102 |
| - self::die(); |
| 110 | + self::die($message); |
103 | 111 | }
|
104 | 112 |
|
105 | 113 | public static function forbidden($message, $error = null, $data = null)
|
106 | 114 | {
|
107 | 115 | $errorid = uniqid();
|
108 | 116 | self::errorLog("forbidden", $message, $errorid, $error, $data);
|
109 | 117 | self::errorToUser("Permission denied.", 403, $errorid);
|
110 |
| - self::die(); |
| 118 | + self::die($message); |
111 | 119 | }
|
112 | 120 |
|
113 | 121 | public static function internalServerError($message, $error = null, $data = null)
|
114 | 122 | {
|
115 | 123 | $errorid = uniqid();
|
116 | 124 | self::errorLog("internal server error", $message, $errorid, $error, $data);
|
117 | 125 | self::errorToUser("An internal server error has occurred.", 500, $errorid);
|
118 |
| - self::die(); |
| 126 | + self::die($message); |
119 | 127 | }
|
120 | 128 |
|
121 | 129 | // https://www.php.net/manual/en/function.register-shutdown-function.php
|
|
0 commit comments