aboutsummaryrefslogtreecommitdiff
path: root/_site/includes/modules/errors.php
diff options
context:
space:
mode:
Diffstat (limited to '_site/includes/modules/errors.php')
-rw-r--r--_site/includes/modules/errors.php182
1 files changed, 182 insertions, 0 deletions
diff --git a/_site/includes/modules/errors.php b/_site/includes/modules/errors.php
new file mode 100644
index 0000000..ecb640f
--- /dev/null
+++ b/_site/includes/modules/errors.php
@@ -0,0 +1,182 @@
+<?php
+function customShutdown() {
+ global $debug;
+
+ if (!is_null(error_get_last())) {
+ ob_clean();
+ $d = error_get_last();
+ echo "
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Something went wrong on UnchainedTech 🌙</title>
+ <style>
+
+ @font-face {
+ src: url(\"/font/regular.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: normal;
+ }
+
+ @font-face {
+ src: url(\"/font/italic.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: italic;
+ }
+
+ *, pre {
+ font-family: \"JetBrains Mono\", sans-serif;
+ transition: none !important;
+ }
+
+ nav, * {
+ color: #00ff00 !important;
+ }
+
+ html, body, nav.navbar, .card {
+ background-color: black !important;
+ }
+
+ a:hover {
+ color: black !important;
+ background: #00ff00;
+ }
+
+ pre {
+ background: #00ff00;
+ border-radius: 5px;
+ padding: 10px;
+ color: black !important;
+ text-align: left;
+ }
+
+ @media (min-width: 700px) {
+ pre {
+ margin-left: 25%;
+ margin-right: 25%;
+ }
+ }
+
+ </style>
+</head>
+<body>
+ <div style='margin-top:50px;text-align: center;'>
+ <h1>Something went wrong <small>(like, for real!)</small></h1>
+ <p>An error occured and UnchainedTech cannot load right now. Even us can make mistakes sometimes, and because you are really nice you will <a href='https://jetbrains.minteck.ro.lt:1024/youtrack/newIssue?project=UT' target='_blank'>report this bug</a>.</p>
+ <p>For you, really tech-savvy people, here is that alien language thing you're probably looking for:</p>
+ <pre>
+#99{$d["type"]}: ";
+
+ $pparts = explode(": ", $d["message"]);
+ array_shift($pparts);
+
+ $parts = explode(" in ", implode(": ", $pparts));
+ echo($parts[0]);
+
+ $stp = explode("\nStack trace:", $parts[1]);
+ echo("\n at " . $stp[0]);
+
+ $stlines = explode("\n", $stp[1]);
+ array_shift($stlines);
+
+ foreach ($stlines as $stline) {
+ $stpparts = explode(" ", $stline);
+ array_shift($stpparts);
+ $stline = implode(" ", $stpparts);
+
+ if ($stline !== " thrown" && $stline !== "{main}") {
+ $pp2 = explode("(", $stline);
+ $pp2n = explode(")", $pp2[1]);
+
+ echo("\n at " . $pp2[0] . ":" . $pp2n[0]);
+ } else if ($stline === "{main}") {
+ echo("\n at UnchainedTech.\$Core (UCT Core " . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../version.txt") . ", PHP " . PHP_VERSION . ")");
+ }
+ }
+
+ echo "
+</pre>
+ </div>
+</body>
+</html>
+ ";
+ die();
+ }
+}
+
+function customError($errno, $errstr, $errfile = "&lt;unknown file&gt;", $errline = "&lt;unknown line&gt;") {
+ global $debug;
+
+ ob_clean();
+ echo "
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Something went wrong on UnchainedTech 🌙</title>
+ <style>
+
+ @font-face {
+ src: url(\"/font/regular.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: normal;
+ }
+
+ @font-face {
+ src: url(\"/font/italic.woff2\");
+ font-family: \"JetBrains Mono\";
+ font-style: italic;
+ }
+
+ *, pre {
+ font-family: \"JetBrains Mono\", sans-serif;
+ transition: none !important;
+ }
+
+ nav, * {
+ color: #00ff00 !important;
+ }
+
+ html, body, nav.navbar, .card {
+ background-color: black !important;
+ }
+
+ a:hover {
+ color: black !important;
+ background: #00ff00;
+ }
+
+ pre {
+ background: #00ff00;
+ border-radius: 5px;
+ padding: 10px;
+ color: black !important;
+ text-align: left;
+ }
+
+ @media (min-width: 700px) {
+ pre {
+ margin-left: 25%;
+ margin-right: 25%;
+ }
+ }
+
+ </style>
+</head>
+<body>
+ <div style='margin-top:50px;text-align: center;'>
+ <h1>Something went wrong <small>(like, for real!)</small></h1>
+ <p>An error occured and UnchainedTech cannot load right now. Even us can make mistakes sometimes, and because you are really nice you will <a href='https://jetbrains.minteck.ro.lt:1024/youtrack/newIssue?project=UT' target='_blank'>report this bug</a>.</p>
+ <p>For you, really tech-savvy people, here is that alien language thing you're probably looking for:</p>
+ <pre>
+#{$errno}: {$errstr}
+ at {$errfile}:{$errline}
+ at UnchainedTech.\$Core (UCT Core " . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/../version.txt") . ", PHP " . PHP_VERSION . ")
+</pre>
+ </div>
+</body>
+</html>
+ ";
+ die();
+}
+set_error_handler("customError", E_ALL);
+register_shutdown_function("customShutdown"); \ No newline at end of file