コード例 #1
0
 /**
  * Decode a string
  *
  * @param string $var
  * @param boolean $isFilePath If $var is a path to a file, set this to true to decode the file.
  * @return integer|string|array
  * @uses Zend_BitTorrent_Decoder::decodeFile()
  * @uses Zend_BitTorrent_Decoder::decode()
  */
 public static function decode($var, $isFilePath = false)
 {
     if ($isFilePath) {
         return Zend_BitTorrent_Decoder::decodeFile($var);
     }
     return Zend_BitTorrent_Decoder::decode($var);
 }
コード例 #2
0
ファイル: Torrent.php プロジェクト: jorgenils/zend-framework
 /**
  * Create a torrent object from a torrent file
  *
  * @return Zend_BitTorrent_Torrent
  */
 protected function buildFromTorrent()
 {
     /* Decode the file */
     $decodedFile = Zend_BitTorrent_Decoder::decodeFile($this->getTorrentFilePath());
     /* Populate the object with data from the file */
     if (isset($decodedFile['announce'])) {
         $this->setAnnounce($decodedFile['announce']);
     }
     if (isset($decodedFile['comment'])) {
         $this->setComment($decodedFile['comment']);
     }
     if (isset($decodedFile['created by'])) {
         $this->setCreatedBy($decodedFile['created by']);
     }
     if (isset($decodedFile['creation date'])) {
         $this->setCreationDate($decodedFile['creation date']);
     }
     if (isset($decodedFile['info'])) {
         $this->setInfo($decodedFile['info']);
     }
     return $this;
 }