if (!preg_match('/^(.+)\\.torrent$/si', $fname, $matches)) { stderr($lang['takeupload_failed'], $lang['takeupload_not_torrent']); } $shortfname = $torrent = $matches[1]; if (!empty($_POST["name"])) { $torrent = unesc($_POST["name"]); } $tmpname = $f["tmp_name"]; if (!is_uploaded_file($tmpname)) { stderr($lang['takeupload_failed'], $lang['takeupload_eek']); } if (!filesize($tmpname)) { stderr($lang['takeupload_failed'], $lang['takeupload_no_file']); } // bencdec by djGrrr <3 $dict = bencdec::decode_file($tmpname, $INSTALLER09['max_torrent_size'], bencdec::OPTION_EXTENDED_VALIDATION); if ($dict === false) { stderr('Error', 'What the hell did you upload? This is not a bencoded file!'); } if (isset($dict['announce-list'])) { unset($dict['announce-list']); } $dict['info']['private'] = 1; if (!isset($dict['info'])) { stderr('Error', 'invalid torrent, info dictionary does not exist'); } $info =& $dict['info']; $infohash = pack("H*", sha1(bencdec::encode($info))); if (bencdec::get_type($info) != 'dictionary') { stderr('Error', 'invalid torrent, info is not a dictionary'); }
// the torrent info_hash $torrent_pass_version = $CURUSER['torrent_pass_version']; // the torrent_pass_version that is stored in the users table for the user in question $uid = $CURUSER['id']; // the uid (userid) in the users table for the user in question $passkey = sprintf('%08x%s', $uid, substr(sha1(sprintf('%s %d %d %s', $site_key, $torrent_pass_version, $uid, $info_hash)), 0, 24)); $CURUSER['torrent_pass'] = $passkey; sql_query('UPDATE users SET torrent_pass='******'torrent_pass']) . 'WHERE id=' . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__); $mc1->begin_transaction('MyUser_' . $CURUSER['id']); $mc1->update_row(false, array('torrent_pass' => $CURUSER['torrent_pass'])); $mc1->commit_transaction($INSTALLER09['expires']['curuser']); $mc1->begin_transaction('user' . $CURUSER['id']); $mc1->update_row(false, array('torrent_pass' => $CURUSER['torrent_pass'])); $mc1->commit_transaction($INSTALLER09['expires']['user_cache']); } $dict = bencdec::decode_file($fn, $INSTALLER09['max_torrent_size']); if (XBT_TRACKER == true) { $dict['announce'] = $INSTALLER09['xbt_prefix'] . $CURUSER['torrent_pass'] . $INSTALLER09['xbt_suffix']; } else { $dict['announce'] = $INSTALLER09['announce_urls'][$ssluse] . '?torrent_pass='******'torrent_pass']; } $dict['uid'] = (int) $CURUSER['id']; $tor = bencdec::encode($dict); if ($zipuse) { require_once INCL_DIR . 'phpzip.php'; $row['name'] = str_replace(array(' ', '.', '-'), '_', $row['name']); $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent'; if (file_put_contents($file_name, $tor)) { $zip = new PHPZip(); $files = array($file_name); $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip';