本文整理汇总了PHP中tfb_shellencode函数的典型用法代码示例。如果您正苦于以下问题:PHP tfb_shellencode函数的具体用法?PHP tfb_shellencode怎么用?PHP tfb_shellencode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tfb_shellencode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instance_start
/**
* start a stream
*
* @param $file
* @param $vidc
* @param $vbit
* @param $audc
* @param $abit
*/
function instance_start($file, $vidc, $vbit, $audc, $abit)
{
global $cfg;
// build command
$this->_command = "nohup";
$this->_command .= " " . $cfg['bin_vlc'];
$this->_command .= " --rc-fake-tty";
if ($vidc == 'direct') {
$this->_command .= " --play-and-stop --intf telnet -vvv \"" . str_replace("'", "\\'", $file) . "\"";
$this->_command .= " --sout '#standard{access=http,mux=ogg,dst=" . $this->addr . ":" . $this->port . "}'";
} else {
$this->_command .= " --sout " . tfb_shellencode("#transcode{vcodec=" . $vidc . ",vb=" . $vbit . ",scale=1,acodec=" . $audc . ",ab=" . $abit . ",channels=2}:std{access=mmsh,mux=asfh,dst=" . $this->addr . ":" . $this->port . "}");
$this->_command .= " " . tfb_shellencode($file);
}
$this->_command = str_replace('//', '/', $this->_command);
$this->_command .= " > /dev/null &";
//2>>/var/log/vlc_tfberr &";
// DEBUG : log the command
if ($cfg['debuglevel'] > 1) {
AuditAction($cfg["constants"]["debug"], "vlcStart : " . $this->_command);
}
// exec command
exec($this->_command);
}
示例2: file_size
/**
* Returns file size... overcomes PHP limit of 2.0GB
*
* @param $file
* @return int
*/
function file_size($file)
{
$size = @filesize($file);
if ($size == 0) {
return exec("ls -l " . tfb_shellencode($file) . " 2>/dev/null | awk '{print \$5}'");
}
return $size;
}
示例3: instance_start
/**
* instance_start
*
* @return boolean
*/
function instance_start()
{
global $cfg;
if ($this->state == FLUAZU_STATE_RUNNING) {
AuditAction($cfg["constants"]["error"], "fluazu already started");
return false;
} else {
// check the needed bins
// python
if (@file_exists($cfg['pythonCmd']) !== true) {
$msg = "cannot start fluazu, specified python-binary does not exist: " . $cfg['pythonCmd'];
AuditAction($cfg["constants"]["error"], $msg);
array_push($this->messages, $msg);
// Set the state
$this->state = FLUAZU_STATE_ERROR;
// return
return false;
}
// start it
$startCommand = "cd " . tfb_shellencode($cfg["docroot"] . "bin/clients/fluazu/") . "; HOME=" . tfb_shellencode($cfg["path"]) . ";";
$startCommand .= " export HOME;";
$startCommand .= " nohup";
$startCommand .= " " . $cfg["pythonCmd"] . " -OO";
$startCommand .= " fluazu.py";
$startCommand .= " " . tfb_shellencode($cfg["path"]);
$startCommand .= " " . tfb_shellencode($cfg["fluazu_host"]);
$startCommand .= " " . tfb_shellencode($cfg["fluazu_port"]);
$startCommand .= " " . tfb_shellencode($cfg["fluazu_secure"]);
$startCommand .= $cfg["fluazu_user"] == "" ? ' ""' : " " . tfb_shellencode($cfg["fluazu_user"]);
$startCommand .= $cfg["fluazu_pw"] == "" ? ' ""' : " " . tfb_shellencode($cfg["fluazu_pw"]);
$startCommand .= " 1>> " . tfb_shellencode($this->_pathLogFile);
$startCommand .= " 2>> " . tfb_shellencode($this->_pathLogFile);
$startCommand .= " &";
// log the command
$this->instance_logMessage("executing command : \n" . $startCommand . "\n", true);
// exec
$result = exec($startCommand);
// check if fluazu could be started
$loop = true;
$maxLoops = 125;
$loopCtr = 0;
$started = false;
while ($loop) {
@clearstatcache();
if (file_exists($this->_pathStatFile)) {
$started = true;
$loop = false;
} else {
$loopCtr++;
if ($loopCtr > $maxLoops) {
$loop = false;
} else {
usleep(200000);
}
// wait for 0.2 seconds
}
}
// check if started
if ($started) {
AuditAction($cfg["constants"]["admin"], "fluazu started");
// Set the state
$this->state = FLUAZU_STATE_RUNNING;
// return
return true;
} else {
AuditAction($cfg["constants"]["error"], "errors starting fluazu");
// Set the state
$this->state = FLUAZU_STATE_ERROR;
// return
return false;
}
}
}
示例4: backupCreate
/**
* backup of flux-installation
*
* @param $talk: boolean if function should talk
* @param $compression: 0 = none | 1 = gzip | 2 = bzip2
* @return string with name of backup-archive, string with "" in error-case.
*/
function backupCreate($talk = false, $compression = 0)
{
global $cfg, $error;
// backup-dir
$dirBackup = $cfg["path"] . _DIR_BACKUP;
if (!checkDirectory($dirBackup)) {
$error = "Errors when checking/creating backup-dir: " . tfb_htmlencodekeepspaces($dirBackup);
return "";
}
// files and more strings
$backupName = "backup_" . _VERSION . "_" . date("YmdHis");
$fileArchiveName = $backupName . ".tar";
$tarSwitch = "-cf";
switch ($compression) {
case 1:
$fileArchiveName .= ".gz";
$tarSwitch = "-zcf";
break;
case 2:
$fileArchiveName .= ".bz2";
$tarSwitch = "-jcf";
break;
}
// files
$files = array();
$files['archive'] = $dirBackup . '/' . $fileArchiveName;
$files['db'] = $dirBackup . '/database.sql';
$files['docroot'] = $dirBackup . '/docroot.tar';
$files['transfers'] = $dirBackup . '/transfers.tar';
$files['fluxd'] = $dirBackup . '/fluxd.tar';
$files['mrtg'] = $dirBackup . '/mrtg.tar';
// exec
$exec = array();
$exec['transfers'] = @is_dir($cfg["transfer_file_path"]) === true;
$exec['fluxd'] = @is_dir($cfg["path"] . '.fluxd') === true;
$exec['mrtg'] = @is_dir($cfg["path"] . '.mrtg') === true;
// commands
$commands = array();
$commands['archive'] = "cd " . tfb_shellencode($dirBackup) . "; tar " . $tarSwitch . " " . $fileArchiveName . " ";
$commands['db'] = "";
switch ($cfg["db_type"]) {
case "mysql":
$commands['db'] = "mysqldump -h " . tfb_shellencode($cfg["db_host"]) . " -u " . tfb_shellencode($cfg["db_user"]) . " --password=" . tfb_shellencode($cfg["db_pass"]) . " --all -f " . tfb_shellencode($cfg["db_name"]) . " > " . tfb_shellencode($files['db']);
$commands['archive'] .= 'database.sql ';
break;
case "sqlite":
$commands['db'] = "sqlite " . tfb_shellencode($cfg["db_host"]) . " .dump > " . tfb_shellencode($files['db']);
$commands['archive'] .= 'database.sql ';
break;
case "postgres":
$commands['db'] = "pg_dump -h " . tfb_shellencode($cfg["db_host"]) . " -D " . tfb_shellencode($cfg["db_name"]) . " -U " . tfb_shellencode($cfg["db_user"]) . " -f " . tfb_shellencode($files['db']);
$commands['archive'] .= 'database.sql ';
break;
}
$commands['archive'] .= 'docroot.tar';
if ($exec['transfers'] === true) {
$commands['archive'] .= ' transfers.tar';
}
if ($exec['fluxd'] === true) {
$commands['archive'] .= ' fluxd.tar';
}
if ($exec['mrtg'] === true) {
$commands['archive'] .= ' mrtg.tar';
}
//$commands['docroot'] = "cd ".tfb_shellencode($dirBackup)."; tar -cf docroot.tar ".tfb_shellencode($cfg["docroot"]); // with path of docroot
$commands['docroot'] = "cd " . tfb_shellencode($cfg["docroot"]) . "; tar -cf " . tfb_shellencode($files['docroot']) . " .";
// only content of docroot
$commands['transfers'] = "cd " . tfb_shellencode($cfg["transfer_file_path"]) . "; tar -cf " . tfb_shellencode($files['transfers']) . " .";
$commands['fluxd'] = "cd " . tfb_shellencode($cfg["path"] . '.fluxd') . "; tar -cf " . tfb_shellencode($files['fluxd']) . " .";
$commands['mrtg'] = "cd " . tfb_shellencode($cfg["path"] . '.mrtg') . "; tar -cf " . tfb_shellencode($files['mrtg']) . " .";
// action
if ($talk) {
sendLine('<br>');
}
// database-command
if ($commands['db'] != "") {
if ($talk) {
sendLine('Backup of Database <em>' . tfb_htmlencodekeepspaces($cfg["db_name"]) . '</em> ...');
}
shell_exec($commands['db']);
}
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// docroot-command
if ($talk) {
sendLine('Backup of Docroot <em>' . tfb_htmlencodekeepspaces($cfg["docroot"]) . '</em> ...');
}
shell_exec($commands['docroot']);
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// transfers-command
//.........这里部分代码省略.........
示例5: start
/**
* 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();
}
示例6: del
/**
* del
*
* @param $file
* @return
*/
function del($file)
{
exec("rm -f " . tfb_shellencode($file));
return true;
}
示例7: str_replace
$dirS = str_replace($cfg["path"], '', $dir);
if (!(tfb_isValidPath($dir) && hasPermission($dirS, $cfg["user"], 'r'))) {
AuditAction($cfg["constants"]["error"], "ILLEGAL SFV-ACCESS: " . $cfg["user"] . " tried to check " . $dirS);
@error("Illegal access. Action has been logged.", "", "");
}
}
if (!empty($file)) {
$fileS = str_replace($cfg["path"], '', $file);
if (!(tfb_isValidPath($file) && isValidEntry(basename($file)) && hasPermission($fileS, $cfg["user"], 'r'))) {
AuditAction($cfg["constants"]["error"], "ILLEGAL SFV-ACCESS: " . $cfg["user"] . " tried to check " . $fileS);
@error("Illegal access. Action has been logged.", "", "");
}
}
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.checkSFV.tmpl");
// process
$cmd = $cfg['bin_cksfv'] . ' -C ' . tfb_shellencode($dir) . ' -f ' . tfb_shellencode($file);
$handle = popen($cmd . ' 2>&1', 'r');
$buff = isset($cfg["debuglevel"]) && $cfg["debuglevel"] == 2 ? "<strong>Debug:</strong> Evaluating command:<br/><br/><pre>" . tfb_htmlencode($cmd) . "</pre><br/>Output follows below:<br/>" : "";
$buff .= "<pre>";
while (!feof($handle)) {
$buff .= tfb_htmlencode(@fgets($handle, 30));
}
$tmpl->setvar('buff', $buff);
pclose($handle);
$buff .= "</pre>";
// set vars
tmplSetTitleBar($cfg["pagetitle"] . ' - checkSFV', false);
tmplSetIidVars();
// parse template
$tmpl->pparse();
示例8: runningDaemonInfo
function runningDaemonInfo()
{
global $cfg;
// ps-string
$screenStatus = shell_exec("ps x a -o pid -o %cpu -o command | " . $cfg['bin_grep'] . " " . tfb_shellencode($this->binClient) . " | " . $cfg['bin_grep'] . " -v grep");
$arScreen = array();
$tok = strtok($screenStatus, "\n");
while ($tok) {
array_push($arScreen, $tok);
$tok = strtok("\n");
}
$retVal = " --- Running Processes ---\n";
$retVal .= " Daemon : " . count($screenStatus) . "\n";
$retVal .= "\n";
$retVal .= " PID %CPU Command\n";
$retVal .= $screenStatus . "\n";
return $retVal;
}
示例9: getDownloadFtpLogUsers
function getDownloadFtpLogUsers($srchFile, $logNumber = "")
{
global $cfg, $db, $dlLog;
$userlist = array();
$userRenamer = array();
//xferlog or xferlog.0 (last month)
//$ftplog = '/var/log/proftpd/xferlog'.$logNumber;
$ftplog = "/var/log/pure-ftpd/stats_transfer{$logNumber}.log";
if (!is_file($ftplog)) {
return array();
}
//Search in Log (for old or external log insert, todo)
$srchFile = str_replace($cfg["path"], '', $srchFile);
//Search in cached db log array
foreach ($dlLog as $row) {
if ($row->file == $srchFile) {
$userlist[$row->user_id] = htmlentities(substr($row->user_id, 0, 3), ENT_QUOTES);
}
}
if (count($userlist) > 0) {
return $userlist;
}
if (!file_exists($ftplog)) {
return $userlist;
}
$userRenamer["root"] = "epsylon3";
$cmdLog = "cat {$ftplog}|" . $cfg["bin_grep"] . ' ' . tfb_shellencode(str_replace(' ', '_', $srchFile));
//.'|'.$cfg["bin_grep"]." -o -E ' r (.*) ftp'"
$dlInfos = trim(@shell_exec($cmdLog));
if ($dlInfos) {
$ftpusers = explode("\n", $dlInfos);
foreach ($ftpusers as $key => $value) {
/* PROFTPD
$value=substr($value,4);
$time=strtotime(substr($value,0,20));
$value=substr($value,21);
$lineWords=explode(' ',$value);
$hostname=$lineWords[1];
$size=0+($lineWords[2]);
$username=$lineWords[count($lineWords)-5];
$complete=$lineWords[count($lineWords)-1]; */
/* pure-ftpd (stats:/var/log/pure-ftpd/stats_transfer.log) */
$lineWords = explode(' ', $value);
$time = 0 + $lineWords[0];
$username = $lineWords[2];
$hostname = $lineWords[3];
$complete = str_replace("D", "c", $lineWords[4]);
$size = 0.0 + $lineWords[5];
//die( "<pre>$size-$complete-$hostname-$username-$time\n$value\n</pre>");
if ($complete == "c") {
//rename user ?
if (array_key_exists($username, $userRenamer)) {
$username = $userRenamer[$username];
}
if (!array_key_exists($username, $userlist)) {
$srchAction = "File Download (FTP)";
$db->Execute("INSERT INTO tf_log (user_id,file,action,ip,ip_resolved,user_agent,time)" . " VALUES (" . $db->qstr($username) . "," . $db->qstr($srchFile) . "," . $db->qstr($srchAction) . "," . $db->qstr('FTP') . "," . $db->qstr($hostname) . "," . $db->qstr('FTP') . "," . $time . ")");
if ($db->ErrorNo() != 0) {
dbError($sql);
}
}
$userlist[$username] = substr($username, 0, 3);
}
}
}
return $userlist;
}
示例10: validateTransmissionCli
/**
* Validates existence + exec + valid version of transmissioncli and returns the status image
*
* @param $the_file
* @return string
*/
function validateTransmissionCli($the_file)
{
global $cfg;
if (!isFile($the_file)) {
return validationMsg(false, 'Path is not valid');
}
if (!is_executable($the_file)) {
return validationMsg(false, 'File exists but is not executable');
}
$transmissionHelp = strtolower(shell_exec("HOME=" . tfb_shellencode($cfg["path"]) . "; export HOME; " . $the_file . ' --help'));
return strpos($transmissionHelp, 'transmission') === false || strpos($transmissionHelp, 'tfcli') === false && strpos($transmissionHelp, 'torrentflux') === false ? validationMsg(false, 'Executable is not TorrentFlux-bundled transmissioncli') : validationMsg(true);
}
示例11: start
/**
* 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 transmission special-pre-start-checks
// check to see if the path to the transmission-bin is valid
if (!is_executable($cfg["btclient_transmission_bin"])) {
$this->state = CLIENTHANDLER_STATE_ERROR;
$msg = "transmissioncli cannot be executed";
AuditAction($cfg["constants"]["error"], $msg);
$this->logMessage($msg . "\n", true);
array_push($this->messages, $msg);
array_push($this->messages, "btclient_transmission_bin : " . $cfg["btclient_transmission_bin"]);
// 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, false);
// 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;
}
/*
// workaround for bsd-pid-file-problem : touch file first
if ((!$this->queue) && ($cfg["_OS"] == 2))
@touch($this->transferFilePath.".pid");
*/
// build the command-string
// note : order of args must not change for ps-parsing-code in
// RunningTransferTransmission
$this->command = "cd " . tfb_shellencode($this->savepath) . ";";
$this->command .= " HOME=" . tfb_shellencode($cfg["path"]) . "; export HOME;" . ($this->command .= $this->umask);
$this->command .= " nohup ";
$this->command .= $this->nice;
$this->command .= tfb_shellencode($cfg["btclient_transmission_bin"]);
$this->command .= " -d " . tfb_shellencode($this->drate);
$this->command .= " -u " . tfb_shellencode($this->rate);
$this->command .= " -p " . tfb_shellencode($this->port);
$this->command .= " -W " . tfb_shellencode($this->runtime == "True" ? 1 : 0);
$this->command .= " -L " . tfb_shellencode($this->sharekill_param);
$this->command .= " -E 6";
$this->command .= " -O " . tfb_shellencode($this->owner);
if (strlen($cfg["btclient_transmission_options"]) > 0) {
$this->command .= " " . $cfg["btclient_transmission_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();
}
示例12: GetLanguages
// languages
$arLang = GetLanguages();
$countLang = count($arLang);
$tmpl->setvar('server_lang_total', $countLang);
// du
switch ($cfg["_OS"]) {
case 1:
//Linux
$duArg = "-D";
break;
case 2:
//BSD
$duArg = "-L";
break;
}
$du = @shell_exec($cfg['bin_du'] . " -ch " . tfb_shellencode($duArg) . " " . tfb_shellencode($cfg['docroot']) . " | " . $cfg['bin_grep'] . " \"total\"");
$tmpl->setvar('server_du_total', substr($du, 0, -7));
// version
$tmpl->setvar('server_version', $cfg["version"]);
// M: db-settings
$tmpl->setvar('db_type', $cfg["db_type"]);
$tmpl->setvar('db_host', $cfg["db_host"]);
$tmpl->setvar('db_name', $cfg["db_name"]);
$tmpl->setvar('db_user', $cfg["db_user"]);
$tmpl->setvar('db_pcon', $cfg["db_pcon"] ? "true" : "false");
// R: server-stats
$tmpl->setvar('server_os', php_uname('s'));
$tmpl->setvar('server_php', PHP_VERSION);
$tmpl->setvar('server_php_state', PHP_VERSION < 4.3 ? 0 : 1);
$loadedExtensions = get_loaded_extensions();
if (in_array("session", $loadedExtensions)) {
示例13: tmplSetDirTree
/**
* set dir tree vars
*
* @param $dir
* @param $maxdepth
*/
function tmplSetDirTree($dir, $maxdepth)
{
global $cfg, $tmpl;
$tmpl->setvar('dirtree_dir', $dir);
if (is_numeric($maxdepth)) {
$retvar_list = array();
$last = $maxdepth == 0 ? exec("find " . tfb_shellencode($dir) . " -type d | sort && echo", $retval) : exec("find " . tfb_shellencode($dir) . " -maxdepth " . tfb_shellencode($maxdepth) . " -type d | sort && echo", $retval);
for ($i = 1; $i < count($retval) - 1; $i++) {
array_push($retvar_list, array('retval' => $retval[$i]));
}
$tmpl->setloop('dirtree_retvar_list', $retvar_list);
}
}
示例14: getTorrentDataSize
$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;
case "rewrite":
/* btreannounce*/
$newUrl = tfb_getRequestVar('announceUrl');
if ($newUrl != $announceUrl) {
echo shell_exec("cd " . tfb_shellencode($cfg["transfer_file_path"]) . "; " . $cfg["pythonCmd"] . " -OO " . tfb_shellencode($cfg["docroot"] . "bin/clients/tornado/btreannounce.py") . " " . tfb_shellencode($newUrl) . ' ' . tfb_shellencode($transfer));
}
break;
default:
/* default */
@error("Invalid pageop", "", "", array($pageop));
}
// title + foot
tmplSetFoot(false);
tmplSetTitleBar($transferLabel . " - Control", false);
// lang vars
$tmpl->setvar('_RUNTRANSFER', $cfg['_RUNTRANSFER']);
$tmpl->setvar('_STOPTRANSFER', $cfg['_STOPTRANSFER']);
$tmpl->setvar('_DELQUEUE', $cfg['_DELQUEUE']);
// iid
tmplSetIidVars();
示例15: start
/**
* 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 nzbperl special-pre-start-checks
// check to see if the path to the nzbperl script is valid
if (!is_file($this->nzbbin)) {
$this->state = CLIENTHANDLER_STATE_ERROR;
$msg = "path for tfnzbperl.pl is not valid";
AuditAction($cfg["constants"]["error"], $msg);
$this->logMessage($msg . "\n", true);
array_push($this->messages, $msg);
array_push($this->messages, "nzbbin : " . $this->nzbbin);
// 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, false, false);
// 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 Command String (do not change order of last args !)
$this->command = "cd " . tfb_shellencode($this->savepath) . ";";
$this->command .= " HOME=" . tfb_shellencode(substr($cfg["path"], 0, -1));
$this->command .= "; export HOME;";
$this->command .= $this->umask;
$this->command .= " nohup ";
$this->command .= $this->nice;
$this->command .= $cfg['perlCmd'];
$this->command .= " -I " . tfb_shellencode($cfg["docroot"] . "bin/lib");
$this->command .= " " . tfb_shellencode($this->nzbbin);
$this->command .= " --conn " . tfb_shellencode($cfg['nzbperl_conn']);
$this->command .= " --uudeview " . tfb_shellencode($cfg["bin_uudeview"]);
$this->command .= $cfg['nzbperl_badAction'] ? " --insane --keepbrokenbin" : " --dropbad";
switch ($cfg['nzbperl_create']) {
case 1:
$this->command .= " --dlcreate";
break;
case 2:
$this->command .= " --dlcreategrp";
break;
}
$this->command .= " --dthreadct " . tfb_shellencode($cfg['nzbperl_threads']);
$this->command .= " --speed " . tfb_shellencode($this->drate);
$this->command .= " --server " . tfb_shellencode($cfg['nzbperl_server']);
$this->command .= " --port " . tfb_shellencode($cfg['nzbperl_port']);
if ($cfg["nzbperl_ssl"] == 1) {
$this->command .= " --ssl";
}
if ($cfg['nzbperl_user'] != "") {
$this->command .= " --user " . tfb_shellencode($cfg['nzbperl_user']);
$this->command .= " --pw " . tfb_shellencode($cfg['nzbperl_pw']);
}
if (strlen($cfg["nzbperl_options"]) > 0) {
$this->command .= " " . $cfg['nzbperl_options'];
}
// do NOT change anything below (not even order)
$this->command .= " --dlpath " . tfb_shellencode($this->savepath);
$this->command .= " --tfuser " . tfb_shellencode($this->owner);
$this->command .= " " . tfb_shellencode($this->transferFilePath);
$this->command .= " 1>> " . tfb_shellencode($this->transferFilePath . ".log");
$this->command .= " 2>> " . tfb_shellencode($this->transferFilePath . ".log");
$this->command .= " &";
// state
$this->state = CLIENTHANDLER_STATE_READY;
// Start the client
$this->_start();
}