public function output() { $output = new LinfoOutput($this); if (defined('LINFO_CLI') && extension_loaded('ncurses') && isset($_SERVER['argv']) && !in_array('--nocurses', $_SERVER['argv'])) { $output->ncursesOut(); return; } switch (array_key_exists('out', $_GET) ? $_GET['out'] : 'html') { case 'html': default: $output->htmlOut(); break; case 'json': case 'jsonp': // To use JSON-P, pass the GET arg - callback=function_name $output->jsonOut(); break; case 'php_array': $output->serializedOut(); break; case 'xml': if (!extension_loaded('SimpleXML')) { throw new LinfoFatalException('Cannot generate XML. Install php\'s SimpleXML extension.'); } $output->xmlOut(); break; } }
public function result() { if (!$this->res) { return false; } $rows[] = array('type' => 'header', 'columns' => array('Torrent/hash' . ($this->hideName ? ' (names hidden)' : ''), 'Size', 'Progress', 'Status', 'Seeds', 'Peers', 'Downloaded', 'Uploaded', 'Ratio', 'Speeds')); foreach ($this->torrents as $name => $info) { $rows[] = array('type' => 'values', 'columns' => array(($this->hideName ? '' : $info['TORRENT_NAME'] . '<br />') . '<span style="font-size: 80%; font-family: monaco, monospace, courier;">' . $info['TORRENT_HASH'] . '</span>', LinfoCommon::byteConvert($info['TORRENT_SIZE']), LinfoOutput::generateBarChart($info['TORRENT_PROGRESS'] / 10), $info['TORRENT_STATUS_MESSAGE'], $info['TORRENT_SEEDS_CONNECTED'] . '/' . $info['TORRENT_SEEDS_SWARM'], $info['TORRENT_SEEDS_CONNECTED'] . '/' . $info['TORRENT_PEERS_SWARM'], LinfoCommon::byteConvert($info['TORRENT_DOWNLOADED']), LinfoCommon::byteConvert($info['TORRENT_UPLOADED']), $info['TORRENT_RATIO'] > 0 ? round($info['TORRENT_RATIO'] / 1000, 2) ?: '0.0' : '0.0', LinfoCommon::byteConvert($info['TORRENT_DOWNSPEED']) . '/s ↓ ' . LinfoCommon::byteConvert($info['TORRENT_UPSPEED']) . '/s ↑ ')); } // Give it off return array('root_title' => 'µTorrent <span style="font-size: 80%;">(' . LinfoCommon::byteConvert($this->stats['downloaded']) . ' ↓ ' . LinfoCommon::byteConvert($this->stats['uploaded']) . ' ↑ ' . round($this->stats['uploaded'] / $this->stats['downloaded'], 2) . ' ratio)</span>', 'rows' => $rows); }