Attention
With this mod, you can upload torrents, downloaded from other trackers, directly to your tracker.
Private-Flag is set, a new unique-ID is written in the torrent to keep your tracker privat.
in
lang_takeupload.php add:
PHP Code:
'takeupload_write_torrent' => "Error while opening torrent file on server (writing not allowed). Please inform the staff.",
in
takeupload.php find:
PHP Code:
if (!isset($dict))
stderr($lang['takeupload_failed'], $lang['takeupload_not_benc']);
and below it ADD:
PHP Code:
//=== external torrent
// For the use of external torrents, we have to do some changes:
// Add private flag to prevent clients from sharing the peers with other clients.
$dict["value"]["announce"] = array("type" => "string", "value" => $TBDEV["announce_urls"][0]);
$dict["value"]["info"]["value"]["private"] = array("type" => "integer", "value" => "1");
// Adding a different random ID will prevent every other peer-sharing client
// (e.g. BitComet) from finding other peers for this torrent, since the infohash is unique.
function mksecret($len = 20)
{
$ret = "";
for ($i = 0; $i < $len; $i++)
$ret .= chr(mt_rand(0, 255));
return $ret;
}
$dict["value"]["info"]["value"]["unique id"] = array("type" => "string", "value" => mksecret());
// Use the new info string to calculate the hash
$infohash = pack("H*", sha1(benc($dict["value"]["info"])));
// write the changed, bencoded version of our dictionary.
$fhandle = fopen($tmpname, "wb");
$bdict = benc($dict);
if ($fhandle) {
$wb = fwrite($fhandle, $bdict);
fclose($fhandle);
} else {
stderr($lang['takeupload_write_torrent']);
}
unset($dict);
$dict = bdec_file($tmpname, $TBDEV['max_torrent_size']);
if (!isset($dict))
stderr($lang['takeupload_failed'], $lang['takeupload_not_benc']);
//=== end external torrents
desaster@tbdev.net/topic/24575-external-torrents