public function getData()
 {
     $torrent = $this->_getTorrentService()->getTorrentByTid($this->tid);
     Wind::import('EXT:torrent.service.srv.helper.PwUtils');
     $torrent['seeders'] = $torrent['seeders'] + 1;
     $torrent['size'] = PwUtils::readableDataTransfer($torrent['size']);
     $torrent['info_hash'] = PwUtils::readableHash($torrent['info_hash']);
     $torrent['list'] = $this->_getTorrentFileService()->getTorrentFileByTorrent($torrent['id']);
     if (is_array($torrent['list'])) {
         foreach ($torrent['list'] as $key => $value) {
             $torrent['list'][$key]['size'] = PwUtils::readableDataTransfer($value['size']);
         }
     }
     $subscribe = $this->_getTorrentSubscribeDs()->getTorrentSubscribeByUidAndTorrent($this->user->uid, $torrent['id']);
     if (!empty($subscribe)) {
         $torrent['sub'] = true;
     } else {
         $torrent['sub'] = false;
     }
     $seeder = $leecher = 0;
     $peers = $this->_getTorrentPeerService()->getTorrentPeerByTorrent($torrent['id']);
     if (is_array($peers)) {
         foreach ($peers as $peer) {
             if ($peer['seeder'] == 'yes') {
                 $seeder++;
             } else {
                 $leecher++;
             }
         }
     }
     $torrent['seeder'] = $seeder == 0 ? '断种' : $seeder;
     $torrent['leecher'] = $leecher;
     $this->torrent = $torrent;
 }
 public function createHtmlAfterUserInfo($user, $read)
 {
     $showuserinfo = Wekit::C('site', 'app.torrent.showuserinfo');
     if (is_array($showuserinfo) && !in_array('threadside', $showuserinfo)) {
         return;
     }
     $peers = Wekit::load('EXT:torrent.service.PwTorrentPeer')->fetchTorrentPeerByUid($user['uid']);
     $torrents = Wekit::load('EXT:torrent.service.PwTorrent')->fetchTorrentByUid($user['uid']);
     $histories = Wekit::load('EXT:torrent.service.PwTorrentHistory')->fetchTorrentHistoryByUid($user['uid']);
     $seeding = $leeching = 0;
     if (is_array($peers)) {
         foreach ($peers as $peer) {
             if ($peer['seeder'] == 'yes') {
                 $seeding++;
             } else {
                 $leeching++;
             }
         }
     }
     if (is_array($histories)) {
         foreach ($histories as $history) {
             $downloaded_total += $history['downloaded'];
             $uploaded_total += $history['uploaded'];
         }
     }
     if ($downloaded_total != 0) {
         $rotio = round($uploaded_total / $downloaded_total, 2);
     } else {
         $rotio = 'Inf.';
     }
     echo '<div id="PTInfo">下载:' . $leeching . '<br>做种:' . $seeding . '<br>发布: ' . count($torrents) . '<br>分享率: ' . $rotio . '<br>下载量: ' . PwUtils::readableDataTransfer($downloaded_total) . '<br>上传量: ' . PwUtils::readableDataTransfer($uploaded_total) . '</div>';
 }
Exemplo n.º 3
0
 public function spaceProfile($space)
 {
     $PwThread = Wekit::load('forum.PwThread');
     $showuserinfo = Wekit::C('site', 'app.torrent.showuserinfo');
     if (is_array($showuserinfo) && !in_array('profile', $showuserinfo)) {
         return;
     }
     $user = Wekit::load('EXT:torrent.service.PwTorrentUser')->getTorrentUserByUid($space->spaceUid);
     $peers = Wekit::load('EXT:torrent.service.PwTorrentPeer')->fetchTorrentPeerByUid($space->spaceUid);
     $this->histories = Wekit::load('EXT:torrent.service.PwTorrentHistory')->fetchTorrentHistoryByUid($space->spaceUid);
     $this->torrents = $PwThread->getThreadByUid($space->spaceUid);
     $this->passkey = $user['passkey'];
     $this->seeding = $this->leeching = 0;
     if (is_array($peers)) {
         foreach ($peers as $peer) {
             if ($peer['seeder'] == 'yes') {
                 $this->seeding++;
             } else {
                 $this->leeching++;
             }
         }
     }
     if (is_array($this->histories)) {
         $PwTorrent = Wekit::load('EXT:torrent.service.PwTorrent');
         foreach ($this->histories as $key => $history) {
             $downloaded_total += $history['downloaded'];
             $uploaded_total += $history['uploaded'];
             $torrent = $PwTorrent->getTorrent($history['torrent']);
             $thread = $PwThread->getThread($torrent['tid']);
             if ($thread) {
                 $this->histories[$key]['tid'] = $torrent['tid'];
                 $this->histories[$key]['subject'] = $thread['subject'];
             } else {
                 unset($this->histories[$key]);
             }
         }
     }
     if ($downloaded_total != 0) {
         $this->rotio = round($uploaded_total / $downloaded_total, 2);
     } else {
         $this->rotio = 'Inf.';
     }
     $this->downloaded_total = PwUtils::readableDataTransfer($downloaded_total);
     $this->uploaded_total = PwUtils::readableDataTransfer($uploaded_total);
     PwHook::template('displayProfileTorrentHtml', 'EXT:torrent.template.profile_injector_after_content', true, $this);
 }