From 0340ccbdbecab8908e072deb5a4f67e9fa0c3b4e Mon Sep 17 00:00:00 2001 From: Arnan de Gans Date: Sat, 9 Dec 2023 11:59:19 -0600 Subject: [PATCH] 1.0.2 - [fix] Magnet links for torrents no longer opening in new tabs. - [change] More useful error response when search doesn't work. - [change] EngineRequest::request_successful() now provides a boolean response. - [change] Removed versioning indicator from help page. - [change] Added version indicator to results.php and help.php footer. - [change] 'Nope, Go away!' for unauthorized users changed to 'Goosle'. --- config.php | 3 ++- engines/search-image.php | 46 ++++++++++++++++++------------------- engines/search-torrent.php | 4 ++-- engines/search.php | 7 +++--- functions/search_engine.php | 6 ++--- help.php | 2 +- index.php | 2 +- readme.md | 15 ++++++++++++ results.php | 4 ++-- 9 files changed, 52 insertions(+), 37 deletions(-) diff --git a/config.php b/config.php index 54bf116..3c70aa8 100644 --- a/config.php +++ b/config.php @@ -107,6 +107,7 @@ "udp://tracker.opentrackr.org:1337/announce", "udp://exodus.desync.com:6969/announce", "udp://tracker.torrent.eu.org:451/announce", - ) + ), + "version" => "1.0.2" ); ?> diff --git a/engines/search-image.php b/engines/search-image.php index b1c3e9e..c189f29 100644 --- a/engines/search-image.php +++ b/engines/search-image.php @@ -40,29 +40,29 @@ public function parse_results($response) { $results = array("search" => array()); $xpath = get_xpath($response); - if(!$xpath) return $results; - - foreach($xpath->query("//a[@rel='noopener']") as $result) { - $meta = $xpath->evaluate(".//img", $result)[0]; - - if($meta) { - $encoded_url = explode("?position", explode("==/", $result->getAttribute("href"))[1])[0]; - - $url = htmlspecialchars(urldecode(base64_decode($encoded_url))); - $alt_text = get_base_url($url)." - ".htmlspecialchars($meta->getAttribute("alt")); - $image = urldecode(htmlspecialchars(urlencode($meta->getAttribute("src")))); - - // filter duplicate urls/results - if(!empty($results)) { - $result_urls = array_column($results, "url"); - if(in_array($url, $result_urls) || in_array(get_base_url($url), $result_urls)) continue; - } - - array_push($results["search"], array ( - "alt" => $alt_text, - "image" => $image, - "url" => $url, - )); + if($xpath) { + foreach($xpath->query("//a[@rel='noopener']") as $result) { + $meta = $xpath->evaluate(".//img", $result)[0]; + + if($meta) { + $encoded_url = explode("?position", explode("==/", $result->getAttribute("href"))[1])[0]; + + $url = htmlspecialchars(urldecode(base64_decode($encoded_url))); + $alt_text = get_base_url($url)." - ".htmlspecialchars($meta->getAttribute("alt")); + $image = urldecode(htmlspecialchars(urlencode($meta->getAttribute("src")))); + + // filter duplicate urls/results + if(!empty($results)) { + $result_urls = array_column($results, "url"); + if(in_array($url, $result_urls) || in_array(get_base_url($url), $result_urls)) continue; + } + + array_push($results["search"], array ( + "alt" => $alt_text, + "image" => $image, + "url" => $url, + )); + } } } diff --git a/engines/search-torrent.php b/engines/search-torrent.php index 041269c..ac929c7 100644 --- a/engines/search-torrent.php +++ b/engines/search-torrent.php @@ -90,8 +90,8 @@ public static function print_results($results, $opts) { // Put result together echo "
  • "; } diff --git a/engines/search.php b/engines/search.php index 7e57e05..121d5ca 100644 --- a/engines/search.php +++ b/engines/search.php @@ -37,17 +37,17 @@ public function parse_results($response) { if(!isset($this->engine_request)) return $results; // Add search results - $success = $this->engine_request->request_successful(); - if($success == "ok") { + if($this->engine_request->request_successful()) { $search_result = $this->engine_request->get_results(); if($search_result) { $results['search'] = $search_result; } + unset($search_result); } else { $results["error"] = array( - "message" => $success + "message" => "Error code ".curl_getinfo($this->engine_request->ch)['http_code']." for ".curl_getinfo($this->engine_request->ch)['url'].".
    Try again in a few seconds or engine_request->ch)['url']."\" target=\"_blank\">visit the search engine in a new tab." ); } @@ -58,6 +58,7 @@ public function parse_results($response) { if($special_result) { $results['special'] = $special_result; } + unset($special_result); } diff --git a/functions/search_engine.php b/functions/search_engine.php index 4006e5a..2299c8b 100644 --- a/functions/search_engine.php +++ b/functions/search_engine.php @@ -62,12 +62,10 @@ public function get_request_url() { --------------------------------------*/ public function request_successful() { if((isset($this->ch) && curl_getinfo($this->ch)['http_code'] == '200') || has_cached_results($this->url, $this->opts->hash)) { - $return = "ok"; - } else { - $return = "Error code ".curl_getinfo($this->ch)['http_code']." for ".curl_getinfo($this->ch)['url'].". ch)['url']."\" target=\"_blank\">Go there now."; + return true; } - return $return; + return false; } abstract function parse_results($response); diff --git a/help.php b/help.php index 8c935f4..ed754f0 100644 --- a/help.php +++ b/help.php @@ -113,7 +113,7 @@ diff --git a/index.php b/index.php index 9e12308..57fa1b1 100644 --- a/index.php +++ b/index.php @@ -65,7 +65,7 @@ Nope, go away!"; + echo "
    Goosle
    "; } ?> diff --git a/readme.md b/readme.md index 5dd17d4..c43d68e 100644 --- a/readme.md +++ b/readme.md @@ -6,6 +6,8 @@ Host for yourself and friends, with a access hash key. Or set up a public search After-all, finding things should be easy and not turn into a chore. +[![Goosle Mainpage](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-mainpage-960x593.png)](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-mainpage.png) + ## Features - Search on DuckDuckGo - Search on Google.com @@ -25,6 +27,11 @@ What Goosle does *not* have. And yet it just works... +## Screenshots +[![Goosle Mainpage](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-mainpage-150x150.png)](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-mainpage.png) +[![Goosle Search results](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-search-150x150.png)](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-search.png) +[![Goosle Torrent results](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-torrentsearch-150x150.png)](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-torrentsearch.png) + ## Requirements Any basic webserver/webhosting package with PHP7.4 or newer. Tested to work on Apache with PHP8.2. @@ -56,6 +63,14 @@ THe name Goosle is my last name with an L added in. Translate it from Dutch. Not Goosle comes with limited support. You can post your questions on Github or on my support forum on [ajdg.solutions](https://ajdg.solutions/support/). ## Changelog +1.0.2 - December 7, 2023 +- [fix] Magnet links for torrents no longer opening in new tabs. +- [change] More useful error response when search doesn't work. +- [change] EngineRequest::request_successful() now provides a boolean response. +- [change] Removed versioning indicator from help page. +- [change] Added version indicator to results.php and help.php footer. +- [change] 'Nope, Go away!' for unauthorized users changed to 'Goosle'. + 1.0.1 - December 5, 2023 - [fix] mktime() getting intermittent strings in 1337x crawler. - [fix] mktime() getting intermittent strings in nyaa crawler. diff --git a/results.php b/results.php index c35dedc..fa11812 100644 --- a/results.php +++ b/results.php @@ -60,14 +60,14 @@ Nope, go away!"; + echo "
    Goosle
    "; } ?>