diff --git a/inc/header.php b/inc/header.php index 2738f37..28d5a45 100644 --- a/inc/header.php +++ b/inc/header.php @@ -6,36 +6,6 @@ class Header { */ function __construct($page) { $this->page = $page; - if ($page->settings->header_show_totals) { - $t = $page->settings->table; - $t_bans = $t['bans']; - $t_mutes = $t['mutes']; - $t_warnings = $t['warnings']; - $t_kicks = $t['kicks']; - try { - $sql = "SELECT - (SELECT id FROM $t_bans ORDER BY id DESC LIMIT 1), - (SELECT id FROM $t_mutes ORDER BY id DESC LIMIT 1), - (SELECT id FROM $t_warnings ORDER BY id DESC LIMIT 1), - (SELECT id FROM $t_kicks ORDER BY id DESC LIMIT 1)"; - - if ($page->settings->verify) { - $sql .= ",(SELECT id FROM " . $t['config'] . " LIMIT 1)"; - } - $st = $page->conn->query($sql); - - ($row = $st->fetch(PDO::FETCH_NUM)) or die('Failed to fetch row counts.'); - $st->closeCursor(); - $this->count = array( - 'bans.php' => $row[0], - 'mutes.php' => $row[1], - 'warnings.php' => $row[2], - 'kicks.php' => $row[3], - ); - } catch (PDOException $ex) { - Settings::handle_error($page->settings, $ex); - } - } } function navbar($links) { @@ -65,7 +35,38 @@ function navbar($links) { } function print_header() { -$settings = $this->page->settings; +$page = $this->page; +$settings = $page->settings; +if ($page->settings->header_show_totals) { + $t = $page->settings->table; + $t_bans = $t['bans']; + $t_mutes = $t['mutes']; + $t_warnings = $t['warnings']; + $t_kicks = $t['kicks']; + try { + $sql = "SELECT + (SELECT id FROM $t_bans ORDER BY id DESC LIMIT 1), + (SELECT id FROM $t_mutes ORDER BY id DESC LIMIT 1), + (SELECT id FROM $t_warnings ORDER BY id DESC LIMIT 1), + (SELECT id FROM $t_kicks ORDER BY id DESC LIMIT 1)"; + + if ($page->settings->verify) { + $sql .= ",(SELECT id FROM " . $t['config'] . " LIMIT 1)"; + } + $st = $page->conn->query($sql); + + ($row = $st->fetch(PDO::FETCH_NUM)) or die('Failed to fetch row counts.'); + $st->closeCursor(); + $this->count = array( + 'bans.php' => $row[0], + 'mutes.php' => $row[1], + 'warnings.php' => $row[2], + 'kicks.php' => $row[3], + ); + } catch (PDOException $ex) { + Settings::handle_error($page->settings, $ex); + } +} ?> diff --git a/inc/page.php b/inc/page.php index 9cdc35b..612c6fb 100644 --- a/inc/page.php +++ b/inc/page.php @@ -24,9 +24,6 @@ class Page { $this->lang = $this->defaultlang; } - if ($header) { - require_once './inc/header.php'; - } $this->conn = $settings->conn; $this->settings = $settings; $this->uuid_name_cache = array(); @@ -92,10 +89,11 @@ class Page { if (filter_var($page, FILTER_VALIDATE_INT)) { $this->page = max(0, (int)$page); } + + require_once './inc/header.php'; + $this->header = new Header($this); if ($header) { - $h = new Header($this); - $this->header = $h; - $h->print_header(); + $this->header->print_header(); } } diff --git a/index.php b/index.php index 7ca0b66..691b8f7 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ settings->simple_urls && count($_GET) !== 0) { $target = $page->get_requested_page(); @@ -13,6 +13,7 @@ if ($page->settings->simple_urls && count($_GET) !== 0) { } } } +$page->header->print_header(); $page->print_title(); ?>