diff options
author | lolcat <will@lolcat.ca> | 2025-08-11 01:55:15 +0000 |
---|---|---|
committer | lolcat <will@lolcat.ca> | 2025-08-11 01:55:15 +0000 |
commit | cdf958d29333d448f4521f4d2faa2592b58e9b27 (patch) | |
tree | 528f2a0ffa789a6f4279d9f54a4a2aaf391f390f /opensearch.php | |
download | shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.gz shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.bz2 shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.zip |
fix wikipedia crashgrafted
Diffstat (limited to 'opensearch.php')
-rw-r--r-- | opensearch.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/opensearch.php b/opensearch.php new file mode 100644 index 0000000..4bdf97c --- /dev/null +++ b/opensearch.php @@ -0,0 +1,42 @@ +<?php + +header("Content-Type: application/xml"); +include "data/config.php"; + +$domain = + htmlspecialchars( + (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) . ($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}"/>'; + +if( + isset($_GET["ac"]) && + is_string($_GET["ac"]) && + $_GET["ac"] != "disabled" +){ + + echo '<Url rel="suggestions" type="application/x-suggestions+json" template="' . $domain . '/api/v1/ac?s={searchTerms}&scraper=' . htmlspecialchars($_GET["ac"]) . '"/>'; +} + +echo '</OpenSearchDescription>'; |