Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
- [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'.
  • Loading branch information
Arnan de Gans committed Dec 9, 2023
1 parent 14745e6 commit 0340ccb
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 37 deletions.
3 changes: 2 additions & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
?>
46 changes: 23 additions & 23 deletions engines/search-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions engines/search-torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public static function print_results($results, $opts) {

// Put result together
echo "<li class=\"result\"><article>";
echo "<div class=\"url\"><a href=\"".$result["magnet"]."\" target=\"_blank\">".$result["source"]."</a></div>";
echo "<div class=\"title\"><a href=\"".$result["magnet"]."\" target=\"_blank\"><h2>".stripslashes($result["name"])."</h2></a></div>";
echo "<div class=\"url\"><a href=\"".$result["magnet"]."\">".$result["source"]."</a></div>";
echo "<div class=\"title\"><a href=\"".$result["magnet"]."\"><h2>".stripslashes($result["name"])."</h2></a></div>";
echo "<div class=\"description\"><strong>Seeds:</strong> <span class=\"seeders\">".$result['seeders']."</span> - <strong>Peers:</strong> <span class=\"leechers\">".$result['leechers']."</span> - <strong>Size:</strong> ".$result['size']."<br />".implode(" - ", $meta)."</div>";
echo "</article></li>";
}
Expand Down
7 changes: 4 additions & 3 deletions engines/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'].".<br />Try again in a few seconds or <a href=\"".curl_getinfo($this->engine_request->ch)['url']."\" target=\"_blank\">visit the search engine</a> in a new tab."
);
}

Expand All @@ -58,6 +58,7 @@ public function parse_results($response) {
if($special_result) {
$results['special'] = $special_result;
}

unset($special_result);
}

Expand Down
6 changes: 2 additions & 4 deletions functions/search_engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'].". <a href=\"".curl_getinfo($this->ch)['url']."\" target=\"_blank\">Go there now</a>.";
return true;
}

return $return;
return false;
}

abstract function parse_results($response);
Expand Down
2 changes: 1 addition & 1 deletion help.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

<div class="footer-wrap">
<div class="footer">
&copy; <?php echo date('Y'); ?> <a href="https://ajdg.solutions/" target="_blank">Arnan de Gans</a>. All rights reserved.
&copy; <?php echo date('Y'); ?> <a href="https://github.com/adegans/Goosle/" target="_blank">Goosle <?php echo $opts->version; ?></a>, by <a href="https://ajdg.solutions/" target="_blank">Arnan de Gans</a>.
<span style="float:right;"><a href="./?a=<?php echo $opts->hash; ?>">Start</a> - <a href="./help.php?a=<?php echo $opts->hash; ?>">Help</a> - Your IP: <?php echo $_SERVER["REMOTE_ADDR"]; ?></span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</div>
<?php
} else {
echo "<div class=\"auth-error\">Nope, go away!</div>";
echo "<div class=\"auth-error\">Goosle</div>";
}
?>
</body>
Expand Down
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions results.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@

<div class="footer-wrap">
<div class="footer">
&copy; <?php echo date('Y'); ?> <a href="https://ajdg.solutions/" target="_blank">Arnan de Gans</a>. All rights reserved.
&copy; <?php echo date('Y'); ?> <a href="https://github.com/adegans/Goosle/" target="_blank">Goosle <?php echo $opts->version; ?></a>, by <a href="https://ajdg.solutions/" target="_blank">Arnan de Gans</a>.
<span style="float:right;"><a href="./?a=<?php echo $opts->hash; ?>">Start</a> - <a href="./help.php?a=<?php echo $opts->hash; ?>">Help</a> - Your IP: <?php echo $_SERVER["REMOTE_ADDR"]; ?></span>
</div>
</div>

<?php
} else {
echo "<div class=\"auth-error\">Nope, go away!</div>";
echo "<div class=\"auth-error\">Goosle</div>";
}
?>
</body>
Expand Down

0 comments on commit 0340ccb

Please sign in to comment.