Fix PHP 5.3 compat issue

This commit is contained in:
ruan 2020-08-07 20:43:55 +02:00
parent abc453bac8
commit ca86925bb3
2 changed files with 28 additions and 28 deletions

View File

@ -29,7 +29,7 @@ class Page {
} }
$this->conn = $settings->conn; $this->conn = $settings->conn;
$this->settings = $settings; $this->settings = $settings;
$this->uuid_name_cache = []; $this->uuid_name_cache = array();
$this->name = $name; $this->name = $name;
@ -40,30 +40,30 @@ class Page {
$info = $this->type_info($name); $info = $this->type_info($name);
$this->set_info($info); $this->set_info($info);
$this->permanent = [ $this->permanent = array(
'ban' => $this->t("generic.permanent.ban"), 'ban' => $this->t("generic.permanent.ban"),
'mute' => $this->t("generic.permanent.mute"), 'mute' => $this->t("generic.permanent.mute"),
'warn' => $this->t("generic.permanent"), 'warn' => $this->t("generic.permanent"),
'kick' => null, 'kick' => null,
]; );
$this->expired = [ $this->expired = array(
'ban' => $this->t("page.expired.ban"), 'ban' => $this->t("page.expired.ban"),
'mute' => $this->t("page.expired.mute"), 'mute' => $this->t("page.expired.mute"),
'warn' => $this->t("page.expired.warning"), 'warn' => $this->t("page.expired.warning"),
'kick' => null, 'kick' => null,
]; );
$this->expired_by = [ $this->expired_by = array(
'ban' => $this->t("page.expired.ban-by"), 'ban' => $this->t("page.expired.ban-by"),
'mute' => $this->t("page.expired.mute-by"), 'mute' => $this->t("page.expired.mute-by"),
'warn' => $this->t("page.expired.warning"), 'warn' => $this->t("page.expired.warning"),
'kick' => null, 'kick' => null,
]; );
$this->punished_by = [ $this->punished_by = array(
'ban' => $this->t("generic.banned.by"), 'ban' => $this->t("generic.banned.by"),
'mute' => $this->t("generic.muted.by"), 'mute' => $this->t("generic.muted.by"),
'warn' => $this->t("generic.warned.by"), 'warn' => $this->t("generic.warned.by"),
'kick' => $this->t("generic.kicked.by"), 'kick' => $this->t("generic.kicked.by"),
]; );
$this->table_headers_printed = false; $this->table_headers_printed = false;
$this->args = array_values($_GET); $this->args = array_values($_GET);
@ -125,43 +125,43 @@ class Page {
switch ($type) { switch ($type) {
case "ban": case "ban":
case "bans": case "bans":
return [ return array(
"type" => "ban", "type" => "ban",
"table" => $settings->table['bans'], "table" => $settings->table['bans'],
"title" => $this->t("title.bans"), "title" => $this->t("title.bans"),
"page" => "bans.php", "page" => "bans.php",
]; );
case "mute": case "mute":
case "mutes": case "mutes":
return [ return array(
"type" => "mute", "type" => "mute",
"table" => $settings->table['mutes'], "table" => $settings->table['mutes'],
"title" => $this->t("title.mutes"), "title" => $this->t("title.mutes"),
"page" => "mutes.php", "page" => "mutes.php",
]; );
case "warn": case "warn":
case "warnings": case "warnings":
return [ return array(
"type" => "warn", "type" => "warn",
"table" => $settings->table['warnings'], "table" => $settings->table['warnings'],
"title" => $this->t("title.warnings"), "title" => $this->t("title.warnings"),
"page" => "warnings.php", "page" => "warnings.php",
]; );
case "kick": case "kick":
case "kicks": case "kicks":
return [ return array(
"type" => "kick", "type" => "kick",
"table" => $settings->table['kicks'], "table" => $settings->table['kicks'],
"title" => $this->t("title.kicks"), "title" => $this->t("title.kicks"),
"page" => "kicks.php", "page" => "kicks.php",
]; );
default: default:
return [ return array(
"type" => null, "type" => null,
"table" => null, "table" => null,
"title" => null, "title" => null,
"page" => null, "page" => null,
]; );
} }
} }
@ -203,13 +203,13 @@ class Page {
return $rows; return $rows;
} catch (PDOException $ex) { } catch (PDOException $ex) {
Settings::handle_error($this->settings, $ex); Settings::handle_error($this->settings, $ex);
return []; return array();
} }
} }
function get_selection($table, $phpIsBroken = true) { function get_selection($table, $phpIsBroken = true) {
$columns = ["id", "uuid", "reason", "banned_by_name", "banned_by_uuid", "time", "until", "server_origin", "server_scope", "active", "ipban"]; $columns = array("id", "uuid", "reason", "banned_by_name", "banned_by_uuid", "time", "until", "server_origin", "server_scope", "active", "ipban");
$bitColumns = ["active", "ipban"]; $bitColumns = array("active", "ipban");
if ($table === $this->settings->table['warnings']) { if ($table === $this->settings->table['warnings']) {
array_push($columns, "warned"); array_push($columns, "warned");
@ -486,7 +486,7 @@ class Page {
} }
if ($print_headers && !$this->table_headers_printed) { if ($print_headers && !$this->table_headers_printed) {
$headers = array_keys($array); $headers = array_keys($array);
$headers_translated = []; $headers_translated = array();
foreach ($headers as $header) { foreach ($headers as $header) {
if ($header === "executor" && $this->name !== "history") { if ($header === "executor" && $this->name !== "history") {
$header = $this->punished_by[$type]; $header = $this->punished_by[$type];
@ -607,11 +607,11 @@ class Page {
$pager_next = "<a href=\"$pager_next_href\">$pager_next</a>"; $pager_next = "<a href=\"$pager_next_href\">$pager_next</a>";
} }
$pager_count = '<div><div class="litebans-pager-number">' . $this->t("table.pager.number") . ' ' . $cur . '/' . $pages . '</div></div>'; $pager_count = '<div><div class="litebans-pager-number">' . $this->t("table.pager.number") . ' ' . $cur . '/' . $pages . '</div></div>';
return [ return array(
"prev" => $pager_prev, "prev" => $pager_prev,
"next" => $pager_next, "next" => $pager_next,
"count" => $pager_count, "count" => $pager_count,
]; );
} }
function print_footer($container_end = true) { function print_footer($container_end = true) {

View File

@ -171,7 +171,7 @@ class Settings {
} }
} }
protected function connect($verify=true) { protected function connect($verify = true) {
$driver = $this->driver; $driver = $this->driver;
$host = $this->host; $host = $this->host;
$port = $this->port; $port = $this->port;
@ -277,7 +277,7 @@ class Settings {
protected function init_tables() { protected function init_tables() {
$table_prefix = $this->table_prefix; $table_prefix = $this->table_prefix;
// Internal table names, do not translate. // Internal table names, do not translate.
$this->table = [ $this->table = array(
'bans' => "${table_prefix}bans", 'bans' => "${table_prefix}bans",
'mutes' => "${table_prefix}mutes", 'mutes' => "${table_prefix}mutes",
'warnings' => "${table_prefix}warnings", 'warnings' => "${table_prefix}warnings",
@ -285,6 +285,6 @@ class Settings {
'history' => "${table_prefix}history", 'history' => "${table_prefix}history",
'servers' => "${table_prefix}servers", 'servers' => "${table_prefix}servers",
'config' => "${table_prefix}config", 'config' => "${table_prefix}config",
]; );
} }
} }