mirror of
https://github.com/hnhx/librex.git
synced 2025-04-29 14:09:27 -04:00
moved to redirect earlier, fixed formatting issues
This commit is contained in:
parent
7559bc8101
commit
e03b930386
1 changed files with 7 additions and 7 deletions
|
@ -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";
|
$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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($url != NULL)
|
if ($url != NULL)
|
||||||
{
|
{
|
||||||
$special_ch = curl_init($url);
|
$special_ch = curl_init($url);
|
||||||
|
@ -70,6 +70,12 @@
|
||||||
do {
|
do {
|
||||||
curl_multi_exec($mh, $running);
|
curl_multi_exec($mh, $running);
|
||||||
} while ($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)
|
if ($special_search != 0)
|
||||||
|
@ -114,12 +120,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$xpath = get_xpath(curl_multi_getcontent($google_ch));
|
$xpath = get_xpath(curl_multi_getcontent($google_ch));
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($xpath->query("//div[@id='search']//div[contains(@class, 'g')]") as $result)
|
foreach($xpath->query("//div[@id='search']//div[contains(@class, 'g')]") as $result)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue