function checkCmd($httpReq, $cmd) { $cmd = getCmd($httpReq); if ($cmd !== $cmd) { WrongRequestException::throwException(8030, "Only the command >{$cmd}< is accepted", 'got: ' . $reqdecoded['cmd']); } }
public static function createTorrent($torrent, $hash) { global $saveUploadedTorrents; $torrent = new Torrent($torrent); if ($torrent->errors()) { return self::STE_DELETED; } if ($torrent->hash_info() == $hash) { return self::STE_UPTODATE; } $req = new rXMLRPCRequest(array(new rXMLRPCCommand("d.get_directory_base", $hash), new rXMLRPCCommand("d.get_custom1", $hash), new rXMLRPCCommand("d.get_throttle_name", $hash), new rXMLRPCCommand("d.get_connection_seed", $hash), new rXMLRPCCommand("d.is_open", $hash), new rXMLRPCCommand("d.is_active", $hash), new rXMLRPCCommand("d.get_state", $hash), new rXMLRPCCommand("d.stop", $hash), new rXMLRPCCommand("d.close", $hash))); if ($req->success()) { $addition = array(getCmd("d.set_connection_seed=") . $req->val[3], getCmd("d.set_custom") . "=chk-state," . self::STE_UPDATED, getCmd("d.set_custom") . "=chk-time," . time(), getCmd("d.set_custom") . "=chk-stime," . time()); $isStart = $req->val[4] != 0 && $req->val[5] != 0 && $req->val[6] != 0; if (!empty($req->val[2])) { $addition[] = getCmd("d.set_throttle_name=") . $req->val[2]; } if (preg_match('/rat_(\\d+)/', $req->val[3], $ratio)) { $addition[] = getCmd("view.set_visible=") . "rat_" . $ratio; } $label = rawurldecode($req->val[1]); if (rTorrent::sendTorrent($torrent, $isStart, false, $req->val[0], $label, $saveUploadedTorrents, false, true, $addition)) { $req = new rXMLRPCRequest(new rXMLRPCCommand("d.erase", $hash)); if ($req->success()) { return null; } } } return self::STE_ERROR; }
public function correct() { $toCorrect = array(); $req = new rXMLRPCRequest(new rXMLRPCCommand("d.multicall", array("", getCmd("d.get_hash="), getCmd("d.get_throttle_name="), getCmd('cat') . '=$' . getCmd("get_throttle_up_max") . '=$' . getCmd("d.get_throttle_name="), getCmd('cat') . '=$' . getCmd("get_throttle_down_max") . '=$' . getCmd("d.get_throttle_name=")))); if ($req->run() && !$req->fault) { for ($i = 0; $i < count($req->val); $i += 4) { if (substr($req->val[$i + 1], 0, 4) == "thr_") { $no = intval(substr($req->val[$i + 1], 4)); if ($req->val[$i + 2] === "-1" && $req->val[$i + 3] === "-1" && $this->isThrottled($no)) { $toCorrect[$req->val[$i]] = $req->val[$i + 1]; } } } if ($this->init()) { $req = new rXMLRPCRequest(); foreach ($toCorrect as $hash => $name) { $req->addCommand(new rXMLRPCCommand("branch", array($hash, getCmd("d.is_active="), getCmd('cat') . '=$' . getCmd("d.stop") . '=,$' . getCmd("d.set_throttle_name=") . $name . ',$' . getCmd('d.start='), getCmd('d.set_throttle_name=') . $name))); } if ($req->getCommandsCount()) { return $req->run() && !$req->fault; } return true; } } return false; }
public function rXMLRPCCommand($cmd, $args = null) { $this->command = getCmd($cmd); $this->params = array(); if ($args !== null) { if (is_array($args)) { foreach ($args as $prm) { $this->addParameter($prm); } } else { $this->addParameter($args); } } }
public function rXMLRPCCommand($cmd, $args = null) { $this->command = getCmd($cmd); $this->params = array(); rTorrentSettings::get()->patchDeprecatedCommand($this, $cmd); if ($args !== null) { if (is_array($args)) { foreach ($args as $prm) { $this->addParameter($prm); } } else { $this->addParameter($args); } } }
function getRatiosStat() { $req = new rXMLRPCRequest(new rXMLRPCCommand("d.multicall", array("main", getCmd("d.get_hash=")))); $ret = 'theWebUI.ratiosStat = {'; if ($req->run() && !$req->fault) { $tm = time(); for ($i = 0; $i < count($req->val); $i++) { $st = new rStat("torrents/" . $req->val[$i] . ".csv"); $ratios = $st->getRatios($tm); if ($ret != 'theWebUI.ratiosStat = {') { $ret .= ','; } $ret .= '"' . $req->val[$i] . '": [' . $ratios[0] . ',' . $ratios[1] . ',' . $ratios[2] . ']'; } } return $ret . '}; '; }
<?php require_once 'xmlrpc.php'; eval(getPluginConf($plugin["name"])); $listPath = getSettingsPath() . "/erasedata"; @makeDirectory($listPath); $thisDir = dirname(__FILE__); $req = new rXMLRPCRequest(array($theSettings->getOnEraseCommand(array('erasedata0' . getUser(), getCmd('d.open') . '= ; ' . getCmd('branch=') . getCmd('d.get_custom5') . '=,"' . getCmd('f.multicall') . '=,\\"' . getCmd('execute') . '={' . $thisDir . '/cat.sh,' . $listPath . ',$system.pid=,$' . getCmd('f.get_frozen_path') . '=}\\""')), $theSettings->getOnEraseCommand(array('erasedata1' . getUser(), getCmd('branch=') . getCmd('d.get_custom5') . '=,"' . getCmd('execute') . '={' . $thisDir . '/fin.sh,' . $listPath . ',$' . getCmd('system.pid') . '=,$' . getCmd('d.get_hash') . '=,$' . getCmd('d.get_base_path') . '=,$' . getCmd('d.is_multi_file') . '=,$' . getCmd('d.get_custom5') . '=}"')), $theSettings->getAbsScheduleCommand("erasedata", $garbageCheckInterval, getCmd('execute') . '={sh,-c,' . escapeshellarg(getPHP()) . ' ' . escapeshellarg($thisDir . '/update.php') . ' ' . escapeshellarg(getUser()) . ' &}'))); if ($req->success()) { $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); } else { $jResult .= "plugin.disable(); noty('erasedata: '+theUILang.pluginCantStart,'error');"; }
<?php $req = new rXMLRPCRequest(array($theSettings->getOnFinishedCommand(array("seedingtime" . getUser(), getCmd('d.set_custom') . '=seedingtime,"$' . getCmd('execute_capture') . '={date,+%s}"')), $theSettings->getOnInsertCommand(array("addtime" . getUser(), getCmd('d.set_custom') . '=addtime,"$' . getCmd('execute_capture') . '={date,+%s}"')), $theSettings->getOnHashdoneCommand(array("seedingtimecheck" . getUser(), getCmd('branch=') . '$' . getCmd('not=') . '$' . getCmd('d.get_complete=') . ',,' . getCmd('d.get_custom') . '=seedingtime,,"' . getCmd('d.set_custom') . '=seedingtime,$' . getCmd('d.get_custom') . '=addtime' . '"')))); if ($req->success()) { $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); } else { $jResult .= "plugin.disable(); noty('seedingtime: '+theUILang.pluginCantStart,'error');"; }
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(); }
<?php $req = new rXMLRPCRequest(array(rTorrentSettings::get()->getRemoveScheduleCommand("ratio"), rTorrentSettings::get()->getOnInsertCommand(array('_ratio' . getUser(), getCmd('cat='))))); $req->run();
<?php $req = new rXMLRPCRequest(array($theSettings->getOnResumedCommand(array('quotapauser' . getUser(), getCmd('cat='))), new rXMLRPCCommand("schedule_remove", 'quotaspace' . getUser()))); $req->run();
public function flush() { $req1 = new rXMLRPCRequest(new rXMLRPCCommand("view_list")); if ($req1->run() && !$req1->fault) { $insCmd = getCmd('branch='); $req = new rXMLRPCRequest(); for ($i = 0; $i < MAX_RATIO; $i++) { $insCmd .= getCmd('d.views.has=') . 'rat_' . $i . ',,'; $rat = $this->rat[$i]; if (!in_array("rat_" . $i, $req1->val)) { $req->addCommand(new rXMLRPCCommand("group.insert_persistent_view", array("", "rat_" . $i))); } if ($this->isCorrect($i)) { $req->addCommand(new rXMLRPCCommand("group.rat_" . $i . ".ratio.enable", array(""))); $req->addCommand(new rXMLRPCCommand("group.rat_" . $i . ".ratio.min.set", $rat["min"])); $req->addCommand(new rXMLRPCCommand("group.rat_" . $i . ".ratio.max.set", $rat["max"])); $req->addCommand(new rXMLRPCCommand("group.rat_" . $i . ".ratio.upload.set", floatval($rat["upload"] * 1024 * 1024))); switch ($rat["action"]) { case RAT_STOP: $req->addCommand(new rXMLRPCCommand("system.method.set", array("group.rat_" . $i . ".ratio.command", getCmd("d.stop=") . "; " . getCmd("d.close=")))); break; case RAT_STOP_AND_REMOVE: $req->addCommand(new rXMLRPCCommand("system.method.set", array("group.rat_" . $i . ".ratio.command", getCmd("d.stop=") . "; " . getCmd("d.close=") . "; " . getCmd("view.set_not_visible") . "=rat_" . $i . "; " . getCmd("d.views.remove") . "=rat_" . $i))); break; case RAT_ERASE: $req->addCommand(new rXMLRPCCommand("system.method.set", array("group.rat_" . $i . ".ratio.command", getCmd("d.stop=") . "; " . getCmd("d.close=") . "; " . getCmd("d.erase=")))); break; case RAT_ERASEDATA: $req->addCommand(new rXMLRPCCommand("system.method.set", array("group.rat_" . $i . ".ratio.command", getCmd("d.stop=") . "; " . getCmd("d.close=") . "; " . getCmd("d.set_custom5=") . "1; " . getCmd("d.erase=")))); break; default: $thr = "thr_" . ($rat["action"] - RAT_FIRSTTHROTTLE); $req->addCommand(new rXMLRPCCommand("system.method.set", array("group.rat_" . $i . ".ratio.command", getCmd('cat') . '=$' . getCmd("d.stop") . '=,$' . getCmd("d.set_throttle_name=") . $thr . ',$' . getCmd('d.start=')))); break; } } } if ($this->isCorrect($this->default - 1)) { $req->addCommand(rTorrentSettings::get()->getOnInsertCommand(array('_ratio' . getUser(), $insCmd . getCmd('view.set_visible=') . 'rat_' . ($this->default - 1)))); } else { $req->addCommand(rTorrentSettings::get()->getOnInsertCommand(array('_ratio' . getUser(), getCmd('cat=')))); } return $req->run() && !$req->fault; } return false; }
public function setHandlers() { global $autowatch_interval; $theSettings = rTorrentSettings::get(); $req = new rXMLRPCRequest($theSettings->getOnInsertCommand(array('autolabel' . getUser(), getCmd('cat=')))); $pathToAutoTools = dirname(__FILE__); if ($this->enable_label) { $cmd = $theSettings->getOnInsertCommand(array('_autolabel' . getUser(), getCmd('branch') . '=$' . getCmd('not') . '=$' . getCmd("d.get_custom1") . '=,"' . getCmd('execute') . '={' . getPHP() . ',' . $pathToAutoTools . '/label.php,$' . getCmd("d.get_hash") . '=,' . getUser() . '}"')); } else { $cmd = $theSettings->getOnInsertCommand(array('_autolabel' . getUser(), getCmd('cat='))); } $req->addCommand($cmd); if ($this->enable_move && trim($this->path_to_finished) != '') { if ($theSettings->iVersion < 0x808) { $cmd = $theSettings->getOnFinishedCommand(array('automove' . getUser(), getCmd('d.set_custom') . '=x-dest,"$' . getCmd('execute_capture') . '={' . getPHP() . ',' . $pathToAutoTools . '/move.php,$' . getCmd('d.get_hash') . '=,$' . getCmd('d.get_base_path') . '=,$' . getCmd('d.get_base_filename') . '=,$' . getCmd('d.is_multi_file') . '=,' . getUser() . '}" ; ' . getCmd('branch') . '=$' . getCmd('not') . '=$' . getCmd('d.get_custom') . '=x-dest,,' . getCmd('d.set_directory_base') . '=$' . getCmd('d.get_custom') . '=x-dest')); } else { if ($this->fileop_type == "Move") { $cmd = $theSettings->getOnFinishedCommand(array('automove' . getUser(), getCmd('d.set_directory_base') . '="$' . getCmd('execute_capture') . '={' . getPHP() . ',' . $pathToAutoTools . '/check.php,$' . getCmd('d.get_base_path') . '=,$' . getCmd('d.get_base_filename') . '=,$' . getCmd('d.is_multi_file') . '=,' . getUser() . '}" ; ' . getCmd('execute') . '={' . getPHP() . ',' . $pathToAutoTools . '/move.php,$' . getCmd('d.get_hash') . '=,$' . getCmd('d.get_base_path') . '=,$' . getCmd('d.get_base_filename') . '=,$' . getCmd('d.is_multi_file') . '=,' . getUser() . '}')); } else { $cmd = $theSettings->getOnFinishedCommand(array('automove' . getUser(), getCmd('execute') . '={' . getPHP() . ',' . $pathToAutoTools . '/move.php,$' . getCmd('d.get_hash') . '=,$' . getCmd('d.get_base_path') . '=,$' . getCmd('d.get_base_filename') . '=,$' . getCmd('d.is_multi_file') . '=,' . getUser() . '}')); } } } else { $cmd = $theSettings->getOnFinishedCommand(array('automove' . getUser(), getCmd('cat='))); } $req->addCommand($cmd); if ($this->enable_watch && trim($this->path_to_watch) != '') { $cmd = $theSettings->getAbsScheduleCommand('autowatch', $autowatch_interval, getCmd('execute') . '={sh,-c,' . escapeshellarg(getPHP()) . ' ' . escapeshellarg($pathToAutoTools . '/watch.php') . ' ' . escapeshellarg(getUser()) . ' &}'); } else { $cmd = $theSettings->getRemoveScheduleCommand('autowatch'); } $req->addCommand($cmd); return $req->success(); }
<?php require_once '../plugins/retrackers/retrackers.php'; $req = new rXMLRPCRequest(array($theSettings->getOnInsertCommand(array('tadd_trackers1' . getUser(), getCmd('d.set_custom4') . '=$' . getCmd('cat') . '=$' . getCmd('d.get_state='))), $theSettings->getOnInsertCommand(array('tadd_trackers2' . getUser(), getCmd('branch') . '=$' . getCmd('not') . '=$' . getCmd('d.get_custom3') . '=,"' . getCmd('cat') . '=$' . getCmd('d.stop') . '=,\\"$' . getCmd('execute') . '={sh,' . $rootPath . '/plugins/retrackers/run.sh' . ',' . getPHP() . ',$' . getCmd('d.get_hash') . '=,' . getUser() . '}\\"" ; ' . getCmd('d.set_custom3='))))); if ($req->run() && !$req->fault) { $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); $trks = rRetrackers::load(); $jResult .= $trks->get(); } else { $jResult .= "plugin.disable(); noty('retrackers: '+theUILang.pluginCantStart,'error');"; }
<?php $req = new rXMLRPCRequest(array(rTorrentSettings::get()->getOnFinishedCommand(array('xmpp' . getUser(), getCmd('cat='))))); $req->run();
<?php eval(getPluginConf($plugin["name"])); require_once '../plugins/trafic/ratios.php'; $st = getSettingsPath(); makeDirectory(array($st . '/trafic', $st . '/trafic/trackers', $st . '/trafic/torrents')); $req = new rXMLRPCRequest($theSettings->getScheduleCommand("trafic", $updateInterval, getCmd('execute') . '={sh,-c,' . escapeshellarg(getPHP()) . ' ' . escapeshellarg($rootPath . '/plugins/trafic/update.php') . ' ' . escapeshellarg(getUser()) . ' & exit 0}')); if ($req->run() && !$req->fault) { $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); } else { $jResult .= "plugin.disable(); noty('trafic: '+theUILang.pluginCantStart,'error');"; } $jResult .= "plugin.collectStatForTorrents = " . ($collectStatForTorrents ? "true;" : "false;"); $jResult .= "plugin.updateInterval = " . $updateInterval . ";"; $jResult .= "plugin.disableClearButton = " . ($disableClearButton ? "true" : "false") . ";";
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 function setHandlers() { if (rTorrentSettings::get()->linkExist) { $req = new rXMLRPCRequest($this->hasAuto() ? rTorrentSettings::get()->getScheduleCommand("loginmgr", 1440, getCmd('execute') . '={sh,-c,' . escapeshellarg(getPHP()) . ' ' . escapeshellarg(dirname(__FILE__) . '/update.php') . ' ' . escapeshellarg(getUser()) . ' & exit 0}') : rTorrentSettings::get()->getRemoveScheduleCommand("loginmgr")); $req->success(); } }
} else { $needToProcessed = false; } } $lst = $torrent->announce_list(); if ($lst && count($trks->todelete)) { $needToProcessed = deleteTrackers($lst, $trks->todelete); if ($needToProcessed) { $torrent->announce_list($lst); } } if ($needToProcessed) { if (isset($torrent->{'rtorrent'})) { unset($torrent->{'rtorrent'}); } $eReq = new rXMLRPCRequest(new rXMLRPCCommand("d.erase", $hash)); if ($eReq->success()) { $label = rawurldecode($req->val[3]); rTorrent::sendTorrent($torrent, $isStart, false, $req->val[4], $label, false, false, false, array(getCmd("d.set_custom3") . "=1")); $processed = true; } } } } } if (!$processed && $isStart) { $req = new rXMLRPCRequest(new rXMLRPCCommand("d.start", $hash)); $req->run(); } } }
public function getTorrents($rss, $url, $isStart, $isAddPath, $directory, $label, $throttle, $ratio, $needFlush = true) { $thash = 'Failed'; $ret = $rss->getTorrent($url); if ($ret !== false) { $addition = array(); if (!empty($throttle)) { $addition[] = getCmd("d.set_throttle_name=") . $throttle; } if (!empty($ratio)) { $addition[] = getCmd("view.set_visible=") . $ratio; } global $saveUploadedTorrents; $thash = $ret === 'magnet' ? rTorrent::sendMagnet($url, $isStart, $isAddPath, $directory, $label, $addition) : rTorrent::sendTorrent($ret, $isStart, $isAddPath, $directory, $label, $saveUploadedTorrents, false, true, $addition); if ($thash === false) { $thash = 'Failed'; @unlink($ret); $ret = false; } } if ($ret === false) { $this->rssList->addError("theUILang.rssCantLoadTorrent", $url); } $this->history->add($url, $thash, $rss->getItemTimestamp($url)); if ($needFlush) { $this->saveHistory(); } }
$req->addCommand($cmd); } if ($req->getCommandsCount()) { if ($req->success()) { $result = $req->val; } } else { $result = array(); } break; case "setprops": $req = new rXMLRPCRequest(); foreach ($ss as $ndx => $s) { if ($s == "superseed") { $conn = $vs[$ndx] != 0 ? "initial_seed" : "seed"; $cmd = new rXMLRPCCommand("branch", array($hash[0], getCmd("d.is_active="), getCmd("cat") . '=$' . getCmd("d.stop=") . ',$' . getCmd("d.close=") . ',$' . getCmd("d.set_connection_seed=") . $conn . ',$' . getCmd("d.open=") . ',$' . getCmd("d.start="), getCmd("d.set_connection_seed=") . $conn)); } else { if ($s == "ulslots") { $cmd = new rXMLRPCCommand("d.set_uploads_max"); } else { if ($s == "pex") { $cmd = new rXMLRPCCommand("d.set_peer_exchange"); } else { $cmd = new rXMLRPCCommand("d.set_" . $s); } } $cmd->addParameters(array($hash[0], $vs[$ndx])); } $req->addCommand($cmd); } if ($req->success()) {
function rtSetDataDir($hash, $dest_path, $add_path, $move_files, $fast_resume, $dbg = false) { if ($dbg) { rtDbg(__FUNCTION__, "hash : " . $hash); } if ($dbg) { rtDbg(__FUNCTION__, "dest_path : " . $dest_path); } if ($dbg) { rtDbg(__FUNCTION__, "add path : " . ($add_path ? "1" : "0")); } if ($dbg) { rtDbg(__FUNCTION__, "move files : " . ($move_files ? "1" : "0")); } if ($dbg) { rtDbg(__FUNCTION__, "fast resume : " . ($fast_resume ? "1" : "0")); } $is_open = false; $is_active = false; $is_multy_file = false; $base_name = ''; $base_path = ''; $base_file = ''; $is_ok = true; if ($dest_path == '') { $is_ok = false; } else { $dest_path = rtAddTailSlash($dest_path); } // Check if torrent is open or active if ($is_ok) { $req = rtExec(array("d.is_open", "d.is_active"), $hash, $dbg); if (!$req) { $is_ok = false; } else { $is_open = $req->val[0] != 0; $is_active = $req->val[1] != 0; if ($dbg) { rtDbg(__FUNCTION__, "is_open=" . $req->val[0] . ", is_active=" . $req->val[1]); } } } // Open closed torrent to get d.get_base_path, d.get_base_filename if ($is_ok && $move_files) { if (!$is_open && !rtExec("d.open", $hash, $dbg)) { $is_ok = false; } } // Ask info from rTorrent if ($is_ok && $move_files) { $req = rtExec(array("d.get_name", "d.get_base_path", "d.get_base_filename", "d.is_multi_file", "d.get_complete"), $hash, $dbg); if (!$req) { $is_ok = false; } else { $base_name = trim($req->val[0]); $base_path = trim($req->val[1]); $base_file = trim($req->val[2]); $is_multy_file = $req->val[3] != 0; if ($req->val[4] == 0) { // if torrent is not completed -> "fast start" is impossible $fast_resume = false; } if ($dbg) { rtDbg(__FUNCTION__, "d.get_name : " . $base_name); } if ($dbg) { rtDbg(__FUNCTION__, "d.get_base_path : " . $base_path); } if ($dbg) { rtDbg(__FUNCTION__, "d.get_base_filename : " . $base_file); } if ($dbg) { rtDbg(__FUNCTION__, "d.is_multy_file : " . $req->val[3]); } if ($dbg) { rtDbg(__FUNCTION__, "d.get_complete : " . $req->val[4]); } } } // Check if paths are valid if ($is_ok && $move_files) { if ($base_path == '' || $base_file == '') { if ($dbg) { rtDbg(__FUNCTION__, "base paths are empty"); } $is_ok = false; } else { // Make $base_path a really BASE path for downloading data // (not including single file or subdir for multiple files). // Add trailing slash, if none. $base_path = rtRemoveTailSlash($base_path); $base_path = rtRemoveLastToken($base_path, '/'); // filename or dirname $base_path = rtAddTailSlash($base_path); } } // Get list of torrent data files $torrent_files = array(); if ($is_ok && $move_files) { $req = rtExec("f.multicall", array($hash, "", "f.get_path="), $dbg); if (!$req) { $is_ok = false; } else { $torrent_files = $req->val; if ($dbg) { rtDbg(__FUNCTION__, "files in torrent : " . count($torrent_files)); } } } // 1. Stop torrent if active (if not, then rTorrent can crash) // 2. Close torrent anyway if ($is_ok) { $cmds = array(); if ($is_active) { $cmds[] = "d.stop"; } if ($is_open || $move_files) { $cmds[] = "d.close"; } if (count($cmds) > 0 && !rtExec($cmds, $hash, $dbg)) { $is_ok = false; } } // Move torrent data files to new location if ($is_ok && $move_files) { $full_base_path = $base_path; $full_dest_path = $dest_path; // Don't use "count( $torrent_files ) > 1" check (there can be one file in a subdir) if ($is_multy_file) { // torrent is a directory $full_base_path .= rtAddTailSlash($base_file); $full_dest_path .= $add_path ? rtAddTailSlash($base_name) : ""; } else { // torrent is a single file } if ($dbg) { rtDbg(__FUNCTION__, "from " . $full_base_path); } if ($dbg) { rtDbg(__FUNCTION__, "to " . $full_dest_path); } if ($full_base_path != $full_dest_path && is_dir($full_base_path)) { if (!rtOpFiles($torrent_files, $full_base_path, $full_dest_path, "Move", $dbg)) { $is_ok = false; } else { // Recursively remove source dirs without files if ($dbg) { rtDbg(__FUNCTION__, "clean " . $full_base_path); } if ($is_multy_file) { rtRemoveDirectory($full_base_path, false); if ($dbg && is_dir($full_base_path)) { rtDbg(__FUNCTION__, "some files were not deleted"); } } } } } if ($is_ok) { // fast resume is requested if ($fast_resume) { if ($dbg) { rtDbg(__FUNCTION__, "trying fast resume"); } // collect variables $session = rTorrentSettings::get()->session; $tied_to_file = null; $label = null; $addition = null; $req = rtExec(array("get_session", "d.get_tied_to_file", "d.get_custom1", "d.get_connection_seed", "d.get_throttle_name"), $hash, $dbg); if (!$req) { $fast_resume = false; } else { $session = $req->val[0]; $tied_to_file = $req->val[1]; $label = rawurldecode($req->val[2]); $addition = array(); if (!empty($req->val[3])) { $addition[] = getCmd("d.set_connection_seed=") . $req->val[3]; } if (!empty($req->val[4])) { $addition[] = getCmd("d.set_throttle_name=") . $req->val[4]; } // build path to .torrent file $fname = rtAddTailSlash($session) . $hash . ".torrent"; if (empty($session) || !is_readable($fname)) { if (!strlen($tied_to_file) || !is_readable($tied_to_file)) { if ($dbg) { rtDbg(__FUNCTION__, "empty session or inaccessible .torrent file"); } $fname = null; $fast_resume = false; } else { $fname = $tied_to_file; } } } // create torrent, remove old and add new one if ($fast_resume) { $torrent = new Torrent($fname); if ($torrent->errors()) { if ($dbg) { rtDbg(__FUNCTION__, "fail to create Torrent object"); } $fast_resume = false; } else { $is_ok = $add_path ? rtExec("d.set_directory", array($hash, $dest_path), $dbg) : rtExec("d.set_directory_base", array($hash, $dest_path), $dbg); // for erasedata plugin if ($is_ok) { if (!rtExec("d.erase", $hash, $dbg)) { if ($dbg) { rtDbg(__FUNCTION__, "fail to erase old torrent"); } $fast_resume = false; } else { if (!rTorrent::sendTorrent($torrent, true, $add_path, $dest_path, $label, true, true, false, $addition)) { if ($dbg) { rtDbg(__FUNCTION__, "fail to add new torrent"); } $fast_resume = false; $is_ok = false; } } } } } if ($dbg) { rtDbg(__FUNCTION__, "fast resume " . ($fast_resume ? "done" : "fail")); } } // fast resume is fail or not requested at all if ($is_ok && !$fast_resume) { // Setup new directory for torrent (we need to stop it first) $is_ok = $add_path ? rtExec("d.set_directory", array($hash, $dest_path), $dbg) : rtExec("d.set_directory_base", array($hash, $dest_path), $dbg); if ($is_ok) { // Start torrent if need if ($is_active) { $is_ok = rtExec(array("d.open", "d.start"), $hash, $dbg); } elseif ($is_open) { $is_ok = rtExec("d.open", $hash, $dbg); } else { $is_ok = rtExec(array("d.open", "d.close"), $hash, $dbg); } } } } if ($dbg) { rtDbg(__FUNCTION__, "finished"); } return $is_ok; }
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(); }
<?php $req = new rXMLRPCRequest(rTorrentSettings::get()->getOnInsertCommand(array('_throttle' . getUser(), getCmd('cat=')))); $req->run();
<?php if (!chdir(dirname(__FILE__))) { exit; } if (count($argv) > 1) { $_SERVER['REMOTE_USER'] = $argv[1]; } require_once "check.php"; $req = new rXMLRPCRequest(new rXMLRPCCommand("d.multicall", array("seeding", getCmd("d.get_hash="), getCmd("d.get_custom=") . "chk-state", getCmd("d.get_custom=") . "chk-time", getCmd("d.get_custom=") . "chk-stime", getCmd("cat") . '="$' . getCmd("t.multicall=") . getCmd("d.get_hash=") . "," . getCmd("t.get_url") . "=," . getCmd("cat=#") . '"'))); if ($req->success()) { for ($i = 0; $i < count($req->val); $i += 5) { if (strpos($req->val[$i + 4], ".rutracker.org/") !== false || strpos($req->val[$i + 4], ".kinozal.tv/") !== false) { if (!ruTrackerChecker::run($req->val[$i], $req->val[$i + 1], $req->val[$i + 2], $req->val[$i + 3])) { break; } } } }
<?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'; if (isset($_REQUEST['mode'])) { $output = array(); $modes = explode(';', $_REQUEST['mode']); $theSettings = rTorrentSettings::get(); if (in_array("labels", $modes)) { $req = new rXMLRPCRequest(new rXMLRPCCommand("d.multicall", array("", getCmd("d.get_custom1=")))); $labels = array(); if ($req->run() && !$req->fault) { for ($i = 0; $i < count($req->val); $i++) { $val = trim(rawurldecode($req->val[$i])); if ($val != '') { $labels[$val] = true; } } $output["labels"] = array_keys($labels); } } if (in_array("dirlist", $modes)) { $dh = false; if (isset($_REQUEST['basedir'])) { $dir = rawurldecode($_REQUEST['basedir']); $theSettings->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;
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(); }
<?php require_once 'rquota.php'; $qt = rQuota::load(); $qt->update(); $tm = getdate(); $startAt = mktime($tm["hours"], (int) ($tm["minutes"] / $quotaUpdateInterval) * $quotaUpdateInterval + $quotaUpdateInterval, 0, $tm["mon"], $tm["mday"], $tm["year"]) - $tm[0]; if ($startAt < 0) { $startAt = 0; } $interval = $quotaUpdateInterval * 60; $req = new rXMLRPCRequest(array(new rXMLRPCCommand("schedule", array('quotaspace' . getUser(), $startAt . "", $interval . "", getCmd('execute') . '={sh,-c,' . escapeshellarg(getPHP()) . ' ' . escapeshellarg($rootPath . '/plugins/quotaspace/update.php') . ' ' . escapeshellarg(getUser()) . ' & exit 0}')), $theSettings->getOnResumedCommand(array('quotapauser' . getUser(), getCmd('execute') . '={sh,' . $rootPath . '/plugins/quotaspace/run.sh' . ',' . getPHP() . ',$' . getCmd("d.get_hash") . '=,$' . getCmd("d.get_complete") . '=,' . getUser() . '}')))); if ($req->success()) { $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]); } else { $jResult .= "plugin.disable(); log('quotaspace: '+theUILang.pluginCantStart);"; }
$torrent->clear_comment(); $comment = trim($comment); if (strlen($comment)) { $torrent->comment($comment); } } if (isset($torrent->{'rtorrent'})) { unset($torrent->{'rtorrent'}); } if (count($req->val) > 9) { $throttle = getCmd("d.set_throttle_name=") . $req->val[9]; } $eReq = new rXMLRPCRequest(new rXMLRPCCommand("d.erase", $hash)); if ($eReq->run() && !$eReq->fault) { $label = rawurldecode($req->val[5]); if (!rTorrent::sendTorrent($torrent, $isStart, false, $req->val[6], $label, false, $req->val[8] == 1, false, array(getCmd("d.set_custom3") . "=1", getCmd("d.set_connection_seed=") . $req->val[7], $throttle))) { $errors[] = array('desc' => "theUILang.errorAddTorrent", 'prm' => $fname); } } else { $errors[] = array('desc' => "theUILang.badLinkTorTorrent", 'prm' => ''); } } else { $errors[] = array('desc' => "theUILang.errorReadTorrent", 'prm' => $fname); } } else { $errors[] = array('desc' => "theUILang.cantFindTorrent", 'prm' => ''); } } else { $errors[] = array('desc' => "theUILang.badLinkTorTorrent", 'prm' => ''); } }