mirror of
https://github.com/hnhx/librex.git
synced 2025-04-29 05:59:27 -04:00
split the google language to site and results, now everything related to instances are defined in the config file
This commit is contained in:
parent
04ae09bd54
commit
a8645b7eb6
4 changed files with 147 additions and 81 deletions
|
@ -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
|
||||
)
|
||||
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
$config = require "config.php";
|
||||
|
||||
function get_base_url($url)
|
||||
{
|
||||
$split_url = explode("/", $url);
|
||||
|
@ -19,14 +21,16 @@
|
|||
|
||||
function try_replace_with_frontend($url, $frontend, $original)
|
||||
{
|
||||
$config = require "config.php";
|
||||
global $config;
|
||||
$frontends = $config->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);
|
||||
|
|
65
settings.php
65
settings.php
|
@ -1,29 +1,31 @@
|
|||
<?php
|
||||
$config = require "config.php";
|
||||
|
||||
|
||||
if (isset($_REQUEST["save"]) || isset($_REQUEST["reset"]))
|
||||
if (isset($_REQUEST["reset"]))
|
||||
{
|
||||
if (isset($_SERVER["HTTP_COOKIE"]))
|
||||
{
|
||||
$cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
|
||||
foreach($cookies as $cookie)
|
||||
{
|
||||
$parts = explode("=", $cookie);
|
||||
$name = trim($parts[0]);
|
||||
setcookie($name, "", time() - 1000);
|
||||
}
|
||||
$cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
|
||||
foreach($cookies as $cookie)
|
||||
{
|
||||
$parts = explode("=", $cookie);
|
||||
$name = trim($parts[0]);
|
||||
setcookie($name, "", time() - 1000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($_REQUEST["save"]))
|
||||
{
|
||||
foreach($_POST as $key=>$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 @@
|
|||
<p>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)</p>
|
||||
<div class="settings-textbox-container">
|
||||
<?php
|
||||
|
||||
$frontends = array(
|
||||
"invidious" => array("https://docs.invidious.io/instances/", "YouTube"),
|
||||
"bibliogram" => array("https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md", "Instagram"),
|
||||
"rimgo" => array("https://codeberg.org/video-prize-ranch/rimgo#instances", "Imgur"),
|
||||
"scribe" => array("https://git.sr.ht/~edwardloveall/scribe/tree/main/docs/instances.md", "Medium"),
|
||||
"gothub" => array("https://codeberg.org/gothub/gothub/wiki/Instances", "GitHub"),
|
||||
"librarian" => array("https://codeberg.org/librarian/librarian#clearnet", "Odysee"),
|
||||
"nitter" => array("https://github.com/zedeus/nitter/wiki/Instances", "Twitter"),
|
||||
"libreddit" => array("https://github.com/spikecodes/libreddit", "Reddit"),
|
||||
"proxitok" => array("https://github.com/pablouser1/ProxiTok/wiki/Public-instances", "TikTok"),
|
||||
"wikiless" => array("https://github.com/Metastem/wikiless#instances", "Wikipedia"),
|
||||
"quetre" => array("https://github.com/zyachel/quetre", "Quora"),
|
||||
"libremdb" => array("https://github.com/zyachel/libremdb", "IMDb"),
|
||||
"breezewiki" => array("https://gitdab.com/cadence/breezewiki", "Fandom"),
|
||||
"anonymousoverflow" => array("https://github.com/httpjamesm/AnonymousOverflow#clearnet-instances", "StackOverflow")
|
||||
);
|
||||
|
||||
foreach($frontends as $frontend => $info)
|
||||
foreach($config->frontends as $frontend => $data)
|
||||
{
|
||||
echo "<div>";
|
||||
echo "<a for=\"$frontend\" href=\"" . $info[0] . "\" target=\"_blank\">" . ucfirst($frontend) . "</a>";
|
||||
echo "<input type=\"text\" name=\"$frontend\" placeholder=\"Replace " . $info[1] . "\" value=";
|
||||
echo isset($_COOKIE["$frontend"]) ? htmlspecialchars($_COOKIE["$frontend"]) : json_decode(json_encode($config), true)[$frontend];
|
||||
echo "<a for=\"$frontend\" href=\"" . $data["project_url"] . "\" target=\"_blank\">" . ucfirst($frontend) . "</a>";
|
||||
echo "<input type=\"text\" name=\"$frontend\" placeholder=\"Replace " . $data["original_name"] . "\" value=";
|
||||
echo isset($_COOKIE["$frontend"]) ? htmlspecialchars($_COOKIE["$frontend"]) : $data["instance_url"];
|
||||
echo ">";
|
||||
echo "</div>";
|
||||
}
|
||||
|
@ -115,10 +99,17 @@
|
|||
<h2>Google settings</h2>
|
||||
<div class="settings-textbox-container">
|
||||
<div>
|
||||
<span>Google language</span>
|
||||
<span>Site language</span>
|
||||
<?php
|
||||
echo "<input type=\"text\" name=\"google_language\" placeholder=\"E.g.: de\" value=\"";
|
||||
echo isset($_COOKIE["google_language"]) ? htmlspecialchars($_COOKIE["google_language"]) : $config->google_language;
|
||||
echo "<input type=\"text\" name=\"google_language_site\" placeholder=\"E.g.: en\" value=\"";
|
||||
echo isset($_COOKIE["google_language_site"]) ? htmlspecialchars($_COOKIE["google_language_site"]) : $config->google_language_site;
|
||||
?>">
|
||||
</div>
|
||||
<div>
|
||||
<span>Results language</span>
|
||||
<?php
|
||||
echo "<input type=\"text\" name=\"google_language_results\" placeholder=\"E.g.: de\" value=\"";
|
||||
echo isset($_COOKIE["google_language_results"]) ? htmlspecialchars($_COOKIE["google_language_results"]) : $config->google_language_results;
|
||||
?>">
|
||||
</div>
|
||||
<div>
|
||||
|
|
Loading…
Add table
Reference in a new issue