opensearch.php 934 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. header("Content-Type: application/xml");
  3. include "data/config.php";
  4. $domain =
  5. htmlspecialchars(
  6. (strpos(strtolower($_SERVER['SERVER_PROTOCOL']), 'https') === false ? 'http' : 'https') .
  7. '://' . $_SERVER["HTTP_HOST"]
  8. );
  9. echo
  10. '<?xml version="1.0" encoding="UTF-8"?>' .
  11. '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">' .
  12. '<ShortName>' . htmlspecialchars(config::SERVER_NAME) . '</ShortName>' .
  13. '<InputEncoding>UTF-8</InputEncoding>' .
  14. '<Image width="16" height="16">' . $domain . '/favicon.ico</Image>' .
  15. '<Url type="text/html" method="GET" template="' . $domain . '/web?s={searchTerms}"/>';
  16. if(
  17. isset($_GET["ac"]) &&
  18. is_string($_GET["ac"]) &&
  19. $_GET["ac"] != "disabled"
  20. ){
  21. echo '<Url rel="suggestions" type="application/x-suggestions+json" template="' . $domain . '/api/v1/ac?s={searchTerms}&amp;scraper=' . htmlspecialchars($_GET["ac"]) . '"/>';
  22. }
  23. echo '</OpenSearchDescription>';