diff --git a/config.php.example b/config.php.example index 531749e..481a276 100644 --- a/config.php.example +++ b/config.php.example @@ -5,7 +5,8 @@ "google_domain" => "com", // Google results will be in this language - "google_language" => "en", + "google_language_site" => "", + "google_language_results" => "", // You can use any Invidious instance here "invidious_instance_for_video_results" => "https://invidious.namazso.eu", @@ -16,23 +17,98 @@ "disable_hidden_service_search" => false, /* - Preset privacy friendly frontends for users, these can be overwritten by users in settings - e.g.: "invidious" => "https://yewtu.be", + Preset privacy friendly frontends for users, these can be overwritten by users in the settings + e.g.: Preset the invidious instance URL: "instance_url" => "https://yewtu.be", */ - "invidious" => "", // youtube - "bibliogram" => "", // instagram - "rimgo" => "", // imgur - "scribe" => "", // medium - "librarian" => "", // odysee - "gothub" => "", // github - "nitter" => "", // twitter - "libreddit" => "", // reddit - "proxitok" => "", // tiktok - "wikiless" => "", // wikipedia - "quetre" => "", // quora - "libremdb" => "", // imdb, - "breezewiki" => "", // fandom, - "anonymousoverflow" => "", // stackoverflow + + "frontends" => array( + "invidious" => array( + "instance_url" => "", + "project_url" => "https://docs.invidious.io/instances/", + "original_name" => "YouTube", + "original_url" => "youtube.com" + ), + "bibliogram" => array( + "instance_url" => "", + "project_url" => "https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md", + "original_name" => "Instagram", + "original_url" => "instagram.com" + ), + "rimgo" => array( + "instance_url" => "", + "project_url" => "https://codeberg.org/video-prize-ranch/rimgo#instances", + "original_name" => "Imgur", + "original_url" => "imgur.com" + ), + "scribe" => array( + "instance_url" => "", + "project_url" => "https://git.sr.ht/~edwardloveall/scribe/tree/main/docs/instances.md", + "original_name" => "Medium", + "original_url" => "medium.com" + ), + "gothub" => array( + "instance_url" => "", + "project_url" => "https://codeberg.org/gothub/gothub/wiki/Instances", + "original_name" => "GitHub", + "original_url" => "github.com" + ), + "librarian" => array( + "instance_url" => "", + "project_url" => "https://codeberg.org/librarian/librarian#clearnet", + "original_name" => "Odysee", + "original_url" => "odysee.com" + ), + + "nitter" => array( + "instance_url" => "", + "project_url" => "https://github.com/zedeus/nitter/wiki/Instances", + "original_name" => "Twitter", + "original_url" => "twitter.com" + ), + + "libreddit" => array( + "instance_url" => "", + "project_url" => "https://github.com/spikecodes/libreddit", + "original_name" => "Reddit", + "original_url" => "reddit.com" + ), + "proxitok" => array( + "instance_url" => "", + "project_url" => "https://github.com/pablouser1/ProxiTok/wiki/Public-instances", + "original_name" => "TikTok", + "original_url" => "tiktok.com" + ), + "wikiless" => array( + "instance_url" => "", + "project_url" => "https://github.com/Metastem/wikiless#instances", + "original_name" => "Wikipedia", + "original_url" => "wikipedia.com" + ), + "quetre" => array( + "instance_url" => "", + "project_url" => "https://github.com/zyachel/quetre", + "original_name" => "Quora", + "original_url" => "quora.com" + ), + "libremdb" => array( + "instance_url" => "", + "project_url" => "https://github.com/zyachel/libremdb", + "original_name" => "IMDb", + "original_url" => "imdb.com" + ), + "breezewiki" => array( + "instance_url" => "", + "project_url" => "https://gitdab.com/cadence/breezewiki", + "original_name" => "Fandom", + "original_url" => "fandom.com" + ), + "anonymousoverflow" => array( + "instance_url" => "", + "project_url" => "https://github.com/httpjamesm/AnonymousOverflow#clearnet-instances", + "original_name" => "StackOverflow", + "original_url" => "stackoverflow.com" + ) + ), /* To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE: @@ -61,6 +137,5 @@ CURLOPT_TIMEOUT => 18, CURLOPT_VERBOSE => false ) - ); ?> diff --git a/engines/google/text.php b/engines/google/text.php index 1ed9afb..78eb6cf 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -8,13 +8,19 @@ $results = array(); $domain = $config->google_domain; - $language = isset($_COOKIE["google_language"]) ? htmlspecialchars($_COOKIE["google_language"]) : $config->google_language; - + $site_language = isset($_COOKIE["google_language_site"]) ? trim(htmlspecialchars($_COOKIE["google_language_site"])) : $config->google_language_site; + $results_language = isset($_COOKIE["google_language_results"]) ? trim(htmlspecialchars($_COOKIE["google_language_results"])) : $config->google_language_results; + $url = "https://www.google.$domain/search?q=$query_encoded&start=$page"; - if (3 > strlen($language)) + if (3 > strlen($site_language) && 0 < strlen($site_language)) { - $url .= "&hl=$language&lr=lang_$language"; + $url .= "&hl=$site_language"; + } + + if (3 > strlen($results_language) && 0 < strlen($results_language)) + { + $url .= "&lr=lang_$results_language"; } if (isset($_COOKIE["safe_search"])) @@ -22,6 +28,8 @@ $url .= "&safe=medium"; } + echo $url; + $google_ch = curl_init($url); curl_setopt_array($google_ch, $config->curl_settings); curl_multi_add_handle($mh, $google_ch); diff --git a/misc/tools.php b/misc/tools.php index 950b793..f6d9268 100644 --- a/misc/tools.php +++ b/misc/tools.php @@ -1,4 +1,6 @@ frontends; - if (isset($_COOKIE[$frontend]) || !empty($config->$frontend)) + if (isset($_COOKIE[$frontend]) || !empty($frontends[$frontend]["instance_url"])) { + if (isset($_COOKIE[$frontend])) $frontend = $_COOKIE[$frontend]; - else if (!empty($config->$frontend)) - $frontend = $config->$frontend; + else if (!empty($frontends[$frontend]["instance_url"])) + $frontend = $frontends[$frontend]["instance_url"]; if ($original == "instagram.com") { @@ -69,28 +73,16 @@ function check_for_privacy_frontend($url) { + + global $config; + if (isset($_COOKIE["disable_frontends"])) return $url; - $frontends = array( - "youtube.com" => "invidious", - "instagram.com" => "bibliogram", - "imgur.com" => "rimgo", - "medium.com" => "scribe", - "github.com" => "gothub", - "odysee.com" => "librarian", - "twitter.com" => "nitter", - "reddit.com" => "libreddit", - "tiktok.com" => "proxitok", - "wikipedia.org" => "wikiless", - "quora.com" => "quetre", - "imdb.com" => "libremdb", - "fandom.com" => "breezewiki", - "stackoverflow.com" => "anonymousoverflow" - ); - - foreach($frontends as $original => $frontend) + foreach($config->frontends as $frontend => $data) { + $original = $data["original_url"]; + if (strpos($url, $original)) { $url = try_replace_with_frontend($url, $frontend, $original); diff --git a/settings.php b/settings.php index 52fdd9f..3e9e36f 100644 --- a/settings.php +++ b/settings.php @@ -1,29 +1,31 @@ $value){ + foreach($_POST as $key=>$value) + { if (!empty($value)) { setcookie($key, $value, time() + (86400 * 90), '/'); - $_COOKIE[$key] = $value; + } + else + { + setcookie($key, "", time() - 1000); } } } @@ -79,30 +81,12 @@
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)