Add disable automatic redirection setting
This commit is contained in:
parent
b5a9f12df9
commit
ff1db195d1
3 changed files with 15 additions and 1 deletions
|
@ -20,6 +20,9 @@
|
||||||
|
|
||||||
"disable_hidden_service_search" => false,
|
"disable_hidden_service_search" => false,
|
||||||
|
|
||||||
|
// You can disable automatic redirection from your instance
|
||||||
|
"automatic_redirection" => true,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Preset privacy friendly frontends for users, these can be overwritten by users in the settings
|
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",
|
e.g.: Preset the invidious instance URL: "instance_url" => "https://yewtu.be",
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$domain = $config->google_domain;
|
$domain = $config->google_domain;
|
||||||
|
$disable_automatic_redirection = isset($_COOKIE["disable_automatic_redirection"]);
|
||||||
$site_language = isset($_COOKIE["google_language_site"]) ? trim(htmlspecialchars($_COOKIE["google_language_site"])) : $config->google_language_site;
|
$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;
|
$results_language = isset($_COOKIE["google_language_results"]) ? trim(htmlspecialchars($_COOKIE["google_language_results"])) : $config->google_language_results;
|
||||||
$number_of_results = isset($_COOKIE["google_number_of_results"]) ? trim(htmlspecialchars($_COOKIE["google_number_of_results"])) : $config->google_number_of_results;
|
$number_of_results = isset($_COOKIE["google_number_of_results"]) ? trim(htmlspecialchars($_COOKIE["google_number_of_results"])) : $config->google_number_of_results;
|
||||||
|
@ -70,7 +71,10 @@
|
||||||
do {
|
do {
|
||||||
curl_multi_exec($mh, $running);
|
curl_multi_exec($mh, $running);
|
||||||
} while ($running);
|
} while ($running);
|
||||||
if (curl_getinfo($google_ch)['http_code'] == '302') {
|
|
||||||
|
if (!$disabled_automatic_redirection
|
||||||
|
&& $config->automatic_redirection
|
||||||
|
&& curl_getinfo($google_ch)['http_code'] == '302') {
|
||||||
$instances_json = json_decode(file_get_contents("instances.json"), true);
|
$instances_json = json_decode(file_get_contents("instances.json"), true);
|
||||||
$instances = array_map(fn($n) => $n['clearnet'], array_filter($instances_json['instances'], fn($n) => !is_null($n['clearnet'])));
|
$instances = array_map(fn($n) => $n['clearnet'], array_filter($instances_json['instances'], fn($n) => !is_null($n['clearnet'])));
|
||||||
header("Location: " . $instances[array_rand($instances)] . "search.php?q=$query");
|
header("Location: " . $instances[array_rand($instances)] . "search.php?q=$query");
|
||||||
|
|
|
@ -103,6 +103,13 @@
|
||||||
|
|
||||||
<h2>Google settings</h2>
|
<h2>Google settings</h2>
|
||||||
<div class="settings-textbox-container">
|
<div class="settings-textbox-container">
|
||||||
|
<?php if ($config->automatic_redirection) : ?>
|
||||||
|
<div>
|
||||||
|
<label>disable automatic redirection</label>
|
||||||
|
<input type="checkbox" name="disable_automatic_redirection" <?php echo isset($_COOKIE["disable_automatic_redirection"]) ? "checked" : ""; ?> >
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span>Site language</span>
|
<span>Site language</span>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in a new issue