Skip to content

Commit

Permalink
Version 1.2.1
Browse files Browse the repository at this point in the history
1.2.1 - January 15, 2024
- [new] Merge identical downloads (determined by info hash) from different torrent sites that provide hashes
- [new] Option to cache to flat files instead of APCu, files stored in /cache/ folder
- [new] Blank index.php files in all subfolders to shield from prying eyes
- [tweak] Improved version check
- [fix] Stray periods in some Limetorrent categories
- [fix] Inconsistent size indication for torrent results
  • Loading branch information
adegans committed Jan 15, 2024
1 parent b0415ee commit 426daab
Show file tree
Hide file tree
Showing 25 changed files with 282 additions and 124 deletions.
4 changes: 4 additions & 0 deletions assets/css/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
4 changes: 4 additions & 0 deletions assets/images/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
4 changes: 4 additions & 0 deletions assets/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
4 changes: 4 additions & 0 deletions cache/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
29 changes: 18 additions & 11 deletions config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@
Disclaimer: This is not meant to 'hack proof' or truly secure the setup. Just a simple token to keep surface level prying eyes out.
CACHE:
If you have ACPu enabled in your server it is highly recommended to enable caching as it'll speed up repeat searches by a lot.
"on" (Recommended) for active sites, requires APCu
"off" Disables cache, useful for testing or if your server lacks APCu support
It is highly recommended to enable caching as it'll speed up repeat searches by a lot.
"on" (Recommended)
"off" Disables cache
CACHE_TIME:
Minutes the result should be cached in ACPu.
Accepts a numeric value between 1 and 30.
Minutes the result should be cached. Accepts a numeric value between 1 and 720.
APCu stores in memory, using a longer time takes up more of it. It is recommended to not exceed 30 minutes for it.
The file cache is only limited by your hosting storage space and can safely be much much longer if you want.
To not show outdated results the 'limit' is 720 minutes, which equals 12 hours.
Ignored if above 'cache' option is set to off.
CACHE_TYPE:
Choose how to cache results. The cache is NOT unique per user but shared between all users. Different users searching for the exact same thing get the same results.
Default caching method is APCu. Alternatively, you can store the results in text files in the /cache/ folder.
Ignored if above 'cache' option is set to off.
"apcu" (Recommended) faster, utilize memory.
"file" Store results in text files.
LANGUAGE:
DuckDuckGo, Google and Ecosia are language agnostic. But they DO profile you for your locale.
Expand Down Expand Up @@ -82,12 +92,12 @@
"off" Disable this special search
USER AGENTS:
Add more or less user agents to the list. Keep at least one.
Add more or less user agents to the list. Keep at least one!
On every search Goosle picks one at random to identify as.
Keep them generic to prevent profiling, but also so that the request comes off as a generic boring browser and not as a server/crawler.
Safari, Firefox and Internet Explorer/Edge should be safe to use.
Chrome may attract attention because of the lack of Chrome information (tracking) aside from the user agent. The search engine will know something is wrong.
Chrome may attract attention because of the lack of Chrome information (tracking) aside from the user agent. The search engine may know something is 'weird'.
Opera/Edge/Brave and many others use Chrome under the hood and are not a good pick for that reason.
Mobile agents may work, but some services like Wikipedia are a bit picky when it comes to answering API calls. Mobile users generally do not use APIs, so they may block your search.
Expand Down Expand Up @@ -120,6 +130,7 @@
"hash" => "j9fg-i2du-er6m",
"hash_auth" => "off", // Default: off
"cache" => "off", // Default: off
"cache_type" => "apcu", // Default: apcu
"cache_time" => 30, // Default: 30 (Minutes)

"duckduckgo_language" => "uk-en", // Default: uk-en (United Kingdom)
Expand Down Expand Up @@ -158,11 +169,7 @@
"udp://tracker.opentrackr.org:1337/announce",
"udp://exodus.desync.com:6969/announce",
"udp://tracker.torrent.eu.org:451/announce",
"udp://tracker.yify-torrents.com/announce",
"udp://coppersurfer.tk:6969/announce",
"udp://opentracker.i2p.rocks:6969/announce",
"udp://tracker.internetwarriors.net:1337/announce",
"udp://tracker.zer0day.to:1337/announce",
)
);
?>
4 changes: 4 additions & 0 deletions engines/image/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
1 change: 1 addition & 0 deletions engines/image/yahoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function parse_results($response) {
$results['search'][] = array ("id" => $id, "source" => "Yahoo! Images", "image" => $image, "alt" => $alt, "url" => $url, "width" => $dimensions_w, "height" => $dimensions_h, "filesize" => $filesize, "direct_link" => $link, "engine_rank" => $rank);
$rank -= 1;
}
unset($response, $xpath, $scrape, $rank);

