From f4f8c50c4619b3d6c7ba8bce889355f4c305c1e5 Mon Sep 17 00:00:00 2001 From: Ruan Date: Sat, 6 Jun 2015 13:43:10 +0200 Subject: [PATCH] Cleanup, minor fixes --- bans.php | 17 +++-------------- check.php | 40 +++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/bans.php b/bans.php index d315c36..daffccf 100644 --- a/bans.php +++ b/bans.php @@ -12,14 +12,14 @@
-
+
diff --git a/check.php b/check.php index a7f5a19..fcd0f2e 100644 --- a/check.php +++ b/check.php @@ -3,31 +3,33 @@ if (isset($_POST['name'], $_POST['table'])) { require 'includes/page.php'; $name = $_POST['name']; // user input global $table_bans, $table_history, $conn; - $stmt = $conn->prepare("SELECT uuid FROM " . $table_history . " WHERE name=? ORDER BY date LIMIT 1"); + $stmt = $conn->prepare("SELECT name,uuid FROM " . $table_history . " WHERE name=? ORDER BY date LIMIT 1"); if ($stmt->execute(array($name))) { if ($row = $stmt->fetch()) { + $name = $row['name']; $uuid = $row['uuid']; } } - if (isset($uuid)) { - $stmt = $conn->prepare("SELECT * FROM " . $table_bans . " WHERE (uuid=? AND active=1) LIMIT 1"); - if ($stmt->execute(array($uuid))) { - if ($row = $stmt->fetch()) { - $banner = get_banner_name($row['banned_by_name']); - $reason = $row['reason']; - $time = millis_to_date($row['time']); - $until = millis_to_date($row['until']); - echo($name . ' is banned!
'); - echo('Banned by ' . $banner . '
'); - echo('Reason: ' . $reason . '
'); - echo('Banned on: ' . $time . '
'); - echo('Banned until: ' . $until . '
'); - } else { - echo($name . ' is not banned.'); - } - } - } else { + if (!isset($uuid)) { + $name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); echo($name . ' has not joined before.'); + return; + } + $stmt = $conn->prepare("SELECT * FROM " . $table_bans . " WHERE (uuid=? AND active=1) LIMIT 1"); + if ($stmt->execute(array($uuid))) { + if (!($row = $stmt->fetch())) { + echo($name . ' is not banned.'); + return; + } + $banner = get_banner_name($row['banned_by_name']); + $reason = $row['reason']; + $time = millis_to_date($row['time']); + $until = millis_to_date($row['until']); + echo($name . ' is banned!
'); + echo('Banned by ' . $banner . '
'); + echo('Reason: ' . $reason . '
'); + echo('Banned on: ' . $time . '
'); + echo('Banned until: ' . $until . '
'); } } ?> \ No newline at end of file