From c4afc1399f3b74f97fd9e2688f97a9184b9cd7f5 Mon Sep 17 00:00:00 2001 From: ruan Date: Sat, 21 Jul 2018 12:51:35 +0200 Subject: [PATCH] Spring cleaning --- history.php | 1 - inc/page.php | 46 +++++++++++----------------------------------- inc/settings.php | 6 +++--- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/history.php b/history.php index e6077ce..a85250c 100644 --- a/history.php +++ b/history.php @@ -204,7 +204,6 @@ try { "date" => $page->millis_to_date($row['time']), "expires" => $page->expiry($row), "server.name" => $page->server($row), - //'i' => $i . "/" . $limit . "/" . $total, )); } diff --git a/inc/page.php b/inc/page.php index d4dddd5..b62c266 100644 --- a/inc/page.php +++ b/inc/page.php @@ -168,7 +168,7 @@ class Page { } } - function get_selection($table, $fatquery = null, $phpIsBroken = true) { + function get_selection($table, $phpIsBroken = true) { $columns = array("id", "uuid", "reason", "banned_by_name", "banned_by_uuid", "time", "until", "server_origin", "server_scope", "active", "ipban"); $bitColumns = array("active", "ipban"); @@ -186,29 +186,12 @@ class Page { // Workaround: cast to unsigned. if ($phpIsBroken === true) { foreach ($bitColumns as $column) { - unset($columns[$column]); - $alias = $column; -// if ($fatquery !== null) { -// $alias = "$fatquery.$column"; -// } - array_push($columns, "CAST($column AS UNSIGNED) AS $alias"); + unset($columns[$column]); + $alias = $column; + array_push($columns, "CAST($column AS UNSIGNED) AS $alias"); } } - - // is there really no better way to do this? -// if ($fatquery !== null) { -// foreach ($columns as $column) { -// if (!array_key_exists($column, $bitColumns)) { -// unset($columns[$column]); -// array_push($columns, "$column AS $fatquery.$column"); -// } -// } -// } - $selection = implode(",", $columns); - -// echo $selection; - return $selection; } @@ -408,24 +391,17 @@ class Page { $time = gettimeofday(); $millis = $time["sec"] * 1000; -// $dtz = new DateTimeZone(date_default_timezone_get()); -// $dt = new DateTime("now", $dtz); -// $millis = ($dt->getTimestamp() + $dt->getOffset()) * 1000; - if ($millis > $until) { - return true; - } - return false; + return ($millis > $until); } function print_title() { $title = $this->title; $name = $this->settings->name; - if ($title === null) { - echo "$name"; - } else { - echo "$title - $name"; + if ($title !== null) { + $name = "$title - $name"; } + echo "$name"; } function print_table_rows($row, $array, $print_headers = true) { @@ -440,7 +416,7 @@ class Page { if ($header === "executor" && $this->name !== "history") { $header = $this->punished_by[$type]; } else { - $header = $this->t("table." . $header); + $header = $this->t("table.$header"); } array_push($headers_translated, $header); } @@ -548,7 +524,7 @@ class Page { } function autoversion($file) { - return $file . "?" . filemtime($file); + return "$file?" . filemtime($file); } function table_begin() { @@ -578,7 +554,7 @@ class Page { */ public function where_append($where) { if ($where !== "") { - return $where . " AND "; + return "$where AND "; } else { return "WHERE "; } diff --git a/inc/settings.php b/inc/settings.php index 97ba7b5..1ffe083 100644 --- a/inc/settings.php +++ b/inc/settings.php @@ -234,7 +234,7 @@ final class Settings { if ($settings->error_reporting === false) { die("Database error"); } - die('Database error: ' . $message); + die("Database error: $message"); } @@ -256,7 +256,7 @@ final class Settings { ob_start(); var_dump($test); $testdump = ob_get_clean(); - echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned " . $testdump); + echo("Error: date_format test failed. gmstrftime(\"" . $this->date_format . "\",0) returned $testdump"); $fail = true; } @@ -266,7 +266,7 @@ final class Settings { var_dump($test); $testdump = ob_get_clean(); echo("Assertion failed: gmstrftime(\"%Y-%m-%d %H:%M\",0) != \"1970-01-01 00:00\"
"); - echo("Actual result: " . $testdump); + echo("Actual result: $testdump"); $fail = true; }