__DIR__ . '/../cache', 'auto_reload' => true, ]); $utils = new App\Utils; $domain = ""; $result = []; $error = ""; if (isset($query) && strlen($query) > 67 || isset($_POST["q"]) && strlen($_POST["q"]) > 67) $result["error"] = "Request is too long, max length is 67 chars"; else if (isset($query) && !empty($query)) $domain = htmlspecialchars($query); else if (isset($_POST["q"])) $domain = htmlspecialchars($_POST["q"]); if(!empty($domain) && !$utils->isValidDomain($domain, $error)) { $domain = ""; $result["error"] = 'Not valid query: ' . $error; } else if(!empty($domain) && $utils->isValidDomain($domain, $error)) { $pdo = (new App\DB($options))->pdo; $STH = $pdo->query("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1"); $STH->setFetchMode(PDO::FETCH_ASSOC); $row = $STH->fetchAll(); if (empty($row)) $result["error"] = "No such host is found"; else $result = array_merge($result, $row[0]); } $template = $twig->load('jump.twig'); echo $template->render(['domain' => $domain, 'result' => $result]);