<table border='0' cellspacing='2' cellpadding='2'>
				<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 
Esempio n. 2
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;
 }
Esempio n. 3
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';
     }
 }
Esempio n. 4
0
 private function uploadTorrent($fileU, $dir, $start_now, $private)
 {
     if ($this->getForceDir() == 1) {
         $dir = $this->getDir();
     }
     $uploadfile = DIR_EXEC . DIR_TORRENTS . time() . basename($fileU['name']);
     if (!is_writable(DIR_EXEC . DIR_TORRENTS)) {
         $this->addMessage($this->_str['err_add_dir']);
         return false;
     }
     if (file_exists($uploadfile)) {
         $this->addMessage($this->_str['err_add_file']);
         return false;
     }
     $res[] = move_uploaded_file($fileU['tmp_name'], $uploadfile);
     chmod($uploadfile, PERM_TORRENTS);
     $message = new xmlrpcmsg("set_directory", array(new xmlrpcval($dir, 'string')));
     $result1 = $this->client->send($message);
     if ($start_now == 'on') {
         $method = 'load_start';
     } else {
         $method = 'load';
     }
     if ($private == 'on') {
         $torrent = new BDECODE($uploadfile);
         $bencode = new BEncodeLib();
         $hash = strtoupper(bin2hex(sha1($bencode->bencode($torrent->result['info']), true)));
         $this->_db->modify('INSERT INTO torrents VALUES(?, ?, 1)', $hash, $this->getIdUser());
     }
     $message = new xmlrpcmsg($method, array(new xmlrpcval($uploadfile, 'string')));
     $result2 = $this->client->send($message);
     if ($result1->errno == 0 && $result2->errno == 0 && $res[0] !== false) {
         $this->addMessage($this->_str['info_add_torrent']);
     } else {
         $this->addMessage($this->_str['err_add_torrent']);
         @unlink($uploadfile);
     }
     $message = new xmlrpcmsg("set_directory", array(new xmlrpcval(DIR_DOWNLOAD, 'string')));
     $result1 = $this->client->send($message);
 }
Esempio n. 5
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;
 }