} $clientHandler = ClientHandler::getClientHandlerInstance($cfg, $btclient); $clientHandler->startTorrentClient($torrent, 0); $htmlMain .= ' - ' . $torrent . ""; $htmlMain .= "\n"; // just 2 sec.. sleep(2); } } $htmlMain .= '</pre>'; $htmlMain .= '<hr><br>'; break; } $htmlMain .= '<br><strong>Torrents :</strong><br>'; $htmlMain .= '<pre>'; $torrents = getTorrentListFromFS(); foreach ($torrents as $torrent) { $htmlMain .= ' - ' . $torrent . ""; if (isTorrentRunning($torrent)) { $htmlMain .= " (running)"; } $htmlMain .= "\n"; } $htmlMain .= '</pre>'; printPage(); exit; } } // standard-action buildPage(@trim($_REQUEST["a"])); printPage();
function repairTorrentflux() { global $cfg, $db; // delete pid-files of torrent-clients if ($dirHandle = opendir($cfg["torrent_file_path"])) { while (false !== ($file = readdir($dirHandle))) { if (substr($file, -1, 1) == "d") { @unlink($cfg["torrent_file_path"] . $file); } } closedir($dirHandle); } // rewrite stat-files include_once "AliasFile.php"; $torrents = getTorrentListFromFS(); foreach ($torrents as $torrent) { $alias = getAliasName($torrent); $owner = getOwner($torrent); $btclient = getTorrentClient($torrent); $af = AliasFile::getAliasFileInstance($cfg["torrent_file_path"] . $alias . ".stat", $owner, $cfg, $btclient); if (isset($af)) { $af->running = 0; $af->percent_done = -100.0; $af->time_left = 'Torrent Stopped'; $af->down_speed = 0; $af->up_speed = 0; $af->seeds = 0; $af->peers = 0; $af->errors = array(); $af->WriteFile(); } } // set flags in db $db->Execute("UPDATE tf_torrents SET running = '0'"); // delete leftovers of tfqmgr.pl (only do this if daemon is not running) $tfqmgrRunning = trim(shell_exec("ps aux 2> /dev/null | " . $cfg['bin_grep'] . " -v grep | " . $cfg['bin_grep'] . " -c tfqmgr.pl")); if ($tfqmgrRunning == "0") { if (file_exists($cfg["path"] . '.tfqmgr/tfqmgr.pid')) { @unlink($cfg["path"] . '.tfqmgr/tfqmgr.pid'); } if (file_exists($cfg["path"] . '.tfqmgr/COMMAND')) { @unlink($cfg["path"] . '.tfqmgr/COMMAND'); } if (file_exists($cfg["path"] . '.tfqmgr/TRANSPORT')) { @unlink($cfg["path"] . '.tfqmgr/TRANSPORT'); } } }
function cliStopTorrents() { $torrents = getTorrentListFromFS(); foreach ($torrents as $torrent) { if (isTorrentRunning($torrent)) { cliStopTorrent($torrent); } } }