Пример #1
0
 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
0
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
0
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;
}
Пример #4
0
 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;
 }
Пример #5
0
 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();
 }
Пример #6
0
                        } 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();
        }
    }
}
Пример #7
0
 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();
 }
Пример #8
0
 public function obtain()
 {
     $req = new rXMLRPCRequest(new rXMLRPCCommand("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(new rXMLRPCCommand("file.prioritize_toc"));
             $req->important = false;
             if ($req->success()) {
                 $this->iVersion = 0x809;
             }
         }
         $this->apiVersion = 0;
         if ($this->iVersion >= 0x901) {
             $req = new rXMLRPCRequest(new rXMLRPCCommand("system.api_version"));
             $req->important = false;
             if ($req->success()) {
                 $this->apiVersion = $req->val[0];
             }
         }
         $req = new rXMLRPCRequest(new rXMLRPCCommand("to_kb", floatval(1024)));
         if ($req->run()) {
             if (!$req->fault) {
                 $this->badXMLRPCVersion = false;
             }
             $req = new rXMLRPCRequest(array(new rXMLRPCCommand("get_directory"), new rXMLRPCCommand("get_session"), new rXMLRPCCommand("system.library_version"), new rXMLRPCCommand("set_xmlrpc_size_limit", 67108863), new rXMLRPCCommand("get_name"), new rXMLRPCCommand("get_port_range")));
             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->port = intval($this->portRange);
                 if ($this->iVersion >= 0x809) {
                     $req = new rXMLRPCRequest(new rXMLRPCCommand("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 = getExternal('id');
                     $req = new rXMLRPCRequest(new rXMLRPCCommand("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();
             }
         }
     }
 }
Пример #9
0
 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();
 }
Пример #10
0
 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();
     }
 }
Пример #11
0
 public function setHandlers()
 {
     $startAt = 0;
     $req = new rXMLRPCRequest(rTorrentSettings::get()->getScheduleCommand("rss", $this->data->interval, getCmd('execute') . '={sh,-c,' . escapeshellarg(getPHP()) . ' ' . escapeshellarg(dirname(__FILE__) . '/update.php') . ' ' . escapeshellarg(getUser()) . ' & exit 0}', $startAt));
     if ($req->success()) {
         $this->setStartTime($startAt);
         return true;
     }
     return false;
 }
Пример #12
0
 public function correct()
 {
     $cmd = new rXMLRPCCommand("d.multicall", array("default", getCmd("d.get_hash=")));
     for ($i = 0; $i < MAX_RATIO; $i++) {
         $cmd->addParameters(array(getCmd("d.views.has") . "=rat_" . $i, getCmd("view.set_not_visible") . "=rat_" . $i));
     }
     $req = new rXMLRPCRequest($cmd);
     $req->setParseByTypes();
     if ($req->success()) {
         $req1 = new rXMLRPCRequest();
         foreach ($req->strings as $no => $hash) {
             for ($i = 0; $i < MAX_RATIO; $i++) {
                 if ($req->i8s[$no * MAX_RATIO * 2 + $i * 2] == 1) {
                     $req1->addCommand(new rXMLRPCCommand("view.set_visible", array($hash, "rat_" . $i)));
                 }
             }
         }
         return $req1->getCommandsCount() == 0 || $req1->success();
     }
     return false;
 }
Пример #13
0
 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();
 }
Пример #14
0
 public static function run($hash, $state = null, $time = null, $successful_time = null)
 {
     global $saveUploadedTorrents;
     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)) {
             $torrent = new Torrent($fname);
             if (!$torrent->errors()) {
                 if (preg_match('`^http://(?P<tracker>rutracker)\\.org/forum/viewtopic\\.php\\?t=(?P<id>\\d+)$`', $torrent->comment(), $matches) || preg_match('`^http://(?P<tracker>kinozal)\\.tv/details\\.php\\?id=(?P<id>\\d+)$`', $torrent->comment(), $matches)) {
                     if ($matches["tracker"] == "rutracker") {
                         $client = self::makeClient($torrent->comment());
                         if ($client->status == 200 && preg_match("`ajax.form_token\\s*=\\s*'(?P<form_token>[^']+)';.*topic_id\\s*:\\s*(?P<topic_id>\\d+),\\s*t_hash\\s*:\\s*'(?P<t_hash>[^']+)'`s", $client->results, $matches1)) {
                             $client->setcookies();
                             $client->fetch("http://rutracker.org/forum/ajax.php", "POST", "application/x-www-form-urlencoded; charset=UTF-8", "action=get_info_hash" . "&topic_id=" . $matches1["topic_id"] . "&t_hash=" . $matches1["t_hash"] . "&form_token=" . $matches1["form_token"]);
                             if ($client->status == 200) {
                                 $ret = json_decode($client->results, true);
                                 if ($ret && array_key_exists("ih_hex", $ret) && strtoupper($ret["ih_hex"]) == $hash) {
                                     self::setState($hash, self::STE_UPTODATE);
                                     return true;
                                 }
                             }
                         }
                         $client->setcookies();
                         $client->fetchComplex("http://dl.rutracker.org/forum/dl.php?t=" . $matches["id"]);
                     } else {
                         if ($matches["tracker"] == "kinozal") {
                             $client = self::makeClient("http://kinozal.tv/get_srv_details.php?action=2&id=" . $matches["id"]);
                             if ($client->status == 200 && preg_match('`<li>.*(?P<hash>[0-9A-Fa-f]{40})</li>`', $client->results, $matches1)) {
                                 if (strtoupper($matches1["hash"]) == $hash) {
                                     self::setState($hash, self::STE_UPTODATE);
                                     return true;
                                 }
                             }
                             $client->setcookies();
                             $client->fetchComplex("http://dl.kinozal.tv/download.php?id=" . $matches["id"]);
                         } else {
                             self::setState($hash, self::STE_NOT_NEED);
                             return true;
                         }
                     }
                     if ($client->status == 200) {
                         $torrent = new Torrent($client->results);
                         if (!$torrent->errors()) {
                             if ($torrent->hash_info() != $hash) {
                                 $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()) {
                                             $state = null;
                                         }
                                     }
                                 }
                             } else {
                                 $state = self::STE_UPTODATE;
                             }
                         } else {
                             $state = self::STE_DELETED;
                         }
                     } else {
                         $state = $client->status < 0 ? self::STE_CANT_REACH_TRACKER : self::STE_DELETED;
                     }
                 } else {
                     $state = self::STE_NOT_NEED;
                 }
             }
         }
         if ($state == self::STE_INPROGRESS) {
             $state == self::STE_ERROR;
         }
         if (!is_null($state)) {
             self::setState($hash, $state);
         }
     }
     return $state != self::STE_CANT_REACH_TRACKER;
 }
Пример #15
0
 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;
 }
Пример #16
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();
 }
Пример #17
0
<?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);";
}
 public static function getTorrentHashFilepath($hash, $fno)
 {
     $fno = intval($fno);
     $req = new \rXMLRPCRequest(new \rXMLRPCCommand("f.get_frozen_path", array($hash, $fno)));
     $filename = '';
     if ($req->success()) {
         $filename = $req->val[0];
         if ($filename == '') {
             $req = new \rXMLRPCRequest(array(new \rXMLRPCCommand("d.open", $hash), new \rXMLRPCCommand("f.get_frozen_path", array($hash, $fno)), new \rXMLRPCCommand("d.close", $hash)));
             if ($req->success()) {
                 $filename = $req->val[1];
             }
         }
     }
     return $filename;
 }