conn = $settings->conn;
$this->settings = $settings;
$this->uuid_name_cache = array();
}
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;
}
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;
}
function get_avatar($name) {
return "$name";
}
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");
if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) {
echo('');
$banner = $row['name'];
$this->uuid_name_cache[$uuid] = $banner;
return $banner;
}
$this->uuid_name_cache[$uuid] = null;
return null;
}
function get_banner_name($row) {
$uuid = $row['banned_by_uuid'];
$name = $this->get_name($uuid);
if ($name !== null) {
return $name;
}
$name = $row['banned_by_name'];
return $this->clean($name);
}
function millis_to_date($millis) {
return date($this->settings->date_format, $millis / 1000);
}
/**
* Prepares text to be displayed on the web interface.
* Removes chat colours, replaces newlines with proper HTML, and sanitizes the text.
* @param $text
* @return mixed|string
*/
function clean($text) {
if (strstr($text, "\xa7") || strstr($text, "&")) {
$regex = "/(?i)(\xa7|&)[0-9A-FK-OR]/";
$text = preg_replace($regex, "", $text);
}
$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
if (strstr($text, "\n")) {
$text = preg_replace("/\n/", "
", $text);
}
return $text;
}
function print_page_header($title) {
echo('