コード例 #1
0
 /**
  * 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();
 }
コード例 #2
0
require_once "metaInfo.php";
// is enabled ?
if ($cfg["advanced_start"] != 1) {
    AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to use advanced start");
    showErrorPage("advanced start is disabled.");
}
$torrent = getRequestVar('torrent');
// Load saved settings
$btclient_default = $cfg["btclient"];
$torrentExists = loadTorrentSettingsToConfig($torrent);
// savepath
if (!isset($cfg["savepath"]) || empty($cfg["savepath"])) {
    $cfg["savepath"] = $cfg["path"] . getOwner($torrent) . '/';
}
// torrent exists ?
$torrentExists = getTorrentDataSize($torrent) > 0;
// display name
$displayName = htmlentities($torrent, ENT_QUOTES);
if (strlen($displayName) >= 55) {
    $displayName = substr($displayName, 0, 52) . "...";
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title><?php 
echo _RUNTORRENT;
?>
 - <?php 
コード例 #3
0
 /**
  * starts a client
  *
  * @param $transfer name of the transfer
  * @param $interactive (boolean) : is this a interactive startup with dialog ?
  * @param $enqueue (boolean) : enqueue ?
  */
 function start($transfer, $interactive = false, $enqueue = false)
 {
     global $cfg;
     // set vars
     $this->_setVarsForTransfer($transfer);
     // log
     $this->logMessage($this->client . "-start : " . $transfer . "\n", true);
     // do tornado special-pre-start-checks
     // check to see if the path to the python script is valid
     if (!is_file($this->tornadoBin)) {
         $this->state = CLIENTHANDLER_STATE_ERROR;
         $msg = "path for tftornado.py is not valid";
         AuditAction($cfg["constants"]["error"], $msg);
         $this->logMessage($msg . "\n", true);
         array_push($this->messages, $msg);
         array_push($this->messages, "tornadoBin : " . $this->tornadoBin);
         // write error to stat
         $sf = new StatFile($this->transfer, $this->owner);
         $sf->time_left = 'Error';
         $sf->write();
         // return
         return false;
     }
     // init starting of client
     $this->_init($interactive, $enqueue, true, $cfg['enable_sharekill'] == 1);
     // only continue if init succeeded (skip start / error)
     if ($this->state != CLIENTHANDLER_STATE_READY) {
         if ($this->state == CLIENTHANDLER_STATE_ERROR) {
             $msg = "Error after init (" . $transfer . "," . $interactive . "," . $enqueue . ",true," . $cfg['enable_sharekill'] . ")";
             array_push($this->messages, $msg);
             $this->logMessage($msg . "\n", true);
         }
         // return
         return false;
     }
     // file-prio
     if ($cfg["enable_file_priority"]) {
         setFilePriority($transfer);
     }
     // pythonCmd
     $pyCmd = $cfg["pythonCmd"] . " -OO";
     // build the command-string
     $skipHashCheck = "";
     if (!empty($this->skip_hash_check) && getTorrentDataSize($transfer) > 0) {
         $skipHashCheck = " --check_hashes 0";
     }
     $filePrio = "";
     if (@file_exists($this->transferFilePath . ".prio")) {
         $priolist = explode(',', @file_get_contents($this->transferFilePath . ".prio"));
         $priolist = implode(',', array_slice($priolist, 1, $priolist[0]));
         $filePrio = " --priority " . tfb_shellencode($priolist);
     }
     // build the command-string
     // note : order of args must not change for ps-parsing-code in
     // RunningTransferTornado
     $this->command = "";
     //	       Proxy Hack
     //	       $this->command .= 'export http_proxy=127.0.0.1:8118; HTTP_PROXY=$http_proxy;';
     $this->command .= "cd " . tfb_shellencode($this->savepath) . ";";
     $this->command .= " HOME=" . tfb_shellencode($cfg["path"]);
     $this->command .= "; export HOME;";
     $this->command .= $this->umask;
     $this->command .= " nohup ";
     $this->command .= $this->nice;
     $this->command .= $pyCmd . " " . tfb_shellencode($this->tornadoBin);
     $this->command .= " " . tfb_shellencode($this->runtime);
     $this->command .= " " . tfb_shellencode($this->sharekill_param);
     $this->command .= " " . tfb_shellencode($this->owner);
     $this->command .= " " . tfb_shellencode($this->transferFilePath);
     $this->command .= " --responsefile " . tfb_shellencode($this->transferFilePath);
     $this->command .= " --display_interval 1";
     $this->command .= " --max_download_rate " . tfb_shellencode($this->drate);
     $this->command .= " --max_upload_rate " . tfb_shellencode($this->rate);
     $this->command .= " --max_uploads " . tfb_shellencode($this->maxuploads);
     $this->command .= " --minport " . tfb_shellencode($this->port);
     $this->command .= " --maxport " . tfb_shellencode($this->maxport);
     $this->command .= " --rerequest_interval " . tfb_shellencode($this->rerequest);
     $this->command .= " --super_seeder " . tfb_shellencode($this->superseeder);
     $this->command .= " --max_connections " . tfb_shellencode($this->maxcons);
     $this->command .= $skipHashCheck;
     $this->command .= $filePrio;
     if (strlen($cfg["btclient_tornado_options"]) > 0) {
         $this->command .= " " . $cfg["btclient_tornado_options"];
     }
     $this->command .= " 1>> " . tfb_shellencode($this->transferFilePath . ".log");
     $this->command .= " 2>> " . tfb_shellencode($this->transferFilePath . ".log");
     $this->command .= " &";
     // start the client
     $this->_start();
 }
