Simple URLs: Fix duplicate header

This commit is contained in:
ruan 2020-09-08 10:59:52 +02:00
parent 764825bdc5
commit 5a0826db1d
3 changed files with 38 additions and 38 deletions

View File

@ -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);
}
}
?>
<!DOCTYPE html>
<html lang="en">

View File

@ -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();
}
}

View File

@ -1,7 +1,7 @@
<?php
require_once './inc/page.php';
$page = new Page("index");
$page = new Page("index",false);
if ($page->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();
?>