用于PHP中修改的Torrent编辑器的UDP Scrapper
问题描述:
我们正在做一个网站,您可以在其中编辑torrent文件的跟踪器。用于PHP中修改的Torrent编辑器的UDP Scrapper
我们正在搜索TRACKER
的SEEDS
和PEERS
。
我们很困惑它是如何工作的。有没有人知道如何在PHP
中显示torrent文件的SEEDS
和PEERS
?
就像在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;
}
}
}
答
所以我研究了一下,它看起来像你可以解码的.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/>';
?>
要使用此代码,您首先需要包括与台钳文件, bdec和hex2bin函数。您可以从Here
我已经准备了一个测试用例,可以发现Here
希望这有助于获得这些功能。
谢谢先生。 :)啊,先生,如果你有备份追踪器?我想得到他们的种子和同龄人?你知道该怎么做吗?非常感谢 –
那idk。对不起 – 131
这没关系:)谢谢你很多先生^ _ ^ –