// Add error if there are no search results
if(empty($results['search'])) {
Expand Down
4 changes: 4 additions & 0 deletions engines/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
20 changes: 9 additions & 11 deletions engines/search-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ public function parse_results($response) {
$engine_result = $request->get_results();

if(!empty($engine_result)) {
if(array_key_exists('search', $engine_result)) {

if(array_key_exists('did_you_mean', $engine_result)) {
$results['did_you_mean'] = $engine_result['did_you_mean'];
}

if(array_key_exists('search_specific', $engine_result)) {
$results['search_specific'][] = $engine_result['search_specific'];
}

$query_terms = explode(" ", preg_replace("/[^a-z0-9 ]+/", "", strtolower($request->query)));
if(array_key_exists('did_you_mean', $engine_result)) {
$results['did_you_mean'] = $engine_result['did_you_mean'];
}

if(array_key_exists('search_specific', $engine_result)) {
$results['search_specific'][] = $engine_result['search_specific'];
}

if(array_key_exists('search', $engine_result)) {
// Merge duplicates and apply relevance scoring
foreach($engine_result['search'] as $result) {
if(array_key_exists('search', $results)) {
Expand All @@ -55,6 +52,7 @@ public function parse_results($response) {
$results['search'][$found_key]['goosle_rank'] += $result['engine_rank'];
} else {
// First find, rank and add to results
$query_terms = explode(" ", preg_replace("/[^a-z0-9 ]+/", "", strtolower($request->query)));
$match_rank = match_count($result['alt'], $query_terms);

$result['goosle_rank'] = $result['engine_rank'] + $match_rank;
Expand Down
41 changes: 35 additions & 6 deletions engines/search-torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,36 @@ public function parse_results($response) {
$engine_result = $request->get_results();

if(!empty($engine_result)) {
$results_temp = array_merge($results_temp, $engine_result);
// No merging of results
// $results_temp = array_merge($results_temp, $engine_result);

// Merge duplicates and apply relevance scoring
foreach($engine_result as $result) {
if(count($results_temp) > 1 && !is_null($result['hash'])) {
$result_urls = array_column($results_temp, "hash", "id");
$found_key = array_search($result['hash'], $result_urls);
} else {
$found_key = false;
}

if($found_key !== false) {
// Duplicate result from another source
// If seeders and/or leechers mismatch, assume they're different users
if($results_temp[$found_key]['seeders'] != $result['seeders']) $results_temp[$found_key]['combo_seeders'] += $result['seeders'];
if($results_temp[$found_key]['leechers'] != $result['leechers']) $results_temp[$found_key]['combo_leechers'] += $result['leechers'];

$results_temp[$found_key]['combo_source'][] = $result['source'];
} else {
// First find, rank and add to results
$result['combo_seeders'] = $result['seeders'];
$result['combo_leechers'] = $result['leechers'];
$result['combo_source'][] = $result['source'];

$results_temp[$result['id']] = $result;
}

unset($result, $result_urls, $found_key, $social_media_multiplier, $goosle_rank, $match_rank);
}
}
} else {
$request_result = curl_getinfo($request->ch);
Expand All @@ -54,7 +83,7 @@ public function parse_results($response) {

if(count($results_temp) > 0) {
// Sort by highest seeders
$seeders = array_column($results_temp, "seeders");
$seeders = array_column($results_temp, "combo_seeders");
array_multisort($seeders, SORT_DESC, $results_temp);

// Cap results to 50
Expand Down Expand Up @@ -102,18 +131,18 @@ public static function print_results($results, $opts) {
foreach($results['search'] as $result) {
// Extra data
$meta = array();
if($opts->show_search_source == "on") $meta[] = "<strong>Source:</strong> ".$result['source'];
if(array_key_exists('quality', $result)) $meta[] = "<strong>Quality:</strong> ".$result['quality'];
if(array_key_exists('year', $result)) $meta[] = "<strong>Year:</strong> ".$result['year'];
if(array_key_exists('category', $result)) $meta[] = "<strong>Category:</strong> ".$result['category'];
if(array_key_exists('runtime', $result)) $meta[] = "<strong>Runtime:</strong> ".date('H:i', mktime(0, $result['runtime']));
if(array_key_exists('date_added', $result)) $meta[] = "<strong>Added:</strong> ".date('M d, Y', $result['date_added']);
if(array_key_exists('url', $result)) $meta[] = "<a href=\"".$result['url']."\" target=\"_blank\" title=\"Careful - Site may contain intrusive popup ads and malware!\">Torrent page</a>";
if(array_key_exists('date_added', $result)) $meta[] = "<strong>Added on:</strong> ".date('M d, Y', $result['date_added']);
if(array_key_exists('url', $result)) $url = " - <a href=\"".$result['url']."\" target=\"_blank\" title=\"Careful - Site may contain intrusive popup ads and malware!\">torrent page</a>";

// Put result together
echo "<li class=\"result\"><article>";
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 "<div class=\"description\"><strong>Seeds:</strong> <span class=\"seeders\">".$result['combo_seeders']."</span> - <strong>Peers:</strong> <span class=\"leechers\">".$result['combo_leechers']."</span> - <strong>Size:</strong> ".$result['size']."<br />".implode(" - ", $meta)."</div>";
if($opts->show_search_source == "on") echo "<div class=\"description\"><strong>Found on:</strong> ".replace_last_comma(implode(", ", $result['combo_source'])).$url."</div>";
echo "</article></li>";

unset($result, $meta);
Expand Down
23 changes: 11 additions & 12 deletions engines/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@ public function parse_results($response) {
$engine_result = $request->get_results();

if(!empty($engine_result)) {
if(array_key_exists('search', $engine_result)) {

if(array_key_exists('did_you_mean', $engine_result)) {
$results['did_you_mean'] = $engine_result['did_you_mean'];
}

if(array_key_exists('search_specific', $engine_result)) {
$results['search_specific'][] = $engine_result['search_specific'];
}

$query_terms = explode(" ", preg_replace("/[^a-z0-9 ]+/", "", strtolower($request->query)));
if(array_key_exists('did_you_mean', $engine_result)) {
$results['did_you_mean'] = $engine_result['did_you_mean'];
}

if(array_key_exists('search_specific', $engine_result)) {
$results['search_specific'][] = $engine_result['search_specific'];
}

if(array_key_exists('search', $engine_result)) {
// Merge duplicates and apply relevance scoring
foreach($engine_result['search'] as $result) {
if(array_key_exists('search', $results)) {
Expand All @@ -68,6 +65,7 @@ public function parse_results($response) {
$results['search'][$found_key]['combo_source'][] = $result['source'];
} else {
// First find, rank and add to results
$query_terms = explode(" ", preg_replace("/[^a-z0-9 ]+/", "", strtolower($request->query)));
$match_rank = match_count($result['title'], $query_terms);
$match_rank += match_count($result['description'], $query_terms);
// $match_rank += match_count($result['url'], $query_terms);
Expand Down Expand Up @@ -111,7 +109,8 @@ public function parse_results($response) {
array_multisort($keys, SORT_DESC, $results['search']);

// Count results per source
$results['sources'] = array_count_values(array_column($results['search'], 'source'));
$sources = array_count_values(array_column($results['search'], 'source'));
if(count($sources) > 0) $results['sources'] = $sources;

unset($keys);
} else {
Expand Down
2 changes: 1 addition & 1 deletion engines/search/google.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function parse_results($response) {
$title = htmlspecialchars(trim($title->textContent));
$id = uniqid(rand(0, 9999));

$results['search'][] = array ("id" => $id, "source" => "Google", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank);
$results['search'][] = array("id" => $id, "source" => "Google", "title" => $title, "url" => $url, "description" => $description, "engine_rank" => $rank);
$rank -= 1;
}
unset($response, $xpath, $scrape, $rank);
Expand Down
4 changes: 4 additions & 0 deletions engines/search/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
4 changes: 4 additions & 0 deletions engines/special/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
13 changes: 8 additions & 5 deletions engines/torrent/1337x.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ public function parse_results($response) {
foreach($xpath->query("//table/tbody/tr") as $result) {
$name = sanitize($xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent);
$url = "https://1337x.to".sanitize($xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent);
$seeders = sanitize($xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent);
$leechers = sanitize($xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent);
$magnet = "./engines/torrent/magnetize_1337x.php?url=".$url;
$seeders = sanitize_numeric(sanitize($xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent));
$leechers = sanitize_numeric(sanitize($xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent));
$size_unformatted = explode(" ", sanitize($xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent));
$size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]);

Expand All @@ -127,21 +128,23 @@ public function parse_results($response) {
if(in_array($category, $this->opts->leetx_categories_blocked)) continue;

// Filter by Season (S01) or Season and Episode (S01E01)
// Where [0][0] = Season and [0][1] = Episode
if(preg_match_all("/(S[0-9]{1,3})|(E[0-9]{1,3})/i", $this->query, $query_episode) && preg_match_all("/(S[0-9]{1,3})|(E[0-9]{1,3})/i", $name, $match_episode)) {
if($query_episode[0][0] != $match_episode[0][0] || (array_key_exists(1, $query_episode[0]) && array_key_exists(1, $match_episode[0]) && $query_episode[0][1] != $match_episode[0][1])) {
continue;
}
}

$id = uniqid(rand(0, 9999));

$results[] = array (
// Required
"source" => "1337x.to", "name" => $name, "magnet" => "./engines/torrent/magnetize_1337x.php?url=".$url, "seeders" => $seeders, "leechers" => $leechers, "size" => $size,
"id" => $id, "source" => "1337x.to", "name" => $name, "magnet" => $magnet, "hash" => null, "seeders" => $seeders, "leechers" => $leechers, "size" => $size,
// Extra
"category" => $categories[$category], "url" => $url
);

unset($name, $seeders, $leechers, $size_unformatted, $size, $category, $url);
}
unset($response, $xpath);

return $results;
}
Expand Down
15 changes: 9 additions & 6 deletions engines/torrent/eztv.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ public function parse_results($response) {
if($json_response['torrents_count'] == 0) return $results;

// Use API result
foreach ($json_response['torrents'] as $episode) {
foreach($json_response['torrents'] as $episode) {
$name = sanitize($episode['title']);
$magnet = sanitize($episode['magnet_url']);
$seeders = sanitize($episode['seeds']);
$leechers = sanitize($episode['peers']);
$hash = sanitize($episode['hash']);
$seeders = sanitize_numeric(sanitize($episode['seeds']));
$leechers = sanitize_numeric(sanitize($episode['peers']));
$size = sanitize($episode['size_bytes']);

// Ignore results with 0 seeders?
Expand All @@ -51,6 +52,7 @@ public function parse_results($response) {
$date_added = sanitize($episode['date_released_unix']);

// Filter by Season (S01) or Season and Episode (S01E01)
// Where [0][0] = Season and [0][1] = Episode
$season = sanitize($episode['season']);
$episode = sanitize($episode['episode']);

Expand All @@ -60,15 +62,16 @@ public function parse_results($response) {
}
}

$id = uniqid(rand(0, 9999));

$results[] = array (
// Required
"source" => "EZTV", "name" => $name, "magnet" => $magnet, "seeders" => $seeders, "leechers" => $leechers, "size" => human_filesize($size),
"id" => $id, "source" => "EZTV", "name" => $name, "magnet" => $magnet, "hash" => $hash, "seeders" => $seeders, "leechers" => $leechers, "size" => human_filesize($size),
// Extra
"quality" => $quality, "date_added" => $date_added
);

unset($name, $magnet, $seeders, $leechers, $size, $quality, $category, $date_added, $season, $episode);
}
unset($json_response);

return $results;
}
Expand Down
4 changes: 4 additions & 0 deletions engines/torrent/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
header("Location: /");
die();
?>
Loading

0 comments on commit 426daab

Please sign in to comment.