mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-23 16:32:45 +00:00
Reformat code
This commit is contained in:
parent
9b3943ad5c
commit
ee70900b8e
@ -96,15 +96,13 @@ 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;
|
||||
/**
|
||||
* @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 "<img class='avatar noselect' src='$src'/>$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>$title - $name</title>";
|
||||
}
|
||||
|
||||
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 "</tr>";
|
||||
}
|
||||
|
||||
function table_print_headers($headers) {
|
||||
echo "<thead><tr>";
|
||||
foreach ($headers as $header) {
|
||||
echo "<th><div style=\"text-align: center;\">$header</div></th>";
|
||||
}
|
||||
echo "<tbody>";
|
||||
}
|
||||
|
||||
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 "<thead><tr>";
|
||||
foreach ($headers as $header) {
|
||||
echo "<th><div style=\"text-align: center;\">$header</div></th>";
|
||||
}
|
||||
echo "<tbody>";
|
||||
}
|
||||
|
||||
function print_check_form() {
|
||||
$table = $this->name;
|
||||
echo '
|
||||
@ -385,13 +394,4 @@ class Page {
|
||||
echo "<script type=\"text/javascript\">withjQuery(function(){ $('tr').click(function(){var href=$(this).find('a').attr('href');if(href!==undefined)window.location=href;}).hover(function(){\$(this).toggleClass('hover');}); });</script>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $info
|
||||
*/
|
||||
function set_info($info) {
|
||||
$this->type = $info['type'];
|
||||
$this->table = $info['table'];
|
||||
$this->title = $info['title'];
|
||||
}
|
||||
}
|
||||
|
8
info.php
8
info.php
@ -38,14 +38,14 @@ abstract class Info {
|
||||
return ((int)$this->row['until']) <= 0;
|
||||
}
|
||||
|
||||
function history_link($player_name, $uuid, $args = "") {
|
||||
return "<a href=\"history.php?uuid=$uuid$args\">$player_name</a>";
|
||||
}
|
||||
|
||||
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 "<a href=\"history.php?uuid=$uuid$args\">$player_name</a>";
|
||||
}
|
||||
|
||||
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"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user