diff --git a/core/polyfills.php b/core/polyfills.php index ad62b2ec..50831343 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -834,20 +834,20 @@ function get_class_from_file(string $file): string return $class; } -function stringer($s) { - if(is_array($s)) { - if(isset($s[0])) { +function stringer($s) +{ + if (is_array($s)) { + if (isset($s[0])) { return "[" . implode(", ", array_map("stringer", $s)) . "]"; - } - else { + } else { $pairs = []; - foreach($s as $k=>$v) { + foreach ($s as $k=>$v) { $pairs[] = "\"$k\"=>" . stringer($v); } return "[" . implode(", ", $pairs) . "]"; } } - if(is_string($s)) { + if (is_string($s)) { return "\"$s\""; // FIXME: handle escaping quotes } return (string)$s; diff --git a/core/user.php b/core/user.php index 26080466..e1976cca 100644 --- a/core/user.php +++ b/core/user.php @@ -242,12 +242,12 @@ class User public function check_auth_token(): bool { return (isset($_POST["auth_token"]) && $_POST["auth_token"] == $this->get_auth_token()); - } + } - public function ensure_authed(): void - { - if(!$this->check_auth_token()) { - die("Invalid auth token"); - } + public function ensure_authed(): void + { + if (!$this->check_auth_token()) { + die("Invalid auth token"); + } } } diff --git a/core/util.php b/core/util.php index 3719c4a1..d19c68f8 100644 --- a/core/util.php +++ b/core/util.php @@ -1,5 +1,6 @@ getTrace()); - foreach($t as $n => $f) { - $c = $f['class'] ?? ''; - $t = $f['type'] ?? ''; - $a = implode(", ", array_map("stringer", $f['args'])); - print("$n: {$f['file']}({$f['line']}): {$c}{$t}{$f['function']}({$a})\n"); - } + print("Trace: "); + $t = array_reverse($e->getTrace()); + foreach ($t as $n => $f) { + $c = $f['class'] ?? ''; + $t = $f['type'] ?? ''; + $a = implode(", ", array_map("stringer", $f['args'])); + print("$n: {$f['file']}({$f['line']}): {$c}{$t}{$f['function']}({$a})\n"); + } - print("Message: $message\n"); + print("Message: $message\n"); - if(isset($e->query)) { - print("Query: {$e->query}\n"); - } + if (isset($e->query)) { + print("Query: {$e->query}\n"); + } - print("Version: $version (on $phpver)\n"); - } - else { - $q = (!isset($e->query) || is_null($e->query)) ? "" : "
Query: " . html_escape($e->query); - header("HTTP/1.0 500 Internal Error"); - echo ' + print("Version: $version (on $phpver)\n"); + } else { + $q = (!isset($e->query) || is_null($e->query)) ? "" : "
Query: " . html_escape($e->query); + header("HTTP/1.0 500 Internal Error"); + echo '