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>';
 }
Esempio n. 3
0
 public function updateInfoAction()
 {
     if (Wekit::C('site', 'app.torrent.titlegen.ifopen') > 0) {
         $t_type = $this->getInput('t_type', 'post');
         $w_type = $this->getInput('w_type', 'post');
         $wikilink = $this->getInput('wikilink', 'post');
         $paras_se = $this->getInput('se', 'post');
         $paras_rip = $this->getInput('rip', 'post');
         $paras_resolution = $this->getInput('resolution', 'post');
         $paras_sub = $this->getInput('sub', 'post');
         $paras_format = $this->getInput('format', 'post');
         $paras_status = $this->getInput('status', 'post');
         $paras_bps = $this->getInput('bps', 'post');
         $paras_platform = $this->getInput('platform', 'post');
         $paras_name = $this->getInput('name', 'post');
         $paras_oname = $this->getInput('oname', 'post');
         $paras_lang = $this->getInput('lang', 'post');
         if (!$this->loginUser->uid) {
             $this->showError('必须登录才能进行本操作!');
         }
         // Check if user was banned
         $userBan = $this->__getUserBanDS()->getBanInfo($this->loginUser->uid);
         if ($userBan) {
             $this->showError('用户处于封禁期!');
         }
         Wind::import('EXT:torrent.service.srv.helper.PwUtils');
         switch ($t_type) {
             case '1':
                 // 书籍
                 $url = 'https://api.douban.com/v2/book/' . $wikilink;
                 if (!empty(Wekit::C('site', 'app.torrent.titlegen.douban'))) {
                     $url .= '?apikey=' . Wekit::C('site', 'app.torrent.titlegen.douban');
                 }
                 $result = json_decode(PwUtils::curl($url));
                 $title = '[' . $result->pubdate . ']';
                 // 年份
                 $title .= '[' . $result->title . ']';
                 // 标题
                 // 子标题
                 if ($result->subtitle) {
                     $title .= '[' . $result->subtitle . ']';
                 }
                 // 作者
                 if ($result->author) {
                     $title .= '[';
                     $i = 0;
                     foreach ($result->author as $author) {
                         if ($i <= 2) {
                             $title .= $author . ' / ';
                             $i++;
                         }
                     }
                     $title = substr($title, 0, strlen($title) - 3);
                     $title .= ']';
                 }
                 $wikilink = $result->alt;
                 $content = '[img]' . $result->image . '[/img]<br />' . $result->summary;
                 break;
             case '2':
             case '21':
                 // 影视
                 if ($w_type == 12) {
                     // 豆瓣
                     $url = 'https://api.douban.com/v2/movie/subject/' . $wikilink;
                     if (!empty(Wekit::C('site', 'app.torrent.titlegen.douban'))) {
                         $url .= '?apikey=' . Wekit::C('site', 'app.torrent.titlegen.douban');
                     }
                     $result = json_decode(PwUtils::curl($url));
                     $title = '[' . $result->countries[0] . ']';
                     // 国别
                     $title .= '[' . $result->year . ']';
                     // 年份
                     $title .= '[' . $result->title . ']';
                     // 影片中文名
                     // 又名
                     $title .= '[';
                     $i = 0;
                     foreach ($result->aka as $aka) {
                         if ($i <= 2 && $aka != $result->title) {
                             $title .= $aka . ' / ';
                             $i++;
                         }
                     }
                     $title = substr($title, 0, strlen($title) - 3);
                     $title .= ']';
                     // 季度、集数
                     if ($paras_se) {
                         $title .= '[' . $paras_se . ']';
                     }
                     // 类型
                     $title .= '[';
                     $i = 0;
                     foreach ($result->genres as $genre) {
                         if ($i <= 2) {
                             $title .= $genre . ' / ';
                             $i++;
                         }
                     }
                     $title = substr($title, 0, strlen($title) - 3);
                     $title .= ']';
                     $title .= '[' . $paras_rip . ']';
                     // 压制
                     $title .= '[' . $paras_resolution . ']';
                     // 分辨率
                     $title .= '[' . $paras_sub . ']';
                     // 字幕
                     $title .= '[' . $paras_format . ']';
                     // 格式
                     // 状态
                     if ($paras_status) {
                         $title .= '[' . $paras_status . ']';
                     }
                     $wikilink = $result->alt;
                     $content = '[img]' . $result->images->large . '[/img]<br />' . $result->summary;
                 } elseif ($w_type == 2) {
                     // IMDB
                     $url = 'http://omdbapi.com/?i=' . $wikilink;
                     $result = json_decode(PwUtils::curl($url));
                     $title = '[' . $result->Country . ']';
                     // 国别
                     $title .= '[' . $result->Year . ']';
                     // 年份
                     $title .= '[' . $result->Title . ']';
                     // 影片名
                     // 季度、集数
                     if ($paras_se) {
                         $title .= '[' . $paras_se . ']';
                     }
                     // 类型
                     $title .= '[' . str_replace(', ', ' ', $result->Genre) . ']';
                     $title .= '[' . $paras_rip . ']';
                     // 压制
                     $title .= '[' . $paras_resolution . ']';
                     // 分辨率
                     $title .= '[' . $paras_sub . ']';
                     // 字幕
                     $title .= '[' . $paras_format . ']';
                     // 格式
                     // 状态
                     if ($paras_status) {
                         $title .= '[' . $paras_status . ']';
                     }
                     $wikilink = 'http://www.imdb.com/title/' . $wikilink;
                     $content = '[img]' . $result->Poster . '[/img]<br />' . $result->Plot;
                 }
                 break;
             case '3':
                 // 音乐
                 $url = 'https://api.douban.com/v2/music/' . $wikilink;
                 if (!empty(Wekit::C('site', 'app.torrent.titlegen.douban'))) {
                     $url .= '?apikey=' . Wekit::C('site', 'app.torrent.titlegen.douban');
                 }
                 $result = json_decode(PwUtils::curl($url));
                 $title = '[' . $result->attrs->pubdate . ']';
                 // 年份
                 $title .= '[' . $result->attrs->title . ']';
                 // 标题
                 $title .= '[' . $result->attrs->singer . ']';
                 // 艺人
                 $title .= '[' . $paras_format . ']';
                 // 格式
                 $title .= '[' . $paras_bps . ']';
                 // 码率
                 $wikilink = $result->alt;
                 $content = '[img]' . $result->image . '[/img]<br />' . $result->summary;
                 break;
             case '4':
                 // 软件
                 $title = '[' . $paras_platform . ']';
                 // 平台
                 $title .= '[' . $paras_name . ']';
                 // 中文名
                 // 原名
                 if ($paras_oname) {
                     $title .= '[' . $paras_oname . ']';
                 }
                 $title .= '[' . $paras_lang . ']';
                 // 语言
                 $title .= '[' . $paras_format . ']';
                 // 格式
                 break;
             case '5':
                 // 其他
                 $title .= '[' . $paras_name . ']';
                 // 中文名
                 // 原名
                 if ($paras_oname) {
                     $title .= '[' . $paras_oname . ']';
                 }
                 $title .= '[' . $paras_lang . ']';
                 // 语言
                 $title .= '[' . $paras_format . ']';
                 // 格式
                 break;
         }
         echo json_encode(array('title' => $title, 'wikilink' => $wikilink, 'content' => $content));
     }
     exit;
 }
Esempio n. 4
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);
 }