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; }