Решил я вновь заняться этой темой.
Итак, что мы имеем:
1) файл benc.php, в который нужно прописать функцию, которая в свою очередь будет прописывать в поле announce-list несколько URL аннонсеров. (Поправьте, если я ошибаюсь).
2) и модуль 2.0.0826 Attachment Download, который отвечает за прописывание URL трекера в сам торрент-файл.
PHP код:
if ($extension == 'torrent' AND !($vbulletin->userinfo['permissions']['vbttpermissions'] & $vbulletin->bf_ugp_vbttpermissions['vbttcanview'])) print_no_permission();
if ($extension == 'torrent' AND !in_array($foruminfo['forumid'], explode(',',$vbulletin->options['vbtt_forums']))) eval(standard_error(fetch_error('vbtt_disabled_forum')));
if ($extension == 'torrent' AND $vbulletin->userinfo['userid'] AND strlen($vbulletin->userinfo['torrent_pass']) == 32 AND $attachmentinfo['info_hash']!='') {
$torrent = $vbulletin->options['attachfile'] ? fread($fp, 2097152) : $attachmentinfo['filedata'];
if (!$comment=strpos($torrent,'4:infod6:lengthi'))
$comment=strpos($torrent,'4:infod5:filesld6:lengthi');
if ($comment)
$torrentstring=substr($torrent,$comment+6,-1);
if (pack('H*', sha1($torrentstring))!= $attachmentinfo['info_hash']) {
require_once(DIR . '/includes/benc.php');
$torrent = bdec($torrent);
$torrentstring = $torrent['value']['info']['string'];
}
unset($torrent);
$announce_url = construct_phrase($vbulletin->options['vbtt_primary_announce'],$vbulletin->userinfo['torrent_pass']);
$comment=$vbulletin->options['bburl'].'/showthread.php?p='.$attachmentinfo['postid'];
$attachmentinfo['filedata'] = sprintf('d8:announce%d:%s7:comment%d:%s13:creation datei%de4:info%se', strlen($announce_url), $announce_url, strlen($comment), $comment, $attachmentinfo['dateline'], $torrentstring);
unset($torrentstring,$announce_url,$comment);
$attachmentinfo['filesize'] = strlen($attachmentinfo['filedata']);
$vbulletin->options['attachfile'] = false;
}
Больше всего нас должен интересовать кусок
Код:
$announce_url = construct_phrase($vbulletin->options['vbtt_primary_announce'],$vbulletin->userinfo['torrent_pass']);
$comment=$vbulletin->options['bburl'].'/showthread.php?p='.$attachmentinfo['postid'];
$attachmentinfo['filedata'] = sprintf('d8:announce%d:%s7:comment%d:%s13:creation datei%de4:info%se', strlen($announce_url), $announce_url, strlen($comment), $comment, $attachmentinfo['dateline'], $torrentstring);
также мы имеем подсказку от Skald
Сообщение от
Skald
HELLRAiSER, вот самый простой пример, на основе чужого кода (заняло 5 минут поиска в гугле)
PHP код:
function put_announce_urls(&$dict,$anarray,$announce_url){
$liststring = '';
unset($dict['value']['announce']);
unset($dict['value']['announce-list']);
$dict['value']['announce'] = bdec(benc_str($announce_url));
$announces[0] = array('type' => 'list', 'value' => array(bdec(benc_str($announce_url))), 'strlen' => strlen("l".$announce_url."e"), 'string' => "l".$announce_url."e");
$liststring .= "l".$announce_url."e";
if (is_array($anarray))
foreach ($anarray as $announce) {
$announces[] = array('type' => 'list', 'value' => array(bdec(benc_str($announce))), 'strlen' => strlen("l".$announce."e"), 'string' => "l".$announce."e");
$liststring .= "l".$announce."e";
}
$dict['value']['announce-list']['type'] = 'list';
$dict['value']['announce-list']['value'] = $announces;
$dict['value']['announce-list']['string'] = "l".$liststring."e";
$dict['value']['announce-list']['strlen'] = strlen($dict['value']['announce-list']['string']);
}
примерный вариант использования:
PHP код:
put_announce_urls($torrent, array('мой_первый_урл','мой_второй_урл','мой_третий_урл'),$announce_url);
Ну а дальше... Дальше вопрос - у кого какие соображения по реализации? Моих познаний не хватает.