本文整理汇总了PHP中rXMLRPCRequest类的典型用法代码示例。如果您正苦于以下问题:PHP rXMLRPCRequest类的具体用法?PHP rXMLRPCRequest怎么用?PHP rXMLRPCRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rXMLRPCRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTorrent
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;
}
示例2: makeSimpleCall
function makeSimpleCall($cmds, $hash)
{
$req = new rXMLRPCRequest();
foreach ($hash as $h) {
foreach ($cmds as $cmd) {
$req->addCommand(new rXMLRPCCommand($cmd, $h));
}
}
return $req->success() ? $req->val : false;
}
示例3: getRatiosStat
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 . '}; ';
}
示例4: getNFO
function getNFO()
{
if ($_GET['id']) {
$hash = $_GET['id'];
$req = new rXMLRPCRequest(array(new rXMLRPCCommand("d.get_base_path", $hash), new rXMLRPCCommand("d.get_name", $hash)));
if ($req->success()) {
$dir = $req->val[0];
if ($h = opendir($dir)) {
while (false !== ($file = readdir($h))) {
if (preg_match("/\\.nfo\$/", $file)) {
return file_get_contents($dir . "/" . $file);
}
}
}
}
}
return false;
}
示例5: fastResume
public static function fastResume($torrent, $base, $add_path = true)
{
$files = array();
$info = $torrent->info;
$psize = intval($info['piece length']);
$base = trim($base);
if ($base == '') {
$req = new rXMLRPCRequest(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, 'get_directory'));
if ($req->success()) {
$base = $req->val[0];
}
}
if ($psize && \model\xmlrpc\rTorrentSettings::get(\config\Conf::$userscgi)->correctDirectory($base)) {
$base = addslash($base);
$tsize = 0.0;
if (isset($info['files'])) {
foreach ($info['files'] as $key => $file) {
$tsize += floatval($file['length']);
$files[] = $add_path ? $info['name'] . "/" . implode('/', $file['path']) : implode('/', $file['path']);
}
} else {
$tsize = floatval($info['length']);
$files[] = $info['name'];
}
$chunks = intval(($tsize + $psize - 1) / $psize);
$torrent->{'libtorrent_resume'}['bitfield'] = intval($chunks);
if (!isset($torrent->{'libtorrent_resume'}['files'])) {
$torrent->{'libtorrent_resume'}['files'] = array();
}
foreach ($files as $key => $file) {
$ss = LFS::stat($base . $file);
if ($ss === false) {
return false;
}
if (count($torrent->{'libtorrent_resume'}['files']) < $key) {
$torrent->{'libtorrent_resume'}['files'][$key]['mtime'] = $ss["mtime"];
} else {
$torrent->{'libtorrent_resume'}['files'][$key] = array("priority" => 2, "mtime" => $ss["mtime"]);
}
}
return $torrent;
}
return false;
}
示例6: trim
}
}
if ($setComment) {
$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 {
示例7: flush
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;
}
示例8: run
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;
}
示例9: rXMLRPCRequest
<?php
if (chdir(dirname(__FILE__))) {
if (count($argv) > 3) {
$_SERVER['REMOTE_USER'] = $argv[3];
}
if (count($argv) > 2 && empty($argv[2])) {
require_once "rquota.php";
$qt = rQuota::load();
if (!$qt->check()) {
$action = new rXMLRPCRequest(new rXMLRPCCommand("d.stop", $argv[1]));
$action->run();
} else {
$qt->restoreDL();
}
}
}
示例10: setHandlers
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();
}
示例11: rXMLRPCRequest
<?php
$req = new rXMLRPCRequest(rTorrentSettings::get()->getRemoveScheduleCommand("rss"));
$req->run();
示例12: setHandlers
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();
}
示例13: getActiveTorrents
public static function getActiveTorrents()
{
$delta = 2;
$cmd = new rXMLRPCCommand("d.multicall", array("started", getCmd("d.get_hash="), getCmd("d.get_connection_current=")));
if (rTorrentSettings::get()->iVersion >= 0x805) {
$cmd->addParameter(getCmd("d.get_custom=") . "sch_ignore");
$delta = 3;
}
$req = new rXMLRPCRequest($cmd);
$seeds = array();
$leeches = array();
if ($req->run() && !$req->fault) {
for ($i = 0; $i < count($req->val); $i += $delta) {
$hash = $req->val[$i];
if ($delta == 2 || empty($req->val[$i + 2])) {
if ($req->val[$i + 1] == 'leech') {
$leeches[$hash] = true;
} else {
$seeds[$hash] = true;
}
}
}
}
return array("seeds" => $seeds, "leeches" => $leeches);
}
示例14: setHandlers
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();
}
示例15: setHandlers
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();
}