/** @function doTheWork() Returns the info to the client. * @return void */ private function doTheWork() { try { $seeders = 0; $leechers = 0; foreach ($this->getClass('PeerTorrentManager')->find() as $PeerTorrentNew) { $PeerNew = new Peer($PeerTorrentNew->get('peerID')); $interval = $this->nice_date('+' . $this->FOGCore->getSetting('FOG_TORRENT_INTERVAL') + $this->FOGCore->getSetting('FOG_TORRENT_TIMEOUT') . ' seconds'); if ($PeerTorrentNew->get('torrentID') == $this->torrent->get('id') && !$PeerTorrentNew->get('stopped') && strtotime($PeerTorrentNew->get('lastUpdated')) <= strtotime($interval->format('Y-m-d H:i:s')) && $PeerNew->isValid() && $PeerNew->get('id') != $this->peer->get('id')) { $reply[] = array(long2ip($this->FOGCore->resolveHostname($PeerNew->get('ip'))), $PeerNew->get('port'), $PeerNew->get('hash')); } if ($PeerTorrentNew->get('torrentID') == $this->torrent->get('id') && !$PeerTorrentNew->get('stopped') && strtotime($PeerTorrentNew->get('lastUpdated')) <= strtotime($interval->format('Y-m-d H:i:s'))) { $PeerTorrentNew->get('left') > 0 ? $leechers++ : ($PeerTorrentNew->get('left') == 0 ? $seeders++ : null); } } throw new Exception($this->FOGCore->track($reply, $seeders, $leechers)); } catch (Exception $e) { die($e->getMessage()); } }