diff options
author | lolcat <will@lolcat.ca> | 2024-04-22 11:12:46 -0400 |
---|---|---|
committer | lolcat <will@lolcat.ca> | 2024-04-22 11:12:46 -0400 |
commit | 81dc93802c32aa6f593a12b3f2efbe38dc9e31f7 (patch) | |
tree | d19c65d8a838582d54d57c42a0955725a49e2166 | |
parent | 0dc9d62985083174854251938daec896edef71bd (diff) |
opensearch onion fix
-rw-r--r-- | opensearch.php | 17 | ||||
-rw-r--r-- | scraper/qwant.php | 1 | ||||
-rw-r--r-- | sitemap.php | 2 |
3 files changed, 17 insertions, 3 deletions
diff --git a/opensearch.php b/opensearch.php index fb51430..4bdf97c 100644 --- a/opensearch.php +++ b/opensearch.php @@ -5,14 +5,27 @@ include "data/config.php"; $domain = htmlspecialchars( - ((isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] === 1)) ? "https" : "http") . + (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on" ? "https" : "http") . '://' . $_SERVER["HTTP_HOST"] ); +if( + preg_match( + '/\.onion$/', + $domain + ) +){ + + $onion = true; +}else{ + + $onion = false; +} + echo '<?xml version="1.0" encoding="UTF-8"?>' . '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">' . - '<ShortName>' . htmlspecialchars(config::SERVER_NAME) . '</ShortName>' . + '<ShortName>' . htmlspecialchars(config::SERVER_NAME) . ($onion ? " (onion)" : "") . '</ShortName>' . '<InputEncoding>UTF-8</InputEncoding>' . '<Image width="16" height="16">' . $domain . '/favicon.ico</Image>' . '<Url type="text/html" method="GET" template="' . $domain . '/web?s={searchTerms}"/>'; diff --git a/scraper/qwant.php b/scraper/qwant.php index 8b160ed..a8b69fe 100644 --- a/scraper/qwant.php +++ b/scraper/qwant.php @@ -259,6 +259,7 @@ class qwant{ } curl_close($curlproc); + return $data; } diff --git a/sitemap.php b/sitemap.php index 041550c..80bda66 100644 --- a/sitemap.php +++ b/sitemap.php @@ -5,7 +5,7 @@ include "data/config.php"; $domain = htmlspecialchars( - ((isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on" || $_SERVER["HTTPS"] === 1)) ? "https" : "http") . + (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on" ? "https" : "http") . '://' . $_SERVER["HTTP_HOST"] ); |