<tr>
					<td class='progressbar' colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td nowrap="nowrap" class="txt" colspan="2"><strong>Torrent content</strong></td>
				</tr>
				<?php 
$file_name = $globalinfo["APP_HOME"] . "/torrents/" . $torrent["hash"] . "/torrent";
?>
				<?php 
if (file_exists($file_name)) {
    ?>
					<?php 
    $torrent_content = file_get_contents($file_name);
    $bencoder = new BEncodeLib();
    $torrent_info = $bencoder->bdecode($torrent_content);
    if (!is_array($torrent_info)) {
        $torrent_info = array();
    }
    ?>
					<?php 
    foreach ($torrent_info as $key => $val) {
        ?>
					<?php 
        if ($globalinfo["isGaya"] && is_array($val)) {
            continue;
        }
        ?>
					<tr>
						<td nowrap="nowrap" class="txt"><?php 
        echo htmlspecialchars(ucfirst(strtolower($key)));
示例#2
0
 /**
  * Torrent.
  * @param	array	media info array
  */
 function torrent(&$mediaArray)
 {
     include_once 'bencode.php';
     $content = $this->fetchContent($this->_mediaInfo['url']);
     if (!empty($content)) {
         $bencode = new BEncodeLib();
         $torrent = $bencode->bdecode($content);
         if (is_array($torrent)) {
             if (is_array($torrent['announce-list'])) {
                 foreach ($torrent['announce-list'] as $key => $value) {
                     $this->_mediaInfo['extra']['announce'] .= $torrent['announce-list'][$key][0] . '<br />';
                 }
             } else {
                 $this->_mediaInfo['extra']['announce'] = $torrent['announce'];
             }
             $this->_mediaInfo['extra']['created_by'] = $torrent['created by'];
             $this->_mediaInfo['extra']['creation_date'] = iif($torrent['creation date'], vbdate($this->vbulletin->options['dateformat'], $torrent['creation date'], false) . ' <span class="time">' . vbdate($this->vbulletin->options['timeformat'], $torrent['creation date'], false) . '</span>');
             $this->_mediaInfo['extra']['encoding'] = $torrent['encoding'];
             $this->_mediaInfo['extra']['codepage'] = $torrent['codepage'];
             $this->_mediaInfo['extra']['name'] = iif($torrent['info']['name.utf-8'], $torrent['info']['name.utf-8'], $torrent['info']['name']);
             $this->_mediaInfo['extra']['length'] = iif($torrent['info']['length'], vb_number_format($torrent['info']['length'], 1, true));
             $this->_mediaInfo['extra']['piece_length'] = iif($torrent['info']['piece length'], vb_number_format($torrent['info']['piece length'], 1, true));
             $this->_mediaInfo['extra']['publisher'] = iif($torrent['info']['publisher.utf-8'], $torrent['info']['publisher.utf-8'], $torrent['info']['publisher']);
             $this->_mediaInfo['extra']['publisher_url'] = iif($torrent['info']['publisher-url.utf-8'], $torrent['info']['publisher-url.utf-8'], $torrent['info']['publisher-url']);
             if (is_array($torrent['nodes'])) {
                 foreach ($torrent['nodes'] as $key => $value) {
                     $this->_mediaInfo['extra']['nodes'] .= $torrent['nodes'][$key][0] . ':' . $torrent['nodes'][$key][1] . '<br />';
                 }
             }
             if (is_array($torrent['info']['files'])) {
                 foreach ($torrent['info']['files'] as $key => $value) {
                     if ($torrent['info']['files'][$key]['path.utf-8']) {
                         $this->_mediaInfo['extra']['files'] .= iif(is_array($torrent['info']['files'][$key]['path.utf-8']), implode('/', $torrent['info']['files'][$key]['path.utf-8']), $torrent['info']['files'][$key]['path.utf-8']) . ' (' . vb_number_format($torrent['info']['files'][$key]['length'], 1, true) . ') <br />';
                     } else {
                         $this->_mediaInfo['extra']['files'] .= iif(is_array($torrent['info']['files'][$key]['path']), implode('/', $torrent['info']['files'][$key]['path']), $torrent['info']['files'][$key]['path']) . ' (' . vb_number_format($torrent['info']['files'][$key]['length'], 1, true) . ') <br />';
                     }
                 }
             }
             $this->_mediaInfo['type'] = 'p2p';
         } else {
             $this->_mediaInfo['type'] = 'error';
         }
     } else {
         $this->_mediaInfo['type'] = 'error';
     }
 }
示例#3
0
 private function req_result($data)
 {
     $bencoder = new BEncodeLib();
     $this->connect();
     $this->sendmsg($bencoder->bencode($data));
     $result = $bencoder->bdecode($this->recvmsg());
     $this->disconnect();
     if (!is_array($result)) {
         die('Invalid responce from btpd (' . __CLASS__ . ':' . __METHOD__ . ' Line:' . __LINE__ . ')');
     }
     return $result;
 }
示例#4
0
 public function add_torrent()
 {
     if (!$this->auth->user()) {
         return 'Please login first!';
     }
     if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
         return 'No torrent file uploaded';
     }
     if (!preg_match('/^[0-9a-zA-Z _:-]/', $this->param['name'])) {
         return 'Invalid name';
     }
     $torrent = file_get_contents($_FILES['file']['tmp_name']);
     $bencoder = new BEncodeLib();
     $torrent_info = $bencoder->bdecode($torrent);
     if (!is_array($torrent_info['info'])) {
         return 'Invalis torrent file - no "info" section.';
     }
     $hash = sha1($bencoder->bencode($torrent_info['info']));
     $directory = btpdConfig::DOWNLOAD_PATH . '/download/' . $hash;
     @mkdir(btpdConfig::DOWNLOAD_PATH . '/download/');
     @mkdir($directory);
     if (!is_dir($directory)) {
         return 'Unable create download directory.';
     }
     @symlink($directory, btpdConfig::DOWNLOAD_PATH . '/' . $this->param['name']);
     $result = $this->btpd_add_torrent($torrent, $directory, $this->param['name']);
     if ($result['code'] != 0) {
         $out .= 'Error:' . $this->get_btpd_error($result['code']);
         return $out;
     }
     $out .= 'Torrent added.<BR />';
     if ($this->param['autostart'] == 'on') {
         $result = $this->btpd_start_torrent($result['num']);
         if ($resilt['code'] != 0) {
             $out .= 'Error:' . $this->get_btpd_error($result['code']);
             return $out;
         }
         $out .= 'Torrent ' . $result['num'] . ' Sarted.<br />';
     }
     return $out;
 }