This commit is contained in:
ruan 2015-09-10 15:01:30 +02:00
parent e870a85a86
commit 7253b08960
16 changed files with 6643 additions and 6064 deletions

View File

@ -1,43 +1,38 @@
<?php <?php
namespace litebans;
use PDO;
require_once './includes/page.php'; require_once './includes/page.php';
$page = new Page(); $page = new Page("bans");
$page->print_title();
$headers = array("Name", "Banned By", "Reason", "Banned On", "Banned Until");
?> ?>
<title>Bans - <?php echo $page->settings->name; ?></title>
<div class="container"> <div class="container">
<?php <?php
$page->print_page_header("Bans"); $page->print_page_header();
$page->print_check_form("bans"); $page->print_check_form();
?> ?>
<div class="row" style="margin-bottom:60px;"> <div class="row" style="margin-bottom:60px;">
<div class="col-lg-12"> <div class="col-lg-12">
<table class="table table-hover table-bordered table-condensed"> <?php
<?php $page->table_begin();
$page->print_table_headers(array("Name", "Banned By", "Reason", "Banned On", "Banned Until")); $page->table_print_headers($headers);
$result = $page->run_query($page->settings->table_bans); $result = $page->run_query();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$player_name = $page->get_name($row['uuid']); $player_name = $page->get_name($row['uuid']);
if ($player_name === null) continue; if ($player_name === null) continue;
$until = $page->millis_to_date($row['until']);
?> $page->print_table_rows($row, array(
<tr> 'Name' => $page->get_avatar($player_name),
<td><?php echo $page->get_avatar($player_name); ?></td> 'Banned By' => $page->get_avatar($page->get_banner_name($row)),
<td><?php echo $page->get_avatar($page->get_banner_name($row)); ?></td> 'Reason' => $page->clean($row['reason']),
<td style="width: 30%;"><?php echo $page->clean($row['reason']); ?></td> 'Banned On' => $page->millis_to_date($row['time']),
<td><?php echo $page->millis_to_date($row['time']); ?></td> 'Banned Until' => $page->expiry($row),
<td> ));
<?php if ($row['until'] <= 0) { }
$until = 'Permanent Ban'; $page->table_end();
} $page->print_pager();
if ($page->settings->show_inactive_bans && !$row['active']) { ?>
$until .= ' (Unbanned)';
}
echo $until;
?>
</td>
</tr>
<?php } ?>
</table>
<?php $page->print_pager("bans.php", $page->settings->table_bans); ?>
</div> </div>
</div> </div>
<?php $page->print_footer(); ?> <?php $page->print_footer(); ?>

View File

