コード例 #1
0
ファイル: takeupload.php プロジェクト: Bigjoos/U-232-V5
    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');
}
if (!isset($info['name']) || !isset($info['piece length']) || !isset($info['pieces'])) {
    stderr('Error', 'invalid torrent, missing parts of the info dictionary');
}
if (bencdec::get_type($info['name']) != 'string' || bencdec::get_type($info['piece length']) != 'integer' || bencdec::get_type($info['pieces']) != 'string') {
    stderr('Error', 'invalid torrent, invalid types in info dictionary');
}
$dname = $info['name'];
$plen = $info['piece length'];
$pieces_len = strlen($info['pieces']);
if ($pieces_len % 20 != 0) {
    stderr('Error', 'invalid pieces');
}
コード例 #2
0
    $fd = fopen($filepath, "rb");
    $alltorrent = fread($fd, filesize($filepath));
    fclose($fd);
    header("Content-Type: application/x-bittorrent");
    header('Content-Disposition: attachment; filename="' . AddSlashes($f) . '"');
    print $alltorrent;
} else {
    $fd = fopen($filepath, "rb");
    $alltorrent = fread($fd, filesize($filepath));
    //uTorrent v3.x.x fix
    $alltorrent = preg_replace("/file-mediali(.*?)ee(.*?):/i", "file-mediali0ee\$2:", $alltorrent);
    $alltorrent = preg_replace("/file-durationli(.*?)ee(.*?):/i", "file-durationli0ee\$2:", $alltorrent);
    $array = bencdec::decode($alltorrent);
    fclose($fd);
    $array["announce"] = $BASEURL . "/announce.php?pid=" . $pid;
    if (isset($array["announce-list"]) && is_array($array["announce-list"])) {
        for ($i = 0; $i < count($array["announce-list"]); $i++) {
            if (in_array($array["announce-list"][$i][0], $TRACKER_ANNOUNCEURLS)) {
                if (strpos($array["announce-list"][$i][0], "announce.php") === false) {
                    $array["announce-list"][$i][0] = trim(str_replace("/announce", "/" . $pid . "/announce", $array["announce-list"][$i][0]));
                } else {
                    $array["announce-list"][$i][0] = trim(str_replace("/announce.php", "/announce.php?pid=" . $pid . "", $array["announce-list"][$i][0]));
                }
            }
        }
    }
    $alltorrent = bencdec::encode($array);
    header("Content-Type: application/x-bittorrent");
    header('Content-Disposition: attachment; filename="' . AddSlashes($f) . '"');
    print $alltorrent;
}
コード例 #3
0
    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';
        $zip->Zip($files, $file_name);
        $zip->forceDownload($file_name);
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent');
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip');
    } else {
        stderr('Error', 'Can\'t create the new file, please contatct staff');
    }
コード例 #4
0
ファイル: takeupload.php プロジェクト: CharlieHD/U-232-V3
    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 = sha1(bencdec::encode($info));
if (bencdec::get_type($info) != 'dictionary') {
    stderr('Error', 'invalid torrent, info is not a dictionary');
}
if (!isset($info['name']) || !isset($info['piece length']) || !isset($info['pieces'])) {
    stderr('Error', 'invalid torrent, missing parts of the info dictionary');
}
if (bencdec::get_type($info['name']) != 'string' || bencdec::get_type($info['piece length']) != 'integer' || bencdec::get_type($info['pieces']) != 'string') {
    stderr('Error', 'invalid torrent, invlaid types in info dictionary');
}
$dname = $info['name'];
$plen = $info['piece length'];
$pieces_len = strlen($info['pieces']);
if ($pieces_len % 20 != 0) {
    stderr('Error', 'invalid pieces');
}