function setPrioriteFile($hashtorrentselectionne, $prio, $keyconnexion = null) { \model\simple\Utilisateur::authentificationPourRtorrent($keyconnexion); if (!\config\Conf::$user["user"]) { throw new \Exception("Non User"); } $req = new \model\xmlrpc\rXMLRPCRequest(\config\Conf::$userscgi); foreach ($_REQUEST["nofiles"] as $v) { $req->addCommand(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "f.priority.set", array($hashtorrentselectionne . ":f" . intval($v), intval($prio)))); } $req->addCommand(new \model\xmlrpc\rXMLRPCCommand(\config\Conf::$userscgi, "d.update_priorities", $hashtorrentselectionne)); if ($req->success()) { $result = $req->val; } }
public function obtain() { $req = new rXMLRPCRequest($this->user, new rXMLRPCCommand($this->user, "system.client_version")); if ($req->run() && count($req->val)) { $this->linkExist = true; $this->version = $req->val[0]; $parts = explode('.', $this->version); $this->iVersion = 0; for ($i = 0; $i < count($parts); $i++) { $this->iVersion = ($this->iVersion << 8) + $parts[$i]; } if ($this->iVersion > 0x806) { $this->mostOfMethodsRenamed = true; $this->aliases = array("d.set_peer_exchange" => "d.peer_exchange.set", "d.set_connection_seed" => "d.connection_seed.set"); } if ($this->iVersion == 0x808) { $req = new rXMLRPCRequest($this->user, new rXMLRPCCommand($this->user, "file.prioritize_toc")); $req->important = false; if ($req->success()) { $this->iVersion = 0x809; } } $this->apiVersion = 0; if ($this->iVersion >= 0x901) { $req = new rXMLRPCRequest($this->user, new rXMLRPCCommand($this->user, "system.api_version")); $req->important = false; if ($req->success()) { $this->apiVersion = $req->val[0]; } } $req = new rXMLRPCRequest($this->user, new rXMLRPCCommand($this->user, "to_kb", floatval(1024))); if ($req->run()) { if (!$req->fault) { $this->badXMLRPCVersion = false; } $req = new rXMLRPCRequest($this->user, array(new rXMLRPCCommand($this->user, "directory.default"), new rXMLRPCCommand($this->user, "session.path"), new rXMLRPCCommand($this->user, "system.library_version"), new rXMLRPCCommand($this->user, "network.xmlrpc.size_limit.set", array("", 67108863)), new rXMLRPCCommand($this->user, "session.name"), new rXMLRPCCommand($this->user, "network.port_range"), new rXMLRPCCommand($this->user, "system.pid"))); if ($req->run() && !$req->fault) { $this->directory = $req->val[0]; $this->session = $req->val[1]; $this->libVersion = $req->val[2]; $this->server = $req->val[4]; $this->portRange = $req->val[5]; $this->pid = intval($req->val[6]); $this->port = intval($this->portRange); if ($this->iVersion >= 0x809) { $req = new rXMLRPCRequest($this->user, new rXMLRPCCommand($this->user, "network.listen.port")); $req->important = false; if ($req->success()) { $this->port = intval($req->val[0]); } } /*if(isLocalMode()) {*/ if (!empty($this->session)) { $this->started = @filemtime($this->session . '/rtorrent.lock'); if ($this->started === false) { $this->started = 0; } } $id = "id"; //getExternal('id'); $req = new rXMLRPCRequest($this->user, new rXMLRPCCommand($this->user, "execute.capture", array("", "sh", "-c", $id . " -u ; " . $id . " -G ; echo ~ "))); if ($req->run() && !$req->fault && ($line = explode("\n", $req->val[0])) !== false && count($line) > 2) { $this->uid = intval(trim($line[0])); $this->gid = explode(' ', trim($line[1])); $this->home = trim($line[2]); if (!empty($this->directory) && $this->directory[0] == '~') { $this->directory = $this->home . substr($this->directory, 1); } } else { $this->idNotFound = true; } /*}*/ $this->store(); } } } }