|
|
|
<?php
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../lib/twig.php';
|
|
|
|
|
|
|
|
$all = false;
|
|
|
|
$offset = $options["tableitems"] * ($page - 1);
|
|
|
|
|
|
|
|
$pdo = (new App\DB($options))->pdo;
|
|
|
|
|
|
|
|
if (isset($_GET["all"]))
|
|
|
|
$all = true;
|
|
|
|
|
|
|
|
/* Get records amount */
|
|
|
|
$STH = $pdo->query ("SELECT COUNT(*) FROM `hosts` " .
|
|
|
|
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0" .
|
|
|
|
($all ? "" : " AND `blacklisted` = 0"));
|
|
|
|
$records = $STH->fetchColumn();
|
|
|
|
|
|
|
|
$pages = intdiv($records, $options["tableitems"]) + 1;
|
|
|
|
|
|
|
|
/* Get records with limit */
|
|
|
|
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` " .
|
|
|
|
"WHERE `approved` = 1 AND `disabled` = 0 AND `hidden` = 0" .
|
|
|
|
($all ? " " : " AND `blacklisted` = 0 ") .
|
|
|
|
"LIMIT " . $offset . ", " . $options["tableitems"]);
|
|
|
|
$STH->setFetchMode(PDO::FETCH_ASSOC);
|
|
|
|
$rows = $STH->fetchAll();
|
|
|
|
|
|
|
|
$template = $twig->load('alive.twig');
|
|
|
|
echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'records' => $records, 'all' => $all]);
|