
1.2 - January 2, 2024 - [new] Preferred language setting for DuckDuckGo results in config.php. - [new] Preferred language setting for Wikipedia results in config.php. - [new] Combined DuckDuckGo, Google, Wikipedia and Ecosia (Bing) results into one page. - [new] Ranking algorithm for search results. - [new] Option to down-rank certain social media sites in results (Makes them show lower down the page). - [new] Option to show the Goosle rank along with the search source. - [new] Crawler for results from Limetorrents.lol. - [new] Periodic check for updates in footer. - [change] Moved duckduckgo.php and google.php into the engines/search/ folder. - [change] Removed Wikipedia special search in favor of actual search results. - [change] Removed 'Date Added' from 1337x results. - [change] Removed Chrome based and Mobile user-agents, as they don't work for the WikiPedia API. - [change] Added more trackers for generating magnet links. - [tweak] 30-50% faster parsing of search results (couple of ms per search query). - [tweak] Expanded the season/episode filter to all sources that support TV Shows. - [tweak] More sensible santization of variables (Searching for html tags/basic code should now work). - [tweak] Moved 'imdb_id_search' out from special results into its 'own' setting. - [tweak] Moved 'password_generator' out from special results into its 'own' setting. - [tweak] More accurate and faster Google scrape. - [tweak] Reduced paragraph margins. - [tweak] More code cleanup, making it more uniform. - [fix] Prevents searching on disabled methods by 'cheating' the search type in the url. - [fix] Better decoding for special characters in urls for search results. - [fix] Better validation for special searches trigger words. - [fix] Better sanitization for DuckDuckGo and Google results.
44 lines
1.8 KiB
PHP
44 lines
1.8 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 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 = htmlspecialchars(trim($result['title']));
|
|
$url = "https://".$this->opts->wikipedia_language.".wikipedia.org/wiki/".htmlspecialchars(str_replace(" ", "_", trim($result['title'])));
|
|
$description = htmlspecialchars(strip_tags(trim($result['snippet'])));
|
|
$id = uniqid(rand(0, 9999));
|
|
|
|
$results['search'][] = array ("id" => $id, "source" => "Wikipedia", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank);
|
|
$rank -= 1;
|
|
}
|
|
unset($response, $json_response, $rank);
|
|
|
|
return $results;
|
|
}
|
|
}
|
|
?>
|