/** * starts a bittorrent-client * @param $torrent name of the torrent * @param $interactive (1|0) : is this a interactive startup with dialog ? */ function startTorrentClient($torrent, $interactive) { // do tornado special-pre-start-checks // check to see if the path to the python script is valid if (!is_file($this->cfg["btclient_tornado_bin"])) { AuditAction($this->cfg["constants"]["error"], "Error Path for " . $this->cfg["btclient_tornado_bin"] . " is not valid"); if (IsAdmin()) { $this->status = -1; header("location: admin.php?op=configSettings"); return; } else { $this->status = -1; $this->messages .= "<b>Error</b> TorrentFlux settings are not correct (path to python script is not valid) -- please contact an admin.<br>"; return; } } // prepare starting of client parent::prepareStartTorrentClient($torrent, $interactive); // prepare succeeded ? if ($this->status != 2) { $this->status = -1; $this->messages .= "<b>Error</b> parent::prepareStartTorrentClient(" . $torrent . "," . $interactive . ") failed<br>"; return; } // build the command-string $skipHashCheck = ""; if (!empty($this->skip_hash_check) && getTorrentDataSize($torrent) > 0) { $skipHashCheck = " --check_hashes 0"; } $this->command = $this->runtime . " " . $this->sharekill_param . " " . $this->cfg["torrent_file_path"] . $this->alias . ".stat " . $this->owner . " --responsefile '" . $this->cfg["torrent_file_path"] . $this->torrent . "' --display_interval 5 --max_download_rate " . $this->drate . " --max_upload_rate " . $this->rate . " --max_uploads " . $this->maxuploads . " --minport " . $this->port . " --maxport " . $this->maxport . " --rerequest_interval " . $this->rerequest . " --super_seeder " . $this->superseeder . " --max_initiate " . $this->maxcons . $skipHashCheck; if (file_exists($this->cfg["torrent_file_path"] . $this->alias . ".prio")) { $priolist = explode(',', file_get_contents($this->cfg["torrent_file_path"] . $this->alias . ".prio")); $priolist = implode(',', array_slice($priolist, 1, $priolist[0])); $this->command .= " --priority " . $priolist; } $this->command .= " " . $this->cfg["btclient_tornado_options"] . " > /dev/null &"; if ($this->cfg["AllowQueing"] && $this->queue == "1") { // This file is queued. } else { // This file is started manually. if (!array_key_exists("pythonCmd", $this->cfg)) { insertSetting("pythonCmd", "/usr/bin/python"); } if (!array_key_exists("debugTorrents", $this->cfg)) { insertSetting("debugTorrents", "0"); } $pyCmd = ""; if (!$this->cfg["debugTorrents"]) { $pyCmd = $this->cfg["pythonCmd"] . " -OO"; } else { $pyCmd = $this->cfg["pythonCmd"]; } $this->command = "cd " . $this->savepath . "; HOME=" . $this->cfg["path"] . "; export HOME;" . $this->umask . " nohup " . $this->nice . $pyCmd . " " . $this->cfg["btclient_tornado_bin"] . " " . $this->command; } // start the client parent::doStartTorrentClient(); }
/** * starts a bittorrent-client * @param $torrent name of the torrent * @param $interactive (1|0) : is this a interactive startup with dialog ? */ function startTorrentClient($torrent, $interactive) { // do transmission special-pre-start-checks // check to see if the path to the transmission-bin is valid if (!is_file($this->cfg["btclient_transmission_bin"])) { AuditAction($this->cfg["constants"]["error"], "Error Path for " . $this->cfg["btclient_transmission_bin"] . " is not valid"); $this->status = -1; if (IsAdmin()) { header("location: admin.php?op=configSettings"); return; } else { $this->messages .= "<b>Error</b> TorrentFlux settings are not correct (path to transmission-bin is not valid) -- please contact an admin.<br>"; return; } } // prepare starting of client parent::prepareStartTorrentClient($torrent, $interactive); // prepare succeeded ? if ($this->status != 2) { $this->status = -1; $this->messages .= "<b>Error</b> parent::prepareStartTorrentClient(" . $torrent . "," . $interactive . ") failed<br>"; return; } // included in transmissioncli // quick-hack for transmission--1 //if ($this->rate == 0) // $this->rate = -1; //if ($this->drate == 0) // $this->drate = -1; // included in transmissioncli // pid-file $this->pidFile = "\"" . $this->cfg["torrent_file_path"] . $this->alias . ".stat.pid\""; // build the command-string $this->command = "-t \"" . $this->cfg["torrent_file_path"] . $this->alias . ".stat\" -w " . $this->owner; // "new" transmission-patch has pid-file included $this->command .= " -z " . $this->pidFile; /* - bsd-workaround */ $this->command .= " -e 5 -p " . $this->port . " -u " . $this->rate . " -c " . $this->sharekill_param . " -d " . $this->drate; $this->command .= " " . $this->cfg["btclient_transmission_options"] . "\"" . $this->cfg["torrent_file_path"] . $this->torrent; // standard, no shell trickery ("new" transmission-patch has pid-file included) : $this->command .= '" &> /dev/null &'; /* - bsd-workaround */ // <begin shell-trickery> to write the pid of the client into the pid-file // * b4rt : //$this->command .= '" &> /dev/null & echo $! > "'. $this->pidFile .'"'; // * lord_nor : //$this->command .= '" > /dev/null & echo $! & > "'. $this->pidFile .'"'; /* + bsd-workaround */ // <end shell-trickery> if ($this->cfg["AllowQueing"] && $this->queue == "1") { // This file is queued. } else { // This file is started manually. $this->command = "cd " . $this->savepath . "; HOME=" . $this->cfg["path"] . "; export HOME;" . $this->umask . " nohup " . $this->nice . $this->cfg["btclient_transmission_bin"] . " " . $this->command; } // start the client parent::doStartTorrentClient(); }
/** * starts a bittorrent-client * @param $torrent name of the torrent * @param $interactive (1|0) : is this a interactive startup with dialog ? */ function startTorrentClient($torrent, $interactive) { // do transmission special-pre-start-checks // check to see if the path to the transmission-bin is valid if (!is_file($this->cfg["btclient_transmission_bin"])) { AuditAction($this->cfg["constants"]["error"], "Error Path for " . $this->cfg["btclient_transmission_bin"] . " is not valid"); $this->state = -1; if (IsAdmin()) { header("location: admin.php?op=configSettings"); return; } else { $this->messages .= "Error: TorrentFlux settings are not correct (path to transmission-bin is not valid) -- please contact an admin."; return; } } // prepare starting of client parent::prepareStartTorrentClient($torrent, $interactive); // only continue if prepare succeeded (skip start / error) if ($this->state != 2) { if ($this->state == -1) { $this->messages .= "Error after call to parent::prepareStartClient(" . $torrent . "," . $interactive . ")"; } return; } // transmission wants -1 for no seeding. if ($this->sharekill == -1) { $this->sharekill_param = -1; } // pid-file $this->pidFile = $this->cfg["torrent_file_path"] . $this->alias . ".stat.pid"; // build the command-string $this->command = "-t " . escapeshellarg($this->cfg["torrent_file_path"] . $this->alias . ".stat"); $this->command .= " -w " . $this->owner; // "new" transmission-patch has pid-file included $this->command .= " -z " . escapeshellarg($this->pidFile); $this->command .= " -e 5"; $this->command .= " -p " . escapeshellarg($this->port); $this->command .= " -u " . escapeshellarg($this->rate); $this->command .= " -c " . escapeshellarg($this->sharekill_param); $this->command .= " -d " . escapeshellarg($this->drate); if (strlen($this->cfg["btclient_transmission_options"]) > 0) { $this->command .= " " . $this->cfg["btclient_transmission_options"]; } $this->command .= " " . escapeshellarg($this->cfg["torrent_file_path"] . $this->torrent); // standard, no shell trickery ("new" transmission-patch has pid-file included) : $this->command .= " > /dev/null &"; // <begin shell-trickery> to write the pid of the client into the pid-file // * b4rt : //$this->command .= " &> /dev/null & echo $! > ".escapeshellarg($this->pidFile); // * lord_nor : //$this->command .= " > /dev/null & echo $! & > ".escapeshellarg($this->pidFile); // <end shell-trickery> if ($this->cfg["AllowQueing"] && $this->queue == "1") { // This file is queued. } else { // This file is started manually. $this->command = "cd " . escapeshellarg($this->savepath) . "; HOME=" . escapeshellarg($this->cfg["path"]) . "; export HOME;" . $this->umask . " nohup " . $this->nice . escapeshellarg($this->cfg["btclient_transmission_bin"]) . " " . $this->command; // workaround for bsd-pid-file-problem : touch file first if (_OS == 2) { @touch($this->pidFile); } } // start the client parent::doStartTorrentClient(); }