@ -1,4 +1,8 @@
<?php <?php
namespace litebans;
use PDOException;
require_once './includes/page.php'; require_once './includes/page.php';
class Check { class Check {
@ -8,8 +12,8 @@ class Check {
$this->println("Invalid name."); $this->println("Invalid name.");
return; return;
} }
$page = new Page(false); $page = new Page("check", false);
$history = $page->settings->table_history; $history = $page->settings->table['history'];
try { try {
$stmt = $page->conn->prepare("SELECT name,uuid FROM $history WHERE name=? ORDER BY date LIMIT 1"); $stmt = $page->conn->prepare("SELECT name,uuid FROM $history WHERE name=? ORDER BY date LIMIT 1");
@ -24,7 +28,7 @@ class Check {
$this->println("$name has not joined before."); $this->println("$name has not joined before.");
return; return;
} }
$table = $page->settings->table_bans; $table = $page->settings->table['bans'];
$stmt = $page->conn->prepare("SELECT * FROM $table WHERE (uuid=? AND active=" . Settings::$TRUE . ") LIMIT 1"); $stmt = $page->conn->prepare("SELECT * FROM $table WHERE (uuid=? AND active=" . Settings::$TRUE . ") LIMIT 1");
if ($stmt->execute(array($uuid))) { if ($stmt->execute(array($uuid))) {

File diff suppressed because it is too large Load Diff

View File

@ -16,3 +16,29 @@ body {
margin-right: 5px; margin-right: 5px;
border-radius: 2px; border-radius: 2px;
} }
table tr td a {
display: block;
height: 100%;
width: 100%;
}
table tr td {
padding-left: 0;
padding-right: 0;
}
/* table links */
a,
a:hover,
a:focus {
text-decoration: none !important;
}
.pager-active {
color: darkcyan;
}
.pager-inactive {
color: transparent;
}

View File

@ -5,8 +5,3 @@
<link rel="shortcut icon" href="includes/img/minecraft.ico"> <link rel="shortcut icon" href="includes/img/minecraft.ico">
<link href="includes/css/bootstrap.css" rel="stylesheet"> <link href="includes/css/bootstrap.css" rel="stylesheet">
<link href="includes/css/custom.css" rel="stylesheet"> <link href="includes/css/custom.css" rel="stylesheet">
<style>
html {
background-image: url('includes/img/377759.png');
}
</style>

View File

@ -1,4 +1,6 @@
<?php <?php
namespace litebans;
require_once './includes/settings.php'; require_once './includes/settings.php';
$settings = new Settings(false); $settings = new Settings(false);
?> ?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 353 B

2323
includes/js/bootstrap.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,11 @@
<?php <?php
namespace litebans;
use PDO;
use PDOException;
class Page { class Page {
public function __construct($header = true) { public function __construct($name, $header = true) {
if ($header) { if ($header) {
require_once './includes/head.php'; require_once './includes/head.php';
require_once './includes/header.php'; require_once './includes/header.php';
@ -19,10 +23,46 @@ class Page {
$this->page = (int)$page; $this->page = (int)$page;
} }
} }
$this->name = $name;
switch ($name) {
case "ban":
case "bans":
$this->type = "ban";
$this->table = $settings->table['bans'];
break;
case "mute":
case "mutes":
$this->type = "mute";
$this->table = $settings->table['mutes'];
break;
case "warn":
case "warnings":
$this->type = "warn";
$this->table = $settings->table['warnings'];
break;
case "kick":
case "kicks":
$this->type = "kick";
$this->table = $settings->table['kicks'];
break;
}
$this->permanent = array(
'ban' => 'Permanent Ban',
'mute' => 'Permanent Mute',
'warn' => 'Permanent',
'kick' => null,
);
$this->expired = array(
'ban' => '(Unbanned)',
'mute' => '(Unmuted)',
'warn' => '(Expired)',
'kick' => null,
);
} }
function run_query($table) { function run_query() {
try { try {
$table = $this->table;
$active_query = $this->settings->active_query; $active_query = $this->settings->active_query;
$limit = $this->settings->limit_per_page; $limit = $this->settings->limit_per_page;
@ -61,7 +101,7 @@ class Page {
*/ */
function get_name($uuid) { function get_name($uuid) {
if (array_key_exists($uuid, $this->uuid_name_cache)) return $this->uuid_name_cache[$uuid]; if (array_key_exists($uuid, $this->uuid_name_cache)) return $this->uuid_name_cache[$uuid];
$history = $this->settings->table_history; $history = $this->settings->table['history'];
$stmt = $this->conn->prepare("SELECT name FROM $history WHERE uuid=? ORDER BY date DESC LIMIT 1"); $stmt = $this->conn->prepare("SELECT name FROM $history WHERE uuid=? ORDER BY date DESC LIMIT 1");
if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) { if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) {
$banner = $row['name']; $banner = $row['name'];
@ -105,28 +145,71 @@ class Page {
*/ */
function clean($text) { function clean($text) {
if (strstr($text, "\xa7") || strstr($text, "&")) { if (strstr($text, "\xa7") || strstr($text, "&")) {
$regex = "/(?i)(\xa7|&)[0-9A-FK-OR]/"; $text = preg_replace("/(?i)(\xa7|&)[0-9A-FK-OR]/", "", $text);
$text = preg_replace($regex, "", $text);
} }
$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); $text = htmlspecialchars($text, ENT_QUOTES, "UTF-8");
if (strstr($text, "\n")) { if (strstr($text, "\n")) {
$text = preg_replace("/\n/", "<br>", $text); $text = preg_replace("/\n/", "<br>", $text);
} }
return $text; return $text;
} }
function print_page_header($title) { /**
$type = ($title === "Bans") ? "modal" : "navbar"; * Returns a string that shows the expiry date of a punishment.
* If the punishment does not expire, it will be shown as permanent.
* If the punishment has already expired, it will show as expired.
* @param row
* @return string
*/
public function expiry($row) {
if ($row['until'] <= 0) {
return $this->permanent[$this->type];
}
$until = $this->millis_to_date($row['until']);
if ($this->settings->show_inactive_bans && !$row['active']) {
$until .= ' ' . $this->expired[$this->type];
}
return $until;
}
function title() {
return ucfirst($this->name);
}
function print_title() {
$title = $this->title();
$name = $this->settings->name;
echo "<title>$title - $name</title>";
}
function print_table_rows($row, $array) {
$id = $row['id'];
$type = $this->type;
echo "<tr>";
foreach ($array as $header => $text) {
$style = "";
if ($header === "Reason") {
$style = "style=\"width: 30%;\"";
}
echo "<td $style><a style=\"color: #fcfcfc;\" href=\"info.php?type=$type&id=$id\">$text</a></td>";
}
echo "</tr>";
}
function print_page_header() {
$title = $this->title();
//$type = ($title === "Bans") ? "modal-header" : "navbar-header";
$type = "modal-header";
echo(" echo("
<div class=\"row\"> <div class=\"row\">
<div class=\"col-lg-12\"> <div style=\"text-align: center;\" class=\"col-lg-12\">
<h1 class=\"$type-header\">$title</h1> <h1 class=\"$type\">$title</h1>
</div> </div>
</div> </div>
"); ");
} }
function print_table_headers($headers) { function table_print_headers($headers) {
echo("<thead><tr>"); echo("<thead><tr>");
foreach ($headers as $header) { foreach ($headers as $header) {
echo "<th><div style=\"text-align: center;\">$header</div></th>"; echo "<th><div style=\"text-align: center;\">$header</div></th>";
@ -134,9 +217,10 @@ class Page {
echo("<tbody>"); echo("<tbody>");
} }
function print_check_form($table) { function print_check_form() {
$table = $this->name;
echo(' echo('
<div class="row"> <div style="text-align: left;" class="row">
<div style="margin-left: 15px;"> <div style="margin-left: 15px;">
<form onsubmit="captureForm(event);" class="form-inline"><div class="form-group"><input type="text" class="form-control" id="user" placeholder="Player"></div><button type="submit" class="btn btn-default" style="margin-left: 5px;">Check</button></form> <form onsubmit="captureForm(event);" class="form-inline"><div class="form-group"><input type="text" class="form-control" id="user" placeholder="Player"></div><button type="submit" class="btn btn-default" style="margin-left: 5px;">Check</button></form>
</div> </div>
@ -146,7 +230,10 @@ class Page {
'); ');
} }
function print_pager($page, $table) { function print_pager() {
$table = $this->table;
$page = $this->name . ".php";
if (!$this->settings->show_pager) return; if (!$this->settings->show_pager) return;
$result = $this->conn->query("SELECT COUNT(*) AS count FROM $table")->fetch(PDO::FETCH_ASSOC); $result = $this->conn->query("SELECT COUNT(*) AS count FROM $table")->fetch(PDO::FETCH_ASSOC);
$total = $result['count']; $total = $result['count'];
@ -157,12 +244,18 @@ class Page {
$prev = $cur - 1; $prev = $cur - 1;
$next = $this->page + 1; $next = $this->page + 1;
$pager_prev = "<div style=\"float:left; font-size:30px;\">«</div>"; $prev_active = ($cur > 1);
$next_active = ($cur < $pages);
$prev_class = $prev_active ? "pager-active" : "pager-inactive";
$next_class = $next_active ? "pager-active" : "pager-inactive";
$pager_prev = "<div class=\"$prev_class\" style=\"float:left; font-size:30px;\">«</div>";
if ($cur > 1) { if ($cur > 1) {
$pager_prev = "<a href=\"$page?page=$prev\">$pager_prev</a>"; $pager_prev = "<a href=\"$page?page=$prev\">$pager_prev</a>";
} }
$pager_next = "<div style=\"float: right; font-size:30px;\">»</div>"; $pager_next = "<div class=\"$next_class\" style=\"float: right; font-size:30px;\">»</div>";
if ($cur < $pages) { if ($cur < $pages) {
$pager_next = "<a href=\"$page?page=$next\">$pager_next</a>"; $pager_next = "<a href=\"$page?page=$next\">$pager_next</a>";
} }
@ -175,4 +268,12 @@ class Page {
$time = microtime(true) - $this->time; $time = microtime(true) - $this->time;
echo "<!-- Page generated in $time seconds. -->"; echo "<!-- Page generated in $time seconds. -->";
} }
public function table_begin() {
echo '<table class="table table-striped table-bordered table-condensed">';
}
public function table_end() {
echo '</table>';
}
} }

View File

@ -1,4 +1,7 @@
<?php <?php
namespace litebans;
use PDO, PDOException;
final class Settings { final class Settings {
public static $TRUE = "1", $FALSE = "0"; public static $TRUE = "1", $FALSE = "0";
@ -28,13 +31,13 @@ final class Settings {
// Amount of bans/mutes/warnings to show on each page // Amount of bans/mutes/warnings to show on each page
$this->limit_per_page = 10; $this->limit_per_page = 10;
// If you set a table prefix in config.yml, put it here too // If you set a table prefix in config.yml, set it here as well
$table_prefix = ""; $table_prefix = "";
// The date format can be changed here. // The date format can be changed here.
// https://secure.php.net/manual/en/function.date.php // https://secure.php.net/manual/en/function.date.php
// Example of default: July 2, 2015, 9:19 pm // Example of default: July 2, 2015, 9:19 PM
$this->date_format = 'F j, Y, g:i a'; $this->date_format = 'F j, Y, g:i A';
date_default_timezone_set("UTC"); date_default_timezone_set("UTC");
// Supported drivers: mysql, pgsql // Supported drivers: mysql, pgsql
@ -42,11 +45,13 @@ final class Settings {
/*** End of configuration ***/ /*** End of configuration ***/
$this->table_bans = "{$table_prefix}bans"; $this->table = array(
$this->table_mutes = "{$table_prefix}mutes"; 'bans' => "${table_prefix}bans",
$this->table_warnings = "{$table_prefix}warnings"; 'mutes' => "${table_prefix}mutes",
$this->table_kicks = "${table_prefix}kicks"; 'warnings' => "${table_prefix}warnings",
$this->table_history = "{$table_prefix}history"; 'kicks' => "${table_prefix}kicks",
'history' => "${table_prefix}history",
);
$this->active_query = ""; $this->active_query = "";
@ -67,10 +72,10 @@ final class Settings {
try { try {
$this->conn = new PDO($dsn, $username, $password); $this->conn = new PDO($dsn, $username, $password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) { } catch (PDOException $e) {
die('Connection failed: ' . $e->getMessage()); die('Connection failed: ' . $e->getMessage());
} }
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($driver === 'pgsql') { if ($driver === 'pgsql') {
$this->conn->query("SET NAMES 'UTF8';"); $this->conn->query("SET NAMES 'UTF8';");
} }

View File

@ -1,7 +1,10 @@
<?php <?php
namespace litebans;
include './includes/head.php'; include './includes/head.php';
include './includes/header.php'; include './includes/header.php';
include_once './includes/settings.php'; include_once './includes/settings.php';
$settings = new Settings(false);
?> ?>
<title>Index - <?php echo $settings->name; ?></title> <title>Index - <?php echo $settings->name; ?></title>
<div class="container"> <div class="container">
@ -10,6 +13,5 @@ include_once './includes/settings.php';
<div style="text-align: center;"><p>Here is where our Bans, Mutes, and Warnings are listed.</p></div> <div style="text-align: center;"><p>Here is where our Bans, Mutes, and Warnings are listed.</p></div>
</div> </div>
</div> </div>
<?php include './includes/footer.php'; ?> <?php include './includes/footer.php'; ?>

172
info.php Normal file
View File

@ -0,0 +1,172 @@
<?php
namespace litebans;
use PDO;
require_once './includes/page.php';
abstract class Info {
/**
* @param $row PDO::PDORow
* @param $page Page
*/
public function __construct($row, $page) {
$this->row = $row;
$this->page = $page;
$this->table = $page->table;
}
function name() {
return ucfirst($this->page->type);
}
function permanent() {
return $this->row['until'] <= 0;
}
abstract function basic_info($row, $player_name);
static function create($row, $page, $type) {
switch ($type) {
case "ban":
return new BanInfo($row, $page);
case "mute":
return new MuteInfo($row, $page);
case "warn":
return new WarnInfo($row, $page);
case "kick":
return new KickInfo($row, $page);
}
return null;
}
}
class BanInfo extends Info {
function basic_info($row, $player_name) {
$page = $this->page;
return array(
'Banned Player' => $page->get_avatar($player_name),
'Banned By' => $page->get_avatar($page->get_banner_name($row)),
'Ban Reason' => $page->clean($row['reason']),
'Ban Placed' => $page->millis_to_date($row['time']),
'Expires' => $page->expiry($row),
);
}
}
class MuteInfo extends Info {
function basic_info($row, $player_name) {
$page = $this->page;
return array(
'Muted Player' => $page->get_avatar($player_name),
'Muted By' => $page->get_avatar($page->get_banner_name($row)),
'Mute Reason' => $page->clean($row['reason']),
'Mute Placed' => $page->millis_to_date($row['time']),
'Expires' => $page->expiry($row),
);
}
}
class WarnInfo extends Info {
function name() {
return "Warning";
}
function basic_info($row, $player_name) {
$page = $this->page;
return array(
'Warned Player' => $page->get_avatar($player_name),
'Warned By' => $page->get_avatar($page->get_banner_name($row)),
'Warning Reason' => $page->clean($row['reason']),
'Warning Placed' => $page->millis_to_date($row['time']),
'Expires' => $page->expiry($row),
);
}
}
class KickInfo extends Info {
function basic_info($row, $player_name) {
$page = $this->page;
return array(
'Kicked Player' => $page->get_avatar($player_name),
'Kicked By' => $page->get_avatar($page->get_banner_name($row)),
'Kick Reason' => $page->clean($row['reason']),
'Kick Date' => $page->millis_to_date($row['time']),
);
}
}
$type = $_GET['type'];
$id = $_GET['id'];
$page = new Page($type);
if ($page->type === null) {
die("Unknown page type requested.");
}
if (!filter_var($id, FILTER_VALIDATE_INT)) {
die("Invalid ID.");
}
$id = (int)$id;
$type = $page->type;
$table = $page->table;
$query = "SELECT * FROM $table WHERE id=? LIMIT 1";
$st = $page->conn->prepare($query);
if ($st->execute(array($id))) {
if (!($row = $st->fetch())) {
die("Error: $type not found in database.");
}
$player_name = $page->get_name($row['uuid']);
if ($player_name == null) {
die("Error: Player name not found.");
}
$info = Info::create($row, $page, $type);
$name = $info->name();
$permanent = $info->permanent();
$active = $row['active'];
$page->name = "$name #$id";
$page->print_title();
if (!($info instanceof KickInfo)) {
$style = 'style="margin-left: 13px; font-size: 16px;"';
if ($active) {
$page->name .= "<span $style class='label label-danger'>Active</span>";
} else {
$page->name .= "<span $style class='label label-warning'>Inactive</span>";
}
if ($permanent) {
$page->name .= "<span $style class='label label-danger'>Permanent</span>";
}
}
$page->print_page_header();
?>
<div class="container">
<div class="row" style="margin-bottom:60px;">
<div style="text-align: center;" class="col-lg-12">
<table class="table st-light table-bordered table-condensed">
<?php
$map = $info->basic_info($row, $player_name);
$permanent_val = $info->page->permanent[$type];
foreach ($map as $key => $val) {
if ($permanent && $key === "Expires" && $val === $permanent_val) {
continue;
}
echo "<tr><td>$key</td><td>$val</td></tr>";
}
?>
</table>
</div>
</div>
<?php
$page->print_footer();
?>
</div>
<?php
}

View File

@ -1,31 +1,36 @@
<?php <?php
namespace litebans;
use PDO;
require_once './includes/page.php'; require_once './includes/page.php';
$page = new Page(); $page = new Page("kicks");
$page->print_title();
$headers = array("Name", "Kicked By", "Reason", "Date");
?> ?>
<title>Kicks - <?php echo $page->settings->name; ?></title>
<div class="container"> <div class="container">
<?php <?php
$page->print_page_header("Kicks"); $page->print_page_header();
?> ?>
<div class="row" style="margin-bottom:60px;"> <div class="row" style="margin-bottom:60px;">
<div class="col-lg-12"> <div class="col-lg-12">
<table class="table table-hover table-bordered table-condensed"> <?php
<?php $page->table_begin();
$page->print_table_headers(array("Name", "Kicked By", "Reason", "Date")); $page->table_print_headers($headers);
$result = $page->run_query($page->settings->table_kicks); $result = $page->run_query();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$player_name = $page->get_name($row['uuid']); $player_name = $page->get_name($row['uuid']);
if ($player_name === null) continue; if ($player_name === null) continue;
?>
<tr> $page->print_table_rows($row, array(
<td><?php echo $page->get_avatar($player_name); ?></td> 'Name' => $page->get_avatar($player_name),
<td><?php echo $page->get_avatar($page->get_banner_name($row)); ?></td> 'Kicked By' => $page->get_avatar($page->get_banner_name($row)),
<td style="width: 30%;"><?php echo $page->clean($row['reason']); ?></td> 'Reason' => $page->clean($row['reason']),
<td><?php echo $page->millis_to_date($row['time']); ?></td> 'Date' => $page->millis_to_date($row['time']),
</tr> ));
<?php } ?> }
</table> $page->table_end();
<?php $page->print_pager("kicks.php", $page->settings->table_kicks); ?> $page->print_pager();
?>
</div> </div>
</div> </div>
<?php $page->print_footer(); ?> <?php $page->print_footer(); ?>

View File

@ -1,42 +1,37 @@
<?php <?php
namespace litebans;
use PDO;
require_once './includes/page.php'; require_once './includes/page.php';
$page = new Page(); $page = new Page("mutes");
$page->print_title();
$headers = array("Name", "Muted By", "Reason", "Muted On", "Muted Until");
?> ?>
<title>Mutes - <?php echo $page->settings->name; ?></title>
<div class="container"> <div class="container">
<?php <?php
$page->print_page_header("Mutes"); $page->print_page_header();
?> ?>
<div class="row" style="margin-bottom:60px;"> <div class="row" style="margin-bottom:60px;">
<div class="col-lg-12"> <div class="col-lg-12">
<table class="table table-hover table-bordered table-condensed"> <?php
<?php $page->table_begin();
$page->print_table_headers(array("Name", "Muted By", "Reason", "Muted On", "Muted Until")); $page->table_print_headers($headers);
$result = $page->run_query($page->settings->table_mutes); $result = $page->run_query();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$player_name = $page->get_name($row['uuid']); $player_name = $page->get_name($row['uuid']);
if ($player_name === null) continue; if ($player_name === null) continue;
$until = $page->millis_to_date($row['until']);
?> $page->print_table_rows($row, array(
<tr> 'Name' => $page->get_avatar($player_name),
<td><?php echo $page->get_avatar($player_name); ?></td> 'Muted By' => $page->get_avatar($page->get_banner_name($row)),
<td><?php echo $page->get_avatar($page->get_banner_name($row)); ?></td> 'Reason' => $page->clean($row['reason']),
<td style="width: 30%;"><?php echo $page->clean($row['reason']); ?></td> 'Muted On' => $page->millis_to_date($row['time']),
<td><?php echo $page->millis_to_date($row['time']); ?></td> 'Muted Until' => $page->expiry($row),
<td> ));
<?php if ($row['until'] <= 0) { }
$until = 'Permanent Mute'; $page->table_end();
} $page->print_pager();
if ($page->settings->show_inactive_bans && !$row['active']) { ?>
$until .= ' (Unmuted)';
}
echo $until;
?>
</td>
</tr>
<?php } ?>
</table>
<?php $page->print_pager("mutes.php", $page->settings->table_mutes); ?>
</div> </div>
</div> </div>
<?php $page->print_footer(); ?> <?php $page->print_footer(); ?>

View File

@ -1,44 +1,37 @@
<?php <?php
namespace litebans;
use PDO;
require_once './includes/page.php'; require_once './includes/page.php';
$page = new Page(); $page = new Page("warnings");
$page->print_title();
$headers = array("Name", "Warned By", "Reason", "Warned Until", "Received Warning?");
?> ?>
<title>Warnings - <?php echo $page->settings->name; ?></title>
<div class="container"> <div class="container">
<?php <?php
$page->print_page_header("Warnings"); $page->print_page_header();
?> ?>
<div class="row" style="margin-bottom:60px;"> <div class="row" style="margin-bottom:60px;">
<div class="col-lg-12"> <div class="col-lg-12">
<table class="table table-hover table-bordered table-condensed"> <?php
<?php $page->table_begin();
$page->print_table_headers(array("Name", "Warned By", "Reason", "Warned Until", "Received Warning?")); $page->table_print_headers($headers);
$result = $page->run_query($page->settings->table_warnings); $result = $page->run_query();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$player_name = $page->get_name($row['uuid']); $player_name = $page->get_name($row['uuid']);
if ($player_name === null) continue; if ($player_name === null) continue;
$until = $page->millis_to_date($row['until']);
?> $page->print_table_rows($row, array(
<tr> 'Name' => $page->get_avatar($player_name),
<td><?php echo $page->get_avatar($player_name); ?></td> 'Warned By' => $page->get_avatar($page->get_banner_name($row)),
<td><?php echo $page->get_avatar($page->get_banner_name($row)); ?></td> 'Reason' => $page->clean($row['reason']),
<td style="width: 30%;"><?php echo $page->clean($row['reason']); ?></td> 'Warned Until' => $page->expiry($row),
<td> 'Received Warning?' => $row['warned'] ? "Yes" : "No",
<?php if ($row['until'] <= 0) { ));
$until = 'Permanent Warning'; }
} $page->table_end();
if ($page->settings->show_inactive_bans && !$row['active']) { $page->print_pager();
$until .= ' (Expired)'; ?>
}
echo $until;
?>
</td>
<td>
<?php echo $row['warned'] ? "Yes" : "No"; ?>
</td>
</tr>
<?php } ?>
</table>
<?php $page->print_pager("warnings.php", $page->settings->table_warnings); ?>
</div> </div>
</div> </div>
<?php $page->print_footer(); ?> <?php $page->print_footer(); ?>