Quellcode durchsuchen

opensearch onion fix

lolcat vor 2 Jahren
Ursprung
Commit
81dc93802c
3 geänderte Dateien mit 17 neuen und 3 gelöschten Zeilen
  1. 15 2
      opensearch.php
  2. 1 0
      scraper/qwant.php
  3. 1 1
      sitemap.php

+ 15 - 2
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}"/>';

+ 1 - 0
scraper/qwant.php

@@ -259,6 +259,7 @@ class qwant{
 		}
 		
 		curl_close($curlproc);
+		
 		return $data;
 	}
 	

+ 1 - 1
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"]
 	);