This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdownload.php
99 lines (64 loc) · 2.5 KB
/
download.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
<?php
/*
+------------------------------------------------
| TBDev.net BitTorrent Tracker PHP
| =============================================
| by CoLdFuSiOn
| (c) 2003 - 2011 TBDev.Net
| http://www.tbdev.net
| =============================================
| svn: http://sourceforge.net/projects/tbdevnet/
| Licence Info: GPL
+------------------------------------------------
| $Date$
| $Revision$
| $Author$
| $URL$
+------------------------------------------------
*/
require_once "include/bittorrent.php";
require_once "include/user_functions.php";
dbconn();
loggedinorreturn();
//$lang = load_language('download');
$lang = array_merge( load_language('global'), load_language('download') );
$id = isset($_GET['torrent']) ? intval($_GET['torrent']) : 0;
if ( !is_valid_id($id) )
stderr("{$lang['download_user_error']}", "{$lang['download_no_id']}");
$res = mysql_query("SELECT name, filename FROM torrents WHERE id = $id") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($res);
$fn = "{$TBDEV['torrent_dir']}/$id.torrent";
if (!$row || !is_file($fn) || !is_readable($fn))
httperr();
@mysql_query("UPDATE torrents SET hits = hits + 1 WHERE id = $id");
require_once "include/benc.php";
if (!isset($CURUSER['passkey']) || strlen($CURUSER['passkey']) != 32)
{
$CURUSER['passkey'] = md5($CURUSER['username'].TIME_NOW.$CURUSER['passhash']);
@mysql_query("UPDATE users SET passkey='{$CURUSER['passkey']}' WHERE id={$CURUSER['id']}");
}
/* blah blah code
$list = '';
$one[] = 'http://tpb.tracker.thepiratebay.org:80/announce';
$one[] = 'http://open.tracker.thepiratebay.org/announce';
$one[] = 'http://denis.stalker.h3q.com:6969/announce';
foreach($one as $x)
{
$list .= 'l'.strlen($x).':'.$x.'e';
}
$list = 'l'.$list.'e';
$list = bdec_list($list);
//$mine = benc_list($list);
//echo '<pre>';
//print_r($list);
//echo '</pre>';exit;
*/
$dict = bdec_file($fn, filesize($fn));
$dict['value']['announce']['value'] = "{$TBDEV['announce_urls'][0]}?passkey={$CURUSER['passkey']}";
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
//$dict['value']['announce-list'] = $list;
header('Content-Disposition: attachment; filename="[TBDev]'.$row['filename'].'"');
header("Content-Type: application/x-bittorrent");
print(benc($dict));
?>