public function subscribeAction() { $id = $this->getInput('id'); $unsub = $this->getInput('unsub'); if (!$this->loginUser->uid) { $this->showError('必须登录才能进行本操作!'); } $userBan = $this->__getUserBanDS()->getBanInfo($this->loginUser->uid); if ($userBan) { $this->showError('用户处于封禁期!'); } $torrent = $this->_getTorrentDS()->getTorrent($id); if (empty($torrent)) { $this->showError('种子文件不存在!'); } $torrent = $this->_getTorrentSubscribeDs()->getTorrentSubscribeByUidAndTorrent($this->loginUser->uid, $id); if (!empty($torrent)) { if ($unsub == 'true') { $this->_getTorrentSubscribeDs()->deleteTorrentSubscribe($torrent['id']); $this->showMessage('取消订阅种子成功!'); } else { $this->showError('已订阅该种子!'); } } Wind::import('EXT:torrent.service.dm.PwTorrentSubscribeDm'); $dm = new PwTorrentSubscribeDm(); $dm->setUid($this->loginUser->uid)->setTorrent($id); $this->_getTorrentSubscribeDs()->addTorrentSubscribe($dm); $this->showMessage('订阅种子成功!'); }
public function subscribeAction() { $id = $this->getInput('id'); $unsub = $this->getInput('unsub'); if (!$this->loginUser->uid) { $this->showError('必须登录才能进行本操作!'); } $userBan = Wekit::load('SRV:user.PwUserBan')->getBanInfo($this->loginUser->uid); if ($userBan) { $this->showError('用户处于封禁期!'); } $torrent = Wekit::load('EXT:torrent.service.PwTorrent')->getTorrent($id); if (empty($torrent)) { $this->showError('种子文件不存在!'); } $torrent = $this->_getTorrentSubscribeDs()->getTorrentSubscribeByUidAndTorrent($this->loginUser->uid, $id); if (!empty($torrent)) { if ($unsub == 'true') { $this->_getTorrentSubscribeDs()->deleteTorrentSubscribe($torrent['id']); exit('{"status":0}'); } else { exit('{"status":1, "message":"已订阅该种子!"}'); } } Wind::import('EXT:torrent.service.dm.PwTorrentSubscribeDm'); $dm = new PwTorrentSubscribeDm(); $dm->setUid($this->loginUser->uid)->setTorrent($id); $this->_getTorrentSubscribeDs()->addTorrentSubscribe($dm); header('Location: ' . $_SERVER['HTTP_REFERER']); exit('{"status":0}'); }