public function create(string $data, string $type = 'md5') : string { $algos = ['golden', 'super']; if (!isHash($type) && !in_array($type, $algos)) { throw new InvalidArgumentException('Error', 'hashParameter', 'String $type'); } if (in_array($type, $algos)) { return Encode::$type($data); } return hash($type, $data); }
public function create(string $data, string $additional = 'default') : string { $algo = CRYPTOGRAPHY_ENCODE_CONFIG['type']; if (!isHash($algo)) { $algo = 'md5'; } // Ek veri şifreleniyor. $additional = hash($algo, $additional); // Veri şifreleniyor. $data = hash($algo, $data); // Veri ve ek yeniden şifreleniyor. return hash($algo, $data . $additional); }
public function create(string $data) : string { $projectKey = PROJECT_CONFIG['key']; $algo = CRYPTOGRAPHY_ENCODE_CONFIG['type']; if (!isHash($algo)) { $algo = 'md5'; } // Proje Anahatarı belirtizme bu veri yerine // Proje anahtarı olarak sitenin host adresi // eklenecek ek veri kabul edilir. if (empty($projectKey)) { $additional = hash($algo, host()); } else { $additional = hash($algo, $projectKey); } // Veri şifreleniyor. $data = hash($algo, $data); // Veri ve ek yeniden şifreleniyor. return hash($algo, $data . $additional); }
public function encode($hash = 'md5') { if (isHash($hash)) { $this->settings['encryption'] = $hash; } else { $this->settings['encryption'] = 'md5'; } return $this; }
protected function _encode() { $encode = $this->settings['encryption']; $length = $this->settings['encodeLength']; if (!isHash($encode)) { $encode = 'md5'; } return substr(Encode::type(uniqid(rand()), $encode), 0, $length) . '-'; }
/** * get Owner (username) * * @param $transfer * @return string */ function getOwner($transfer) { global $cfg, $db, $transfers; if (isset($transfers['owner'][$transfer])) { return $transfers['owner'][$transfer]; } else { $uid = (int) getTransferOwnerID($transfer); if ($uid > 0) { //fast method return GetUsername($uid); } elseif (isHash($transfer)) { $uid = $db->GetOne("SELECT uid FROM tf_transfer_totals WHERE tid=" . $db->qstr($transfer) . " ORDER BY created DESC"); if ($db->ErrorNo() != 0) { dbError($sql); } $transfers['owner'][$transfer] = GetUsername($uid); } else { //slower, needed for old transfers (before TFNG) // Check log to see what user has a history with this file $transfers['owner'][$transfer] = $db->GetOne("SELECT user_id FROM tf_log WHERE file=" . $db->qstr($transfer) . " AND (action=" . $db->qstr($cfg["constants"]["file_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["url_upload"]) . " OR action=" . $db->qstr($cfg["constants"]["reset_owner"]) . ") ORDER BY time DESC"); return $transfers['owner'][$transfer] != "" ? $transfers['owner'][$transfer] : resetOwner($transfer); // try and get the owner from the stat file; } } }
/** * SOAP::Value::_getSoapType * * convert php type to soap type * @param string value * @param string type - presumed php type * * @return string type - soap type * @access private */ function _getSoapType(&$value, &$type) { $doconvert = FALSE; if (0 && $this->wsdl) { # see if it's a complex type so we can deal properly with SOAPENC:arrayType if (!$type && $this->name) { # XXX TODO: # look up the name in the wsdl and validate the type $this->debug("SOAP_VALUE no type for {$this->name}!"); } else { if ($type) { # XXX TODO: # this code currently handles only one way of encoding array types in wsdl # need to do a generalized function to figure out complex types if (array_key_exists($type, $this->wsdl->complexTypes)) { if ($this->arrayType = $this->wsdl->complexTypes[$type]['arrayType']) { $type = 'Array'; } else { if ($this->wsdl->complexTypes[$type]['order'] == 'sequence' && array_key_exists('elements', $this->wsdl->complexTypes[$type])) { reset($this->wsdl->complexTypes[$type]['elements']); # assume an array if (count($this->wsdl->complexTypes[$type]['elements']) == 1) { $arg = current($this->wsdl->complexTypes[$type]['elements']); $this->arrayType = $arg['type']; $type = 'Array'; } else { foreach ($this->wsdl->complexTypes[$type]['elements'] as $element) { if ($element['name'] == $type) { $this->arrayType = $element['type']; $type = $element['type']; } } } } } } } } } if (!$type || !$this->verifyType($type)) { if ($type && $this->wsdl && array_key_exists($type, $this->wsdl->complexTypes)) { # do nothing, this preserves our complex types } else { if (is_object($value)) { # allows for creating special classes to handle soap types $type = get_class($value); # this may return a different type that we process below $value = $value->toSOAP(); } elseif (isArray($value)) { $type = isHash($value) ? 'Struct' : 'Array'; } elseif (isInt($value)) { $type = 'int'; } elseif (isFloat($value)) { $type = 'float'; } elseif (SOAP_Type_hexBinary::is_hexbin($value)) { $type = 'hexBinary'; } elseif (isBase64($value)) { $type = 'base64Binary'; } elseif (isBoolean($value)) { $type = 'boolean'; } else { $type = gettype($value); # php defaults a lot of stuff to string, if we have no # idea what the type realy is, we have to try to figure it out # this is the best we can do if the user did not use the SOAP_Value class if ($type == 'string') { $doconvert = TRUE; } } } } # we have the type, handle any value munging we need if ($doconvert) { $dt = new SOAP_Type_dateTime($value); if ($dt->toUnixtime() != -1) { $type = 'dateTime'; $value = $dt->toSOAP(); } } else { if ($type == 'dateTime') { # encode a dateTime to ISOE $dt = new SOAP_Type_dateTime($value); $value = $dt->toSOAP(); } else { // php type name mangle if ($type == 'integer') { $type = 'int'; } else { if ($type == 'boolean') { if ($value != 0 && $value != '0' || strcasecmp($value, 'true') == 0) { $value = 'true'; } else { $value = 'false'; } } } } } return $type; }
/** * (internal) Function with which metafiles are downloaded and injected * * @param $url url to download * @param $type */ function _dispatcher_processDownload($url, $type = 'torrent', $ext = '.torrent') { global $cfg; $filename = ""; $downloadMessages = array(); $origurl = $url; // Added by deadeyes; copied as later $url gets changed if (!empty($url)) { $hash = false; // Added by deadeyes to detect a magnet link if ($type === 'torrent' && strlen(stristr($url, 'magnet:')) > 0) { $client = getTransferClient('magnet.torrent'); // We have a magnet link :D if ($client == 'transmissionrpc' && $cfg["transmission_rpc_enable"]) { require_once 'inc/functions/functions.rpc.transmission.php'; $hash = addTransmissionTransfer($cfg['uid'], $url, $cfg['path'] . $cfg['user']); if (isHash($hash)) { startTransmissionTransfer($hash); } } if (($client == 'vuzerpc' || $client == 'azureus') && $cfg["vuze_rpc_enable"]) { require_once 'inc/functions/functions.rpc.vuze.php'; $hash = addVuzeMagnetTransfer($cfg['uid'], $url, $cfg['transfer_file_path']); } if ($cfg['debuglevel'] > 0) { AuditAction($cfg["constants"]["debug"], "Download Magnet ({$client}) : {$hash} " . htmlentities(addslashes($url), ENT_QUOTES)); } } if (!$hash) { // not a magnet torrent.. $arURL = explode("/", $url); $filename = urldecode($arURL[count($arURL) - 1]); // get the file name $filename = str_replace(array("'", ","), "", $filename); $filename = stripslashes($filename); // Check to see if url has something like ?passkey=12345 // If so remove it. if (($point = strrpos($filename, "?")) !== false) { $filename = substr($filename, 0, $point); } $ret = strrpos($filename, "."); if ($ret === false) { $filename .= $ext; } else { if (!strcmp(strtolower(substr($filename, -strlen($ext))), $ext) == 0) { $filename .= $ext; } } $url = str_replace(" ", "%20", $url); // This is to support Sites that pass an id along with the url for downloads. $tmpId = tfb_getRequestVar("id"); if (!empty($tmpId)) { $url .= "&id=" . $tmpId; } // retrieve the file require_once "inc/classes/SimpleHTTP.php"; $content = ""; switch ($type) { default: case 'torrent': $content = SimpleHTTP::getTorrent($url); break; case 'nzb': $content = SimpleHTTP::getNzb($url); break; } if (SimpleHTTP::getState() == SIMPLEHTTP_STATE_OK && strlen($content) > 0) { $fileNameBackup = $filename; $filename = SimpleHTTP::getFilename(); if ($filename != "") { $filename = strpos($filename, $ext) !== false ? tfb_cleanFileName($filename) : tfb_cleanFileName($filename . $ext); } if (empty($filename) || transferExists($filename)) { $filename = substr($cfg['user'], 0, 3) . "_" . date('ymdHis') . "_" . sprintf('%x', crc32($filename)) . $ext; } /* if (($filename == "") || ($filename === false) || (transferExists($filename))) { $filename = tfb_cleanFileName($fileNameBackup); if (($filename === false) || (transferExists($filename))) { $filename = tfb_cleanFileName($url.$ext); if (($filename === false) || (transferExists($filename))) { $filename = tfb_cleanFileName(md5($url.strval(@microtime())).$ext); if (($filename === false) || (transferExists($filename))) { // Error array_push($downloadMessages , "failed to get a valid transfer-filename for ".$url); } } } } */ if (empty($downloadMessages)) { // no messages // check if content contains html if ($cfg['debuglevel'] > 0) { if (strpos($content, "<br />") !== false) { AuditAction($cfg["constants"]["debug"], "download-content contained html : " . htmlentities(addslashes($url), ENT_QUOTES)); } } if (is_file($cfg["transfer_file_path"] . $filename)) { // Error array_push($downloadMessages, "the file " . $filename . " already exists on the server."); } else { // write to file $handle = false; $handle = @fopen($cfg["transfer_file_path"] . $filename, "w"); if (!$handle) { array_push($downloadMessages, "cannot open " . $filename . " for writing."); } else { $result = @fwrite($handle, $content); @fclose($handle); if ($result === false) { array_push($downloadMessages, "cannot write content to " . $filename . "."); } } } } } else { $msgs = SimpleHTTP::getMessages(); if (count($msgs) > 0) { $downloadMessages = array_merge($downloadMessages, $msgs); } } if (empty($downloadMessages) && is_file($cfg["transfer_file_path"] . $filename)) { // no messages AuditAction($cfg["constants"]["url_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) { $downloadMessages = array_merge($downloadMessages, $ch->messages); } } } } } else { array_push($downloadMessages, "Invalid Url : " . $url); } if (count($downloadMessages) > 0) { AuditAction($cfg["constants"]["error"], $cfg["constants"]["url_upload"] . " :: " . $filename); @error("There were Problems", "", "", $downloadMessages); } }
/** * gets current status of one Transfer (realtime) * for transferStat popup * * @return array (stat) or Error String */ function monitorTransfer($transfer, $format = "rpc") { //by default, monitoring not available. // set vars $this->_setVarsForTransfer($transfer); if (isHash($transfer)) { $hash = $transfer; } else { $hash = getTransferHash($transfer); } if (empty($hash)) { return "Hash for {$transfer} was not found"; } //original rpc format, you can add fields here $fields = array('id', 'name', 'status', 'hashString', 'totalSize', 'downloadedEver', 'uploadedEver', 'percentDone', 'uploadRatio', 'peersConnected', 'peersGettingFromUs', 'peersSendingToUs', 'rateDownload', 'rateUpload', 'downloadLimit', 'uploadLimit', 'downloadLimited', 'uploadLimited', 'seedRatioLimit', 'seedRatioMode', 'downloadDir', 'eta', 'error', 'errorString'); $stat_rpc = getTransmissionTransfer($hash, $fields); $rpc = Transmission::getInstance(); if (is_array($stat_rpc)) { if ($format == "rpc") { return $stat_rpc; } else { return $rpc->rpc_to_tf($stat_rpc); } } return $rpc->lastError; }
public function delete($name = '', $path = '') { if (!isValue($name) || empty($name)) { return Error::set(lang('Error', 'valueParameter', 'name')); } $cookieConfig = $this->config; if (!empty($path)) { $this->path = $path; } if (empty($this->path)) { $this->path = $cookieConfig["path"]; } if (isset($this->encode['name'])) { if (isHash($this->encode['name'])) { $name = hash($this->encode['name'], $name); $this->encode = array(); } } else { if ($cookieConfig["encode"] === true) { $name = md5($name); } } if (isset($_COOKIE[$name])) { setcookie($name, '', time() - 1, $this->path); $this->path = NULL; } else { return false; } }
/** * This method adds a Transmission transfer to transmission-daemon * * @return array with uid and transmission transfer hash * TODO: generate an error when adding does fail */ function addTransmissionTransfer($uid = 0, $url, $path, $paused = true) { // $path holds the download path require_once 'inc/classes/Transmission.class.php'; $rpc = Transmission::getInstance(); $result = $rpc->add($url, $path, array('paused' => $paused)); if ($result["result"] !== "success") { //rpc_error("addTransmissionTransfer","","",$result['result']. " url=$url"); return $result; } $hash = $result['arguments']['torrent-added']['hashString']; //rpc_error("The hash is: $hash. The uid is $uid"); exit(); if (isHash($hash)) { addTransmissionTransferToDB($uid, $hash); } return $hash; }
public function delete(string $name, string $path = NULL) : bool { $cookieConfig = SERVICES_COOKIE_CONFIG; if (!empty($path)) { $this->path = $path; } if (empty($this->path)) { $this->path = $cookieConfig["path"]; } if (isset($this->encode['name'])) { if (isHash($this->encode['name'])) { $name = hash($this->encode['name'], $name); $this->encode = []; } } else { $encode = $cookieConfig["encode"]; if ($encode === true) { $name = md5($name); } elseif (is_string($encode)) { if (isHash($encode)) { $name = hash($encode, $name); } } } if (isset($_COOKIE[$name])) { setcookie($name, '', time() - 1, $this->path); $this->path = NULL; return true; } else { return false; } }
public function decode($hash = '') { if (!isHash($hash)) { Error::set('Error', 'hashParameter', 'hash'); return $this; } $this->encode['name'] = $name; return $this; }
public function delete(string $name) : bool { $sessionConfig = SERVICES_SESSION_CONFIG; if (isset($this->encode['name'])) { if (isHash($this->encode['name'])) { $name = hash($this->encode['name'], $name); $this->encode = []; } } else { $encode = $sessionConfig["encode"]; if ($encode === true) { $name = md5($name); } elseif (is_string($encode)) { if (isHash($encode)) { $name = hash($encode, $name); } } } if (isset($_SESSION[$name])) { unset($_SESSION[$name]); return true; } else { return false; } }
/** * setFileVars */ function transfer_setFileVars() { global $cfg, $tmpl, $transfer, $transferLabel, $ch; // set vars for transfer $transferFilesList = array(); switch ($ch->type) { case "torrent": require_once "inc/classes/BDecode.php"; $tFile = $cfg["transfer_file_path"] . $transfer; if ($fd = @fopen($tFile, "rd")) { $alltorrent = @fread($fd, @filesize($tFile)); $btmeta = @BDecode($alltorrent); @fclose($fd); } $transferSizeSum = 0; $isTransmissionTorrent = false; if ($cfg["transmission_rpc_enable"] && isHash($transfer)) { require_once 'inc/functions/functions.rpc.transmission.php'; $theTorrent = getTransmissionTransfer($transfer, array('hashString', 'id', 'name', 'files')); $isTransmissionTorrent = is_array($theTorrent); } if ($isTransmissionTorrent) { foreach ($theTorrent['files'] as $aFile) { $transferSizeSum += $aFile['length']; $fileNameParts = explode("/", $aFile['name']); $name = $fileNameParts[count($fileNameParts) - 1]; $size = $aFile['length']; array_push($transferFilesList, array('name' => $name, 'size' => $size != 0 ? formatBytesTokBMBGBTB($size) : 0)); } } else { if (isset($btmeta) && is_array($btmeta) && isset($btmeta['info'])) { if (array_key_exists('files', $btmeta['info'])) { foreach ($btmeta['info']['files'] as $filenum => $file) { $name = is_array($file['path']) ? implode("/", $file['path']) : $file['path']; $size = isset($file['length']) && is_numeric($file['length']) ? $file['length'] : 0; $transferSizeSum += $size; array_push($transferFilesList, array('name' => $name, 'size' => $size != 0 ? formatBytesTokBMBGBTB($size) : 0)); } } else { $size = $btmeta["info"]["piece length"] * (strlen($btmeta["info"]["pieces"]) / 20); $transferSizeSum += $size; array_push($transferFilesList, array('name' => $btmeta["info"]["name"], 'size' => formatBytesTokBMBGBTB($size))); } } } if (empty($transferFilesList)) { $tmpl->setvar('transferFilesString', "Empty"); $tmpl->setvar('transferFileCount', count($btmeta['info']['files'])); } else { $tmpl->setloop('transferFilesList', $transferFilesList); $tmpl->setvar('transferFileCount', count($transferFilesList)); } $tmpl->setvar('transferSizeSum', $transferSizeSum > 0 ? formatBytesTokBMBGBTB($transferSizeSum) : 0); return; case "wget": $ch = ClientHandler::getInstance('wget'); $ch->setVarsFromFile($transfer); $transferSizeSum = 0; if (!empty($ch->url)) { require_once "inc/classes/SimpleHTTP.php"; $size = SimpleHTTP::getRemoteSize($ch->url); $transferSizeSum += $size; array_push($transferFilesList, array('name' => $ch->url, 'size' => formatBytesTokBMBGBTB($size))); } if (empty($transferFilesList)) { $tmpl->setvar('transferFilesString', "Empty"); $tmpl->setvar('transferFileCount', 0); } else { $tmpl->setloop('transferFilesList', $transferFilesList); $tmpl->setvar('transferFileCount', count($transferFilesList)); } $tmpl->setvar('transferSizeSum', $transferSizeSum > 0 ? formatBytesTokBMBGBTB($transferSizeSum) : 0); return; case "nzb": require_once "inc/classes/NZBFile.php"; $nzb = new NZBFile($transfer); $transferSizeSum = 0; if (empty($nzb->files)) { $tmpl->setvar('transferFilesString', "Empty"); $tmpl->setvar('transferFileCount', 0); } else { foreach ($nzb->files as $file) { $transferSizeSum += $file['size']; array_push($transferFilesList, array('name' => $file['name'], 'size' => formatBytesTokBMBGBTB($file['size']))); } $tmpl->setloop('transferFilesList', $transferFilesList); $tmpl->setvar('transferFileCount', $nzb->filecount); } $tmpl->setvar('transferSizeSum', $transferSizeSum > 0 ? formatBytesTokBMBGBTB($transferSizeSum) : 0); return; } }
public function data($data = '', $type = 'md5') { if (!is_scalar($data)) { return Error::set('Error', 'scalarParameter', '1.(data)'); } if (!isHash($type)) { return Error::set('Error', 'hashParameter', '2.(type)'); } return hash($type, $data); }
public function delete($name = '') { if (!is_scalar($name) || empty($name)) { return Error::set('Error', 'valueParameter', 'name'); } $sessionConfig = $this->config; if (isset($this->encode['name'])) { if (isHash($this->encode['name'])) { $name = hash($this->encode['name'], $name); $this->encode = array(); } } else { if ($sessionConfig["encode"] === true) { $name = md5($name); } } if (isset($_SESSION[$name])) { unset($_SESSION[$name]); } else { return false; } }
// prevent direct invocation if (!isset($cfg['user']) || isset($_REQUEST['cfg'])) { @ob_end_clean(); @header("location: ../../index.php"); exit; } /******************************************************************************/ // transfer functions 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;
/** * 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); } 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), image_getColors(), array('Seeds : ' . $peerData['seedsLabel'], 'Peers : ' . $peerData['peersLabel']), 58, 130, 2, 14); }
/** * gets scrape-info of a torrent as string * * @param $transfer name of the torrent * @return string with torrent-scrape-info */ function getTorrentScrapeInfo($transfer) { global $cfg; $hasClient = false; // transmissioncli if (!$cfg["transmission_rpc_enable"]) { $hasClient = true; $retVal = ""; $retVal = @shell_exec("HOME=" . tfb_shellencode($cfg["path"]) . "; export HOME; " . $cfg["btclient_transmission_bin"] . " -s " . tfb_shellencode($cfg["transfer_file_path"] . $transfer)); if (isset($retVal) && $retVal != "" && !preg_match('/.*failed.*/i', $retVal)) { return trim($retVal); } } else { require_once 'inc/functions/functions.transfer.php'; require_once 'inc/functions/functions.rpc.transmission.php'; if (isHash($transfer)) { $hash = $transfer; } else { $hash = getTransferHash($transfer); } $a = getTransmissionTransfer($hash, array("trackerStats")); if (!empty($a['trackerStats'])) { $stats = $a['trackerStats'][0]; return $stats['seederCount'] . ' seeder(s), ' . $stats['leecherCount'] . ' leecher(s).' . "\n"; } } // ttools.pl if (is_executable($cfg["perlCmd"])) { $hasClient = true; $retVal = ""; $retVal = @shell_exec($cfg["perlCmd"] . ' -I ' . tfb_shellencode($cfg["docroot"] . 'bin/ttools') . ' ' . tfb_shellencode($cfg["docroot"] . 'bin/ttools/ttools.pl') . ' -s ' . tfb_shellencode($cfg["transfer_file_path"] . $transfer)); if (isset($retVal) && $retVal != "" && !preg_match('/.*failed.*/i', $retVal)) { return trim($retVal); } } // failed return $hasClient ? "Scrape failed" : "No Scrape-Client"; }
/** * Pulls out the options hash from $array if any. * * @internal DO NOT remove the reference on $array. * @param array &$array An array * @return array A valid options array */ public static function extractAndValidateOptions(array &$array) { $options = []; if ($array) { $last =& $array[\count($array) - 1]; try { if (self::isOptionsHash($last)) { \array_pop($array); $options = $last; } } catch (Activerecord $e) { if (!isHash($last)) { throw $e; } $options = ['conditions' => $last]; } } return $options; }