/** * 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); } } }
} } // 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(); $page->name = "{$name} #{$id}"; $page->print_title(); if (!$info instanceof KickInfo) { $style = 'style="margin-left: 13px; font-size: 16px;"'; $active = $page->active($row); if ($active === true) {