Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Torrent - seed & peer ...
Forum PHP.pl > Forum > Gotowe rozwiązania
saint99
Czy ktoś orientuje sie jak uzyskać informacje na temat ilości seedów i peerów danego pliku torrenta questionmark.gif

** plik torrent - plik który zawiera informacje o udostemnionych zasobach na innym kompie
** seed - osoba która udostempnia
** peer - osoba która ściąga
FastRed
Mój post co prawda nic nie wniesie do tematu, ale go napisze. Szukałem już trochę czasu info o tym jak odczytać info o seedach i peerach i znajduję tylko sposoby, które działają na jednym trackerze. Jeśli ktoś będzie znał sposób na rozwiązanie tego problemu to będę wdzięczny.
saint99
Znalazłem coś takiego ... nie wiem czy to od tego jest ale nie działa sad.gif Pokazuje sie tylko tabelka ale bez danych (nie uzupełniona).

Kod
<table border="1" cellpadding="0" cellspacing="0" width="100%">

  <tr>

    <td nowrap>.torrent file</td>

    <td nowrap>Name</td>

    <td nowrap>Size</td>

    <td nowrap>Seeds</td>

    <td nowrap>Peers</td>

    <td nowrap>Hash</td>

    <td nowrap>Announce</td>

    <td nowrap>Tracker</td>

  </tr>

[php:1:861859e2f2]<?php
### Settings... ###
$path = "/upload/"; #Kansio mistä etsitään .torrent päätteisiä tiedostoja...
$max_cache_file_age = "10"; #(1h)
###/Settings... ###
$time_alku=explode(" ", microtime());
$time_alku=$time_alku[0] + $time_alku[1];
set_time_limit(900);
ini_set(register_globals, "On");
function torrent_nfo($torrent) {
global $max_cache_file_age;
require_once("bencode.php");
$bencode = new BEncodeLib();
$file = fopen($torrent, "r");
$stream = fread($file, filesize($torrent));
fclose($file);
$torrent = $bencode->bdecode($stream);
$torrent[hash] = sha1($bencode->bencode($torrent[info]));
$temp = tiedosto_loppu($torrent[announce]);
$torrent[tracker] = ereg_replace($temp, "", $torrent[announce]);
## Tracker status... ##
$tracker = "$torrent[tracker]" . "scrape";
$tracker_md5 = md5($tracker);
$cache_age = time() - @filemtime("/tmp/cache/$tracker_md5");
if(file_exists("/tmp/cache/$tracker_md5") && $cache_age < $max_cache_file_age) {
$open = fopen("/tmp/cache/$tracker_md5", "r");
$scrape = fread($open, filesize("/tmp/cache/$tracker_md5"));
$scrape = gzuncompress($scrape);
fclose($open);
}
if(file_exists("/tmp/cache/$tracker_md5") && $cache_age > $max_cache_file_age) {
$scrape = file_get_contents("$tracker");
if(strlen($scrape) > 10) {
$save = fopen("/tmp/cache/$tracker_md5", "w");
fwrite($save, gzcompress($scrape));
fclose($save);
}
}
if(!file_exists("/tmp/cache/$tracker_md5")) {
$scrape = file_get_contents("$tracker");
if(strlen($scrape) > 10) {
$save = fopen("/tmp/cache/$tracker_md5", "w");
fwrite($save, gzcompress($scrape));
fclose($save);
}
}
$info = $bencode->bdecode($scrape);
$torrent[seeds] = $info['files'][hex2bin($torrent[hash])]['complete'];
$torrent[peers] = $info['files'][hex2bin($torrent[hash])]['incomplete'];
##/Tracker status... ##
return $torrent;
}
function tiedosto_loppu($tiedosto) {
$tiedosto = explode("/", $tiedosto);
$tiedosto_pit = sizeof($tiedosto); $tiedosto_pit--;
$tiedosto = $tiedosto[$tiedosto_pit];
return($tiedosto);
}
function tiedosto_paate($tiedosto) {
$tiedosto = explode(".", $tiedosto);
$tiedosto_pit = sizeof($tiedosto); $tiedosto_pit--;
$tiedosto = $tiedosto[$tiedosto_pit];
return($tiedosto);
}
function hex2bin($hex)
{
$result = '';
for ($i = 0; $i < strlen($hex); $i += 2)
$result .= chr(hexdec(substr($hex,$i,2)));
return $result;
}
$files = shell_exec("find $path | grep -i torrent");
$files = explode("n", $files);
natcasesort($files);
foreach($files as $file) {
if(is_file($file) && filesize($file) > 0 && strtolower(tiedosto_paate($file)) == "torrent") {
$torrent = torrent_nfo($file);
$file_end = tiedosto_loppu($file);
print("<tr><td nowrap>$file_end</td><td nowrap>" . $torrent[info][name] . "</td><td nowrap>" . $torrent[info][length] . "</td><td nowrap>" . $torrent[seeds] . "</td><td nowrap>" . $torrent[peers] . "</td><td nowrap>" . $torrent[hash] . "</td><td nowrap>" . $torrent[announce] . "</td><td nowrap>" . $torrent[tracker] . "</td></tr>n");
}
}
$time_loppu=explode(" ", microtime());
$time_loppu=$time_loppu[0] + $time_loppu[1];
$time = round($time_loppu - $time_alku, 2);
print("</table>n<b>Processtime $time secs..");
?>[/php:1:861859e2f2]
Kod
</table>
saint99
Może ktoś wie jak to jest zrobione na tych stronach torrenta questionmark.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.