трабла заключается в добавлении ретрекера в announce-list самого торрент файла, а именно: максимальный результат добавления: Код | d8:announce 79: http://mytorrent.myhost.ua/announce.php?pk...79863c5e7bd4813 :announce-list 31: http://retracker.local/announce 10: created by 13: uTorrent/190B 13:creation date i 1255560628 e 8: encoding 5: UTF-8 4:infod 6: length i 411772928 e 4: name 55: House.M.D.s06e05.Instant.Karma.HDRip.Rus.1001cinema.avi 12: piece length i 524288 e 6: pieces 15720:тут_sha1_хэш_длинной=15720_символов
|
для тех кто не знает структуру .торрент файла выложу и её: Код | dict { announce => str = http://tracker.vktracker.ru/announce.php?passkey=14b9XbXa6b7X48fa451Xf0bX8 (len = 74) announce-list => list [ list [ str = http://bt.rutor.org:2710/announce (len = 33) ] list [ str = http://announce.opensharing.ru:2710/announce (len = 44) ] ] comment => str = RuTor.Org (len = 9) created by => str = uTorrent/1830 (len = 13) creation date => int = 1251702046 encoding => str = UTF-8 (len = 5) info => dict { files => list [ dict { length => int = 1567461376 path => list [ str = Adrenalin.2.Vysokoe.Napryazhenie.2009.RUS.BDRip.Xv iD.AC3.-HQ-VIDEO.avi (len = 70) ] } dict { length => int = 276028416 path => list [ str = Adrenalin.2.Vysokoe.Napryazhenie.ENG.ac3 (len = 40) ] } dict { length => int = 275735040 path => list [ str = Adrenalin.2.Vysokoe.Napryazhenie.GOB.ac3 (len = 40) ] } dict { length => int = 63818 path => list [ str = Subtitles.ENG.srt (len = 17) ] } dict { length => int = 49204 path => list [ str = Subtitles.RUS.srt (len = 17) ] } ] name => str = Adrenalin.2.Vysokoe.Napryazhenie.2009.RUS.BDRip.Xv iD.AC3.-HQ-VIDEO (len = 66) piece length => int = 2097152 pieces => str = aaaa (len = 4) //замененное мною значения хешсуммы } } //СПАСИБО ShAnKaR за разъяснение
|
в общем анонс-лист добавляется, а толку, если его не видят клиенты... вот и код кодирования в торрент файл: Код | class BEncode{
function encodeEntry($entry, &$fd, $unstrip = false){ if (is_bool($entry)){ $fd .= "de"; return; } if (is_int($entry) || is_float($entry)){ $fd .= "i".$entry."e"; return; } if ($unstrip) $myentry = stripslashes($entry); else $myentry = $entry; $length = strlen($myentry); $fd .= $length.":".$myentry; return; } // Encodes lists function encodeList($array, &$fd){ $fd .= "l"; // The empty list is defined as array(); if (empty($array)){ $fd .= "e"; return; } for ($i = 0; isset($array[$i]); $i++) $this->decideEncode($array[$i], $fd); $fd .= "e"; return; } // Passes lists and dictionaries accordingly, and has encodeEntry handle // the strings and integers. function decideEncode($unknown, &$fd){ if (is_array($unknown)){ if (isset($unknown[0]) || empty($unknown) || is_null($unknown))// || $unknown["announce-list"]) return $this->encodeList($unknown, $fd); else return $this->encodeDict($unknown, $fd); } $this->encodeEntry($unknown, $fd); } // Encodes dictionaries function encodeDict($array, &$fd){ $fd .= "d"; if (is_bool($array)){ $fd .= "e"; return; } //$newarray = $this->makeSorted($array); ksort($array, SORT_STRING); foreach($array as $left => $right){ $this->encodeEntry($left, $fd, true); $this->decideEncode($right, $fd); } $fd .= "e"; return; } // End of class declaration. }
// Use this function in your own code. function BEncode($array){ $string = ""; $encoder = new BEncode; $encoder->decideEncode($array, $string); return $string; }
|
декод выглядит так : Код | class BDecode{ function numberdecode($wholefile, $start){ $ret[0] = 0; $offset = $start; // Funky handling of negative numbers and zero $negative = false; if ($wholefile[$offset] == '-'){ $negative = true; $offset++; } if ($wholefile[$offset] == '0'){ $offset++; if ($negative) return array(false); if ($wholefile[$offset] == ':' || $wholefile[$offset] == 'e'){ $offset++; $ret[0] = 0; $ret[1] = $offset; return $ret; } return array(false); } while (true){ if ($wholefile[$offset] >= '0' && $wholefile[$offset] <= '9'){ $ret[0] *= 10; $ret[0] += ord($wholefile[$offset]) - ord("0"); $offset++; } // Tolerate : or e because this is a multiuse function else if ($wholefile[$offset] == 'e' || $wholefile[$offset] == ':'){ $ret[1] = $offset+1; if ($negative){ if ($ret[0] == 0) return array(false); $ret[0] = - $ret[0]; } return $ret; }else return array(false); } } function decodeEntry($wholefile, $offset=0){ if ($wholefile[$offset] == 'd') return $this->decodeDict($wholefile, $offset); if ($wholefile[$offset] == 'l') return $this->decodelist($wholefile, $offset); if ($wholefile[$offset] == "i"){ $offset++; return $this->numberdecode($wholefile, $offset); } // String value: decode number, then grab substring $info = $this->numberdecode($wholefile, $offset); if ($info[0] === false) return array(false); $ret[0] = substr($wholefile, $info[1], $info[0]); $ret[1] = $info[1]+strlen($ret[0]); return $ret; } function decodeList($wholefile, $start){ $offset = $start+1; $i = 0; if ($wholefile[$start] != 'l') return array(false); $ret = array(); while (true){ if ($wholefile[$offset] == 'e') break; $value = $this->decodeEntry($wholefile, $offset); if ($value[0] === false) return array(false); $ret[$i] = $value[0]; $offset = $value[1]; $i ++; } // The empy list is an empty array. Seems fine. $final[0] = $ret; $final[1] = $offset+1; return $final; } // Tries to construct an array function decodeDict($wholefile, $start=0){ $offset = $start; if ($wholefile[$offset] == 'l') return $this->decodeList($wholefile, $start); if ($wholefile[$offset] != 'd') return false; $ret = array(); $offset++; while (true){ if ($wholefile[$offset] == 'e'){ $offset++; break; } $left = $this->decodeEntry($wholefile, $offset); if (!$left[0]) return false; $offset = $left[1]; if ($wholefile[$offset] == 'd'){ // Recurse $value = $this->decodedict($wholefile, $offset); if (!$value[0]) return false; $ret[addslashes($left[0])] = $value[0]; $offset= $value[1]; continue; } else if ($wholefile[$offset] == 'l'){ $value = $this->decodeList($wholefile, $offset); if (!$value[0] && is_bool($value[0])) return false; $ret[addslashes($left[0])] = $value[0]; $offset = $value[1]; }else{ $value = $this->decodeEntry($wholefile, $offset); if ($value[0] === false) return false; $ret[addslashes($left[0])] = $value[0]; $offset = $value[1]; } } if (empty($ret)) $final[0] = true; else $final[0] = $ret; $final[1] = $offset; return $final; } } // End of class declaration. // Use this function. eg: BDecode("d8:announce44:http://www. ... e"); function BDecode($wholefile){ $decoder = new BDecode; $return = $decoder->decodeEntry($wholefile); return $return[0]; }
|
далее чтобы отослать юзверю файл делается: Код | if($_SERVER['PHP_SELF'] == "") { $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; } $dir = $tr_prefs["torrdir"]; $file = $_GET["torr_id"].".torrent"; $announce = "http://".$_SERVER["HTTP_HOST"].($tr_prefs["announce_type"]=="short" ? str_replace("/".$PLUGINS_DIRECTORY."tracker_menu","",dirname($_SERVER["PHP_SELF"])) : dirname($_SERVER['PHP_SELF']))."/announce.php"; $torrdata = file_get_contents($dir."/".$file) or die("Can't open file: ".$file); $torrA = BDecode($torrdata); if($ulevel > -1){ $torrA["announce"] = $announce."?pk=".$passkey; $torrA["announce-list"] = "http://retracker.local/announce"; }else{ $torrA["announce"] = $announce; $torrA["announce-list"] = "http://retracker.local/announce"; } //if(isset($torrA["announce-list"])) unset($torrA["announce-list"]); $fname = $torrA["info"]["name"].".torrent"; $torrdata = BEncode($torrA); header("Content-Type: application/x-bittorrent"); header("Content-Disposition: attachment; filename=\"$fname\""); print $torrdata;
|
добивался добавления анонс-листа при помощи комментирования строки Код | if(isset($torrA["announce-list"])) unset($torrA["announce-list"]);
|
и добавления в условия ulevel $torrA["announce-list"] двиг е107 плагин Tracker e107 plugin v1.06 Beta 4 заранее спасибо за помощь Это сообщение отредактировал(а) ISQman - 22.10.2009, 10:16
|