Ejemplo n.º 1
0
 /**
  * Fetches all relevant information from the file and generates a 
  * .torrent
  */
 public function toEncoded()
 {
     $infoArray["name"] = $this->name;
     $infoArray["piece length"] = $this->pieceLength;
     $infoArray["length"] = filesize($this->filename);
     $this->ensureSHA1Loaded();
     $infoArray["pieces"] = $this->concattedSHA1;
     $infoDictionary = new BElement(BDictionary::toEncoded($infoArray));
     $this->infoHash = sha1($infoDictionary->toEncoded(), true);
     $metainfoArray = array("announce" => $this->trackerURL, "info" => $infoDictionary);
     $metainfoArray["url-list"] = new BElement(BList::toEncoded($this->webseeds));
     $metainfoDictionary = BDictionary::toEncoded($metainfoArray);
     return $metainfoDictionary;
 }
Ejemplo n.º 2
0
function trackerError($error)
{
    echo BDictionary::toEncoded(array("failure_reason" => $error));
    exit;
}