1
0
mirror of https://github.com/PurpleI2P/regi2p.git synced 2025-01-15 09:49:56 +00:00
regi2p/views/hidden.php

42 lines
1.2 KiB
PHP
Raw Normal View History

<?php
$all = false;
// Check for option before loading anything
if (isset($_GET["all"])) {
$all = true;
} else {
header("Location: /");
exit();
}
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../config.php';
/* Initialize Twig engine */
$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../templates');
$twig = new \Twig\Environment($loader, [
'cache' => __DIR__ . '/../cache',
'auto_reload' => true,
]);
$offset = $options["tableitems"] * ($page - 1);
$pdo = (new App\DB($options))->pdo;
/* Get records amount */
$STH = $pdo->query ("SELECT COUNT(*) FROM `hosts` " .
2023-02-19 11:46:55 +00:00
"WHERE `approved` = 1 AND `blacklisted` = 1");
$records = $STH->fetchColumn();
$pages = intdiv($records, $options["tableitems"]) + 1;
/* Get records with limit */
$STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` " .
2023-02-19 11:46:55 +00:00
"WHERE `approved` = 1 AND `blacklisted` = 1 " .
"LIMIT " . $offset . ", " . $options["tableitems"]);
$rows = $STH->fetchAll(PDO::FETCH_ASSOC);
$template = $twig->load('hidden.twig');
echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'all' => $all]);