1
0
mirror of https://github.com/PurpleI2P/regi2p.git synced 2025-02-11 15:54:13 +00:00
regi2p/views/all.php
r4sas 4777b23615
add i18n extension, pluralize strings
Signed-off-by: r4sas <r4sas@i2pmail.org>
2023-06-02 23:58:32 +00:00

28 lines
989 B
PHP

<?php
require_once __DIR__ . '/../lib/twig.php';
$all = false;
$offset = $options["tableitems"] * ($page - 1);
$newregoffs = date ("Y-m-d H:i:s", strtotime ("-7 day"));
$newseenlim = date ("Y-m-d H:i:s", strtotime ("-3 day"));
$oldseenlim = date ("Y-m-d H:i:s", strtotime ("-7 day"));
$pdo = (new App\DB($options))->pdo;
if (isset($_GET["all"]))
$all = true;
/* Get records amount */
$STH = $pdo->query ("SELECT COUNT(*) FROM `hosts`" . ($all ? "" : " WHERE `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`" . ($all ? "" : " WHERE `blacklisted` = 0") . " LIMIT " . $offset . ", " . $options["tableitems"]);
$rows = $STH->fetchAll(PDO::FETCH_ASSOC);
$template = $twig->load('all.twig');
echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'records' => $records, 'all' => $all]);