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 5
/
scrape.php
65 lines (49 loc) · 2.03 KB
/
scrape.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
<?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: 199 $
| $Author$
| $URL$
+------------------------------------------------
*/
require_once("include/config.php");
if (!@mysql_connect($TBDEV['mysql_host'], $TBDEV['mysql_user'], $TBDEV['mysql_pass']))
{
exit();
}
@mysql_select_db($TBDEV['mysql_db']) or exit();
if ( !isset($_GET['info_hash']) OR (strlen($_GET['info_hash']) != 20) )
error('Invalid hash');
$res = @mysql_query( "SELECT info_hash, seeders, leechers, times_completed FROM torrents WHERE " . hash_where( $_GET['info_hash']) );
if( !mysql_num_rows($res) )
error('No torrent with that hash found');
$benc = 'd5:files';
while ($row = mysql_fetch_assoc($res))
{
$benc .= 'd20:'.pack('H*', $row['info_hash'])."d8:completei{$row['seeders']}e10:downloadedi{$row['times_completed']}e10:incompletei{$row['leechers']}eeee";
//$benc .= 'd20:'.pack('H*', $row['info_hash'])."d8:completei{$row['seeders']}e10:downloadedi{$row['times_completed']}e10:incompletei{$row['leechers']}e";
}
//$benc .= 'd5:flagsd20:min_request_intervali1800ee';
//$benc .= 'd5:flagsd20:min_request_intervali1800eee';
header('Content-Type: text/plain; charset=UTF-8');
header('Pragma: no-cache');
print($benc);
function error($err){
header('Content-Type: text/plain; charset=UTF-8');
header('Pragma: no-cache');
exit("d14:failure reason".strlen($err).":{$err}ed5:flagsd20:min_request_intervali1800eeee");
}
function hash_where($hash) {
return "info_hash = '" . mysql_real_escape_string( bin2hex($hash) ) . "'";
}
?>