diff --git a/includes/page.php b/includes/page.php index 81de62f..565e0fd 100644 --- a/includes/page.php +++ b/includes/page.php @@ -36,13 +36,13 @@ class Page { $this->set_info($info); $this->permanent = array( - 'ban' => 'Permanent Ban', + 'ban' => 'Permanent Ban', 'mute' => 'Permanent Mute', 'warn' => 'Permanent', 'kick' => null, ); $this->expired = array( - 'ban' => '(Unbanned)', + 'ban' => '(Unbanned)', 'mute' => '(Unmuted)', 'warn' => '(Expired)', 'kick' => null, @@ -62,49 +62,47 @@ class Page { case "ban": case "bans": return array( - "type" => "ban", + "type" => "ban", "table" => $settings->table['bans'], "title" => "Bans", ); case "mute": case "mutes": return array( - "type" => "mute", + "type" => "mute", "table" => $settings->table['mutes'], "title" => "Mutes", ); case "warn": case "warnings": return array( - "type" => "warn", + "type" => "warn", "table" => $settings->table['warnings'], "title" => "Warnings", ); case "kick": case "kicks": return array( - "type" => "kick", + "type" => "kick", "table" => $settings->table['kicks'], "title" => "Kicks", ); default: return array( - "type" => null, + "type" => null, "table" => null, "title" => null, ); } } - function get_selection($table) { - // Under certain versions of PHP, there is a bug with BIT columns. - // An empty string is returned no matter what the value is. - // Workaround: cast to unsigned. - $selection = "id,uuid,reason,banned_by_name,banned_by_uuid,time,until,CAST(active AS UNSIGNED) AS active"; - if ($table === $this->settings->table['warnings']) { - $selection .= ",CAST(warned AS UNSIGNED) AS warned"; - } - return $selection; + /** + * @param $info + */ + function set_info($info) { + $this->type = $info['type']; + $this->table = $info['table']; + $this->title = $info['title']; } function run_query() { @@ -135,6 +133,17 @@ class Page { } } + function get_selection($table) { + // Under certain versions of PHP, there is a bug with BIT columns. + // An empty string is returned no matter what the value is. + // Workaround: cast to unsigned. + $selection = "id,uuid,reason,banned_by_name,banned_by_uuid,time,until,CAST(active AS UNSIGNED) AS active"; + if ($table === $this->settings->table['warnings']) { + $selection .= ",CAST(warned AS UNSIGNED) AS warned"; + } + return $selection; + } + /** * Returns HTML representing the Minecraft avatar for a specific name or UUID. * @param $name @@ -165,28 +174,6 @@ class Page { return "$name"; } - /** - * Returns the last name for a UUID, or null if their name is not recorded in the database. - * @param string - * @return null|string - */ - function get_name($uuid) { - if (in_array($uuid, $this->settings->console_aliases)) { - return $this->settings->console_name; - } - if (array_key_exists($uuid, $this->uuid_name_cache)) return $this->uuid_name_cache[$uuid]; - - $history = $this->settings->table['history']; - $stmt = $this->conn->prepare("SELECT name FROM $history WHERE uuid=? ORDER BY date DESC LIMIT 1"); - if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) { - $banner = $row['name']; - $this->uuid_name_cache[$uuid] = $banner; - return $banner; - } - $this->uuid_name_cache[$uuid] = null; - return null; - } - /** * Returns the banner name for a specific row in the database * using their UUID->name if possible, otherwise returns their last recorded name. @@ -208,12 +195,25 @@ class Page { } /** - * Converts a timestamp (in milliseconds) to a date using the configured date format. - * @param int - * @return string + * Returns the last name for a UUID, or null if their name is not recorded in the database. + * @param string + * @return null|string */ - function millis_to_date($millis) { - return date($this->settings->date_format, $millis / 1000); + function get_name($uuid) { + if (in_array($uuid, $this->settings->console_aliases)) { + return $this->settings->console_name; + } + if (array_key_exists($uuid, $this->uuid_name_cache)) return $this->uuid_name_cache[$uuid]; + + $history = $this->settings->table['history']; + $stmt = $this->conn->prepare("SELECT name FROM $history WHERE uuid=? ORDER BY date DESC LIMIT 1"); + if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) { + $banner = $row['name']; + $this->uuid_name_cache[$uuid] = $banner; + return $banner; + } + $this->uuid_name_cache[$uuid] = null; + return null; } /** @@ -255,12 +255,17 @@ class Page { return $until; } - function active($row, $field = 'active') { - return (((int)$row[$field]) !== 0); + /** + * Converts a timestamp (in milliseconds) to a date using the configured date format. + * @param int + * @return string + */ + function millis_to_date($millis) { + return date($this->settings->date_format, $millis / 1000); } - function title() { - return ucfirst($this->name); + function active($row, $field = 'active') { + return (((int)$row[$field]) !== 0); } function print_title() { @@ -269,6 +274,10 @@ class Page { echo "$title - $name"; } + function title() { + return ucfirst($this->name); + } + function print_table_rows($row, $array, $print_headers = true) { if ($print_headers && !$this->table_headers_printed) { $headers = array_keys($array); @@ -297,6 +306,14 @@ class Page { echo ""; } + function table_print_headers($headers) { + echo ""; + foreach ($headers as $header) { + echo "
$header
"; + } + echo ""; + } + function print_page_header($container_start = true) { $title = $this->title(); if ($container_start) { @@ -309,14 +326,6 @@ class Page { } } - function table_print_headers($headers) { - echo ""; - foreach ($headers as $header) { - echo "
$header
"; - } - echo ""; - } - function print_check_form() { $table = $this->name; echo ' @@ -385,13 +394,4 @@ class Page { echo ""; } } - - /** - * @param $info - */ - function set_info($info) { - $this->type = $info['type']; - $this->table = $info['table']; - $this->title = $info['title']; - } } diff --git a/info.php b/info.php index 468a423..c34899f 100644 --- a/info.php +++ b/info.php @@ -38,14 +38,14 @@ abstract class Info { return ((int)$this->row['until']) <= 0; } - function history_link($player_name, $uuid, $args = "") { - return "$player_name"; - } - function punished_avatar($player_name, $row) { return $this->page->get_avatar($player_name, $row['uuid'], false, $this->history_link($player_name, $row['uuid'])); } + function history_link($player_name, $uuid, $args = "") { + return "$player_name"; + } + function moderator_avatar($row) { $banner_name = $this->page->get_banner_name($row); return $this->page->get_avatar($banner_name, $row['banned_by_uuid'], false, $this->history_link($banner_name, $row['banned_by_uuid'], "&staffhistory=1"));