本文整理汇总了PHP中getTransferClient函数的典型用法代码示例。如果您正苦于以下问题:PHP getTransferClient函数的具体用法?PHP getTransferClient怎么用?PHP getTransferClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getTransferClient函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resetTransferTotals
/**
* resets totals of a transfer
*
* @param $transfer name of the transfer
* @param $delete boolean if to delete meta-file
* @return array
*/
function resetTransferTotals($transfer, $delete = false)
{
global $cfg, $db, $transfers;
$msgs = array();
$tid = getTransferHash($transfer);
$client = getTransferClient($transfer);
// delete meta-file
if ($delete) {
$ch = ClientHandler::getInstance($client);
$ch->delete($transfer);
if (count($ch->messages) > 0) {
$msgs = array_merge($msgs, $ch->messages);
}
} else {
// reset in stat-file
$sf = new StatFile($transfer, getOwner($transfer));
$sf->uptotal = 0;
$sf->downtotal = 0;
$sf->write();
if ($client == "vuzerpc") {
require_once "inc/functions/functions.rpc.vuze.php";
vuzeResetUpload($tid);
}
}
// reset in db
$uid = (int) getTransferOwnerID($transfer);
$sql = "UPDATE tf_transfer_totals SET uptotal=0 WHERE tid = " . $db->qstr($tid) . " AND uid IN (0,{$uid})";
$db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
// set transfers-cache
cacheTransfersSet();
return $msgs;
}
示例2: dispatcher_processUpload
/**
* processUpload
*/
function dispatcher_processUpload()
{
global $cfg;
// check if files exist
if (empty($_FILES)) {
// log
AuditAction($cfg["constants"]["error"], "no file in file-upload");
// return
return;
}
// action-id
$actionId = tfb_getRequestVar('aid');
// file upload
$uploadMessages = array();
// stack
$tStack = array();
// process upload
while (count($_FILES) > 0) {
$upload = array_shift($_FILES);
if (is_array($upload['size'])) {
foreach ($upload['size'] as $id => $size) {
if ($size > 0) {
_dispatcher_processUpload($upload['name'][$id], $upload['tmp_name'][$id], $size, $actionId, $uploadMessages, $tStack);
}
}
} else {
if ($upload['size'] > 0) {
_dispatcher_processUpload($upload['name'], $upload['tmp_name'], $upload['size'], $actionId, $uploadMessages, $tStack);
}
}
}
// instant action ?
if ($actionId > 1 && !empty($tStack)) {
foreach ($tStack as $transfer) {
$ch = ClientHandler::getInstance(getTransferClient($transfer));
switch ($actionId) {
case 3:
$ch->start($transfer, false, true);
break;
case 2:
$ch->start($transfer, false, false);
break;
}
if (count($ch->messages) > 0) {
$uploadMessages = array_merge($uploadMessages, $ch->messages);
}
}
}
// messages
if (count($uploadMessages) > 0) {
@error("There were Problems", "", "", $uploadMessages);
}
}
示例3: tmplInitializeInstance
require_once 'inc/functions/functions.transfer.php';
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.transferHosts.tmpl");
// init transfer
transfer_init();
$isTransmissionTransfer = false;
if ($cfg["transmission_rpc_enable"] > 0) {
if (isHash($transfer)) {
$hash = $transfer;
} else {
$hash = getTransferHash($transfer);
}
require_once 'inc/functions/functions.rpc.transmission.php';
$isTransmissionTransfer = isTransmissionTransfer($hash);
if (!$isTransmissionTransfer && $cfg["transmission_rpc_enable"] == 1) {
$isTransmissionTransfer = getTransferClient($transfer) == 'transmissionrpc';
}
}
$list_host = array();
if ($isTransmissionTransfer) {
$options = array('peers');
$transfer = getTransmissionTransfer($hash, $options);
$isRunning = true;
//TODO make this actually determine if the torrent is running
if ($isRunning) {
foreach ($transfer['peers'] as $peer) {
array_push($list_host, array('host' => @gethostbyaddr($peer['address']), 'port' => $peer['port']));
}
}
} else {
// stat
示例4: tmplInitializeInstance
*******************************************************************************/
// prevent direct invocation
if (!isset($cfg['user']) || isset($_REQUEST['cfg'])) {
@ob_end_clean();
@header("location: ../../index.php");
exit;
}
/******************************************************************************/
// common functions
require_once 'inc/functions/functions.common.php';
// transfer functions
require_once 'inc/functions/functions.transfer.php';
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.transferDetails.tmpl");
// init transfer
transfer_init();
// init ch-instance
$ch = ClientHandler::getInstance(getTransferClient($transfer));
// load settings, default if settings could not be loaded (fresh transfer)
if ($ch->settingsLoad($transfer) !== true) {
$ch->settingsDefault();
}
// set details vars
transfer_setDetailsVars();
// title + foot
tmplSetFoot(false);
tmplSetTitleBar($transferLabel . " - Details", false);
// iid
tmplSetIidVars();
// parse template
$tmpl->pparse();
示例5: _maintenanceTransfers
/**
* _maintenanceTransfers
*
* @param $trestart
* @return boolean
*/
function _maintenanceTransfers($trestart = false)
{
global $cfg, $db, $transfers;
// set var
$this->_restartTransfers = $trestart;
// output
$this->_outputMessage("transfers-maintenance...\n");
// sanity-check for transfers-dir
if (!is_dir($cfg["transfer_file_path"])) {
$this->state = MAINTENANCEANDREPAIR_STATE_ERROR;
$msg = "invalid dir-settings. no dir : " . $cfg["transfer_file_path"];
array_push($this->messages, $msg);
$this->_outputError($msg . "\n");
return false;
}
// pid-files of transfer-clients
$pidFiles = array();
if ($dirHandle = @opendir($cfg["transfer_file_path"])) {
while (false !== ($file = @readdir($dirHandle))) {
if (strlen($file) > 3 && substr($file, -4, 4) == ".pid") {
array_push($pidFiles, $file);
}
}
@closedir($dirHandle);
}
// return if no pid-files found
if (count($pidFiles) < 1) {
$this->_outputMessage("no pid-files found.\n");
$this->_outputMessage("transfers-maintenance done.\n");
return true;
}
// get process-list
$psString = trim(shell_exec("ps x -o pid='' -o ppid='' -o command='' -ww"));
// test if client for pid is still up
$this->_bogusTransfers = array();
foreach ($pidFiles as $pidFile) {
$transfer = substr($pidFile, 0, -4);
if (stristr($psString, $transfer) === false) {
if (getTransferClient($transfer) != "azureus") {
array_push($this->_bogusTransfers, $transfer);
}
}
}
// return if no stale pid-files
$this->_countProblems = count($this->_bogusTransfers);
if ($this->_countProblems < 1) {
$this->_outputMessage("no stale pid-files found.\n");
$this->_outputMessage("transfers-maintenance done.\n");
return true;
}
/* repair the bogus clients */
$this->_countFixed = 0;
$this->_outputMessage("repairing died clients...\n");
foreach ($this->_bogusTransfers as $transfer) {
// output
$this->_outputMessage("repairing " . $transfer . " ...\n");
// set stopped flag in db
stopTransferSettings($transfer);
// rewrite stat-file
$sf = new StatFile($transfer, getOwner($transfer));
$sf->running = 0;
$sf->percent_done = -100.0;
$sf->time_left = 'Transfer Died';
$sf->down_speed = 0;
$sf->up_speed = 0;
$sf->seeds = 0;
$sf->peers = 0;
$sf->write();
// delete pid-file
@unlink($cfg["transfer_file_path"] . $transfer . ".pid");
// DEBUG : log the repair of the bogus transfer
if ($cfg['debuglevel'] > 0) {
AuditAction($cfg["constants"]["debug"], "transfers-maintenance : transfer repaired : " . $transfer);
}
// output
$this->_outputMessage("done.\n");
// count
$this->_countFixed++;
}
// output
if ($this->_countProblems > 0) {
$this->_outputMessage("repaired transfers : " . $this->_countFixed . "/" . $this->_countProblems . "\n");
}
/* restart transfers */
if ($this->_restartTransfers) {
$this->_fixedTransfers = array();
$this->_outputMessage("restarting died clients...\n");
// hold current user
$whoami = $this->_mode == MAINTENANCEANDREPAIR_MODE_CLI ? GetSuperAdmin() : $cfg["user"];
foreach ($this->_bogusTransfers as $transfer) {
// output
$this->_outputMessage("Starting " . $transfer . " ...\n");
// set current user to transfer-owner
$cfg["user"] = getOwner($transfer);
//.........这里部分代码省略.........
示例6: _tset
/**
* set transfer setting
*
* @param $transfer
* @param $key
* @param $val
* @param $options
* @return mixed
*/
function _tset($transfer, $key, $val, $options)
{
global $cfg;
// check transfer
if (!transferExists($transfer)) {
$this->_outputError("transfer does not exist.\n");
return false;
}
// check params
$settingsKeys = array('uprate' => 'NUMBER', 'downrate' => 'NUMBER', 'completion' => 'BOOL', 'sharekill' => 'NUMBER');
if (!array_key_exists($key, $settingsKeys)) {
$this->_outputError("invalid settings-key: " . $key . "\n");
return false;
}
if (strlen($val) < 1) {
$this->_outputError("value for " . $key . " invalid.\n");
return false;
}
switch ($settingsKeys[$key]) {
case 'NUMBER':
if (!preg_match('/^[0-9\\-]+$/D', $val)) {
$this->_outputError("value for " . $key . " must be a number: " . $val . "\n");
return false;
}
break;
case 'BOOL':
$val = strtolower($val);
if ($val != 'true' && $val != 'false') {
$this->_outputError("value for " . $key . " must be true or false: " . $val . "\n");
return false;
}
break;
}
// set user
$cfg["user"] = getOwner($transfer);
// output
$this->_outputMessage("Setting " . $key . " to " . $val . " for " . $transfer . " for user " . $cfg["user"] . "...\n");
// init ch-instance
$ch = ClientHandler::getInstance(getTransferClient($transfer));
// load settings, default if settings could not be loaded (fresh transfer)
if ($ch->settingsLoad($transfer) !== true) {
$ch->settingsDefault();
}
// autosend
$send = strpos($options, 's') !== false && isTransferRunning($transfer);
// set setting
switch ($key) {
case 'uprate':
if ($ch->rate != $val) {
$ch->setRateUpload($transfer, $val, $send);
break;
} else {
$this->_outputMessage("no changes.\n");
return false;
}
case 'downrate':
if ($ch->drate != $val) {
$ch->setRateDownload($transfer, $val, $send);
break;
} else {
$this->_outputMessage("no changes.\n");
return false;
}
case 'completion':
if (strtolower($ch->runtime) != $val) {
$ch->setRuntime($transfer, $val == 'true' ? 'True' : 'False', $send);
break;
} else {
$this->_outputMessage("no changes.\n");
return false;
}
case 'sharekill':
if ($ch->sharekill != $val) {
$ch->setSharekill($transfer, $val, $send);
break;
} else {
$this->_outputMessage("no changes.\n");
return false;
}
}
// save
$ch->settingsSave();
// output + return
if ($send) {
$this->_outputMessage("settings saved + changes sent to client.\n");
} else {
$this->_outputMessage("settings saved.\n");
}
return true;
}
示例7: getTransferDetails
/**
* gets details of a transfer as array
*
* @param $transfer
* @param $full
* @return array with details
*
* array-keys :
*
* running
* speedDown
* speedUp
* downCurrent
* upCurrent
* downTotal
* upTotal
* percentDone
* sharing
* timeLeft
* seeds
* peers
* cons
*
* owner
* size
* maxSpeedDown
* maxSpeedUp
* maxcons
* sharekill
* port
*
*/
function getTransferDetails($transfer, $full)
{
global $cfg, $transfers;
$details = array();
// common functions
require_once 'inc/functions/functions.common.php';
$transferowner = getOwner($transfer);
// settings
if (isset($transfers['settings'][$transfer])) {
$settingsAry = $transfers['settings'][$transfer];
} else {
$settingsAry = array();
$ftransfer = str_replace('.imported', '', $transfer);
if (substr($ftransfer, -8) == ".torrent") {
// this is a t-client
$settingsAry['type'] = "torrent";
$settingsAry['client'] = getTransferClient($transfer);
if (empty($settingsAry['client'])) {
$settingsAry['client'] = $cfg["btclient"];
}
} else {
if (substr($transfer, -5) == ".wget") {
// this is wget.
$settingsAry['type'] = "wget";
$settingsAry['client'] = "wget";
} else {
if (substr($transfer, -4) == ".nzb") {
// this is nzbperl.
$settingsAry['type'] = "nzb";
$settingsAry['client'] = "nzbperl";
} else {
AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $ftransfer);
@error("Invalid Transfer", "", "", array($transfer));
}
}
}
$settingsAry['hash'] = "";
$settingsAry["savepath"] = $cfg["enable_home_dirs"] != 0 ? $cfg["path"] . $transferowner . '/' : $cfg["path"] . $cfg["path_incoming"] . '/';
$settingsAry['datapath'] = "";
}
$totalsCurrent = array("downtotal" => 0, "uptotal" => 0);
$totals = array("downtotal" => 0, "uptotal" => 0);
// stat
$sf = new StatFile($transfer, $transferowner);
// totals
$afu = $sf->uptotal;
$afd = $sf->downtotal;
if (isset($settingsAry['client'])) {
$ch = ClientHandler::getInstance($settingsAry['client']);
$totalsCurrent = $ch->getTransferCurrentOP($transfer, $settingsAry['hash'], $afu, $afd);
$totals = $ch->getTransferTotalOP($transfer, $settingsAry['hash'], $afu, $afd);
$ch->updateStatFiles($transfer);
$sf = new StatFile($transfer, $transferowner);
$bIsRPC = (int) $ch->useRPC;
}
// size
$size = floatval($sf->size);
// running
$running = $sf->running;
$details['running'] = $running;
$details['cons'] = "";
$details['port'] = "";
// speed_down + speed_up + seeds + peers + cons
if ($bIsRPC) {
$stat = $ch->monitorTransfer($transfer, $format = "tf");
$totals["downtotal"] = $stat['downTotal'];
$totals["uptotal"] = $stat['upTotal'];
$details['running'] = $stat['running'];
//.........这里部分代码省略.........
示例8: sa_transfers
/**
* transfers
*
* @param $action
*/
function sa_transfers($action = "")
{
global $cfg, $error, $statusImage, $statusMessage, $htmlTitle, $htmlTop, $htmlMain;
if ($action == "") {
return;
}
buildPage("t");
switch ($action) {
case "0":
// Transfers-main
$htmlTitle = "Transfer Bulk Operations";
$htmlMain .= '<br><div align="left">';
$htmlMain .= '<p>Select action to perform on all items in the transfer list:</p>';
$htmlMain .= '<a href="' . _FILE_THIS . '?t=1"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Stop All Transfers" border="0"> Stop All Transfers</a>';
$htmlMain .= '<p>';
$htmlMain .= '<a href="' . _FILE_THIS . '?t=2"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Start All Transfers" border="0"> Start All Transfers</a>';
$htmlMain .= '<p>';
$htmlMain .= '<a href="' . _FILE_THIS . '?t=3"><img src="themes/' . $cfg["theme"] . '/images/arrow.gif" width="9" height="9" title="Resume All Transfers" border="0"> Resume All Transfers</a>';
$htmlMain .= '<br><br><strong>Note:</strong><br>\'Start All Transfers\' will start all transfers in the transfer list, regardless of whether they have been started previously or not.<br><br>\'Resume All Transfers\' will only start those transfers that have previously been started and are currently in the \'stopped\' state';
$htmlMain .= '</div><br><br>';
break;
case "1":
// Transfers-Stop
$htmlTitle = "Transfers - Stop";
$htmlMain .= '<br><strong>Transfers Stopped:</strong><br>';
$htmlMain .= '<pre>';
$transferList = getTransferArray();
foreach ($transferList as $transfer) {
if (isTransferRunning($transfer)) {
$ch = ClientHandler::getInstance(getTransferClient($transfer));
$ch->stop($transfer);
$htmlMain .= ' - ' . $transfer . "";
$htmlMain .= "\n";
}
}
$htmlMain .= '</pre>';
$htmlMain .= '<hr><br>';
break;
case "2":
// Transfers-Start
$htmlTitle = "Transfers - Start";
$htmlMain .= '<br><strong>Transfers Started:</strong><br>';
$htmlMain .= '<pre>';
$transferList = getTransferArray();
foreach ($transferList as $transfer) {
if (!isTransferRunning($transfer)) {
$ch = ClientHandler::getInstance(getTransferClient($transfer));
$ch->start($transfer, false, false);
$htmlMain .= ' - ' . $transfer . "";
$htmlMain .= "\n";
}
}
$htmlMain .= '</pre>';
$htmlMain .= '<hr><br>';
break;
case "3":
// Transfers-Resume
$htmlTitle = "Transfers - Resume";
$htmlMain .= '<br><strong>Transfers Resumed:</strong><br>';
$htmlMain .= '<pre>';
$transferList = getTransferArray();
$sf = new StatFile("");
foreach ($transferList as $transfer) {
$sf->init($transfer);
if (trim($sf->running) == 0 && !isTransferRunning($transfer)) {
$ch = ClientHandler::getInstance(getTransferClient($transfer));
$ch->start($transfer, false, false);
$htmlMain .= ' - ' . $transfer . "";
$htmlMain .= "\n";
}
}
$htmlMain .= '</pre>';
$htmlMain .= '<hr><br>';
break;
}
$htmlMain .= '<br><strong>Transfers:</strong><br>';
$htmlMain .= '<pre>';
$transferList = getTransferArray();
foreach ($transferList as $transfer) {
$htmlMain .= ' - ' . $transfer . "";
if (isTransferRunning($transfer)) {
$htmlMain .= " (running)";
}
$htmlMain .= "\n";
}
$htmlMain .= '</pre>';
printPage();
exit;
}
示例9: tmplInitializeInstance
}
/******************************************************************************/
// common functions
require_once 'inc/functions/functions.common.php';
// transfer functions
require_once 'inc/functions/functions.transfer.php';
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.transferSettings.tmpl");
// init transfer
transfer_init();
// request-vars
$saveop = tfb_getRequestVar('save');
$client = tfb_getRequestVar('client');
$isSave = $saveop == 1 ? true : false;
// init ch-instance
$ch = $client == "" ? ClientHandler::getInstance(getTransferClient($transfer)) : ClientHandler::getInstance($client);
// customize-vars
transfer_setCustomizeVars();
// load settings, default if settings could not be loaded (fresh transfer)
if ($ch->settingsLoad($transfer) !== true) {
$ch->settingsDefault();
}
// set running-field
$ch->running = isTransferRunning($transfer) ? 1 : 0;
// save/display
if ($isSave) {
/* save */
// set save-var
$tmpl->setvar('isSave', 1);
// send to client
$doSend = isset($_REQUEST['sendbox']) && $ch->running == 1 ? true : false;
示例10: image_pieTransferPeers
/**
* pieTransferPeers
*/
function image_pieTransferPeers()
{
global $cfg;
// transfer-id
$transfer = tfb_getRequestVar('transfer');
if (empty($transfer)) {
Image::paintNoOp();
}
// validate transfer
$validTransfer = false;
if (isHash($transfer)) {
$hash = $transfer;
} else {
$hash = getTransferHash($transfer);
}
if ($cfg["transmission_rpc_enable"]) {
require_once 'inc/functions/functions.rpc.transmission.php';
$options = array('trackerStats', 'peers');
$transTransfer = getTransmissionTransfer($hash, $options);
// false if not found; TODO check if transmission enabled
if (is_array($transTransfer)) {
$validTransfer = true;
$client = "transmissionrpc";
}
}
if (!$validTransfer) {
// If not found in transmission transfer
if (tfb_isValidTransfer($transfer)) {
// stat
$sf = new StatFile($transfer);
$seeds = trim($sf->seeds);
$peers = trim($sf->peers);
// client-switch + get peer-data
$peerData = array();
$peerData['seeds'] = 0;
$peerData['peers'] = 0;
$peerData['seedsLabel'] = $seeds != "" ? $seeds : 0;
$peerData['peersLabel'] = $peers != "" ? $peers : 0;
$client = getTransferClient($transfer);
$validTransfer = true;
}
}
if (!$validTransfer) {
AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $transfer);
Image::paintNoOp();
}
switch ($client) {
case "tornado":
if ($seeds != "") {
if (strpos($seeds, "+") !== false) {
$seeds = preg_replace('/(\\d+)\\+.*/i', '${1}', $seeds);
}
if (is_numeric($seeds)) {
$peerData['seeds'] = $seeds;
}
$peerData['seedsLabel'] = $seeds;
}
if ($peers != "") {
if (strpos($peers, "+") !== false) {
$peers = preg_replace('/(\\d+)\\+.*/i', '${1}', $peers);
}
if (is_numeric($peers)) {
$peerData['peers'] = $peers;
}
$peerData['peersLabel'] = $peers;
}
break;
case "transmission":
case "transmissionrpc":
$peers = sizeof($transTransfer['peers']);
$seeds = 0;
foreach ($transTransfer['trackerStats'] as $tracker) {
$seeds += $tracker['seederCount'] == -1 ? 0 : $tracker['seederCount'];
}
$peerData['seedsLabel'] = $seeds;
$peerData['seeds'] = $seeds;
$peerData['peersLabel'] = $peers;
$peerData['peers'] = $peers;
break;
case "vuzerpc":
if (empty($seeds) || empty($peers)) {
$ch = ClientHandler::getInstance($client);
$running = $ch->monitorRunningTransfers();
$hash = strtoupper(getTransferHash($transfer));
if (!empty($running[$hash])) {
$t = $running[$hash];
$peerData['seeds'] = $t['seeds'];
$peerData['seedsLabel'] = $t['seeds'];
$peerData['peers'] = $t['peers'];
$peerData['peersLabel'] = $t['peers'];
}
}
break;
case "azureus":
if ($seeds != "") {
if (strpos($seeds, "(") !== false) {
$seeds = preg_replace('/.*(\\d+) .*/i', '${1}', $seeds);
//.........这里部分代码省略.........
示例11: resetTransferTotals
/**
* resets totals of a transfer
*
* @param $transfer name of the transfer
* @param $delete boolean if to delete meta-file
* @return array
*/
function resetTransferTotals($transfer, $delete = false)
{
global $cfg, $db, $transfers;
$msgs = array();
$tid = getTransferHash($transfer);
// delete meta-file
if ($delete) {
$ch = ClientHandler::getInstance(getTransferClient($transfer));
$ch->delete($transfer);
if (count($ch->messages) > 0) {
$msgs = array_merge($msgs, $ch->messages);
}
} else {
// reset in stat-file
$sf = new StatFile($transfer, getOwner($transfer));
$sf->uptotal = 0;
$sf->downtotal = 0;
$sf->write();
}
// reset in db
$sql = "DELETE FROM tf_transfer_totals WHERE tid = " . $db->qstr($tid);
$db->Execute($sql);
if ($db->ErrorNo() != 0) {
dbError($sql);
}
// set transfers-cache
cacheTransfersSet();
return $msgs;
}
示例12: image_pieTransferPeers
/**
* pieTransferPeers
*/
function image_pieTransferPeers()
{
global $cfg;
// transfer-id
$transfer = tfb_getRequestVar('transfer');
if (empty($transfer)) {
Image::paintNoOp();
}
// validate transfer
if (tfb_isValidTransfer($transfer) !== true) {
AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $transfer);
Image::paintNoOp();
}
// stat
$sf = new StatFile($transfer);
$seeds = trim($sf->seeds);
$peers = trim($sf->peers);
// client-switch + get peer-data
$peerData = array();
$peerData['seeds'] = 0;
$peerData['peers'] = 0;
$peerData['seedsLabel'] = $seeds != "" ? $seeds : 0;
$peerData['peersLabel'] = $peers != "" ? $peers : 0;
$client = getTransferClient($transfer);
switch ($client) {
case "tornado":
if ($seeds != "") {
if (strpos($seeds, "+") !== false) {
$seeds = preg_replace('/(\\d+)\\+.*/i', '${1}', $seeds);
}
if (is_numeric($seeds)) {
$peerData['seeds'] = $seeds;
}
$peerData['seedsLabel'] = $seeds;
}
if ($peers != "") {
if (strpos($peers, "+") !== false) {
$peers = preg_replace('/(\\d+)\\+.*/i', '${1}', $peers);
}
if (is_numeric($peers)) {
$peerData['peers'] = $peers;
}
$peerData['peersLabel'] = $peers;
}
break;
case "transmission":
case "azureus":
if ($seeds != "") {
if (strpos($seeds, "(") !== false) {
$seeds = preg_replace('/.*(\\d+) .*/i', '${1}', $seeds);
}
if (is_numeric($seeds)) {
$peerData['seeds'] = $seeds;
}
$peerData['seedsLabel'] = $seeds;
}
if ($peers != "") {
if (strpos($peers, "(") !== false) {
$peers = preg_replace('/.*(\\d+) .*/i', '${1}', $peers);
}
if (is_numeric($peers)) {
$peerData['peers'] = $peers;
}
$peerData['peersLabel'] = $peers;
}
break;
case "mainline":
if ($seeds != "" && is_numeric($seeds)) {
$peerData['seeds'] = $seeds;
$peerData['seedsLabel'] = $seeds;
}
if ($peers != "" && is_numeric($peers)) {
$peerData['peers'] = $peers;
$peerData['peersLabel'] = $peers;
}
break;
case "wget":
case "nzbperl":
$peerData['seeds'] = $seeds != "" ? $seeds : 0;
$peerData['peers'] = $peers != "" ? $peers : 0;
break;
default:
AuditAction($cfg["constants"]["error"], "INVALID TRANSFER: " . $transfer);
Image::paintNoOp();
}
// draw image
Image::paintPie3D(202, 160, 100, 50, 200, 100, 20, Image::stringToRGBColor($cfg["body_data_bg"]), array($peerData['seeds'] + 1.0E-5, $peerData['peers'] + 1.0E-5), array(array('r' => 0x0, 'g' => 0xeb, 'b' => 0xc), array('r' => 0x10, 'g' => 0x0, 'b' => 0xff)), array('Seeds : ' . $peerData['seedsLabel'], 'Peers : ' . $peerData['peersLabel']), 58, 130, 2, 14);
}
示例13: compat_tf_processUpload
/**
* Function with which metafiles are uploaded and injected
*
* @deprecated
*/
function compat_tf_processUpload()
{
global $cfg;
$filename = "";
$uploadMessages = array();
if (isset($_FILES['upload_file']) && !empty($_FILES['upload_file']['name'])) {
$filename = stripslashes($_FILES['upload_file']['name']);
$filename = tfb_cleanFileName($filename);
if ($filename === false) {
// invalid file
array_push($uploadMessages, "The type of file you are uploading is not allowed.");
array_push($uploadMessages, "\nvalid file-extensions: ");
array_push($uploadMessages, $cfg["file_types_label"]);
} else {
// file is valid
if (substr($filename, -5) == ".wget") {
// is enabled ?
if ($cfg["enable_wget"] == 0) {
AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to upload wget-file " . $filename);
@error("wget is disabled", "", "");
} else {
if ($cfg["enable_wget"] == 1) {
if (!$cfg['isAdmin']) {
AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to upload wget-file " . $filename);
@error("wget is disabled for users", "", "");
}
}
}
} else {
if (substr($filename, -4) == ".nzb") {
// is enabled ?
if ($cfg["enable_nzbperl"] == 0) {
AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to upload nzb-file " . $filename);
@error("nzbperl is disabled", "", "");
} else {
if ($cfg["enable_nzbperl"] == 1) {
if (!$cfg['isAdmin']) {
AuditAction($cfg["constants"]["error"], "ILLEGAL ACCESS: " . $cfg["user"] . " tried to upload nzb-file " . $filename);
@error("nzbperl is disabled for users", "", "");
}
}
}
}
}
if ($_FILES['upload_file']['size'] <= $cfg["upload_limit"] && $_FILES['upload_file']['size'] > 0) {
//FILE IS BEING UPLOADED
if (@is_file($cfg["transfer_file_path"] . $filename)) {
// Error
array_push($uploadMessages, "the file " . $filename . " already exists on the server.");
} else {
if (@move_uploaded_file($_FILES['upload_file']['tmp_name'], $cfg["transfer_file_path"] . $filename)) {
@chmod($cfg["transfer_file_path"] . $filename, 0644);
AuditAction($cfg["constants"]["file_upload"], $filename);
// inject
injectTransfer($filename);
// instant action ?
$actionId = tfb_getRequestVar('aid');
if ($actionId > 1) {
$ch = ClientHandler::getInstance(getTransferClient($filename));
switch ($actionId) {
case 3:
$ch->start($filename, false, true);
break;
case 2:
$ch->start($filename, false, false);
break;
}
if (count($ch->messages) > 0) {
$uploadMessages = array_merge($uploadMessages, $ch->messages);
}
}
} else {
array_push($uploadMessages, "File not uploaded, file could not be found or could not be moved: " . $cfg["transfer_file_path"] . $filename);
}
}
} else {
array_push($uploadMessages, "File not uploaded, file size limit is " . $cfg["upload_limit"] . ". file has " . $_FILES['upload_file']['size']);
}
}
}
if (count($uploadMessages) > 0) {
AuditAction($cfg["constants"]["error"], $cfg["constants"]["file_upload"] . " :: " . $filename);
@error("There were Problems", "", "", $uploadMessages);
}
}