diff --git a/api/v1/ac.php b/api/v1/ac.php index c909aab..457897a 100644 --- a/api/v1/ac.php +++ b/api/v1/ac.php @@ -7,7 +7,7 @@ class autocomplete{ public function __construct(){ - header("Content-Type: application/json"); + header("Content-Type: application/x-suggestions+json"); $this->scrapers = [ "brave" => "https://search.brave.com/api/suggest?q={searchTerms}", @@ -18,7 +18,6 @@ class autocomplete{ "marginalia" => "https://search.marginalia.nu/suggest/?partial={searchTerms}", "yt" => "https://suggestqueries-clients6.youtube.com/complete/search?client=youtube&q={searchTerms}", "sc" => "", - "startpage" => "https://www.startpage.com/suggestions?q={searchTerms}&format=opensearch&segment=startpage.defaultffx&lui=english", "kagi" => "https://kagi.com/api/autosuggest?q={searchTerms}" ]; diff --git a/opensearch.php b/opensearch.php index 4bdf97c..dc36ea1 100644 --- a/opensearch.php +++ b/opensearch.php @@ -3,32 +3,46 @@ header("Content-Type: application/xml"); include "data/config.php"; -$domain = - htmlspecialchars( - (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on" ? "https" : "http") . - '://' . $_SERVER["HTTP_HOST"] - ); +$host = strtolower(explode(":", $_SERVER["HTTP_HOST"], 2)[0]); +// detect if 4get should serve the HTTPS endpoint if( preg_match( - '/\.onion$/', - $domain + '/\.(onion|i2p)$/', + strtolower($host), + $match ) ){ - $onion = true; + $ssl = false; + $src = $match[1]; +}elseif( + is_string( + filter_var( + $host, + FILTER_VALIDATE_IP + ) + ) || + $host == "localhost" +){ + + $ssl = false; + $src = "localhost"; }else{ - $onion = false; + $ssl = true; } +$domain = ($ssl ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"]; + echo '' . - '' . - '' . htmlspecialchars(config::SERVER_NAME) . ($onion ? " (onion)" : "") . '' . + '' . + '' . htmlspecialchars(config::SERVER_NAME) . ($ssl === false ? " ({$src})" : "") . '' . + '' . htmlspecialchars(config::SERVER_SHORT_DESCRIPTION) . '' . 'UTF-8' . - '' . $domain . '/favicon.ico' . - ''; + '' . htmlspecialchars($domain) . '/favicon.ico' . + ''; if( isset($_GET["ac"]) && @@ -36,7 +50,7 @@ if( $_GET["ac"] != "disabled" ){ - echo ''; + echo ''; } echo '';