Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "include/bittorrent.php";
- require_once "include/user_functions.php";
- dbconn();
- loggedinorreturn();
- $lang = array_merge( load_language('global'), load_language('download') );
- $id = isset($_GET['torrent']) ? intval($_GET['torrent']) : 0;
- $ssluse = isset($_GET['ssl']) && $_GET['ssl'] == 1 ? 1 : 0;
- if ( !is_valid_id($id) )
- stderr("{$lang['download_user_error']}", "{$lang['download_no_id']}");
- $res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT name, owner, filename FROM torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
- $row = mysqli_fetch_assoc($res);
- $fn = "{$TBDEV['torrent_dir']}/$id.torrent";
- if (!$row || !is_file($fn) || !is_readable($fn))
- httperr();
- if (!($CURUSER["id"] == $row["owner"])) {
- if ($CURUSER["downloadpos"] == 0 || $CURUSER["downloadpos"] > 1 )
- stderr("Error","Your download rights have been disabled.");
- }
- mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE torrents SET hits = hits + 1 WHERE id = " . sqlesc($id));
- /** free mod for TBDev 09 by pdq **/
- include ROOT_PATH.'/mods/freeslots_inc.php';
- /** end **/
- require_once "include/benc.php";
- if (!isset($CURUSER['passkey']) || strlen($CURUSER['passkey']) != 32)
- {
- $CURUSER['passkey'] = md5($CURUSER['username'].time().$CURUSER['passhash']);
- mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE users SET passkey=" . sqlesc($CURUSER['passkey']) . "WHERE id=" . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);
- }
- $dict = bdec_file($fn, filesize($fn));
- $dict['value']['announce']['value'] = "{$TBDEV['announce_urls'][$ssluse]}?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-Disposition: attachment; filename="'.$row['filename'].'"');
- header("Content-Type: application/x-bittorrent");
- print(benc($dict));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement