public function run($name, $from) { // validate user input if (strlen($name) > 16 || !preg_match("/^[0-9a-zA-Z_]{1,16}\$/", $name)) { $this->println("Invalid name."); return; } $page = new Page("check", false); $history = $page->settings->table['history']; try { $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']; $uuid = $row['uuid']; } } if (!isset($uuid)) { $name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); $this->println("{$name} has not joined before."); return; } $href = "history.php?uuid={$uuid}"; // sanitize $_POST['table'] ($from) $from_type = $page->type_info($from); $type = $from_type['type']; if ($type !== null) { $href .= "&from=" . lcfirst($from_type['title']); } echo "<br><script type=\"text/javascript\">document.location=\"{$href}\";</script>"; /* $table = $page->settings->table['bans']; $stmt = $page->conn->prepare("SELECT * FROM $table WHERE (uuid=? AND active=" . Settings::$TRUE . ") LIMIT 1"); if ($stmt->execute(array($uuid))) { if (!($row = $stmt->fetch())) { $this->println("$name is not banned."); return; } $banner = $page->get_banner_name($row); $reason = $page->clean($row['reason']); $time = $page->millis_to_date($row['time']); $until = $page->millis_to_date($row['until']); $this->println("$name is banned!"); $this->println("Banned by: $banner"); $this->println("Reason: $reason"); $this->println("Banned on: $time"); if ($row['until'] > 0) { $this->println("Banned until: $until"); } else { $this->println("Banned permanently."); } } */ } catch (PDOException $ex) { die($ex->getMessage()); } }
public function run($name) { // validate user input if (strlen($name) > 16 || !preg_match("/^[0-9a-zA-Z_]{1,16}\$/", $name)) { $this->println("Invalid name."); return; } $page = new Page("check", false); $history = $page->settings->table['history']; try { $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']; $uuid = $row['uuid']; } } if (!isset($uuid)) { $name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); $this->println("{$name} has not joined before."); return; } $table = $page->settings->table['bans']; $stmt = $page->conn->prepare("SELECT * FROM {$table} WHERE (uuid=? AND active=" . Settings::$TRUE . ") LIMIT 1"); if ($stmt->execute(array($uuid))) { if (!($row = $stmt->fetch())) { $this->println("{$name} is not banned."); return; } $banner = $page->get_banner_name($row); $reason = $page->clean($row['reason']); $time = $page->millis_to_date($row['time']); $until = $page->millis_to_date($row['until']); $this->println("{$name} is banned!"); $this->println("Banned by: {$banner}"); $this->println("Reason: {$reason}"); $this->println("Banned on: {$time}"); if ($row['until'] > 0) { $this->println("Banned until: {$until}"); } else { $this->println("Banned permanently."); } } } catch (PDOException $ex) { die($ex->getMessage()); } }
/** * Appends COUNT(*) from $table matching $uuid to $counts, * then appends all rows from $table matching $uuid to $array * @param Page $page * @param array $array * @param string $type * @param string $uuid * @param string $field * @param array $counts */ static function push($page, &$array, $type, $uuid, $field, &$counts) { $table = $page->settings->table[$type]; $count_st = $page->conn->prepare("SELECT COUNT(*) AS count FROM {$table} WHERE {$field}=:uuid"); $count_st->bindParam(":uuid", $uuid, PDO::PARAM_STR); if ($count_st->execute() && ($row = $count_st->fetch()) !== null) { $counts[$type] = $row['count']; } $sel = $page->get_selection($table); $st = $page->conn->prepare("SELECT {$sel} FROM {$table} WHERE {$field}=:uuid ORDER BY time"); $st->bindParam(":uuid", $uuid, PDO::PARAM_STR); if ($st->execute()) { while ($row = $st->fetch(PDO::FETCH_ASSOC)) { $row['__table__'] = $type; array_push($array, $row); } } }
<?php namespace litebans; use PDO; require_once './includes/page.php'; $page = new Page("mutes"); $page->print_title(); $headers = array("Name", "Muted By", "Reason", "Muted On", "Muted Until"); $page->print_page_header(); $page->table_begin(); $page->table_print_headers($headers); $result = $page->run_query(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $player_name = $page->get_name($row['uuid']); if ($player_name === null) { continue; } $page->print_table_rows($row, array('Name' => $page->get_avatar($player_name, $row['uuid']), 'Muted By' => $page->get_avatar($page->get_banner_name($row), $row['banned_by_uuid']), 'Reason' => $page->clean($row['reason']), 'Muted On' => $page->millis_to_date($row['time']), 'Muted Until' => $page->expiry($row))); } $page->table_end(); $page->print_pager(); $page->print_footer();
<?php namespace litebans; use PDO; require_once './includes/page.php'; $page = new Page("warnings"); $page->print_title(); $headers = array("Name", "Warned By", "Reason", "Warned Until", "Received Warning?"); $page->print_page_header(); $page->table_begin(); $page->table_print_headers($headers); $result = $page->run_query(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $player_name = $page->get_name($row['uuid']); if ($player_name === null) { continue; } $page->print_table_rows($row, array('Name' => $page->get_avatar($player_name, $row['uuid']), 'Warned By' => $page->get_avatar($page->get_banner_name($row), $row['banned_by_uuid']), 'Reason' => $page->clean($row['reason']), 'Warned Until' => $page->expiry($row), 'Received Warning?' => $row['warned'] ? "Yes" : "No")); } $page->table_end(); $page->print_pager(); $page->print_footer();
class KickInfo extends Info { function basic_info($row, $player_name) { $page = $this->page; return array('Kicked Player' => $this->punished_avatar($player_name, $row), 'Kicked By' => $this->moderator_avatar($row), 'Kick Reason' => $page->clean($row['reason']), 'Kick Date' => $page->millis_to_date($row['time'])); } } // check if info.php is requested, otherwise it's included if (substr($_SERVER['SCRIPT_NAME'], -strlen("info.php")) !== "info.php") { return; } isset($_GET['type'], $_GET['id']) && is_string($_GET['type']) && is_string($_GET['id']) or die("Missing arguments (type, id)."); $type = $_GET['type']; $id = $_GET['id']; $page = new Page($type); $page->type !== null or die("Unknown page type requested."); filter_var($id, FILTER_VALIDATE_INT) or die("Invalid ID."); $id = (int) $id; $type = $page->type; $table = $page->table; $sel = $page->get_selection($table); $query = "SELECT {$sel} FROM {$table} WHERE id=? LIMIT 1"; $st = $page->conn->prepare($query); if ($st->execute(array($id))) { $row = $st->fetch() or die("Error: {$type} not found in database."); $player_name = $page->get_name($row['uuid']); $player_name !== null or die("Error: Player name not found."); $info = Info::create($row, $page, $type); $name = $info->name(); $permanent = $info->permanent();
<?php namespace litebans; use PDO; require_once './includes/page.php'; $page = new Page("kicks"); $page->print_title(); $page->print_page_header(); $page->print_check_form(); $page->table_begin(); $result = $page->run_query(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $player_name = $page->get_name($row['uuid']); if ($player_name === null) { continue; } $page->print_table_rows($row, array('Name' => $page->get_avatar($player_name, $row['uuid']), 'Kicked By' => $page->get_avatar($page->get_banner_name($row), $row['banned_by_uuid']), 'Reason' => $page->clean($row['reason']), 'Date' => $page->millis_to_date($row['time']))); } $page->table_end(); $page->print_pager(); $page->print_footer();
{ $page = $this->page; return array('Warned Player' => $page->get_avatar($player_name, $row['uuid']), 'Warned By' => $page->get_avatar($page->get_banner_name($row), $row['banned_by_uuid']), '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, $row['uuid']), 'Kicked By' => $page->get_avatar($page->get_banner_name($row), $row['banned_by_uuid']), '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."); }