LibreY- privacy respecting meta search engine |
git clone git://git.acid.vegas/LibreY.git |
Log | Files | Refs | Archive | README | LICENSE |
commit 0bdd6f9c578eecc9175b691caa094229cdc78baf
parent a75a233fbdc34429f93a230bb724bab472ce622f Author: hnhx <49120638+hnhx@users.noreply.github.com> Date: Sat, 24 Jun 2023 08:46:10 +0000 Merge pull request #237 from GospodinHoroshiy/main Redirect to random instance if google is ratelimiting Diffstat:
|
1 file changed, 7 insertions(+), 1 deletion(-) |
diff --git a/engines/google/text.php b/engines/google/text.php @@ -57,7 +57,7 @@ $url = "https://$wikipedia_language.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded"; break; } - + if ($url != NULL) { $special_ch = curl_init($url); @@ -70,6 +70,12 @@ do { curl_multi_exec($mh, $running); } while ($running); + if (curl_getinfo($google_ch)['http_code'] == '302') { + $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']))); + header("Location: " . $instances[array_rand($instances)] . "search.php?q=$query"); + die(); + } if ($special_search != 0) |