-
Notifications
You must be signed in to change notification settings - Fork 7
/
userdetails.php
394 lines (365 loc) · 23.7 KB
/
userdetails.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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<?php
/////////////////////////////////////////////////////////////////////////////////////
// xbtit - Bittorrent tracker/frontend
//
// Copyright (C) 2004 - 2019 Btiteam
//
// This file is part of xbtit.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
////////////////////////////////////////////////////////////////////////////////////
error_reporting(E_ALL & ~E_NOTICE);
if (!defined('IN_BTIT')) {
die('non direct access!');
}
// load language file
require load_language('lang_userdetails.php');
$id = ((int) 0 + $_GET['id']);
if (!isset($_GET['returnto'])) {
$_GET['returnto'] = '';
}
$link = rawurlencode($_GET['returnto']);
if ($CURUSER['view_users'] != 'yes') {
err_msg($language['ERROR'], $language['NOT_AUTHORIZED'].' '.$language['MEMBERS']);
stdfoot();
die();
}
if ($id == 1) { // trying to view guest details?
err_msg($language['ERROR'], $language['GUEST_DETAILS']);
stdfoot();
die();
}
if ($XBTT_USE) {
$tseeds = 'f.seeds+ifnull(x.seeders,0)';
$tleechs = 'f.leechers+ifnull(x.leechers,0)';
$tcompletes = 'f.finished+ifnull(x.completed,0)';
$ttables = "{$TABLE_PREFIX}files f LEFT JOIN xbt_files x ON x.info_hash=f.bin_hash";
$udownloaded = 'u.downloaded+IFNULL(x.downloaded,0)';
$uuploaded = 'u.uploaded+IFNULL(x.uploaded,0)';
$utables = "{$TABLE_PREFIX}users u LEFT JOIN xbt_users x ON x.uid=u.id";
} else {
$tseeds = 'f.seeds';
$tleechs = 'f.leechers';
$tcompletes = 'f.finished';
$ttables = "{$TABLE_PREFIX}files f";
$udownloaded = 'u.downloaded';
$uuploaded = 'u.uploaded';
$utables = "{$TABLE_PREFIX}users u";
}
if ($id > 1) {
$res = get_result("SELECT u.avatar,u.email,u.cip,u.username,$udownloaded as downloaded,$uuploaded as uploaded,UNIX_TIMESTAMP(u.joined) as joined,UNIX_TIMESTAMP(u.lastconnect) as lastconnect,ul.level, u.flag, c.name, c.flagpic, u.pid, u.time_offset, u.smf_fid, u.ipb_fid FROM $utables INNER JOIN {$TABLE_PREFIX}users_level ul ON ul.id=u.id_level LEFT JOIN {$TABLE_PREFIX}countries c ON u.flag=c.id WHERE u.id=$id", true, $btit_settings['cache_duration']);
$num = count($res);
if ($num == 0) {
err_msg($language['ERROR'], $language['BAD_ID']);
stdfoot();
die();
} else {
$row = $res[0];
}
} else {
err_msg($language['ERROR'], $language['BAD_ID']);
stdfoot();
die();
}
include 'include/offset.php';
// user's ratio
if (((int) $row['downloaded']) > 0) {
$sr = $row['uploaded'] / $row['downloaded'];
if ($sr >= 4) {
$s = 'images/smilies/thumbsup.gif';
} elseif ($sr >= 2) {
$s = 'images/smilies/grin.gif';
} elseif ($sr >= 1) {
$s = 'images/smilies/smile1.gif';
} elseif ($sr >= 0.5) {
$s = 'images/smilies/noexpression.gif';
} elseif ($sr >= 0.25) {
$s = 'images/smilies/sad.gif';
} else {
$s = 'images/smilies/thumbsdown.gif';
}
$ratio = number_format($sr, 2)." <img src=\"$s\" alt=\"\" />";
} else {
$ratio = '∞';
}
$utorrents = ((int) $CURUSER['torrentsperpage']);
$userdetailtpl = new bTemplate();
$userdetailtpl->set('language', $language);
$userdetailtpl->set('userdetail_username', unesc($row['username']));
//$userdetailtpl-> set("userdetail_no_guest", $CURUSER["uid"]>1, TRUE);
if ($CURUSER['uid'] > 1 && $id != $CURUSER['uid']) {
$userdetailtpl->set('userdetail_send_pm', ' <a href="index.php?page=usercp&do=pm&action=edit&uid='.$CURUSER['uid'].'&what=new&to='.urlencode(unesc($row['username'])).'">'.image_or_link("$STYLEPATH/images/pm.png", '', $language['PM']).'</a>');
}
if ($CURUSER['edit_users'] == 'yes' && $id != $CURUSER['uid']) {
$userdetailtpl->set('userdetail_edit', '  <a href="index.php?page=admin&user='.$CURUSER['uid'].'&code='.$CURUSER['random']."&do=users&action=edit&uid=$id&returnto=index.php?page=userdetails&id=$id\">".image_or_link("$STYLEPATH/images/edit.png", '', $language['EDIT']).'</a>');
}
if ($CURUSER['delete_users'] == 'yes' && $id != $CURUSER['uid']) {
$userdetailtpl->set('userdetail_delete', "  <a onclick=\"return confirm('".addslashes($language['DELETE_CONFIRM'])."')\" href=index.php?page=admin&user=".$CURUSER['uid'].'&code='.$CURUSER['random']."&do=users&action=delete&uid=$id&smf_fid=".$row['smf_fid'].'&returnto='.urlencode('index.php?page=users').'>'.image_or_link("$STYLEPATH/images/delete.png", '', $language['DELETE']).'</a>');
}
$userdetailtpl->set('userdetail_has_avatar', $row['avatar'] && $row['avatar'] != '', true);
$userdetailtpl->set('userdetail_avatar', '<img border="0" onload="resize_avatar(this);" src="'.htmlspecialchars($row['avatar']).'" alt="" />');
$userdetailtpl->set('userdetail_edit_admin', $CURUSER['edit_users'] == 'yes' || $CURUSER['admin_access'] == 'yes', true);
if ($CURUSER['edit_users'] == 'yes' || $CURUSER['admin_access'] == 'yes') {
$userdetailtpl->set('userdetail_email', '<a href="mailto:'.$row['email'].'">'.$row['email'].'</a>');
$userdetailtpl->set('userdetail_last_ip', ($row['cip']));
$userdetailtpl->set('userdetail_level_admin', ($row['level']));
$userdetailtpl->set('userdetail_colspan', '2');
} else {
$userdetailtpl->set('userdetail_level', ($row['level']));
$userdetailtpl->set('userdetail_colspan', '0');
}
$userdetailtpl->set('userdetail_joined', ($row['joined'] == 0 ? 'N/A' : get_date_time($row['joined'])));
$userdetailtpl->set('userdetail_lastaccess', ($row['lastconnect'] == 0 ? 'N/A' : get_date_time($row['lastconnect'])));
$userdetailtpl->set('userdetail_country', ($row['flag'] == 0 ? '' : unesc($row['name'])).' <img src="images/flag/'.(!$row['flagpic'] || $row['flagpic'] == '' ? 'unknown.gif' : $row['flagpic']).'" alt="'.($row['flag'] == 0 ? 'unknown' : unesc($row['name'])).'" />');
$userdetailtpl->set('userdetail_local_time', (date('d/m/Y H:i:s', time() - $offset).' (GMT'.($row['time_offset'] > 0 ? ' +'.$row['time_offset'] : ($row['time_offset'] == 0 ? '' : ' '.$row['time_offset'])).')'));
$userdetailtpl->set('userdetail_downloaded', (makesize($row['downloaded'])));
$userdetailtpl->set('userdetail_uploaded', (makesize($row['uploaded'])));
$userdetailtpl->set('userdetail_ratio', ($ratio));
$userdetailtpl->set('userdetail_forum_internal', ($GLOBALS['FORUMLINK'] == '' || $GLOBALS['FORUMLINK'] == 'internal' || substr($GLOBALS['FORUMLINK'], 0, 3) == 'smf' || $GLOBALS['FORUMLINK'] == 'ipb'), true);
// Only show if forum is internal
if ($GLOBALS['FORUMLINK'] == '' || $GLOBALS['FORUMLINK'] == 'internal') {
$sql = get_result("SELECT count(*) as tp FROM {$TABLE_PREFIX}posts p INNER JOIN {$TABLE_PREFIX}users u ON p.userid = u.id WHERE u.id = ".$id, true, $btit_settings['cache_duration']);
$posts = $sql[0]['tp'];
unset($sql);
$memberdays = max(1, round((time() - $row['joined']) / 86400));
$posts_per_day = number_format(round($posts / $memberdays, 2), 2);
$userdetailtpl->set('userdetail_forum_posts', $posts.' ['.sprintf($language['POSTS_PER_DAY'], $posts_per_day).']');
} elseif (substr($GLOBALS['FORUMLINK'], 0, 3) == 'smf') {
$forum = get_result('SELECT `date'.(($GLOBALS['FORUMLINK'] == 'smf') ? 'R' : '_r')."egistered`, `posts` FROM `{$db_prefix}members` WHERE ".(($GLOBALS['FORUMLINK'] == 'smf') ? '`ID_MEMBER`' : '`id_member`').'='.$row['smf_fid'], true, $btit_settings['cache_duration']);
$forum = $forum[0];
$memberdays = max(1, round((time() - (($GLOBALS['FORUMLINK'] == 'smf') ? $forum['dateRegistered'] : $forum['date_registered'])) / 86400));
$posts_per_day = number_format(round($forum['posts'] / $memberdays, 2), 2);
$userdetailtpl->set('userdetail_forum_posts', $forum['posts'].' ['.sprintf($language['POSTS_PER_DAY'], $posts_per_day).']');
unset($forum);
} elseif ($GLOBALS['FORUMLINK'] == 'ipb') {
$forum = get_result("SELECT `joined`, `posts` FROM `{$ipb_prefix}members` WHERE `member_id`=".$row['ipb_fid'], true, $btit_settings['cache_duration']);
$forum = $forum[0];
$memberdays = max(1, round((time() - $forum['joined']) / 86400));
$posts_per_day = number_format(round($forum['posts'] / $memberdays, 2), 2);
$userdetailtpl->set('userdetail_forum_posts', $forum['posts'].' ['.sprintf($language['POSTS_PER_DAY'], $posts_per_day).']');
unset($forum);
}
$resuploaded = get_result("SELECT count(*) as tf FROM {$TABLE_PREFIX}files f WHERE uploader=$id AND f.anonymous = \"false\" ORDER BY data DESC", true, $btit_settings['cache_duration']);
$numtorrent = $resuploaded[0]['tf'];
unset($resuploaded);
$userdetailtpl->set('pagertop', '');
if ($numtorrent > 0) {
list($pagertop, $pagerbottom, $limit) = pager(($utorrents == 0 ? 15 : $utorrents), $numtorrent, $_SERVER['PHP_SELF']."?page=userdetails&id=$id&pagename=uploaded&", ['pagename' => 'uploaded']);
$userdetailtpl->set('pagertop', $pagertop);
$resuploaded = get_result("SELECT f.info_hash, f.filename, UNIX_TIMESTAMP(f.data) as added, f.size, $tseeds as seeds, $tleechs as leechers, $tcompletes as finished FROM $ttables WHERE uploader=$id AND anonymous = \"false\" ORDER BY data DESC $limit", true, $btit_settings['cache_duration']);
}
if ($resuploaded && $numtorrent > 0) {
$userdetailtpl->set('RESULTS', true, true);
$uptortpl = [];
$i = 0;
foreach ($resuploaded as $ud_id => $rest) {
$rest['filename'] = unesc($rest['filename']);
$filename = cut_string($rest['filename'], ((int) $btit_settings['cut_name']));
if ($GLOBALS['usepopup']) {
$uptortpl[$i]['filename'] = "<a href=\"javascript:popdetails('index.php?page=torrent-details&id=".$rest['info_hash']."')\" title=\"".$language['VIEW_DETAILS'].': '.$rest['filename'].'">'.$filename.'</a>';
$uptortpl[$i]['added'] = date('d/m/Y', $rest['added'] - $offset);
$uptortpl[$i]['size'] = makesize($rest['size']);
$uptortpl[$i]['seedcolor'] = linkcolor($rest['seeds']);
$uptortpl[$i]['seeds'] = "<a href=\"javascript:poppeer('index.php?page=peers&id=".$rest['info_hash']."')\">$rest[seeds]</a>";
$uptortpl[$i]['leechcolor'] = linkcolor($rest['leechers']);
$uptortpl[$i]['leechs'] = "<a href=\"javascript:poppeer('index.php?page=peers&id=".$rest['info_hash']."')\">$rest[leechers]</a>";
if ($rest['finished'] > 0) {
$uptortpl[$i]['completed'] = "<a href=\"javascript:poppeer('index.php?page=torrent_history&id=".$rest['info_hash']."')\">".$rest['finished'].'</a>';
} else {
$uptortpl[$i]['completed'] = '---';
}
$i++;
} else {
$uptortpl[$i]['filename'] = '<a href="index.php?page=torrent-details&id='.$rest['info_hash'].'" title="'.$language['VIEW_DETAILS'].': '.$rest['filename'].'">'.$filename.'</a>';
$uptortpl[$i]['added'] = date('d/m/Y', $rest['added'] - $offset);
$uptortpl[$i]['size'] = makesize($rest['size']);
$uptortpl[$i]['seedcolor'] = linkcolor($rest['seeds']);
$uptortpl[$i]['seeds'] = '<a href="index.php?page=peers&id='.$rest['info_hash']."\">$rest[seeds]</a>";
$uptortpl[$i]['leechcolor'] = linkcolor($rest['leechers']);
$uptortpl[$i]['leechs'] = '<a href="index.php?page=peers&id='.$rest['info_hash']."\">$rest[leechers]</a>";
if ($rest['finished'] > 0) {
$uptortpl[$i]['completed'] = '<a href="index.php?page=torrent_history&id='.$rest['info_hash'].'">'.$rest['finished'].'</a>';
} else {
$uptortpl[$i]['completed'] = '---';
}
$i++;
}
}
$userdetailtpl->set('uptor', $uptortpl);
} else {
$userdetailtpl->set('RESULTS', false, true);
}
if ($XBTT_USE) {
$anq = get_result("SELECT count(*) as tp FROM xbt_files_users xfu WHERE active=1 AND uid=$id", true, $btit_settings['cache_duration']);
} else {
if ($PRIVATE_ANNOUNCE) {
$anq = get_result("SELECT count(*) as tp FROM {$TABLE_PREFIX}peers p INNER JOIN {$TABLE_PREFIX}files f ON f.info_hash = p.infohash WHERE p.pid='".$row['pid']."'", true, $btit_settings['cache_duration']);
} else {
$anq = get_result("SELECT count(*) as tp FROM {$TABLE_PREFIX}peers p INNER JOIN {$TABLE_PREFIX}files f ON f.info_hash = p.infohash WHERE p.ip='".($row['cip'])."'", true, $btit_settings['cache_duration']);
}
}
$userdetailtpl->set('pagertopact', '');
// active torrents
if ($anq[0]['tp'] > 0) {
$userdetailtpl->set('RESULTS_1', true, true);
$tortpl = [];
$i = 0;
list($pagertop, $pagerbottom, $limit) = pager(($utorrents == 0 ? 15 : $utorrents), $anq[0]['tp'], "index.php?page=userdetails&id=$id&pagename=active&", ['pagename' => 'active']);
$userdetailtpl->set('pagertopact', $pagertop);
if ($XBTT_USE) {
$anq = get_result("SELECT '127.0.0.1' as ip, f.info_hash as infohash, f.filename, f.size, IF(p.left=0,'seeder','leecher') as status, p.downloaded, p.uploaded, $tseeds as seeds, $tleechs as leechers, $tcompletes as finished
FROM xbt_files_users p INNER JOIN xbt_files x ON p.fid=x.fid INNER JOIN {$TABLE_PREFIX}files f ON f.bin_hash = x.info_hash
WHERE p.uid=$id AND p.active=1 ORDER BY status DESC $limit", true, $btit_settings['cache_duration']);
} else {
if ($PRIVATE_ANNOUNCE) {
$anq = get_result("SELECT p.ip, p.infohash, f.filename, f.size, p.status, p.downloaded, p.uploaded, f.seeds, f.leechers, f.finished
FROM {$TABLE_PREFIX}peers p INNER JOIN {$TABLE_PREFIX}files f ON f.info_hash = p.infohash
WHERE p.pid='".$row['pid']."' ORDER BY p.status DESC $limit", true, $btit_settings['cache_duration']);
} else {
$anq = get_result("SELECT p.ip, p.infohash, f.filename, f.size, p.status, p.downloaded, p.uploaded, f.seeds, f.leechers, f.finished
FROM {$TABLE_PREFIX}peers p INNER JOIN {$TABLE_PREFIX}files f ON f.info_hash = p.infohash
WHERE p.ip='".($row['cip'])."' ORDER BY p.status DESC $limit", true, $btit_settings['cache_duration']);
}
}
// print("<div align=\"center\">$pagertop</div>");
foreach ($anq as $ud_id => $torlist) {
if ($torlist['ip'] != '') {
$torlist['filename'] = unesc($torlist['filename']);
$filename = cut_string($torlist['filename'], ((int) $btit_settings['cut_name']));
if ($GLOBALS['usepopup']) {
$tortpl[$i]['filename'] = "<a href=\"javascript:popdetails('index.php?page=torrent-details&id=".$torlist['infohash']."')\" title=\"".$language['VIEW_DETAILS'].': '.$torlist['filename'].'">'.$filename.'</a>';
$tortpl[$i]['size'] = makesize($torlist['size']);
$tortpl[$i]['status'] = unesc($torlist['status']);
$tortpl[$i]['downloaded'] = makesize($torlist['downloaded']);
$tortpl[$i]['uploaded'] = makesize($torlist['uploaded']);
if ($torlist['downloaded'] > 0) {
$peerratio = number_format($torlist['uploaded'] / $torlist['downloaded'], 2);
} else {
$peerratio = '∞';
}
$tortpl[$i]['peerratio'] = unesc($peerratio);
$tortpl[$i]['seedscolor'] = linkcolor($torlist['seeds']);
$tortpl[$i]['seeds'] = "<a href=\"javascript:poppeer('index.php?page=peers&id=".$torlist['infohash']."')\">".$torlist['seeds'].'</a>';
$tortpl[$i]['leechcolor'] = linkcolor($torlist['leechers']);
$tortpl[$i]['leechs'] = "<a href=\"javascript:poppeer('index.php?page=peers&id=".$torlist['infohash']."')\">".$torlist['leechers'].'</a>';
$tortpl[$i]['completed'] = "<a href=\"javascript:poppeer('index.php?page=torrent_history.php&id=".$torlist['infohash']."')\">".$torlist['finished'].'</a>';
$i++;
$userdetailtpl->set('tortpl', $tortpl);
} else {
$tortpl[$i]['filename'] = '<a href="index.php?page=torrent-details&id='.$torlist['infohash'].'" title="'.$language['VIEW_DETAILS'].': '.$torlist['filename'].'">'.$filename.'</a>';
$tortpl[$i]['size'] = makesize($torlist['size']);
$tortpl[$i]['status'] = unesc($torlist['status']);
$tortpl[$i]['downloaded'] = makesize($torlist['downloaded']);
$tortpl[$i]['uploaded'] = makesize($torlist['uploaded']);
if ($torlist['downloaded'] > 0) {
$peerratio = number_format($torlist['uploaded'] / $torlist['downloaded'], 2);
} else {
$peerratio = '∞';
}
$tortpl[$i]['peerratio'] = unesc($peerratio);
$tortpl[$i]['seedscolor'] = linkcolor($torlist['seeds']);
$tortpl[$i]['seeds'] = '<a href="index.php?page=peers&id='.$torlist['infohash'].'">'.$torlist['seeds'].'</a>';
$tortpl[$i]['leechcolor'] = linkcolor($torlist['leechers']);
$tortpl[$i]['leechs'] = '<a href="index.php?page=peers&id='.$torlist['infohash'].'">'.$torlist['leechers'].'</a>';
$tortpl[$i]['completed'] = '<a href="index.php?page=torrent_history&id='.$torlist['infohash'].'">'.$torlist['finished'].'</a>';
$i++;
$userdetailtpl->set('tortpl', $tortpl);
}
}
}
} else {
$userdetailtpl->set('RESULTS_1', false, true);
}
unset($anq);
if ($XBTT_USE) {
$anq = get_result("SELECT count(h.fid) as th FROM xbt_files_users h INNER JOIN xbt_files f ON h.fid=f.fid WHERE h.uid=$id AND h.completed=1", true, $btit_settings['cache_duration']);
} else {
$anq = get_result("SELECT count(h.infohash) as th FROM {$TABLE_PREFIX}history h INNER JOIN {$TABLE_PREFIX}files f ON h.infohash=f.info_hash WHERE h.uid=$id AND h.date IS NOT NULL", true, $btit_settings['cache_duration']);
}
$userdetailtpl->set('pagertophist', '');
if ($anq[0]['th'] > 0) {
$userdetailtpl->set('RESULTS_2', true, true);
$torhistory = [];
$i = 0;
list($pagertop, $pagerbottom, $limit) = pager(($utorrents == 0 ? 15 : $utorrents), $sanq[0]['th'], "index.php?page=userdetails&id=$id&pagename=history&", ['pagename' => 'history']);
$userdetailtpl->set('pagertophist', $pagertop);
if ($XBTT_USE) {
$anq = get_result("SELECT f.filename, f.size, f.info_hash, IF(h.active=1,'yes','no'), 'unknown' as agent, h.downloaded, h.uploaded, $tseeds as seeds, $tleechs as leechers, $tcompletes as finished
FROM $ttables INNER JOIN xbt_files_users h ON h.fid=x.fid WHERE h.uid=$id AND h.completed=1 ORDER BY h.mtime DESC $limit", true, $btit_settings['cache_duration']);
} else {
$anq = get_result("SELECT f.filename, f.size, f.info_hash, h.active, h.agent, h.downloaded, h.uploaded, $tseeds as seeds, $tleechs as leechers, $tcompletes as finished
FROM $ttables INNER JOIN {$TABLE_PREFIX}history h ON h.infohash=f.info_hash WHERE h.uid=$id AND h.date IS NOT NULL ORDER BY date DESC $limit", true, $btit_settings['cache_duration']);
}
// print("<div align=\"center\">$pagertop</div>");
foreach ($anq as $ud_id => $torlist) {
$torlist['filename'] = unesc($torlist['filename']);
$filename = cut_string($torlist['filename'], ((int) $btit_settings['cut_name']));
if ($GLOBALS['usepopup']) {
$torhistory[$i]['filename'] = "<a href=\"javascript:popdetails('index.php?page=torrent-details&id=".$torlist['info_hash']."')\" title=\"".$language['VIEW_DETAILS'].': '.$torlist['filename'].'">'.$filename.'</a>';
$torhistory[$i]['size'] = makesize($torlist['size']);
$torhistory[$i]['agent'] = htmlspecialchars($torlist['agent']);
$torhistory[$i]['status'] = ($torlist['active'] == 'yes' ? $language['ACTIVATED'] : 'Stopped');
$torhistory[$i]['downloaded'] = makesize($torlist['downloaded']);
$torhistory[$i]['uploaded'] = makesize($torlist['uploaded']);
if ($torlist['downloaded'] > 0) {
$peerratio = number_format($torlist['uploaded'] / $torlist['downloaded'], 2);
} else {
$peerratio = '∞';
}
$torhistory[$i]['ratio'] = unesc($peerratio);
$torhistory[$i]['seedscolor'] = linkcolor($torlist['seeds']);
$torhistory[$i]['seeds'] = "<a href=\"javascript:poppeer('index.php?page=peers&id=".$torlist['info_hash']."')\">".$torlist['seeds'].'</a>';
$torhistory[$i]['leechcolor'] = linkcolor($torlist['leechers']);
$torhistory[$i]['leechs'] = "<a href=\"javascript:poppeer('index.php?page=peers&id=".$torlist['info_hash']."')\">".$torlist['leechers'].'</a>';
$torhistory[$i]['completed'] = "<a href=\"javascript:poppeer('index.php?page=torrent_history&id=".$torlist['info_hash'].'">'.$torlist['finished'].'</a>';
$i++;
$userdetailtpl->set('torhistory', $torhistory);
} else {
$torhistory[$i]['filename'] = '<a href="index.php?page=torrent-details&id='.$torlist['info_hash'].'" title="'.$language['VIEW_DETAILS'].': '.$torlist['filename'].'">'.$filename.'</a>';
$torhistory[$i]['size'] = makesize($torlist['size']);
$torhistory[$i]['agent'] = htmlspecialchars($torlist['agent']);
$torhistory[$i]['status'] = ($torlist['active'] == 'yes' ? $language['ACTIVATED'] : 'Stopped');
$torhistory[$i]['downloaded'] = makesize($torlist['downloaded']);
$torhistory[$i]['uploaded'] = makesize($torlist['uploaded']);
if ($torlist['downloaded'] > 0) {
$peerratio = number_format($torlist['uploaded'] / $torlist['downloaded'], 2);
} else {
$peerratio = '∞';
}
$torhistory[$i]['ratio'] = unesc($peerratio);
$torhistory[$i]['seedscolor'] = linkcolor($torlist['seeds']);
$torhistory[$i]['seeds'] = '<a href="index.php?page=peers&id='.$torlist['info_hash'].'">'.$torlist['seeds'].'</a>';
$torhistory[$i]['leechcolor'] = linkcolor($torlist['leechers']);
$torhistory[$i]['leechs'] = '<a href="index.php?page=peers&id='.$torlist['info_hash'].'">'.$torlist['leechers'].'</a>';
$torhistory[$i]['completed'] = '<a href="index.php?page=torrent_history&id='.$torlist['info_hash'].'">'.$torlist['finished'].'</a>';
$i++;
$userdetailtpl->set('torhistory', $torhistory);
}
}
} else {
$userdetailtpl->set('RESULTS_2', false, true);
}
unset($sanq);
$userdetailtpl->set('userdetail_back', '<a href="javascript: history.go(-1);">'.$language['BACK'].'</a>');
?>