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)); }