diff --git a/check.php b/check.php
index 3901604..3d6cfe4 100644
--- a/check.php
+++ b/check.php
@@ -3,13 +3,14 @@ if (isset($_POST['name'], $_POST['table'])) {
$name = $_POST['name'];
// validate user input
if (strlen($name) > 16 || !preg_match("/^[0-9a-zA-Z_]{1,16}$/", $name)) {
- echo('Invalid name.');
+ echo "Invalid name.";
return;
}
require './includes/page.php';
$page = new Page();
+ $history = $page->settings->table_history;
- $stmt = $page->conn->prepare("SELECT name,uuid FROM " . $page->settings->table_history . " WHERE name=? ORDER BY date LIMIT 1");
+ $stmt = $page->conn->prepare("SELECT name,uuid FROM $history WHERE name=? ORDER BY date LIMIT 1");
if ($stmt->execute(array($name))) {
if ($row = $stmt->fetch()) {
$name = $row['name'];
@@ -18,29 +19,29 @@ if (isset($_POST['name'], $_POST['table'])) {
}
if (!isset($uuid)) {
$name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8');
- echo($name . ' has not joined before.
');
+ echo "$name has not joined before.
";
return;
}
$table = $page->settings->table_bans;
- $stmt = $page->conn->prepare("SELECT * FROM " . $table . " WHERE (uuid=? AND active=1) LIMIT 1");
+ $stmt = $page->conn->prepare("SELECT * FROM $table WHERE (uuid=? AND active=1) LIMIT 1");
if ($stmt->execute(array($uuid))) {
if (!($row = $stmt->fetch())) {
- echo($name . ' is not banned.
');
+ echo "$name is not banned.
";
return;
}
$banner = $page->get_banner_name($row);
- $reason = $row['reason'];
+ $reason = $page->clean($row['reason']);
$time = $page->millis_to_date($row['time']);
$until = $page->millis_to_date($row['until']);
- echo($name . ' is banned!
');
- echo('Banned by: ' . $banner . '
');
- echo('Reason: ' . $page->clean($reason) . '
');
- echo('Banned on: ' . $time . '
');
+ echo "$name is banned!
";
+ echo "Banned by: $banner
";
+ echo "Reason: $reason
";
+ echo "Banned on: $time
";
if ($row['until'] > 0) {
- echo('Banned until: ' . $until . '
');
+ echo "Banned until: $until
";
} else {
- echo('Banned permanently.
');
+ echo "Banned permanently.
";
}
}
}
diff --git a/includes/page.php b/includes/page.php
index f87f459..4a8858e 100644
--- a/includes/page.php
+++ b/includes/page.php
@@ -12,18 +12,17 @@ class Page {
}
function get_query($table) {
- return 'SELECT * FROM ' . $table . $this->settings->active_query .
- ' GROUP BY ' . $table . '.id ORDER BY time DESC LIMIT ' . $this->settings->limit_per_page;
+ $active_query = $this->settings->active_query;
+ $limit = $this->settings->limit_per_page;
+ return "SELECT * FROM $table $active_query GROUP BY $table.id ORDER BY time DESC LIMIT $limit";
}
function run_query($table) {
- $time = microtime(true);
try {
$result = $this->conn->query($this->get_query($table));
} catch (PDOException $ex) {
die($ex->getMessage());
}
- echo('');
return $result;
}
@@ -33,10 +32,9 @@ class Page {
function get_name($uuid) {
if (array_key_exists($uuid, $this->uuid_name_cache)) return $this->uuid_name_cache[$uuid];
- $time = microtime(true);
- $stmt = $this->conn->prepare("SELECT name FROM " . $this->settings->table_history . " WHERE uuid=? ORDER BY date DESC LIMIT 1");
+ $history = $this->settings->table_history;
+ $stmt = $this->conn->prepare("SELECT name FROM $history WHERE uuid=? ORDER BY date DESC LIMIT 1");
if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) {
- echo('');
$banner = $row['name'];
$this->uuid_name_cache[$uuid] = $banner;
return $banner;
@@ -78,19 +76,20 @@ class Page {
}
function print_page_header($title) {
- echo('
-