public static function sendTorrent($fname, $isStart, $directory = null) { $hash = false; $torrent = is_object($fname) ? $fname : new \model\simple\Torrent($fname); if (!$torrent->errors()) { $raw_value = base64_encode($torrent->__toString()); $filename = is_object($fname) ? $torrent->getFileName() : $fname; if (strlen($raw_value) < self::RTORRENT_PACKET_LIMIT || is_null($filename)) { $cmd = new rXMLRPCCommand(\config\Conf::$userscgi, $isStart ? 'load.raw_start' : 'load.raw'); $cmd->addParameter(""); $cmd->addParameter($raw_value, "base64"); if (!is_null($filename) && !true) { @unlink($filename); } } else { $cmd = new rXMLRPCCommand(\config\Conf::$userscgi, $isStart ? 'load.start' : 'load.normal'); $cmd->addParameter(""); $cmd->addParameter($filename); } if (!is_null($filename) && rTorrentSettings::get(\config\Conf::$userscgi)->iVersion >= 0x805) { $cmd->addParameter(rTorrentSettings::getCmd(\config\Conf::$userscgi, "d.custom.set") . "=x-filename," . rawurlencode(basename($filename))); } $req = new rXMLRPCRequest(\config\Conf::$userscgi); $req->addCommand($cmd); if (!is_null($directory)) { $cmd->addParameter(rTorrentSettings::getCmd(\config\Conf::$userscgi, "d.directory.set=") . "\"" . $directory . "\""); } if ($req->run() && !$req->fault) { $hash = $req->val; } } return $hash; }
public function correct($deltaUp, $deltaDown) { $tm = getdate(); $ndx = $tm["hours"]; $was = getdate($this->hourHitTimes[$ndx]); if ($tm[0] - $this->hourHitTimes[$ndx] > 3600 + 3600 || $ndx != $was["hours"]) { $this->hourHitTimes[$ndx] = $tm[0]; $this->hourUp[$ndx] = 0; $this->hourDown[$ndx] = 0; } $this->hourUp[$ndx] += $deltaUp; $this->hourDown[$ndx] += $deltaDown; $ndx = $tm["mday"] - 1; $was = getdate($this->monthHitTimes[$ndx]); if ($tm[0] - $this->monthHitTimes[$ndx] > 3600 * 24 + 3600 || $ndx != $was["mday"] - 1) { $this->monthHitTimes[$ndx] = $tm[0]; $this->monthUp[$ndx] = 0; $this->monthDown[$ndx] = 0; } $this->monthUp[$ndx] += $deltaUp; $this->monthDown[$ndx] += $deltaDown; $ndx = $tm["mon"] - 1; $was = getdate($this->yearHitTimes[$ndx]); if ($tm[0] - $this->yearHitTimes[$ndx] > 3600 * 24 * 31 + 3600 || $ndx != $was["mon"] - 1) { $this->yearHitTimes[$ndx] = $tm[0]; $this->yearUp[$ndx] = 0; $this->yearDown[$ndx] = 0; } $this->yearUp[$ndx] += $deltaUp; $this->yearDown[$ndx] += $deltaDown; rTorrentSettings::get()->pushEvent("TraficUpdated", array("stat" => &$this)); }
public function __construct($user, $cmd, $args = null) { //\trigger_error("ddd"); //throw new \Exception("ddd"); $this->user = $user; $this->command = rTorrentSettings::getCmd($this->user, $cmd); $this->params = array(); if ($args !== null) { if (is_array($args)) { foreach ($args as $prm) { $this->addParameter($prm); } } else { $this->addParameter($args); } } }
public function init() { $req = new rXMLRPCRequest(); for ($i = 0; $i < MAX_THROTTLE; $i++) { if ($this->isCorrect($i)) { $up = $this->thr[$i]["up"]; $down = $this->thr[$i]["down"]; } else { $up = 0; $down = 0; } $req->addCommand(new rXMLRPCCommand("throttle_up", array("thr_" . $i, $up . ""))); $req->addCommand(new rXMLRPCCommand("throttle_down", array("thr_" . $i, $down . ""))); } if ($this->isCorrect($this->default - 1)) { $req->addCommand(rTorrentSettings::get()->getOnInsertCommand(array('_throttle' . getUser(), getCmd('branch') . '=$' . getCmd('not') . '=$' . getCmd("d.get_throttle_name") . '=,' . getCmd('d.set_throttle_name') . '=thr_' . ($this->default - 1)))); } else { $req->addCommand(rTorrentSettings::get()->getOnInsertCommand(array('_throttle' . getUser(), getCmd('cat=')))); } return $req->run() && !$req->fault; }
public static function load($mngr = null) { $cache = new rCache(); $ar = new rURLRewriteRulesList(); $cache->get($ar); if (rTorrentSettings::get()->isPluginRegistered("rss")) { $changed = false; if (is_null($mngr)) { require_once dirname(__FILE__) . '/../rss/rss.php'; $mngr = new rRSSManager(); } foreach ($ar->lst as $rule) { if (!empty($rule->rssHash) && !$mngr->rssList->isExist($rule->rssHash) && !$mngr->groups->get($rule->rssHash)) { $rule->rssHash = ''; $changed = true; } } if ($changed) { $ar->store(); } } return $ar; }
Debug("enabled : " . $at->enable_watch); Debug("autostart : " . $at->watch_start); if ($at->enable_watch) { $auto_start = $at->watch_start; $path_to_watch = rtAddTailSlash(trim($at->path_to_watch)); Debug("path_to_watch : " . $path_to_watch); if ($path_to_watch == '' || $path_to_watch == '/') { $is_ok = false; } } else { $is_ok = false; } } // Ask info from rTorrent if ($is_ok) { $directory = rtAddTailSlash(rTorrentSettings::get()->directory); Debug("get_directory : " . $directory); if ($directory == '' || $directory == '/') { $is_ok = false; } } // Scan for *.torrent files at $path_to_watch if ($is_ok) { $files = rtScanFiles($path_to_watch, "/.*\\.torrent\$/i"); // ignore case foreach ($files as $file) { $torrent_file = $path_to_watch . $file; // don't use realpath() here !!! $dest_path = rtAddTailSlash(dirname($directory . $file)); Debug("torrent file : " . $torrent_file); Debug("save data to : " . $dest_path);
public static function run($hash, $state = null, $time = null, $successful_time = null) { if (is_null($state)) { self::getState($hash, $state, $time, $successful_time); } if ($state == self::STE_INPROGRESS && time() - $time > self::MAX_LOCK_TIME) { $state = 0; } if ($state !== self::STE_INPROGRESS) { $state = self::STE_INPROGRESS; if (!self::setState($hash, $state)) { return false; } $fname = rTorrentSettings::get()->session . $hash . ".torrent"; if (is_readable($fname)) { $state = self::run_ex($hash, $fname); } if ($state == self::STE_INPROGRESS) { $state = self::STE_ERROR; } if (!is_null($state)) { self::setState($hash, $state); } } return $state != self::STE_CANT_REACH_TRACKER; }
} break; case "add_peer": $req = new rXMLRPCRequest(new rXMLRPCCommand("add_peer", array($hash[0], $vs[0]))); if ($req->success()) { $result = $req->val; } break; case "getchunks": $req = new rXMLRPCRequest(array(new rXMLRPCCommand("d.get_bitfield", $hash[0]), new rXMLRPCCommand("d.get_chunk_size", $hash[0]), new rXMLRPCCommand("d.get_size_chunks", $hash[0]))); if (rTorrentSettings::get()->apiVersion >= 4) { $req->addCommand(new rXMLRPCCommand("d.chunks_seen", $hash[0])); } if ($req->success()) { $result = array("chunks" => $req->val[0], "size" => $req->val[1], "tsize" => $req->val[2]); if (rTorrentSettings::get()->apiVersion >= 4) { $result["seen"] = $req->val[3]; } } break; default: if (isset($HTTP_RAW_POST_DATA)) { $result = rXMLRPCRequest::send($HTTP_RAW_POST_DATA); if (!empty($result)) { $pos = strpos($result, "\r\n\r\n"); if ($pos !== false) { $result = substr($result, $pos + 4); } cachedEcho($result, "text/xml"); } }
<?php $req = new rXMLRPCRequest(rTorrentSettings::get()->getRemoveScheduleCommand('rutracker_check')); $req->run();
if (isset($request['comment'])) { $comment = trim($request['comment']); if (strlen($comment)) { $torrent->comment($comment); } } if ($request['private']) { $torrent->is_private(true); } $fname = rTask::formatPath($taskNo) . '/result.torrent'; $torrent->save($fname); if ($request['start_seeding']) { $fname = getUniqueUploadedFilename($torrent->info['name'] . '.torrent'); $path_edit = trim($request['path_edit']); if (is_dir($path_edit)) { $path_edit = addslash($path_edit); } if (rTorrentSettings::get()->correctDirectory($path_edit)) { $path_edit = dirname($path_edit); if ($resumed = rTorrent::fastResume($torrent, $path_edit)) { $torrent = $resumed; } $torrent->save($fname); rTorrent::sendTorrent($torrent, true, true, $path_edit, null, true, isLocalMode()); @chmod($fname, $profileMask & 0666); } } exit(0); } exit(1); }
require_once "./util_rt.php"; require_once "./autotools.php"; $base_path = $argv[1]; $base_name = $argv[2]; $is_multy = $argv[3]; $base_path = rtRemoveTailSlash($base_path); $base_path = rtRemoveLastToken($base_path, '/'); // filename or dirname $base_path = rtAddTailSlash($base_path); $dest_path = $base_path; $at = rAutoTools::load(); if ($at->enable_move) { $path_to_finished = trim($at->path_to_finished); if ($path_to_finished != '') { $path_to_finished = rtAddTailSlash($path_to_finished); $directory = rTorrentSettings::get()->directory; if (!empty($directory)) { $directory = rtAddTailSlash($directory); $rel_path = rtGetRelativePath($directory, $base_path); //------------------------------------------------------------------------------ // !! this is a feature !! // ($rel_path == '') means, that $base_path is NOT a SUBDIR of $directory at all // so, we have to skip all automove actions // for example, if we don't want torrent to be automoved - we save it out of $directory subtree //------------------------------------------------------------------------------ if ($rel_path != '') { if ($rel_path == './') { $rel_path = ''; } $dest_path = rtAddTailSlash($path_to_finished . $rel_path); }
public function setHandlers() { global $rootPath; if ($this->enabled) { $cmd = rTorrentSettings::get()->getOnFinishedCommand(array('unpack' . getUser(), getCmd('execute') . '={' . getPHP() . ',' . $rootPath . '/plugins/unpack/update.php,$' . getCmd('d.get_directory') . '=,$' . getCmd('d.get_base_filename') . '=,$' . getCmd('d.is_multi_file') . '=,$' . getCmd('d.get_custom1') . '=,$' . getCmd('d.get_name') . '=,' . getCmd('d.get_hash') . '=,' . getUser() . '}')); } else { $cmd = rTorrentSettings::get()->getOnFinishedCommand(array('unpack' . getUser(), getCmd('cat='))); } $req = new rXMLRPCRequest($cmd); return $req->success(); }
protected function makeCall() { rTorrentSettings::get()->patchDeprecatedRequest($this->commands); $this->fault = false; $this->content = ""; $cnt = count($this->commands); if ($cnt > 0) { $this->content = '<?xml version="1.0" encoding="UTF-8"?><methodCall><methodName>'; if ($cnt == 1) { $cmd = $this->commands[0]; $this->content .= "{$cmd->command}</methodName><params>\r\n"; foreach ($cmd->params as &$prm) { $this->content .= "<param><value><{$prm->type}>{$prm->value}</{$prm->type}></value></param>\r\n"; } } else { $this->content .= "system.multicall</methodName><params><param><value><array><data>"; foreach ($this->commands as &$cmd) { $this->content .= "\r\n<value><struct><member><name>methodName</name><value><string>" . "{$cmd->command}</string></value></member><member><name>params</name><value><array><data>"; foreach ($cmd->params as &$prm) { $this->content .= "\r\n<value><{$prm->type}>{$prm->value}</{$prm->type}></value>"; } $this->content .= "\r\n</data></array></value></member></struct></value>"; } $this->content .= "\r\n</data></array></value></param>"; } $this->content .= "</params></methodCall>"; } return $cnt > 0; }
public function setHandlers() { global $rootPath; $throttleRulesExist = false; $ratioRulesExist = false; foreach ($this->lst as $item) { if ($item->ratio != '') { $ratioRulesExist = true; } if ($item->channel != '') { $throttleRulesExist = true; } } if ($ratioRulesExist) { eval(getPluginConf('ratio')); $insCmd = ''; for ($i = 0; $i < MAX_RATIO; $i++) { $insCmd .= getCmd('d.views.has=') . 'rat_' . $i . ',,'; } $ratCmd = getCmd('d.set_custom') . '=x-extratio1,"$' . getCmd('execute_capture') . '={' . getPHP() . ',' . $rootPath . '/plugins/extratio/update.php,\\"$' . getCmd('t.multicall') . '=$' . getCmd('d.get_hash') . '=,' . getCmd('t.get_url') . '=,' . getCmd('cat') . '=#\\",$' . getCmd('d.get_custom1') . '=,ratio,' . getUser() . '}" ; ' . getCmd('branch') . '=$' . getCmd('not') . '=$' . getCmd('d.get_custom') . '=x-extratio1,,' . $insCmd . getCmd('view.set_visible') . '=$' . getCmd('d.get_custom') . '=x-extratio1'; } else { $ratCmd = getCmd('cat='); } if ($throttleRulesExist) { $thrCmd = getCmd('d.set_custom') . '=x-extratio2,"$' . getCmd('execute_capture') . '={' . getPHP() . ',' . $rootPath . '/plugins/extratio/update.php,\\"$' . getCmd('t.multicall') . '=$' . getCmd('d.get_hash') . '=,' . getCmd('t.get_url') . '=,' . getCmd('cat') . '=#\\",$' . getCmd('d.get_custom1') . '=,channel,' . getUser() . '}" ; ' . getCmd('branch') . '=$' . getCmd('not') . '=$' . getCmd('d.get_custom') . '=x-extratio2,,' . getCmd('d.set_throttle_name') . '=$' . getCmd('d.get_custom') . '=x-extratio2'; } else { $thrCmd = getCmd('cat='); } $req = new rXMLRPCRequest(array(rTorrentSettings::get()->getOnInsertCommand(array('_exratio1' . getUser(), $ratCmd)), rTorrentSettings::get()->getOnInsertCommand(array('_exratio2' . getUser(), $thrCmd)))); return $req->success(); }
public static function get($create = false) { if (is_null(self::$theSettings)) { self::$theSettings = new rTorrentSettings(); if ($create) { self::$theSettings->obtain(); } else { $cache = new rCache(); $cache->get(self::$theSettings); } } return self::$theSettings; }
foreach ($settingsFlags as $flagName => $flagVal) { if (array_key_exists($flagName, $permissions) && $permissions[$flagName]) { $perms |= $flagVal; } } $jResult .= "theWebUI.showFlags = " . $perms . ";\n"; $jResult .= "theURLs.XMLRPCMountPoint = '" . $XMLRPCMountPoint . "';\n"; $jResult .= "theWebUI.systemInfo = {};\ntheWebUI.systemInfo.php = { canHandleBigFiles : " . (PHP_INT_SIZE <= 4 ? "false" : "true") . " };\n"; if ($handle = opendir('../plugins')) { ignore_user_abort(true); set_time_limit(0); @chmod('/tmp', 0777); if (!function_exists('preg_match_all')) { $jResult .= "log(theUILang.PCRENotFound);"; } else { $theSettings = new rTorrentSettings(); $theSettings->obtain(); if (!$theSettings->linkExist) { $jResult .= "log(theUILang.badLinkTorTorrent);"; $jResult .= "theWebUI.systemInfo.rTorrent = { started: false, version : '?', libVersion : '?' };\n"; } else { $jResult .= "theWebUI.systemInfo.rTorrent = { started: true, version : '" . $theSettings->version . "', libVersion : '" . $theSettings->libVersion . "' };\n"; if ($do_diagnostic) { $up = getUploadsPath(); $st = getSettingsPath(); @chmod($up, 0777); @chmod($st, 0777); @chmod('./test.sh', 0755); if (!isUserHavePermission($theSettings->myuid, $theSettings->mygid, $up, 0x7)) { $jResult .= "log(theUILang.badUploadsPath+' (" . $up . ")');"; }
} } } } } } } } if (count($trackers) > 0) { $announce_list[] = $trackers; } if ($setComment || $setTrackers || $setPrivate) { foreach ($hashes as $hash) { $req = new rXMLRPCRequest(array(new rXMLRPCCommand("get_session"), new rXMLRPCCommand("d.is_open", $hash), new rXMLRPCCommand("d.is_active", $hash), new rXMLRPCCommand("d.get_state", $hash), new rXMLRPCCommand("d.get_tied_to_file", $hash), new rXMLRPCCommand("d.get_custom1", $hash), new rXMLRPCCommand("d.get_directory_base", $hash), new rXMLRPCCommand("d.get_connection_seed", $hash), new rXMLRPCCommand("d.get_complete", $hash))); $throttle = null; if (rTorrentSettings::get()->isPluginRegistered("throttle")) { $req->addCommand(new rXMLRPCCommand("d.get_throttle_name", $hash)); } if ($req->run() && !$req->fault) { $isStart = $req->val[1] != 0 && $req->val[2] != 0 && $req->val[3] != 0; $fname = $req->val[0] . $hash . ".torrent"; if (empty($req->val[0]) || !is_readable($fname)) { if (strlen($req->val[4]) && is_readable($req->val[4])) { $fname = $req->val[4]; } else { $fname = null; } } if ($fname) { $torrent = new Torrent($fname); if (!$torrent->errors()) {
public function setHandlers() { global $rootPath; if ($this->log["addition"] || $this->log["pushbullet_enabled"] && $this->log["pushbullet_addition"]) { $addCmd = getCmd('execute') . '={' . getPHP() . ',' . $rootPath . '/plugins/history/update.php' . ',1,$' . getCmd('d.get_name') . '=,$' . getCmd('d.get_size_bytes') . '=,$' . getCmd('d.get_bytes_done') . '=,$' . getCmd('d.get_up_total') . '=,$' . getCmd('d.get_ratio') . '=,$' . getCmd('d.get_creation_date') . '=,$' . getCmd('d.get_custom') . '=addtime,$' . getCmd('d.get_custom') . '=seedingtime' . ',"$' . getCmd('t.multicall') . '=$' . getCmd('d.get_hash') . '=,' . getCmd('t.get_url') . '=,' . getCmd('cat') . '=#",$' . getCmd('d.get_custom1') . "=,\$" . getCmd('d.get_custom') . "=x-pushbullet," . getUser() . '}'; } else { $addCmd = getCmd('cat='); } if ($this->log["finish"] || $this->log["pushbullet_enabled"] && $this->log["pushbullet_finish"]) { $finCmd = getCmd('execute') . '={' . getPHP() . ',' . $rootPath . '/plugins/history/update.php' . ',2,$' . getCmd('d.get_name') . '=,$' . getCmd('d.get_size_bytes') . '=,$' . getCmd('d.get_bytes_done') . '=,$' . getCmd('d.get_up_total') . '=,$' . getCmd('d.get_ratio') . '=,$' . getCmd('d.get_creation_date') . '=,$' . getCmd('d.get_custom') . '=addtime,$' . getCmd('d.get_custom') . '=seedingtime' . ',"$' . getCmd('t.multicall') . '=$' . getCmd('d.get_hash') . '=,' . getCmd('t.get_url') . '=,' . getCmd('cat') . '=#",$' . getCmd('d.get_custom1') . "=,\$" . getCmd('d.get_custom') . "=x-pushbullet," . getUser() . '}'; } else { $finCmd = getCmd('cat='); } if ($this->log["deletion"] || $this->log["pushbullet_enabled"] && $this->log["pushbullet_deletion"]) { $delCmd = getCmd('execute') . '={' . getPHP() . ',' . $rootPath . '/plugins/history/update.php' . ',3,$' . getCmd('d.get_name') . '=,$' . getCmd('d.get_size_bytes') . '=,$' . getCmd('d.get_bytes_done') . '=,$' . getCmd('d.get_up_total') . '=,$' . getCmd('d.get_ratio') . '=,$' . getCmd('d.get_creation_date') . '=,$' . getCmd('d.get_custom') . '=addtime,$' . getCmd('d.get_custom') . '=seedingtime' . ',"$' . getCmd('t.multicall') . '=$' . getCmd('d.get_hash') . '=,' . getCmd('t.get_url') . '=,' . getCmd('cat') . '=#",$' . getCmd('d.get_custom1') . "=,\$" . getCmd('d.get_custom') . "=x-pushbullet," . getUser() . '}'; } else { $delCmd = getCmd('cat='); } $req = new rXMLRPCRequest(array(rTorrentSettings::get()->getOnInsertCommand(array('thistory' . getUser(), $addCmd)), rTorrentSettings::get()->getOnFinishedCommand(array('thistory' . getUser(), $finCmd)), rTorrentSettings::get()->getOnEraseCommand(array('thistory' . getUser(), $delCmd)))); return $req->success(); }
public function setHandlers() { $theSettings = rTorrentSettings::get(); $pathToXmpp = dirname(__FILE__); $req = new rXMLRPCRequest(); if ($this->message !== '' && isset($this->jabberServer) && isset($this->jabberLogin) && isset($this->jabberPasswd) && isset($this->jabberFor)) { $cmd = $theSettings->getOnFinishedCommand(array('xmpp' . getUser(), getCmd('execute.nothrow.bg') . '={' . getPHP() . ',' . $pathToXmpp . '/notify.php,"$' . getCmd('d.name') . '=","' . getUser() . '"}')); } else { $cmd = $theSettings->getOnFinishedCommand(array('xmpp' . getUser(), getCmd('cat='))); } $req->addCommand($cmd); return $req->success(); }
if ($handle = opendir('../plugins')) { ignore_user_abort(true); set_time_limit(0); $tmp = getTempDirectory(); if ($tmp != '/tmp/') { makeDirectory($tmp); } if (!@file_exists($tempDirectory . '/.') || !is_readable($tempDirectory) || !is_writable($tempDirectory)) { $jResult .= "noty(theUILang.badTempPath+' (" . $tempDirectory . ")','error');"; } if (!function_exists('preg_match_all')) { $jResult .= "noty(theUILang.PCRENotFound,'error');"; $jResult .= "theWebUI.systemInfo.rTorrent = { started: false, iVersion : 0, version : '?', libVersion : '?' };\n"; } else { $remoteRequests = array(); $theSettings = rTorrentSettings::get(true); if (!$theSettings->linkExist) { $jResult .= "noty(theUILang.badLinkTorTorrent,'error');"; $jResult .= "theWebUI.systemInfo.rTorrent = { started: false, iVersion : 0, version : '?', libVersion : '?', apiVersion : 0 };\n"; } else { if ($theSettings->idNotFound) { $jResult .= "noty(theUILang.idNotFound,'error');"; } $jResult .= "theWebUI.systemInfo.rTorrent = { started: true, iVersion : " . $theSettings->iVersion . ", version : '" . $theSettings->version . "', libVersion : '" . $theSettings->libVersion . "', apiVersion : " . $theSettings->apiVersion . " };\n"; if ($do_diagnostic) { $up = getUploadsPath(); $st = getSettingsPath(); @chmod($up, $profileMask); @chmod($st, $profileMask); @chmod('./test.sh', $profileMask & 0755); if (PHP_USE_GZIP && findEXE('gzip') === false) {
<?php require_once dirname(__FILE__) . "/../../php/settings.php"; require_once dirname(__FILE__) . "/../../php/Snoopy.class.inc"; $ret = 0; $port = rTorrentSettings::get()->port; $client = new Snoopy(); $client->read_timeout = 15; $client->use_gzip = HTTP_USE_GZIP; @$client->fetch("http://www.canyouseeme.org", "POST", "application/x-www-form-urlencoded", "port=" . $port . "&submit=Check+Your+Port"); if ($client->status == 200) { if (strpos($client->results, ">Error:<") !== false) { $ret = 1; } else { if (strpos($client->results, ">Success:<") !== false) { $ret = 2; } } } cachedEcho('{ "port": ' . $port . ', "status": ' . $ret . ' }', "application/json");
<?php require_once '../../php/util.php'; require_once '../../php/settings.php'; $theSettings = rTorrentSettings::get(); $dh = false; $curFile = null; $btn_id = "'" . $_REQUEST['btn'] . "'"; $edit_id = "'" . $_REQUEST['edit'] . "'"; $frame_id = "'" . $_REQUEST['frame'] . "'"; if (isset($_REQUEST['dir'])) { $dir = rawurldecode($_REQUEST['dir']); if (LFS::is_file($dir) && ($theSettings->uid < 0 || isUserHavePermission($theSettings->uid, $theSettings->gid, $dir, 0x4))) { $curFile = basename($dir); $dir = dirname($dir); } if (is_dir($dir)) { $dh = @opendir($dir); $dir = addslash($dir); if ($dh && (strpos($dir, $topDirectory) !== 0 || $theSettings->uid >= 0 && !isUserHavePermission($theSettings->uid, $theSettings->gid, $dir, 0x5))) { closedir($dh); $dh = false; } } } if (!$dh) { $curFile = null; $dir = isLocalMode() ? $theSettings->directory : $topDirectory; if (strpos(addslash($dir), $topDirectory) !== 0) { $dir = $topDirectory; }
<?php $diskUpdateInterval = 10; // in seconds $notifySpaceLimit = 512; // in Mb // If we run locally && we the download directory seems to exists if (isLocalMode() && rTorrentSettings::get()->linkExist && file_exists(rTorrentSettings::get()->directory)) { $partitionDirectory = rTorrentSettings::get()->directory; // Then we can show the disk space of the download directory } else { $partitionDirectory =& $topDirectory; // Else, we show $topDirectory by default as fallback }
<?php require_once "xmlrpc.php"; eval(getPluginConf($plugin["name"])); $session = rTorrentSettings::get()->session; if (!strlen($session) || !@file_exists(addslash(rTorrentSettings::get()->session) . '.')) { $jResult .= "plugin.disable(); noty('" . $plugin["name"] . ": '+theUILang.webBadSessionError+' (" . $session . ").','error');"; } else { if ($updateInterval) { $req = new rXMLRPCRequest($theSettings->getScheduleCommand('rutracker_check', $updateInterval, getCmd('execute') . '={sh,-c,' . escapeshellarg(getPHP()) . ' ' . escapeshellarg(dirname(__FILE__) . '/update.php') . ' ' . escapeshellarg(getUser()) . ' &}')); if ($req->success()) { $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); } else { $jResult .= "plugin.disable(); noty('rutracker_check: '+theUILang.pluginCantStart, 'error');"; } } else { require 'done.php'; $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); } }
<?php require_once '../../php/util.php'; require_once '../../php/settings.php'; $dh = false; $theSettings = rTorrentSettings::get(); $btn_id = "'" . $_REQUEST['btn'] . "'"; $edit_id = "'" . $_REQUEST['edit'] . "'"; $frame_id = "'" . $_REQUEST['frame'] . "'"; if (isset($_REQUEST['dir']) && strlen($_REQUEST['dir'])) { $dir = rawurldecode($_REQUEST['dir']); rTorrentSettings::get()->correctDirectory($dir); $dh = @opendir($dir); $dir = addslash($dir); if ($dh && (strpos($dir, $topDirectory) !== 0 || $theSettings->uid >= 0 && !isUserHavePermission($theSettings->uid, $theSettings->gid, $dir, 0x7))) { closedir($dh); $dh = false; } } if (!$dh) { $dir = isLocalMode() ? $theSettings->directory : $topDirectory; if (strpos(addslash($dir), $topDirectory) !== 0) { $dir = $topDirectory; } $dh = @opendir($dir); } $files = array(); if ($dh) { $dir = addslash($dir); while (false !== ($file = readdir($dh))) { $path = fullpath($dir . $file);
public static function loadHistory($withRSS = false) { $cache = new rCache(); $history = new rSearchHistory(); $cache->get($history); if ($withRSS) { if (rTorrentSettings::get()->isPluginRegistered("rss")) { global $rootPath; require_once $rootPath . '/plugins/rss/rss.php'; $cache = new rCache('/rss/cache'); $rssHistory = new rRSSHistory(); if ($cache->get($rssHistory)) { foreach ($rssHistory->lst as $url => $info) { if (strlen($info["hash"]) == 40) { $history->add($url, $info["hash"]); } } } } } return $history; }
<?php $req = new rXMLRPCRequest(rTorrentSettings::get()->getRemoveScheduleCommand("rss")); $req->run();
function getCmd($cmd) { return rTorrentSettings::get()->getCommand($cmd); }
public static function run($cmd, $flags = 0) { $ret = -1; $params = " >/dev/null 2>&1"; if (!($flags & self::FLG_WAIT)) { $params .= " &"; } if ($flags & self::FLG_RUN_AS_WEB) { if (self::FLG_RUN_AS_CMD) { $cmd = '-c "' . $cmd . '"'; } exec('sh ' . $cmd . $params, $output, $ret); } else { $req = new rXMLRPCRequest(rTorrentSettings::get()->iVersion >= 0x900 && !($flags & self::FLG_WAIT) ? new rXMLRPCCommand("execute.nothrow.bg", array("", "sh", $cmd)) : new rXMLRPCCommand("execute_nothrow", array("sh", "-c", $cmd . $params))); if ($req->success() && count($req->val)) { $ret = intval($req->val[0]); } } return $ret; }
<?php require_once "xmlrpc.php"; require_once 'settings.php'; $theSettings = rTorrentSettings::load(); $jResult = ""; if (!isset($HTTP_RAW_POST_DATA)) { $HTTP_RAW_POST_DATA = file_get_contents("php://input"); } if (isset($HTTP_RAW_POST_DATA)) { $vars = split('&', $HTTP_RAW_POST_DATA); foreach ($vars as $var) { $parts = split("=", $var); if ($parts[0] == "plg") { $php = "../plugins/" . $parts[1] . "/done.php"; if (is_file($php) && is_readable($php)) { require_once $php; } $jResult .= "thePlugins.get('" . $parts[1] . "').remove();"; } } } echo $jResult;