-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.php
More file actions
266 lines (226 loc) · 14.4 KB
/
results.php
File metadata and controls
266 lines (226 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
/* ------------------------------------------------------------------------------------
* GooseTOR - The fast, privacy oriented torrent search tool that just works.
*
* COPYRIGHT NOTICE
* Copyright 2023-2026 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.
------------------------------------------------------------------------------------ */
if(!defined('MAIN_PATH')) {
define('MAIN_PATH', __DIR__);
}
require_once(MAIN_PATH . '/config.php');
require_once(MAIN_PATH . '/functions/functions.php');
// Basic "security"
$access_key = isset($_GET['access']) ? sanitize($_GET['access']) : '';
if(empty($access_key) OR $access_key !== trim(ACCESS)) {
die("Access key incorrect!");
if(ERROR_LOG) logger('Search: Access key incorrect.');
exit;
}
// Process url arguments
$query = isset($_GET['q']) ? sanitize($_GET['q']) : '';
$colorscheme = (isset($_GET['c']) AND $_GET['c'] === 'dark') ? 'dark' : 'light';
$results_page = isset($_GET['p']) ? strtolower(sanitize($_GET['p'])) : 1;
// True = include, False = exclude
$query_filter = array();
$query_filter['movies'] = (isset($_GET['f']) AND $_GET['f'] === '1') ? true : false; // Videos/movies
$query_filter['shows'] = (isset($_GET['t']) AND $_GET['t'] === '1') ? true : false; // TV-Shows
$query_filter['anime'] = (isset($_GET['a']) AND $_GET['a'] === '1') ? true : false; // Anime
$query_filter['audio'] = (isset($_GET['m']) AND $_GET['m'] === '1') ? true : false; // Audio/music
$query_filter['software'] = (isset($_GET['s']) AND $_GET['s'] === '1') ? true : false; // Software/games
$query_filter['nsfw'] = (isset($_GET['x']) AND $_GET['x'] === '1') ? true : false; // XXX
// Make sure the filter always has something useful in it
if(array_search(true, $query_filter, true) === false) {
$query_filter['movies'] = true;
$query_filter['shows'] = true;
$query_filter['anime'] = true;
}
// For use in URLs
$query_urlsafe = urlencode(strtolower($query));
// Make sure certain files and folders exist and clean up cache
check_config();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>GooseTOR Search | Results</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta name="robots" content="noodp,noydir" />
<meta name="referrer" content="no-referrer"/>
<meta name="description" content="Check out these GooseTOR search results!" />
<meta property="og:site_name" content="GooseTOR Search" />
<meta property="og:title" content="The best magnet search engine" />
<meta property="og:description" content="Check out these GooseTOR search results!" />
<meta property="og:url" content="<?php echo MAIN_URL; ?>/results.php" />
<meta property="og:image" content="<?php echo MAIN_URL; ?>/assets/images/goosle.webp" />
<meta property="og:type" content="website" />
<link rel="icon" href="favicon.ico" />
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<link rel="canonical" href="<?php echo MAIN_URL; ?>/results.php" />
<link rel="stylesheet" type="text/css" href="<?php echo MAIN_URL; ?>/assets/css/simple.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo MAIN_URL; ?>/assets/css/<?php echo $colorscheme; ?>.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo MAIN_URL; ?>/assets/css/grid.css"/>
<script src="<?php echo MAIN_URL;?>/assets/js/goose.js" id="goosebox-js"></script>
</head>
<body class="page results">
<header>
<h1><span class="goosetor-g">G</span>ooseTOR</h1>
<form action="<?php echo MAIN_URL; ?>/results.php" method="get" autocomplete="off">
<input type="hidden" id="access" name="access" value="<?php echo $access_key; ?>" />
<input type="hidden" id="colorscheme" name="c" value="<?php echo $colorscheme; ?>" />
<div class="searchwrap">
<input tabindex="1" type="text" id="search" class="search-field" name="q" value="<?php echo (strlen($query) > 0) ? htmlspecialchars($query) : "" ; ?>" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" /><input tabindex="2" type="submit" id="search-button" class="button" value="Search" />
</div>
<div class="optionwrap">
<input tabindex="3" type="checkbox" id="films" class="search-checkbox" name="f" value="1" <?php echo ($query_filter['movies']) ? 'checked' : ''; ?> /> Movies
<input tabindex="4" type="checkbox" id="tv-shows" class="search-checkbox" name="t" value="1" <?php echo ($query_filter['shows']) ? 'checked' : ''; ?> /> TV-Shows
<input tabindex="5" type="checkbox" id="anime" class="search-checkbox" name="a" value="1" <?php echo ($query_filter['anime']) ? 'checked' : ''; ?> /> Anime
<input tabindex="6" type="checkbox" id="audio" class="search-checkbox" name="m" value="1" <?php echo ($query_filter['audio']) ? 'checked' : ''; ?> /> Audio
<input tabindex="7" type="checkbox" id="software" class="search-checkbox" name="s" value="1" <?php echo ($query_filter['software']) ? 'checked' : ''; ?> /> Software
<input tabindex="8" type="checkbox" id="nsfw" class="search-checkbox" name="x" value="1" <?php echo ($query_filter['nsfw']) ? 'checked' : ''; ?> /> NSFW
</div>
</form>
<nav>
<ul>
<li><a class="tab-home" href="<?php echo MAIN_URL; ?>/search.php?access=<?php echo $access_key; ?>&c=<?php echo $colorscheme;?>">Home</a></li>
<li><a class="tab-boxoffice" href="<?php echo MAIN_URL; ?>/boxoffice.php?access=<?php echo $access_key; ?>&c=<?php echo $colorscheme;?>">Box Office</a></li>
</ul>
</nav>
</header>
<main>
<?php
if(!empty($query) AND !empty($query_filter)) {
$start_time = microtime(true);
// Load search script
require_once(MAIN_PATH . '/functions/search-engine.php');
$search_results = search_request($query, $query_filter);
// Add elapsed time to results
$search_results['time'] = number_format(microtime(true) - $start_time, 5, '.', '');
// Output search results
if($search_results['number_of_results'] > 0) {
// Pagination offset
$search_results_per_page = 20;
$offset = (($results_page - 1) * $search_results_per_page);
$search_results['items'] = array_slice($search_results['items'], $offset, $search_results_per_page);
// Elapsed time and search sources
echo "<section class=\"results\">";
echo " <p class=\"meta timer\">Fetched ".$search_results['number_of_results']." results in ".$search_results['time']." seconds.</p>";
// Search results
foreach($search_results['items'] as $hash => $result) {
// Extra data
$base = $meta = $download = array();
if(!empty($result['verified_uploader'])) {
$icon = ($result['verified_uploader'] == 'yes') ? 'magnet-verified' : 'magnet-not-verified';
$base[] = "<a onclick=\"openpopup('info-torrentverified')\" title=\"".$icon." - Click for more information\"><span class=\"".$icon."\"></span></a>";
}
if(!empty($result['combo_seeders'])) $base[] = "<strong>Seeds:</strong> <span class=\"green\">".$result['combo_seeders']."</span>";
if(!empty($result['combo_leechers'])) $base[] = "<strong>Peers:</strong> <span class=\"red\">".$result['combo_leechers']."</span>";
if(!empty($result['filesize'])) $base[] = "<strong>Size:</strong> ".human_filesize($result['filesize']);
if(!empty($result['timestamp'])) $base[] = "<strong>Added on:</strong> ".date("M d, Y", $result['timestamp']);
if(!empty($result['mpa_rating'])) $base[] = "<strong>MPA Rating:</strong> ".$result['mpa_rating'];
if(!empty($result['imdb_id'])) {
$base[] = "<a href=\"https://www.imdb.com/title/".$result['imdb_id']."\" target=\"_blank\" title=\"More information on IMDb.com\">IMDb</a>";
if(!empty(GOOSERSS) AND !empty($result['episode'])) {
$base[] = "<a href=\"".GOOSERSS."/subscribe.php?access=".GOOSERSS_ACCESS."&handle=".$result['imdb_id']."\" title=\"Subscribe in GooseRSS\"><span class=\"magnet-rss\"></span></a>";
}
}
$base[] = "<a onclick=\"openpopup('result-".$hash."')\" title=\"Share magnet result\"><span class=\"magnet-share\"></span></a>";
if(!empty($result['category'])) $meta[] = "<strong>Category:</strong> ".$result['category'];
if(!empty($result['year'])) $meta[] = "<strong>Year:</strong> ".$result['year'];
if(!empty($result['runtime'])) $meta[] = "<strong>Runtime:</strong> ".$result['runtime'];
if(!empty($result['quality'])) $meta[] = "<strong>Quality:</strong> ".$result['quality'];
if(!empty($result['type'])) $meta[] = "<strong>Type:</strong> ".$result['type'];
if(!empty($result['audio'])) $meta[] = "<strong>Audio:</strong> ".$result['audio'];
// Put result together
echo "<article class=\"result magnet id-".$hash."\">";
if(!empty(TORRENT_REMOTE) AND TORRENT_REMOTE_PRIMARY) {
echo " <h2><a href=\"".MAIN_URL."/remote.php?access=".$access_key."&hash=".$hash."\" target=\"_blank\" title=\"Add to remote client\">".stripslashes($result['title'])."</a></h2>";
echo " <h3><span class=\"magnet-internal\"></span> <a href=\"".$result['magnet']."\" title=\"Add magnet to Torrent App\">".stripslashes($result['title'])."</a></h3>";
} else if(!empty(TORRENT_REMOTE) AND !TORRENT_REMOTE_PRIMARY) {
echo " <h2><a href=\"".$result['magnet']."\" title=\"Add magnet to Torrent App\">".stripslashes($result['title'])."</a></h2>";
echo " <h3><span class=\"magnet-external\"></span> <a href=\"".MAIN_URL."/remote.php?access=".$access_key."&hash=".$hash."\" target=\"_blank\" title=\"Add to remote client\">".stripslashes($result['title'])."</a></h3>";
} else {
echo " <h2><a href=\"".$result['magnet']."\" title=\"Add magnet to Torrent App\">".stripslashes($result['title'])."</a></h2>";
}
echo " <div class=\"description\">";
echo " <p>".implode(" • ", $base)."</p>";
echo " <p>".implode(" • ", $meta)."</p>";
echo " <p><small>Found on ".replace_last_comma(implode(', ', $result['combo_source'])).".</small></p>";
echo " </div>";
// Share popup
echo " <dialog id=\"result-".$hash."\" class=\"goosebox\">";
echo " <h2>Copy Magnet Link</h2>";
echo " <p>Tap or click on the field below to copy the magnet link to your clipboard.</p>";
echo " <h3>".stripslashes($result['title'])."</h3>";
echo " <p><input tabindex=\"2\" type=\"text\" id=\"share-result-".$hash."\" class=\"share-field\" value=\"".$result['magnet']."\" /><button tabindex=\"1\" class=\"share-button\" onclick=\"clipboard('share-result-".$hash."')\">Copy magnet link</button></p>";
echo " <p><button class=\"close-button\" onclick=\"closepopup()\">Close</button> <span id=\"share-result-".$hash."-response\"></span></p>";
echo " </dialog>";
echo "</article>";
unset($hash, $result, $base, $meta, $url);
}
echo "</section>";
echo "<div class=\"pagination\">";
// Pagination
$number_of_pages = ceil($search_results['number_of_results'] / $search_results_per_page);
if($results_page > 1) {
$prev = $results_page - 1;
echo "<a href=\"".MAIN_URL."/results.php?access=".$access_key."&q=".$query_urlsafe."&p=".$prev."&c=".$colorscheme."\" title=\"Previous page\"><span class=\"arrow-left\"></span></a> ";
}
for($page = 1; $page <= $number_of_pages; $page++) {
$class = ($results_page == $page) ? "current" : "";
echo "<a href=\"".MAIN_URL."/results.php?access=".$access_key."&q=".$query_urlsafe."&p=".$page."&c=".$colorscheme."\" class=\"".$class."\" title=\"To page ".$page."\">".$page."</a> ";
}
if($results_page < $number_of_pages) {
$next = $results_page + 1;
echo "<a href=\"".MAIN_URL."/results.php?access=".$access_key."&q=".$query_urlsafe."&p=".$next."&c=".$colorscheme."\" title=\"Next page\"><span class=\"arrow-right\"></span></a> ";
}
echo "</div>";
// Verified magnet info popup (Normally hidden)
echo "<dialog id=\"info-torrentverified\" class=\"goosebox\">";
echo " <h2>Trusted uploaders</h2>";
echo " <p>Some websites have a group of verified and/or trusted uploaders. These usually are persons or groups that are known to provide good quality torrents. Unfortunately most sites do not make this disctintion and as such the badge is generally not something to seek out when you're looking for downloads.</p>";
echo "<hr>";
echo " <p><span class=\"magnet-verified\"></span> These torrents, with a shield and checkmark are from a verified or trusted uploader according to the torrent site.</p>";
echo " <p><span class=\"magnet-not-verified\"></span> Torrents with a red shield and questionmark indicate that the uploader is <em>not</em> verified by the torrent site. Unverified magnet links are not necessarily bad but may contain low quality or misleading content.</p>";
echo " <p><a class=\"button\" onclick=\"closepopup()\">Close</a></p>";
echo "</dialog>";
} else {
echo "<section id=\"no-results\">";
echo " <h3>No results!</h3>";
echo " <p>Whoops! Nothing was found for query '".$query."' Try another search.</p>";
echo "</section>";
}
// Something went wrong
if(!empty($search_results['error'])) {
echo "<section id=\"errors\">";
foreach($search_results['error'] as $error) {
echo "<p class=\"error\">".$error."</p>";
}
echo "</section>";
}
} else {
echo "<section class=\"warning\">";
echo " <h3>Search query can not be empty!</h3>";
echo " <p>Not sure what went wrong? Learn more about <a href=\"".MAIN_URL."/help.php?access=".$access_key."&c=".$colorscheme."\" title=\"how to use GooseTOR!\">how to use GooseTOR</a>.</p>";
echo "</section>";
}
?>
</main>
<footer>
<div class="grid">
<div class="col-12 md-col-6 lg-col-8 grid-item">
© <?php echo date('Y'); ?> <a href="https://github.com/adegans/goosetor" target="_blank" title="GooseTOR on Github">GooseTOR</a> ⋅ <small>GooseTOR does not index, offer or distribute torrent files. Found content may be subject to copyright.</small>
</div>
<div class="col-12 md-col-6 lg-col-4 grid-item text-right">
<a href="<?php echo MAIN_URL; ?>/search.php?access=<?php echo $access_key; ?>&c=<?php echo $colorscheme;?>" title="GooseTOR">Home</a> ⋅ <a href="<?php echo MAIN_URL; ?>/boxoffice.php?access=<?php echo $access_key; ?>&c=<?php echo $colorscheme;?>" title="Boxoffice">Boxoffice</a> ⋅ <a href="<?php echo MAIN_URL; ?>/help.php?access=<?php echo $access_key; ?>&c=<?php echo $colorscheme;?>" title="Help">Help</a> ⋅ <?php echo ($colorscheme == 'dark') ? "<a href=\"".MAIN_URL."/search.php?access=".$access_key."&c=light\" title=\"Light mode\">Light Mode</a>" : "<a href=\"".MAIN_URL."/search.php?access=".$access_key."&c=dark\" title=\"Darkmode\">Darkmode</a>"; ?>
</div>
</div>
</footer>
</body>
</body>
</html>