1
Fork 1
mirror of https://git.lolcat.ca/lolcat/4get.git synced 2024-10-25 17:26:50 -05:00
4get/opensearch.php

43 lines
1 KiB
PHP
Raw Normal View History

2023-11-07 08:04:56 -05:00
<?php
header("Content-Type: application/xml");
include "data/config.php";
$domain =
htmlspecialchars(
2024-04-22 10:12:46 -05:00
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on" ? "https" : "http") .
2023-11-07 08:04:56 -05:00
'://' . $_SERVER["HTTP_HOST"]
);
2024-04-22 10:12:46 -05:00
if(
preg_match(
'/\.onion$/',
$domain
)
){
$onion = true;
}else{
$onion = false;
}
2023-11-07 08:04:56 -05:00
echo
'<?xml version="1.0" encoding="UTF-8"?>' .
'<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">' .
2024-04-22 10:12:46 -05:00
'<ShortName>' . htmlspecialchars(config::SERVER_NAME) . ($onion ? " (onion)" : "") . '</ShortName>' .
2023-11-07 08:04:56 -05:00
'<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>';