コード例 #4
0
            $tmpl->setvar('file_priority_enabled', 0);
            $tmpl->setvar('enable_file_priority', 0);
        }
        // dirtree
        if ($cfg["supportMap"][$ch->client]['savepath'] == 1) {
            $tmpl->setvar('showdirtree', $cfg["showdirtree"]);
            if ($cfg["showdirtree"] == 1) {
                tmplSetDirTree($ch->savepath, $cfg["maxdepth"]);
            }
        } else {
            $tmpl->setvar('showdirtree', 0);
        }
        // hash-check
        $tmpl->setvar('skip_hash_check_enabled', $cfg["supportMap"][$ch->client]['skip_hash_check']);
        if ($cfg["supportMap"][$ch->client]['skip_hash_check'] == 1) {
            $dsize = getTorrentDataSize($transfer);
            $tmpl->setvar('is_skip', $dsize > 0 && $dsize != 4096 ? $cfg["skiphashcheck"] : 0);
        } else {
            $tmpl->setvar('is_skip', 0);
        }
        // queue
        $tmpl->setvar('is_queue', FluxdQmgr::isRunning() ? 1 : 0);
        // break
        break;
    default:
        /* default */
        @error("Invalid pageop", "", "", array($pageop));
}
// title + foot
tmplSetFoot(false);
tmplSetTitleBar($transferLabel . " - Control", false);
コード例 #5
0
 /**
  * starts a client
  *
  * @param $transfer name of the transfer
  * @param $interactive (boolean) : is this a interactive startup with dialog ?
  * @param $enqueue (boolean) : enqueue ?
  */
 function start($transfer, $interactive = false, $enqueue = false)
 {
     global $cfg;
     // set vars
     $this->_setVarsForTransfer($transfer);
     // log
     $this->logMessage($this->client . "-start : " . $transfer . "\n", true);
     // do mainline special-pre-start-checks
     // check to see if the path to the python script is valid
     if (!is_file($this->mainlineBin)) {
         $this->state = CLIENTHANDLER_STATE_ERROR;
         $msg = "path for tfmainline.py is not valid";
         AuditAction($cfg["constants"]["error"], $msg);
         $this->logMessage($msg . "\n", true);
         array_push($this->messages, $msg);
         array_push($this->messages, "mainlineBin : " . $this->mainlineBin);
         // write error to stat
         $sf = new StatFile($this->transfer, $this->owner);
         $sf->time_left = 'Error';
         $sf->write();
         // return
         return false;
     }
     // init starting of client
     $this->_init($interactive, $enqueue, true, $cfg['enable_sharekill'] == 1);
     // only continue if init succeeded (skip start / error)
     if ($this->state != CLIENTHANDLER_STATE_READY) {
         if ($this->state == CLIENTHANDLER_STATE_ERROR) {
             $msg = "Error after init (" . $transfer . "," . $interactive . "," . $enqueue . ",true," . $cfg['enable_sharekill'] . ")";
             array_push($this->messages, $msg);
             $this->logMessage($msg . "\n", true);
         }
         // return
         return false;
     }
     // build the command-string
     // note : order of args must not change for ps-parsing-code in
     // RunningTransferMainline
     $this->command = "cd " . tfb_shellencode($this->savepath) . ";";
     $this->command .= " HOME=" . tfb_shellencode($cfg["path"]);
     $this->command .= "; export HOME;";
     $this->command .= $this->umask;
     $this->command .= " nohup ";
     $this->command .= $this->nice;
     $this->command .= $cfg["pythonCmd"] . " -OO" . " " . tfb_shellencode($this->mainlineBin);
     $this->command .= " --tf_owner " . tfb_shellencode($this->owner);
     $this->command .= " --display_interval 1";
     $this->command .= " --save_incomplete_in " . tfb_shellencode($this->savepath);
     $this->command .= " --save_in " . tfb_shellencode($this->savepath);
     $this->command .= " --die_when_done " . tfb_shellencode($this->runtime);
     $this->command .= " --seed_limit " . tfb_shellencode($this->sharekill_param);
     $this->command .= $this->drate != 0 ? " --max_download_rate " . tfb_shellencode($this->drate * 1024) : " --max_download_rate 125000000";
     // 1 GBit local net = 125MB/s
     $this->command .= $this->rate != 0 ? " --max_upload_rate " . tfb_shellencode($this->rate * 1024) : " --max_upload_rate 125000000";
     // 1 GBit local net = 125MB/s
     $this->command .= " --max_uploads " . tfb_shellencode($this->maxuploads);
     $this->command .= " --minport " . tfb_shellencode($this->port);
     $this->command .= " --maxport " . tfb_shellencode($this->maxport);
     $this->command .= " --rerequest_interval " . tfb_shellencode($this->rerequest);
     $this->command .= " --max_initiate " . tfb_shellencode($this->maxcons);
     if (!empty($this->skip_hash_check) && getTorrentDataSize($this->transfer) > 0) {
         $this->command .= " --no_check_hashes";
     }
     if (strlen($cfg["btclient_mainline_options"]) > 0) {
         $this->command .= " " . $cfg["btclient_mainline_options"];
     }
     $this->command .= " " . tfb_shellencode($this->transferFilePath);
     $this->command .= " 1>> " . tfb_shellencode($this->transferFilePath . ".log");
     $this->command .= " 2>> " . tfb_shellencode($this->transferFilePath . ".log");
     $this->command .= " &";
     // start the client
     $this->_start();
 }