diff --git a/config.php b/config.php index eb8cec0..6566c7c 100755 --- a/config.php +++ b/config.php @@ -10,6 +10,16 @@ "disable_bittorent_search" => false, "bittorent_trackers" => "&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce", + /* + Preset privacy friendly frontends for users, these can be overwritten by users in settings + e.g.: "invidious" => "https://yewtu.be", + */ + "invidious" => "", + "bibliogram" => "", + "nitter" => "", + "libreddit" => "", + "wikiless" => "", + /* To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE: @@ -28,7 +38,7 @@ // CURLOPT_PROXYTYPE => CURLPROXY_HTTP, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", - CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36", + CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36", CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_SSL_VERIFYHOST => false, diff --git a/engines/google/text.php b/engines/google/text.php index e9b009a..772bd64 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -110,7 +110,7 @@ $url = $url->textContent; - $url = privacy_friendly_alternative($url); + $url = check_for_privacy_frontend($url); $title = $xpath->evaluate(".//h3", $result)[0]; $description = $xpath->evaluate(".//div[contains(@class, 'VwiC3b')]", $result)[0]; @@ -142,7 +142,7 @@ echo "

"; if (array_key_exists("image", $special["special_response"])) - echo ""; + echo ""; echo $response; echo "$source"; echo "

"; diff --git a/engines/google/video.php b/engines/google/video.php index 5526fc4..a9a2b6c 100644 --- a/engines/google/video.php +++ b/engines/google/video.php @@ -22,7 +22,7 @@ $url = $url->textContent; - $url = privacy_friendly_alternative($url); + $url = check_for_privacy_frontend($url); $title = $xpath->evaluate(".//h3", $result)[0]; diff --git a/engines/special/wikipedia.php b/engines/special/wikipedia.php index 714868d..f1df6ed 100644 --- a/engines/special/wikipedia.php +++ b/engines/special/wikipedia.php @@ -11,7 +11,7 @@ { $description = substr($first_page["extract"], 0, 250) . "..."; - $source = "https://en.wikipedia.org/wiki/$query"; + $source = check_for_privacy_frontend("https://wikipedia.org/wiki/$query"); $response = array( "special_response" => array( "response" => $description, @@ -20,7 +20,12 @@ ); if (array_key_exists("thumbnail", $first_page)) - $response["special_response"]["image"] = $first_page["thumbnail"]["source"]; + { + $img_url = $first_page["thumbnail"]["source"]; + $img_src = request($img_url); + $base64_src = base64_encode($img_src); + $response["special_response"]["image"] = $base64_src; + } return $response; } diff --git a/misc/footer.php b/misc/footer.php index 7e67261..9797a9f 100644 --- a/misc/footer.php +++ b/misc/footer.php @@ -1,10 +1,9 @@ diff --git a/misc/tools.php b/misc/tools.php index 6268873..8f448fe 100644 --- a/misc/tools.php +++ b/misc/tools.php @@ -6,11 +6,18 @@ return $base_url; } - function check_for_privacy_friendly_alternative($url, $frontend, $tobereplaced) + function try_replace_with_frontend($url, $frontend, $tobereplaced) { - if (isset($_COOKIE[$frontend]) || isset($_REQUEST[$frontend])) + $config = require "config.php"; + + if (isset($_COOKIE[$frontend]) || isset($_REQUEST[$frontend]) || !empty($config->$frontend)) { - $frontend = isset($_COOKIE[$frontend]) ? $_COOKIE[$frontend] : $_REQUEST[$frontend]; + if (isset($_COOKIE[$frontend])) + $frontend = $_COOKIE[$frontend]; + else if (isset($_REQUEST[$frontend])) + $frontend = $_REQUEST[$frontend]; + else if (!empty($config->$frontend)) + $frontend = $config->$frontend; if ($tobereplaced == "instagram.com") { @@ -26,16 +33,18 @@ return $url; } - function privacy_friendly_alternative($url) + function check_for_privacy_frontend($url) { if (strpos($url, "youtube.com")) - $url = check_for_privacy_friendly_alternative($url, "invidious", "youtube.com"); + $url = try_replace_with_frontend($url, "invidious", "youtube.com"); else if (strpos($url, "instagram.com")) - $url = check_for_privacy_friendly_alternative($url, "bibliogram", "instagram.com"); + $url = try_replace_with_frontend($url, "bibliogram", "instagram.com"); else if (strpos($url, "twitter.com")) - $url = check_for_privacy_friendly_alternative($url, "nitter", "twitter.com"); + $url = try_replace_with_frontend($url, "nitter", "twitter.com"); else if (strpos($url, "reddit.com")) - $url = check_for_privacy_friendly_alternative($url, "libreddit", "reddit.com"); + $url = try_replace_with_frontend($url, "libreddit", "reddit.com"); + else if (strpos($url, "wikipedia.org")) + $url = try_replace_with_frontend($url, "wikiless", "wikipedia.org"); return $url; } diff --git a/search.php b/search.php index ff97c67..a6a9d0c 100644 --- a/search.php +++ b/search.php @@ -4,14 +4,15 @@
- + strlen($query) || strlen($query) > 256) { - header("Location: /"); + header("Location: ./"); die(); } @@ -31,7 +32,6 @@ -
@@ -41,8 +41,6 @@ $page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0; - $query_encoded = urlencode($query); - $start_time = microtime(true); switch ($type) { diff --git a/settings.php b/settings.php index 636ada2..3652238 100644 --- a/settings.php +++ b/settings.php @@ -1,6 +1,7 @@ -

Privacy friendly frontends

For an example if you want to view YouTube without getting spied on, click on "Invidious", find the instance that is most suitable for you then paste it in (correct format: https://example.com)

-
- +
- Invidious - + Invidious + invidious\""; ?> >
Bibliogram - + bibliogram\""; ?> >
Nitter - + nitter\""; ?> >
Libreddit - + libreddit\""; ?> + > +
+ +
+ Wikiless + wikiless\""; ?> >
@@ -129,4 +137,4 @@
- + \ No newline at end of file