-
Notifications
You must be signed in to change notification settings - Fork 10
/
details.php
363 lines (356 loc) · 15.2 KB
/
details.php
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<?php
/**
* ------- U-232 Codename Trinity ----------*
* ---------------------------------------------*
* -------- @authors U-232 Team --------------*
* ---------------------------------------------*
* ----- @site https://u-232.duckdns.org/ ----*
* ---------------------------------------------*
* ----- @copyright 2020 U-232 Team ----------*
* ---------------------------------------------*
* ------------ @version V6 ------------------*
*/
require_once(__DIR__.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
require_once(INCL_DIR.'bbcode_functions.php');
require_once(INCL_DIR.'pager_functions.php');
require_once(INCL_DIR.'comment_functions.php');
require_once(INCL_DIR.'add_functions.php');
require_once(INCL_DIR.'html_functions.php');
require_once(INCL_DIR.'function_rating.php');
require_once(INCL_DIR.'tvmaze_functions.php');
require_once(IMDB_DIR.'imdb.class.php');
require_once(INCL_DIR.'getpre.php');
//require_once(CLASS_DIR.'TVMazeIncludes.php');
dbconn(false);
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('details'), load_language('free_details'));
parked();
$stdhead = [
/* include css **/
'css' => [
'bbcode',
'details',
'rating_style',
],
];
$stdfoot = [
/* include js **/
'js' => [
'popup',
'jquery.thanks',
'thumbs',
'sack',
],
];
$id = isset($_GET["id"]) ? (int)$_GET["id"] : 0;
if (!is_valid_id($id)) {
stderr("{$lang['details_user_error']}", "{$lang['details_bad_id']}");
}
$HTMLOUT = $torrent_cache = '';
$categorie = genrelist();
foreach ($categorie as $key => $value) {
$change[$value['id']] = [
'id' => $value['id'],
'name' => $value['name'],
'image' => $value['image'],
'min_class' => $value['min_class'],
];
}
if (($torrents = $cache->get($cache_keys['torrent_details'].$id)) === false) {
$tor_fields_ar_int = [
'id',
'leechers',
'seeders',
'thanks',
'comments',
'owner',
'size',
'added',
'views',
'hits',
'numfiles',
'times_completed',
'points',
'last_reseed',
'category',
'free',
'freetorrent',
'silver',
'rating_sum',
'checked_when',
'num_ratings',
'mtime',
'checked_when',
];
$tor_fields_ar_str = [
'banned',
'info_hash',
'checked_by',
'filename',
'search_text',
'name',
'save_as',
'visible',
'type',
'poster',
'url',
'anonymous',
'allow_comments',
'description',
'nuked',
'nukereason',
'vip',
'subs',
'username',
'newgenre',
'release_group',
'youtube',
'tags',
'user_likes',
];
$tor_fields = implode(', ', array_merge($tor_fields_ar_int, $tor_fields_ar_str));
($result = sql_query("SELECT ".$tor_fields.", (SELECT MAX(id) FROM torrents ) as max_id, (SELECT MIN(id) FROM torrents) as min_id, LENGTH(nfo) AS nfosz, IF(num_ratings < {$TRINITY20['minvotes']}, NULL, ROUND(rating_sum / num_ratings, 1)) AS rating FROM torrents WHERE id = ".sqlesc($id))) || sqlerr(__FILE__,
__LINE__);
$torrents = $result->fetch_assoc();
foreach ($tor_fields_ar_int as $i) {
$torrents[$i] = (int)$torrents[$i];
}
foreach ($tor_fields_ar_str as $i) {
$torrents[$i] = $torrents[$i];
}
$cache->set($cache_keys['torrent_details'].$id, $torrents, $TRINITY20['expires']['torrent_details']);
}
$tor_cat = $torrents['category'] ?? '';
if ($change[$tor_cat]['min_class'] > $CURUSER['class']) {
stderr("{$lang['details_user_error']}", "{$lang['details_bad_id']}");
}
//==
if (($torrents_xbt = $cache->get($cache_keys['torrent_xbt'].$id)) === false && XBT_TRACKER == true) {
($t_xbt_d = sql_query("SELECT seeders, leechers, times_completed FROM torrents WHERE id =".sqlesc($id))) || sqlerr(__FILE__, __LINE__);
$torrents_xbt = $t_xbt_d->fetch_assoc();
$cache->set($cache_keys['torrent_xbt'].$id, $torrents_xbt, $TRINITY20['expires']['torrent_xbt_data']);
}
//==
if (($torrents_txt = $cache->get($cache_keys['torrent_details_txt'].$id)) === false) {
($t_txt_des = sql_query("SELECT descr FROM torrents WHERE id =".sqlesc($id))) || sqlerr(__FILE__, __LINE__);
$torrents_txt = $t_txt_des->fetch_assoc();
$cache->set($cache_keys['torrent_details_txt'].$id, $torrents_txt, $TRINITY20['expires']['torrent_details_text']);
}
//Memcache Pretime
if (($pretime = $cache->get($cache_keys['torrent_pretime'].$id)) === false) {
$prename = htmlsafechars($torrents['name']);
($pre_q = sql_query("SELECT time FROM releases WHERE releasename = ".sqlesc($prename))) || sqlerr(__FILE__, __LINE__);
$pret = $pre_q->fetch_assoc();
if (!is_array($pretime)) {
$pretime = [];
}
$pretime['time'] = strtotime($pret['time'] ?? '');
$cache->set($cache_keys['torrent_pretime'].$id, $pretime, $TRINITY20['expires']['torrent_pretime']);
}
$newgenre = '';
if (!empty($torrents['newgenre'])) {
$newgenre = [];
$torrents['newgenre'] = explode(',', $torrents['newgenre']);
foreach ($torrents['newgenre'] as $foo) {
$newgenre[] = '<a href="browse.php?search='.trim(strtolower($foo)).'&searchin=genre">'.$foo.'</a>';
}
$newgenre = '<i>'.implode(' | ', $newgenre).'</i>';
}
//==
if (isset($_GET["hit"])) {
sql_query("UPDATE torrents SET views = views + 1 WHERE id =".sqlesc($id));
$update['views'] = ($torrents['views'] + 1);
$cache->update_row($cache_keys['torrent_details'].$id, [
'views' => $update['views'],
], $TRINITY20['expires']['torrent_details']);
header("Location: {$TRINITY20['baseurl']}/details.php?id=$id");
exit();
}
$What_String = (XBT_TRACKER == true ? 'mtime' : 'last_action');
$What_String_Key = (XBT_TRACKER == true ? $cache_keys['last_action_xbt'] : $cache_keys['last_action']);
if (($l_a = $cache->get($What_String_Key.$id)) === false) {
($last_t_ac = sql_query('SELECT '.$What_String.' AS lastseed '.'FROM torrents '.'WHERE id = '.sqlesc($id))) || sqlerr(__FILE__, __LINE__);
$l_a = $last_t_ac->fetch_assoc();
$l_a['lastseed'] = (int)$l_a['lastseed'];
$cache->set($cache_keys['last_action'].$id, $l_a, 1800);
}
//==Thumbs Up
if (($thumbs = $cache->get($cache_keys['thumbs_up'].$id)) === false) {
($thumbs_query = sql_query("SELECT id, type, torrentid, userid FROM thumbsup WHERE torrentid = ".sqlesc($torrents['id']))) || sqlerr(__FILE__,
__LINE__);
$thumbs = $thumbs_query->num_rows;
$thumbs = (int)$thumbs;
$cache->set($cache_keys['thumbs_up'].$id, $thumbs, 0);
}
//==
/* seeders/leechers/completed caches pdq**/
$torrents['times_completed'] = ((XBT_TRACKER === false || $torrents_xbt['times_completed'] === false || $torrents_xbt['times_completed'] === 0 || $torrents_xbt['times_completed'] === false) ? $torrents['times_completed'] : $torrents_xbt['times_completed']);
//==rep user query by pdq
$torrent_user_rep = $torrent_cache['rep'] ?? '';
if (($torrent_user_rep = $cache->get($cache_keys['user_rep'].$torrents['owner'])) === false) {
$torrent_user_rep = [];
($us = sql_query("SELECT reputation FROM users WHERE id =".sqlesc($torrents['owner']))) || sqlerr(__FILE__, __LINE__);
if ($us->num_rows) {
$torrent_user_rep = $us->fetch_assoc();
$cache->set($cache_keys['user_rep'].$torrents['owner'], $torrent_user_rep, 14 * 86400);
}
}
$HTMLOUT .= '<script type="text/javascript">
jQuery(\'link[href="/css/bootstrap.min.css"]\').prop("disabled", true);
</script>';
$HTMLOUT .= "
<script type='text/javascript'>
/*<![CDATA[*/
//var e = new sack();
function do_rate(rate,id,what) {
var box = document.getElementById('rate_'+id);
e.setVar('rate',rate);
e.setVar('id',id);
e.setVar('ajax','1');
e.setVar('what',what);
e.requestFile = 'rating.php';
e.method = 'GET';
e.element = 'rate_'+id;
e.onloading = function () {
box.innerHTML = 'Loading ...'
}
e.onCompletion = function() {
if(e.responseStatus)
box.innerHTML = e.response();
}
e.onerror = function () {
alert('That was something wrong with the request!');
}
e.runAJAX();
}
/*]]>*/
</script>";
$owned = $moderator = 0;
if ($CURUSER["class"] >= UC_STAFF) {
$owned = $moderator = 1;
} elseif ($CURUSER["id"] == $torrents["owner"]) {
$owned = 1;
}
if ($torrents["vip"] == "1" && $CURUSER["class"] < UC_VIP) {
stderr("{$lang['details_add_err1']}", "{$lang['details_add_err2']}");
}
if (!$torrents || ($torrents["banned"] == "yes" && !$moderator)) {
stderr("{$lang['details_error']}", "{$lang['details_torrent_id']}");
}
$owned = $CURUSER["id"] == $torrents["owner"] || $CURUSER["class"] >= UC_STAFF ? 1 : 0;
$spacer = " ";
if (empty($torrents["tags"])) {
$keywords = $lang['details_add_key'];
} else {
$tags = explode(",", $torrents['tags']);
$keywords = "";
foreach ($tags as $tag) {
$keywords .= "<a href='browse.php?search=$tag&searchin=tags&incldead=1'>".htmlsafechars($tag)."</a>,";
}
$keywords = substr($keywords, 0, (strlen($keywords) - 1));
}
if (isset($_GET["uploaded"])) {
$HTMLOUT .= "<div class='alert alert-success' align='center'><h2>{$lang['details_success']}</h2>";
$HTMLOUT .= "<p>{$lang['details_start_seeding']}</p></div>";
$HTMLOUT .= '<meta http-equiv="refresh" content="1;url=download.php?torrent='.$id.'">';
} elseif (isset($_GET["edited"])) {
$HTMLOUT .= "<div class='alert alert-success span11' align='center'><h2>{$lang['details_success_edit']}</h2></div>\n";
if (isset($_GET["returnto"])) {
$HTMLOUT .= "<p><b>{$lang['details_go_back']}<a href='".htmlsafechars($_GET["returnto"])."'>{$lang['details_whence']}</a>.</b></p>\n";
}
} elseif (isset($_GET["reseed"])) {
$HTMLOUT .= "<div class='alert alert-success' align='center'><h2>{$lang['details_add_succ1']}</h2></div>\n";
}
//==pdq's Torrent Moderation
if ($CURUSER['class'] >= UC_STAFF) {
if (isset($_GET["checked"]) && $_GET["checked"] == 1) {
sql_query("UPDATE torrents SET checked_by = ".sqlesc($CURUSER['username']).",checked_when = ".TIME_NOW." WHERE id =".sqlesc($id)." LIMIT 1") || sqlerr(__FILE__,
__LINE__);
$cache->update_row($cache_keys['torrent_details'].$id, [
'checked_by' => $CURUSER['username'],
'checked_when' => TIME_NOW,
], $TRINITY20['expires']['torrent_details']);
$cache->delete($cache_keys['checked_by'].$id);
write_log("Torrent <a href={$TRINITY20['baseurl']}/details.php?id=$id>(".htmlsafechars($torrents['name']).")</a>{$lang['details_add_chk']}{$CURUSER['username']}");
header("Location: {$TRINITY20["baseurl"]}/details.php?id=$id&checked=done#Success");
} elseif (isset($_GET["rechecked"]) && $_GET["rechecked"] == 1) {
sql_query("UPDATE torrents SET checked_by = ".sqlesc($CURUSER['username']).",checked_when = ".TIME_NOW." WHERE id =".sqlesc($id)." LIMIT 1") || sqlerr(__FILE__,
__LINE__);
$cache->update_row($cache_keys['torrent_details'].$id, [
'checked_by' => $CURUSER['username'],
'checked_when' => TIME_NOW,
], $TRINITY20['expires']['torrent_details']);
$cache->delete($cache_keys['checked_by'].$id);
write_log("Torrent <a href={$TRINITY20['baseurl']}/details.php?id=$id>(".htmlsafechars($torrents['name']).")</a>{$lang['details_add_rchk']}{$CURUSER['username']}");
header("Location: {$TRINITY20["baseurl"]}/details.php?id=$id&rechecked=done#Success");
} elseif (isset($_GET["clearchecked"]) && $_GET["clearchecked"] == 1) {
sql_query("UPDATE torrents SET checked_by = '', checked_when='' WHERE id =".sqlesc($id)." LIMIT 1") || sqlerr(__FILE__, __LINE__);
$cache->update_row($cache_keys['torrent_details'].$id, [
'checked_by' => '',
'checked_when' => '',
], $TRINITY20['expires']['torrent_details']);
$cache->delete($cache_keys['checked_by'].$id);
write_log("Torrent <a href={$TRINITY20["baseurl"]}/details.php?id=$id>(".htmlsafechars($torrents['name']).")</a>{$lang['details_add_uchk']}{$CURUSER['username']}");
header("Location: {$TRINITY20["baseurl"]}/details.php?id=$id&clearchecked=done#Success");
}
if (isset($_GET["checked"]) && $_GET["checked"] == 'done') {
$HTMLOUT .= "<div class='alert alert-success span11' align='center'><h2><a name='Success'>{$lang['details_add_chksc']}{$CURUSER['username']}!</a></h2></div>";
}
if (isset($_GET["rechecked"]) && $_GET["rechecked"] == 'done') {
$HTMLOUT .= "<div class='alert alert-success span11' align='center'><h2><a name='Success'>{$lang['details_add_rchksc']}{$CURUSER['username']}!</a></h2></div>";
}
if (isset($_GET["clearchecked"]) && $_GET["clearchecked"] == 'done') {
$HTMLOUT .= "<div class='alert alert-success span11' align='center'><h2><a name='Success'>{$lang['details_add_uchksc']}{$CURUSER['username']}!</a></h2></div>";
}
}
// end
$prev_id = ($id - 1);
$next_id = ($id + 1);
$url = "edit.php?id=".(int)$torrents["id"];
if (isset($_GET["returnto"])) {
$addthis = "&returnto=".urlencode($_GET["returnto"]);
$url .= $addthis;
$keepget = $addthis;
}
$editlink = "a href=\"$url\"";
if (!($CURUSER["downloadpos"] == 0 && $CURUSER["id"] != $torrents["owner"] || $CURUSER["downloadpos"] > 1)) {
require_once MODS_DIR.'free_details.php';
$possible_actions = [
'torrents',
'description',
'moreinfo',
'snatches',
'imdb',
];
$action = isset($_GET["action"]) ? htmlsafechars(trim($_GET["action"])) : 'torrents';
if (!in_array($action, $possible_actions)) {
stderr('Error',
'<br><div class="alert alert-error span11">Error! Change a few things up and try submitting again.</div>');
}
get_script_access(basename($_SERVER['REQUEST_URI']));
/*Tab selector begins*/
require_once(BLOCK_DIR.'details/download.php');
require_once(BLOCK_DIR.'details/nav.php');
$HTMLOUT .= '<div class="tabs-content" data-tabs-content="details-tabs">
<div class="tabs-panel is-active padding-0" id="details_panel1">';
$HTMLOUT .= '</div>
<div class="tabs-panel" id="details_panel2">';
require_once(BLOCK_DIR.'details/description.php');
$HTMLOUT .= '</div>
<div class="tabs-panel" id="details_panel3">';
require_once(BLOCK_DIR.'details/info.php');
$HTMLOUT .= '</div>';
$HTMLOUT .= "</div>";
} else {
$HTMLOUT .= "<table class='striped'><tr><td align='right' class='heading'>{$lang['details_err_down1']}</td><td>{$lang['details_err_down2']}</td></tr></table>";
}
$HTMLOUT .= "<ul class='menu expanded align-center'>";
if ($torrents["id"] != $torrents["min_id"]) {
$HTMLOUT .= "<li class='pagination-previous'><a href='details.php?id={$prev_id}'><b>{$lang['details_add_next']}</b></a></li>";
}
if ($torrents["id"] != $torrents["max_id"]) {
$HTMLOUT .= "<li class='pagination-next'><a href='details.php?id={$next_id}'><b>{$lang['details_add_prev']}</b></a></li>";
}
echo stdhead("{$lang['details_details']}\"".htmlsafechars($torrents["name"], ENT_QUOTES)."\"", true, $stdhead).$HTMLOUT.stdfoot($stdfoot);
?>