summaryrefslogtreecommitdiff
path: root/opensearch.php
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2023-11-07 08:04:56 -0500
committerlolcat <will@lolcat.ca>2023-11-07 08:04:56 -0500
commit785452873f0ee0a27fc157b482b7551560f0282d (patch)
tree4c70e240031ed3868425ca683c83ebfd378a9159 /opensearch.php
parent64b090ee058953aed2246967332c7f0b6623cd8f (diff)
fix typo
Diffstat (limited to 'opensearch.php')
-rw-r--r--opensearch.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/opensearch.php b/opensearch.php
new file mode 100644
index 0000000..632a533
--- /dev/null
+++ b/opensearch.php
@@ -0,0 +1,29 @@
+<?php
+
+header("Content-Type: application/xml");
+include "data/config.php";
+
+$domain =
+ htmlspecialchars(
+ (strpos(strtolower($_SERVER['SERVER_PROTOCOL']), 'https') === false ? 'http' : 'https') .
+ '://' . $_SERVER["HTTP_HOST"]
+ );
+
+echo
+ '<?xml version="1.0" encoding="UTF-8"?>' .
+ '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">' .
+ '<ShortName>' . htmlspecialchars(config::SERVER_NAME) . '</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}&amp;scraper=' . htmlspecialchars($_GET["ac"]) . '"/>';
+}
+
+echo '</OpenSearchDescription>';