Another try

This commit is contained in:
ruan 2015-10-09 08:44:10 +02:00
parent 55ebee2724
commit 180d757078
3 changed files with 10 additions and 10 deletions

View File

@ -6,6 +6,7 @@ use PDOException;
class Page { class Page {
public function __construct($name, $header = true) { public function __construct($name, $header = true) {
$this->time = microtime(true);
if ($header) { if ($header) {
require_once './includes/header.php'; require_once './includes/header.php';
} }
@ -14,7 +15,6 @@ class Page {
$this->conn = $settings->conn; $this->conn = $settings->conn;
$this->settings = $settings; $this->settings = $settings;
$this->uuid_name_cache = array(); $this->uuid_name_cache = array();
$this->time = microtime(true);
$this->page = 1; $this->page = 1;
if (isset($_GET['page'])) { if (isset($_GET['page'])) {
$page = $_GET['page']; // user input $page = $_GET['page']; // user input
@ -240,12 +240,16 @@ class Page {
} else { } else {
$until = $this->millis_to_date($row['until']); $until = $this->millis_to_date($row['until']);
} }
if ($this->settings->show_inactive_bans && $row['active'] === "0") { if ($this->settings->show_inactive_bans && $this->active($row) === false) {
$until .= ' ' . $this->expired[$this->type]; $until .= ' ' . $this->expired[$this->type];
} }
return $until; return $until;
} }
function active($row, $field = 'active') {
return (((int)$row[$field]) !== 0);
}
function title() { function title() {
return ucfirst($this->name); return ucfirst($this->name);
} }
@ -376,9 +380,4 @@ class Page {
$this->table = $info['table']; $this->table = $info['table'];
$this->title = $info['title']; $this->title = $info['title'];
} }
public function active($row, $column = "active") {
$active = $row[$column];
return $active === "1" || $active === 1 || $active === true;
}
} }

View File

@ -35,7 +35,7 @@ abstract class Info {
} }
function permanent() { function permanent() {
return $this->row['until'] <= 0; return ((int)$this->row['until']) <= 0;
} }
function history_link($player_name, $uuid, $args = "") { function history_link($player_name, $uuid, $args = "") {
@ -149,7 +149,8 @@ if ($st->execute(array($id))) {
if (!($info instanceof KickInfo)) { if (!($info instanceof KickInfo)) {
$style = 'style="margin-left: 13px; font-size: 16px;"'; $style = 'style="margin-left: 13px; font-size: 16px;"';
if ($row['active'] === "1") { $active = $page->active($row);
if ($active === true) {
$page->name .= "<span $style class='label label-danger'>Active</span>"; $page->name .= "<span $style class='label label-danger'>Active</span>";
} else { } else {
$page->name .= "<span $style class='label label-warning'>Inactive</span>"; $page->name .= "<span $style class='label label-warning'>Inactive</span>";

View File

@ -25,7 +25,7 @@ while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
'Warned By' => $page->get_avatar($page->get_banner_name($row), $row['banned_by_uuid']), 'Warned By' => $page->get_avatar($page->get_banner_name($row), $row['banned_by_uuid']),
'Reason' => $page->clean($row['reason']), 'Reason' => $page->clean($row['reason']),
'Warned Until' => $page->expiry($row), 'Warned Until' => $page->expiry($row),
'Received Warning' => ($row['warned'] === "1") ? "Yes" : "No", 'Received Warning' => (($page->active($row, 'warned') === true) ? "Yes" : "No"),
)); ));
} }
$page->table_end(); $page->table_end();