]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/System.php
Add themed error pages
[friendica.git] / src / Core / System.php
index 83c3dc908167fa6091f304c6e5203a7bd4f03962..e2966a9b0e8df7d69b96fb765a76da40503aad19 100644 (file)
@@ -120,58 +120,17 @@ class System extends BaseObject
        /**
         * @brief Send HTTP status header and exit.
         *
-        * @param integer $val         HTTP status result value
-        * @param array   $description optional message
-        *                             'title' => header title
-        *                             'description' => optional message
-        * @throws InternalServerErrorException
+        * @param integer $val     HTTP status result value
+        * @param string  $message Error message. Optional.
+        * @param string  $content Response body. Optional.
+        * @throws \Exception
         */
-       public static function httpExit($val, $description = [])
+       public static function httpExit($val, $message = '', $content = '')
        {
-               $err = '';
-               if ($val >= 400) {
-                       if (!empty($description['title'])) {
-                               $err = $description['title'];
-                       } else {
-                               $title = [
-                                       '400' => L10n::t('Error 400 - Bad Request'),
-                                       '401' => L10n::t('Error 401 - Unauthorized'),
-                                       '403' => L10n::t('Error 403 - Forbidden'),
-                                       '404' => L10n::t('Error 404 - Not Found'),
-                                       '500' => L10n::t('Error 500 - Internal Server Error'),
-                                       '503' => L10n::t('Error 503 - Service Unavailable'),
-                                       ];
-                               $err = defaults($title, $val, 'Error ' . $val);
-                               $description['title'] = $err;
-                       }
-                       if (empty($description['description'])) {
-                               // Explanations are taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
-                               $explanation = [
-                                       '400' => L10n::t('The server cannot or will not process the request due to an apparent client error.'),
-                                       '401' => L10n::t('Authentication is required and has failed or has not yet been provided.'),
-                                       '403' => L10n::t('The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource, or may need an account.'),
-                                       '404' => L10n::t('The requested resource could not be found but may be available in the future.'),
-                                       '500' => L10n::t('An unexpected condition was encountered and no more specific message is suitable.'),
-                                       '503' => L10n::t('The server is currently unavailable (because it is overloaded or down for maintenance). Please try again later.'),
-                                       ];
-                               if (!empty($explanation[$val])) {
-                                       $description['description'] = $explanation[$val];
-                               }
-                       }
-               }
-
-               if ($val >= 200 && $val < 300) {
-                       $err = 'OK';
-               }
-
                Logger::log('http_status_exit ' . $val);
-               header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
+               header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $message);
 
-               if (isset($description["title"])) {
-                       $tpl = Renderer::getMarkupTemplate('http_status.tpl');
-                       echo Renderer::replaceMacros($tpl, ['$title' => $description["title"],
-                               '$description' => defaults($description, 'description', '')]);
-               }
+               echo $content;
 
                exit();
        }