2021-02-21 16:37:27 +00:00
< ? php
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 ,
]);
2021-07-15 22:37:33 +00:00
$all = false ;
2021-02-21 16:37:27 +00:00
$pdo = ( new App\DB ( $options )) -> pdo ;
2021-07-15 22:37:33 +00:00
if ( isset ( $_GET [ " all " ]))
$all = true ;
2021-02-21 16:37:27 +00:00
/* Get records with limit */
2021-07-15 22:37:33 +00:00
$STH = $pdo -> query ( " SELECT `host`, `base64`, `base32`, `add_date`, `last_seen` FROM `hosts` WHERE `disabled` = 0 " . ( $all ? " " : " AND `blacklisted` = 0 " ) . " ORDER BY `add_date` DESC LIMIT " . $options [ " tableitems " ]);
2022-08-26 23:40:48 +00:00
$rows = $STH -> fetchAll ( PDO :: FETCH_ASSOC );
2021-02-21 16:37:27 +00:00
$template = $twig -> load ( 'latest.twig' );
2021-09-13 17:21:23 +00:00
echo $template -> render ([ 'limit' => $options [ " tableitems " ], 'hosts' => $rows , 'all' => $all ]);