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'.
This commit is contained in:
parent
14745e63b2
commit
0340ccbdbe
9 changed files with 52 additions and 37 deletions
|
@ -107,6 +107,7 @@ return (object) array(
|
|||
"udp://tracker.opentrackr.org:1337/announce",
|
||||
"udp://exodus.desync.com:6969/announce",
|
||||
"udp://tracker.torrent.eu.org:451/announce",
|
||||
)
|
||||
),
|
||||
"version" => "1.0.2"
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -40,29 +40,29 @@ class ImageSearch extends EngineRequest {
|
|||
$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,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ class TorrentSearch extends EngineRequest {
|
|||
|
||||
// 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>";
|
||||
}
|
||||
|
|
|
@ -37,17 +37,17 @@ class TextSearch extends EngineRequest {
|
|||
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."
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ class TextSearch extends EngineRequest {
|
|||
if($special_result) {
|
||||
$results['special'] = $special_result;
|
||||
}
|
||||
|
||||
unset($special_result);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,12 +62,10 @@ abstract class EngineRequest {
|
|||
--------------------------------------*/
|
||||
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);
|
||||
|
|
2
help.php
2
help.php
|
@ -113,7 +113,7 @@ if(verify_hash($opts, $auth)) {
|
|||
|
||||
<div class="footer-wrap">
|
||||
<div class="footer">
|
||||
© <?php echo date('Y'); ?> <a href="https://ajdg.solutions/" target="_blank">Arnan de Gans</a>. All rights reserved.
|
||||
© <?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>
|
||||
|
|
|
@ -65,7 +65,7 @@ if(verify_hash($opts, $auth)) {
|
|||
</div>
|
||||
<?php
|
||||
} else {
|
||||
echo "<div class=\"auth-error\">Nope, go away!</div>";
|
||||
echo "<div class=\"auth-error\">Goosle</div>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
|
15
readme.md
15
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.
|
||||
|
||||
[](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
|
||||
[](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-mainpage.png)
|
||||
[](https://ajdg.solutions/wp-content/uploads/2023/12/goosle-search.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.
|
||||
|
|
|
@ -60,14 +60,14 @@ if(verify_hash($opts, $auth)) {
|
|||
|
||||
<div class="footer-wrap">
|
||||
<div class="footer">
|
||||
© <?php echo date('Y'); ?> <a href="https://ajdg.solutions/" target="_blank">Arnan de Gans</a>. All rights reserved.
|
||||
© <?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>
|
||||
|
|
Loading…
Add table
Reference in a new issue