12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- /*
- * Part of Shuzanne - An extensible sequel to an open-source imageboard.
- *
- * @package Shuzanne
- * @author MisleadingName, Shuzanne Contributors
- * @license MPL v2.0
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- */
- namespace app\Exceptions;
- use Exception;
- use JetBrains\PhpStorm\Pure;
- use app\Logger;
- use app\Hajeebtok;
- use Throwable;
- class SecurityFaultException extends Exception
- {
- public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
- {
- Logger::Fatal("Security fault tripped: $message Request details:");
- $incidentId = bin2hex(random_bytes(16));
- $devmode = Hajeebtok::$Config->GetByDotKey("Instance.DebugMode") == "true";
- Logger::Fatal("Incident ID: $incidentId");
- $details = json_encode($_SERVER, JSON_PRETTY_PRINT);
- Logger::Fatal($details);
- $otherDetails = json_encode($_REQUEST, JSON_PRETTY_PRINT);
- Logger::Fatal($otherDetails);
- parent::__construct("Security fault tripped: $message", $code, $previous);
- $details = $devmode ? $details : "Redacted";
- $otherDetails = $devmode ? $otherDetails : "Redacted";
- http_response_code(403);
- CORSHelper();
- die(<<<HTML
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Hajeebtok</title>
- </head>
- <body style="font-family: sans-serif; background-color: #eee; color: #333; padding: 20px;">
- <div style="border: 8px solid #f00; padding: 1em; background-color: #ffff00;">
- <h1 style="margin: 0;">You have triggered a security fault.</h1>
- <p style="margin: 1em 0;">Your request has been terminated, and the incident has been logged. Please contact the site administrator if you believe this was in error.</p>
- <summary>
- <details>
- <p>Message: $message</p>
- <summary>Request details</summary>
- <p>Incident ID: $incidentId</p>
- <pre style="white-space: pre-wrap;">$details</pre>
- <pre style="white-space: pre-wrap;">$otherDetails</pre>
- </details>
- </summary>
- </div>
- <p><a href="javascript:history.back()">Go back</a></p>
- </body>
- </html>
- HTML);
- }
- }
|