mirror of
https://github.com/hnhx/librex.git
synced 2025-04-29 14:09: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_domain" => "com",
|
||||||
|
|
||||||
// Google results will be in this language
|
// Google results will be in this language
|
||||||
"google_language" => "en",
|
"google_language_site" => "",
|
||||||
|
"google_language_results" => "",
|
||||||
|
|
||||||
// You can use any Invidious instance here
|
// You can use any Invidious instance here
|
||||||
"invidious_instance_for_video_results" => "https://invidious.namazso.eu",
|
"invidious_instance_for_video_results" => "https://invidious.namazso.eu",
|
||||||
|
@ -16,23 +17,98 @@
|
||||||
"disable_hidden_service_search" => false,
|
"disable_hidden_service_search" => false,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Preset privacy friendly frontends for users, these can be overwritten by users in settings
|
Preset privacy friendly frontends for users, these can be overwritten by users in the settings
|
||||||
e.g.: "invidious" => "https://yewtu.be",
|
e.g.: Preset the invidious instance URL: "instance_url" => "https://yewtu.be",
|
||||||
*/
|
*/
|
||||||
"invidious" => "", // youtube
|
|
||||||
"bibliogram" => "", // instagram
|
"frontends" => array(
|
||||||
"rimgo" => "", // imgur
|
"invidious" => array(
|
||||||
"scribe" => "", // medium
|
"instance_url" => "",
|
||||||
"librarian" => "", // odysee
|
"project_url" => "https://docs.invidious.io/instances/",
|
||||||
"gothub" => "", // github
|
"original_name" => "YouTube",
|
||||||
"nitter" => "", // twitter
|
"original_url" => "youtube.com"
|
||||||
"libreddit" => "", // reddit
|
),
|
||||||
"proxitok" => "", // tiktok
|
"bibliogram" => array(
|
||||||
"wikiless" => "", // wikipedia
|
"instance_url" => "",
|
||||||
"quetre" => "", // quora
|
"project_url" => "https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md",
|
||||||
"libremdb" => "", // imdb,
|
"original_name" => "Instagram",
|
||||||
"breezewiki" => "", // fandom,
|
"original_url" => "instagram.com"
|
||||||
"anonymousoverflow" => "", // stackoverflow
|
),
|
||||||
|
"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:
|
To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE:
|
||||||
|
@ -61,6 +137,5 @@
|
||||||
CURLOPT_TIMEOUT => 18,
|
CURLOPT_TIMEOUT => 18,
|
||||||
CURLOPT_VERBOSE => false
|
CURLOPT_VERBOSE => false
|
||||||
)
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -8,13 +8,19 @@
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$domain = $config->google_domain;
|
$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";
|
$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"]))
|
if (isset($_COOKIE["safe_search"]))
|
||||||
|
@ -22,6 +28,8 @@
|
||||||
$url .= "&safe=medium";
|
$url .= "&safe=medium";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo $url;
|
||||||
|
|
||||||
$google_ch = curl_init($url);
|
$google_ch = curl_init($url);
|
||||||
curl_setopt_array($google_ch, $config->curl_settings);
|
curl_setopt_array($google_ch, $config->curl_settings);
|
||||||
curl_multi_add_handle($mh, $google_ch);
|
curl_multi_add_handle($mh, $google_ch);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
$config = require "config.php";
|
||||||
|
|
||||||
function get_base_url($url)
|
function get_base_url($url)
|
||||||
{
|
{
|
||||||
$split_url = explode("/", $url);
|
$split_url = explode("/", $url);
|
||||||
|
@ -19,14 +21,16 @@
|
||||||
|
|
||||||
function try_replace_with_frontend($url, $frontend, $original)
|
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]))
|
if (isset($_COOKIE[$frontend]))
|
||||||
$frontend = $_COOKIE[$frontend];
|
$frontend = $_COOKIE[$frontend];
|
||||||
else if (!empty($config->$frontend))
|
else if (!empty($frontends[$frontend]["instance_url"]))
|
||||||
$frontend = $config->$frontend;
|
$frontend = $frontends[$frontend]["instance_url"];
|
||||||
|
|
||||||
if ($original == "instagram.com")
|
if ($original == "instagram.com")
|
||||||
{
|
{
|
||||||
|
@ -69,28 +73,16 @@
|
||||||
|
|
||||||
function check_for_privacy_frontend($url)
|
function check_for_privacy_frontend($url)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
if (isset($_COOKIE["disable_frontends"]))
|
if (isset($_COOKIE["disable_frontends"]))
|
||||||
return $url;
|
return $url;
|
||||||
|
|
||||||
$frontends = array(
|
foreach($config->frontends as $frontend => $data)
|
||||||
"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)
|
|
||||||
{
|
{
|
||||||
|
$original = $data["original_url"];
|
||||||
|
|
||||||
if (strpos($url, $original))
|
if (strpos($url, $original))
|
||||||
{
|
{
|
||||||
$url = try_replace_with_frontend($url, $frontend, $original);
|
$url = try_replace_with_frontend($url, $frontend, $original);
|
||||||
|
|
65
settings.php
65
settings.php
|
@ -1,29 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
$config = require "config.php";
|
$config = require "config.php";
|
||||||
|
|
||||||
|
if (isset($_REQUEST["reset"]))
|
||||||
if (isset($_REQUEST["save"]) || isset($_REQUEST["reset"]))
|
|
||||||
{
|
{
|
||||||
if (isset($_SERVER["HTTP_COOKIE"]))
|
if (isset($_SERVER["HTTP_COOKIE"]))
|
||||||
{
|
{
|
||||||
$cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
|
$cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
|
||||||
foreach($cookies as $cookie)
|
foreach($cookies as $cookie)
|
||||||
{
|
{
|
||||||
$parts = explode("=", $cookie);
|
$parts = explode("=", $cookie);
|
||||||
$name = trim($parts[0]);
|
$name = trim($parts[0]);
|
||||||
setcookie($name, "", time() - 1000);
|
setcookie($name, "", time() - 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_REQUEST["save"]))
|
if (isset($_REQUEST["save"]))
|
||||||
{
|
{
|
||||||
foreach($_POST as $key=>$value){
|
foreach($_POST as $key=>$value)
|
||||||
|
{
|
||||||
if (!empty($value))
|
if (!empty($value))
|
||||||
{
|
{
|
||||||
setcookie($key, $value, time() + (86400 * 90), '/');
|
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>
|
<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">
|
<div class="settings-textbox-container">
|
||||||
<?php
|
<?php
|
||||||
|
foreach($config->frontends as $frontend => $data)
|
||||||
$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)
|
|
||||||
{
|
{
|
||||||
echo "<div>";
|
echo "<div>";
|
||||||
echo "<a for=\"$frontend\" href=\"" . $info[0] . "\" target=\"_blank\">" . ucfirst($frontend) . "</a>";
|
echo "<a for=\"$frontend\" href=\"" . $data["project_url"] . "\" target=\"_blank\">" . ucfirst($frontend) . "</a>";
|
||||||
echo "<input type=\"text\" name=\"$frontend\" placeholder=\"Replace " . $info[1] . "\" value=";
|
echo "<input type=\"text\" name=\"$frontend\" placeholder=\"Replace " . $data["original_name"] . "\" value=";
|
||||||
echo isset($_COOKIE["$frontend"]) ? htmlspecialchars($_COOKIE["$frontend"]) : json_decode(json_encode($config), true)[$frontend];
|
echo isset($_COOKIE["$frontend"]) ? htmlspecialchars($_COOKIE["$frontend"]) : $data["instance_url"];
|
||||||
echo ">";
|
echo ">";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
}
|
}
|
||||||
|
@ -115,10 +99,17 @@
|
||||||
<h2>Google settings</h2>
|
<h2>Google settings</h2>
|
||||||
<div class="settings-textbox-container">
|
<div class="settings-textbox-container">
|
||||||
<div>
|
<div>
|
||||||
<span>Google language</span>
|
<span>Site language</span>
|
||||||
<?php
|
<?php
|
||||||
echo "<input type=\"text\" name=\"google_language\" placeholder=\"E.g.: de\" value=\"";
|
echo "<input type=\"text\" name=\"google_language_site\" placeholder=\"E.g.: en\" value=\"";
|
||||||
echo isset($_COOKIE["google_language"]) ? htmlspecialchars($_COOKIE["google_language"]) : $config->google_language;
|
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>
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue