mirror of
https://github.com/PurpleI2P/regi2p.git
synced 2025-01-15 13:59:56 +00:00
31 lines
825 B
PHP
31 lines
825 B
PHP
|
<?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));
|
||
|
}
|