0

トレントファイルのトラッカーを編集できるサイトを運営しています。

SEEDS現在、 のとPEERSについて検索していTRACKERます。

私たちはそれがどのように機能したか混乱しています。で torrent ファイルのSEEDSとを表示する方法を知っている人はいますか?PEERSPHP

のように、TORRENTEDITOR.COMこのようなコードを見てきましたが、それがどのように機能するのか理解できません。助けてください。

    // global $seedsandpeers;
    if ($seedsandpeers === TRUE){
    if (!empty($array["announce-list"])){
        $announce = $array["announce-list"];
    // Possibly HtTp://
        $announce = strtolower($announce);
    if (substr($announce, 0, 7) === "http://"){
        if ((substr_count($announce, "/announce")) == 1){
            $scrape = str_replace('/announce', '/scrape', $announce);
            $httpget = "?info_hash=";
            $binsha1 = pack("H*", $infohash);
            $binsha1s = addslashes($binsha1);
            $fullurl = "$scrape$httpget$binsha1";
            $httpurl = pathurlencode($fullurl);
    sapeerconnect($httpurl, $binsha1s, $torrentsize);
    }  else {
$error = '<BR><label style="font-family:timesnewroman;font-size:12px;">Bad Tracker enter code hereURL for scraping (Maybe trackerless torrent).<br>' ;
echo $error;
}
}
else {
$error = '<BR><label style="font-family:timesnewroman;font-size:12px;">Bad Tracker URL for scraping (Maybe trackerless torrent).<br>';
echo $error;
}
}
}
4

1 に答える 1

1

少し調べてみたところ、.torrent ファイルをデコードできるようです :$

<?php
include 'functions.php';

$torrent_data = bdec(file_get_contents('test.torrent'));

$info=strtolower(sha1(benc($torrent_data['info'])));
$scrape=str_replace('announce','scrape',$torrent_data['announce']);
$sources=bdec(@file_get_contents($scrape.'?info_hash='.urlencode(hex2bin($info))));

$c=count($torrent_data['info']['files']);
echo '<h2>Files</h2>';

$files=array();
if($c > 1)
{
    for ($i = 0; $i < $c; $i++) $files[]=$torrent_data['info']['files'][$i]['path']['1'];
    sort($files);
    foreach($files as $file) echo $file."<br>";
}
else echo $torrent_data['info']['name']."<br>";

$seeds = $sources['files'][hex2bin($info)]['complete'];
$leechs = $sources['files'][hex2bin($info)]['incomplete'];
$downloads = $sources['files'][hex2bin($info)]['downloaded'];

echo '<h2>Sources</h2>'.
    '<b>Seeds:</b> '.$seeds.'<br/>'.
    '<b>Leechs:</b> '.$leechs.'<br/>' .
    '<b>Downloads:</b> '.$downloads.'<br/>';
?>

このコードを使用するには、最初に benc、bdec、および hex2bin 関数を含むファイルを含める必要があります。これらの機能はここから入手できます

ここにあるテストケースを用意しました

これが役に立ったことを願っています。

于 2014-01-23T04:09:07.530 に答える