
- NOTICE: config.default.php has changed, re-create your config.php!! - [fix] Footer no longer overlaps results - [fix] Search navigation no longer bunched up on smaller displays - [fix] Double search type when searching from start page - [new] Filter for additional/different headers per cURL request - [new] Image search via Openverse API (Access token and cronjob required, see installation instructions) - [new] Image search via Qwant API - [new] Web (recent news) search via Qwant API - [tweak] Merged 'cache' option into 'cache-type', see config.default.php for details - [tweak] Better filtering for duplicate web results - [tweak] File size formatting for images more uniform - [tweak] Optimized curl_multi_exec handling - [tweak] Improved SEO headers - [tweak] Layout tweaks and optimizations for search results, header and footer - [tweak] Removed redundant HTML, CSS and some PHP - [tweak] MagnetDL search disabled by default because of Cloudflare (Will probably be removed in future version) - [tweak] Removed non-functional magnet trackers - [tweak] Added 15 extra public magnet trackers - [change] Removed Ecosia support - [change] Removed Reddit support - [change] Removed 1337x support - [change] Removed MagnetDL support
55 lines
2 KiB
PHP
55 lines
2 KiB
PHP
<?php
|
|
/* ------------------------------------------------------------------------------------
|
|
* Goosle - A meta search engine for private and fast internet fun.
|
|
*
|
|
* COPYRIGHT NOTICE
|
|
* Copyright 2023-2024 Arnan de Gans. All Rights Reserved.
|
|
*
|
|
* COPYRIGHT NOTICES AND ALL THE COMMENTS SHOULD REMAIN INTACT.
|
|
* By using this code you agree to indemnify Arnan de Gans from any
|
|
* liability that might arise from its use.
|
|
------------------------------------------------------------------------------------ */
|
|
class WikiRequest extends EngineRequest {
|
|
public function get_request_url() {
|
|
$args = array("srsearch" => $this->query, "action" => "query", "format" => "json", "list" => "search", "limit" => "10");
|
|
$url = "https://".$this->opts->wikipedia_language.".wikipedia.org/w/api.php?".http_build_query($args);
|
|
|
|
return $url;
|
|
}
|
|
|
|
public function get_request_headers() {
|
|
return array(
|
|
'Accept' => 'application/json, */*;q=0.8',
|
|
'Accept-Language' => null,
|
|
'Accept-Encoding' => null,
|
|
'Connection' => null,
|
|
'Sec-Fetch-Dest' => null,
|
|
'Sec-Fetch-Mode' => null,
|
|
'Sec-Fetch-Site' => null
|
|
);
|
|
}
|
|
|
|
public function parse_results($response) {
|
|
$results = array();
|
|
$json_response = json_decode($response, true);
|
|
|
|
if(empty($json_response)) return $results;
|
|
|
|
// No results
|
|
if($json_response['query']['searchinfo']['totalhits'] == 0) return $results;
|
|
|
|
$rank = $results['amount'] = count($json_response['query']['search']);
|
|
foreach($json_response['query']['search'] as $result) {
|
|
$title = sanitize($result['title']);
|
|
$url = "https://".$this->opts->wikipedia_language.".wikipedia.org/wiki/".sanitize(str_replace(" ", "_", $result['title']));
|
|
$description = sanitize(strip_tags($result['snippet']));
|
|
|
|
$results['search'][] = array ("id" => uniqid(rand(0, 9999)), "source" => "Wikipedia", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank);
|
|
$rank -= 1;
|
|
}
|
|
unset($response, $json_response, $rank);
|
|
|
|
return $results;
|
|
}
|
|
}
|
|
?>
|