<?
require_once("include/functions.php");
dbconn();
if($CURUSER["downloadno"] == yes)
stderr("Sorry","Your download rights has been removed because a low ratio please get your ratio up to 1.00 by seeding the torrents you have downloaded. When you get a 1.0 ratio your download rights will be reinstalled.");
hit_start();
$id = (int)$_GET["id"];
$name = $_GET["name"];
if (!$id)
httperr();
hit_count();
$res = mysql_query("SELECT 1 FROM torrents WHERE id = $id");
$row = mysql_fetch_array($res);
$fn = "$torrent_dir/$id.torrent";
//print $fn;
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 (strlen($CURUSER['passkey']) != 32) {
$CURUSER['passkey'] = md5($CURUSER['username'].get_date_time().$CURUSER['passhash']);
mysql_query("UPDATE users SET passkey='$CURUSER[passkey]' WHERE id=$CURUSER[id]");
}
$dict = bdec_file($fn, (1024*1024));
$dict['value']['announce']['value'] = "$DEFAULTBASEURL/announce.php?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']);
header("Content-Type: torrents");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$_GET["name"]."");
readfile($fn);
hit_end();
?>