Domain registry project http://reg.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
825 B

<?php
require_once __DIR__ . '/../config.php';
$all = false;
$pdo = (new App\DB($options))->pdo;
header('Content-Type: application/json');
if (isset($_GET["all"]))
$all = true;
if(!$command || !in_array($command, ['all', 'status']))
exit(json_encode(["status" => "error", "message" => "Incorrect request"]));
if($command == "all") {
$STH = $pdo->query ("SELECT `base32`, UNIX_TIMESTAMP(`last_seen`) as `last_seen` FROM `hosts` " .
"WHERE `approved` = 1 AND `disabled` = 0" .
($all ? " " : " AND `blacklisted` = 0 "));
$STH->setFetchMode(PDO::FETCH_ASSOC);
$rows = $STH->fetchAll();
$data = [];
foreach($rows as $row) {
$data[$row["base32"] . ".b32.i2p"] = $row["last_seen"];
}
exit(json_encode($data, JSON_PRETTY_PRINT));
}