Advertisement
Guest User

dl

a guest
Dec 1st, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1.  <?php
  2. require_once "include/bittorrent.php";
  3. require_once "include/user_functions.php";
  4. dbconn();
  5. loggedinorreturn();
  6. $lang = array_merge( load_language('global'), load_language('download') );
  7.  
  8.   $id = isset($_GET['torrent']) ? intval($_GET['torrent']) : 0;
  9.   $ssluse = isset($_GET['ssl']) && $_GET['ssl'] == 1 ? 1 : 0;
  10.  
  11.   if ( !is_valid_id($id) )
  12.     stderr("{$lang['download_user_error']}", "{$lang['download_no_id']}");
  13.  
  14.  
  15.   $res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT name, owner, filename FROM torrents WHERE id = " . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
  16.   $row = mysqli_fetch_assoc($res);
  17.  
  18.   $fn = "{$TBDEV['torrent_dir']}/$id.torrent";
  19.  
  20.   if (!$row || !is_file($fn) || !is_readable($fn))
  21.     httperr();
  22.    
  23.    if (!($CURUSER["id"] == $row["owner"])) {
  24.      if ($CURUSER["downloadpos"] == 0 || $CURUSER["downloadpos"] > 1 )
  25.        stderr("Error","Your download rights have been disabled.");
  26. }
  27.  
  28.  
  29.   mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE torrents SET hits = hits + 1 WHERE id = " . sqlesc($id));
  30.       /** free mod for TBDev 09 by pdq **/
  31.     include ROOT_PATH.'/mods/freeslots_inc.php';
  32.     /** end **/
  33.  
  34.   require_once "include/benc.php";
  35.  
  36.  
  37.  
  38.   if (!isset($CURUSER['passkey']) || strlen($CURUSER['passkey']) != 32)
  39.   {
  40.  
  41.     $CURUSER['passkey'] = md5($CURUSER['username'].time().$CURUSER['passhash']);
  42.  
  43.   mysqli_query($GLOBALS["___mysqli_ston"], "UPDATE users SET passkey=" . sqlesc($CURUSER['passkey']) . "WHERE id=" . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);
  44.   }
  45.  
  46.  
  47.  
  48.   $dict = bdec_file($fn, filesize($fn));
  49.  
  50.   $dict['value']['announce']['value'] = "{$TBDEV['announce_urls'][$ssluse]}?passkey={$CURUSER['passkey']}";
  51.  
  52.   $dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];
  53.  
  54.   $dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
  55.  
  56.  
  57.  
  58.   header('Content-Disposition: attachment; filename="'.$row['filename'].'"');
  59.  
  60.   header("Content-Type: application/x-bittorrent");
  61.  
  62.  
  63.  
  64.   print(benc($dict));
  65.  
  66.  
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement