示例#1
0
<?php

require_once 'retrackers.php';
$trks = new rRetrackers();
$trks->set();
cachedEcho($trks->get(), "application/javascript");
示例#2
0
                $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]);
            }
            if ($plugin["js"]) {
                $js = file_get_contents($plugin["js"]);
                if ($theSettings->isPluginRegistered($plugin["name"])) {
                    $jResult .= $js;
                } else {
                    if (strpos($js, "plugin.loadLang()") !== false) {
                        $jResult .= "plugin.loadLang();";
                    }
                }
                $jResult .= "\n";
            }
            $jResult .= $jEnd;
            $jResult .= "\n})();";
        }
        foreach ($disabled as $name => $pInfo) {
            $jResult .= "(function () { var plugin = new rPlugin( '" . $name . "'," . $pInfo["plugin.version"] . ",'" . $pInfo["plugin.author"] . "','" . $pInfo["plugin.description"] . "'," . $pInfo["perms"] . ",'" . $pInfo["plugin.help"] . "' );\n";
            $jResult .= "plugin.disable(); ";
            if ($pInfo["perms"] & $disabledByUser) {
                $jResult .= "plugin.unlaunch(); ";
            }
            $jResult .= "\n})();";
        }
        $jResult .= testRemoteRequests($remoteRequests);
        $theSettings->store();
    }
    closedir($handle);
}
cachedEcho($jResult, "application/javascript", true);
示例#3
0
                if (is_dir($path) && is_readable($path) && strpos(addslash($path), $topDirectory) === 0 && ($theSettings->uid < 0 || isUserHavePermission($theSettings->uid, $theSettings->gid, $path, 0x7))) {
                    $files[] = $file;
                }
            }
            closedir($dh);
            sort($files, SORT_STRING);
            $output["basedir"] = fullpath($dir);
            $output["dirlist"] = $files;
        }
    }
    if (in_array("channels", $modes) && $theSettings->isPluginRegistered('throttle')) {
        require_once '../throttle/throttle.php';
        $trt = rThrottle::load();
        $tnames = array();
        foreach ($trt->thr as $thr) {
            $tnames[] = $thr["name"];
        }
        $output["channels"] = $tnames;
    }
    if (in_array("ratios", $modes) && $theSettings->isPluginRegistered('ratio')) {
        require_once '../ratio/ratio.php';
        $rat = rRatio::load();
        $rnames = array();
        foreach ($rat->rat as $r) {
            $rnames[] = $r["name"];
        }
        $output["ratios"] = $rnames;
    }
}
cachedEcho(json_encode($output), "application/json");
示例#4
0
<?php

require_once 'unpack.php';
ignore_user_abort(true);
set_time_limit(0);
$ret = array();
if (isset($_REQUEST['cmd'])) {
    $cmd = $_REQUEST['cmd'];
    switch ($cmd) {
        case "set":
            $up = rUnpack::load();
            $up->set();
            cachedEcho($up->get(), "application/javascript");
            break;
        case "unpack":
            $up = rUnpack::load();
            $ret = $up->startTask($_REQUEST['hash'], $_REQUEST['dir'], $_REQUEST['mode'], $_REQUEST['no']);
            break;
    }
}
cachedEcho(json_encode($ret), "application/json");
示例#5
0
<?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");
示例#6
0
                            }
                        }
                        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' => '');
            }
        }
    }
}
cachedEcho(json_encode(array("errors" => $errors, "hash" => $hashes)), "application/json");
示例#7
0
            $settings["popup"] = $_REQUEST["popup"] ? 1 : 0;
            $settings["pm"] = $_REQUEST["pm"] ? 1 : 0;
            $settings["aInterval"] = $aInterval;
            $settings["iInterval"] = $iInterval;
            $settings["smileys"] = $_REQUEST["smileys"] ? 1 : 0;
            $settings["smileySet"] = $smileySet;
            $settings["format"] = $_REQUEST["format"];
            $settings["lastLine"] = $lastLine;
            if ($settings["pm"] && file_exists(getSettingsPath() . "/chat/nopm")) {
                if (!unlink(getSettingsPath() . "/chat/nopm")) {
                    $ret = "{ \"error\": theUILang.chatPMError }";
                }
            } elseif (!$settings["pm"]) {
                if (!touch(getSettingsPath() . "/chat/nopm")) {
                    $ret = "{ \"error\": theUILang.chatPMError }";
                }
            }
            $chat = new rChat();
            if (!$chat->set($settings)) {
                $ret = "{ \"error\": theUILang.chatSettingsSave }";
            } else {
                $ret = json_encode($chat->get());
            }
            break;
    }
}
if (empty($ret)) {
    $ret = "{ \"error\": theUILang.chatInvalidReq }";
}
cachedEcho($ret, "application/json");
示例#8
0
<?php

require_once 'Snoopy.class.inc';
require_once 'rtorrent.php';
set_time_limit(0);
if (isset($_REQUEST['result'])) {
    if (isset($_REQUEST['json'])) {
        cachedEcho('{ "result" : "' . $_REQUEST['result'][0] . '" }', "application/json");
    } else {
        $js = '';
        foreach ($_REQUEST['result'] as $ndx => $result) {
            $js .= 'noty("' . (isset($_REQUEST['name'][$ndx]) ? addslashes(rawurldecode($_REQUEST['name'][$ndx])) . ' - ' : '') . '"+theUILang.addTorrent' . $_REQUEST['result'][$ndx] . ',"' . ($_REQUEST['result'][$ndx] == 'Success' ? 'success' : 'error') . '");';
        }
        cachedEcho($js, "text/html");
    }
} else {
    $uploaded_files = array();
    $label = null;
    if (isset($_REQUEST['label'])) {
        $label = trim($_REQUEST['label']);
    }
    $dir_edit = null;
    if (isset($_REQUEST['dir_edit'])) {
        $dir_edit = trim($_REQUEST['dir_edit']);
        if (strlen($dir_edit) > 0 && !rTorrentSettings::get()->correctDirectory($dir_edit)) {
            $uploaded_files = array(array('status' => "FailedDirectory"));
        }
    }
    if (empty($uploaded_files)) {
        if (isset($_FILES['torrent_file'])) {
            if (is_array($_FILES['torrent_file']['name'])) {
示例#9
0
        if ($_REQUEST['tracker'] != "global") {
            $storage = "trackers/" . $_REQUEST['tracker'] . ".csv";
        }
    }
}
if (isset($_REQUEST['mode'])) {
    $mode = $_REQUEST['mode'];
    if ($mode == 'clear') {
        if (!$disableClearButton) {
            @unlink(getSettingsPath() . '/trafic/' . $storage);
        }
        if ($_REQUEST['tracker'] != "none") {
            $mode = 'day';
            $storage = "global.csv";
        }
    }
    $st = new rStat($storage);
    if ($mode == 'day') {
        $val = $st->getDay();
    } else {
        if ($mode == 'month') {
            $val = $st->getMonth();
        } else {
            if ($mode == 'year') {
                $val = $st->getYear();
            }
        }
    }
}
cachedEcho($val, "application/json");
示例#10
0
<?php

require_once '../../php/util.php';
eval(getPluginConf('geoip'));
require_once 'ip_db.php';
$db = new ipDB();
$db->add($_REQUEST["ip"], $_REQUEST["comment"]);
cachedEcho(json_encode(array("ip" => $_REQUEST["ip"], "comment" => $_REQUEST["comment"])), "application/json");
示例#11
0
    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(false)) {
            $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, false);
            if (!empty($result)) {
                $pos = strpos($result, "\r\n\r\n");
                if ($pos !== false) {
                    $result = substr($result, $pos + 4);
                }
                cachedEcho($result, "text/xml");
            }
        }
        break;
}
if (is_null($result)) {
    header("HTTP/1.0 500 Server Error");
    cachedEcho(isset($req) && $req->fault ? "Warning: XMLRPC call is failed." : "Link to XMLRPC failed. May be, rTorrent is down?", "text/html");
} else {
    cachedEcho(safe_json_encode($result), "application/json");
}
示例#12
0
            $item["description"] = formatItemDescription($torrent);
        }
        $items[] = $item;
    }
    usort($items, create_function('$a,$b', 'return( (intval($a["pubDate"]) > intval($b["pubDate"])) ? -1 : ((intval($a["pubDate"]) < intval($b["pubDate"])) ? 1 : strcmp($a["title"],$b["title"])) );'));
    foreach ($items as $item) {
        $ret .= "\r\n<item>";
        foreach ($item as $key => $val) {
            if ($key == "guid") {
                $ret .= "\r\n\t<guid isPermaLink=\"false\">" . $val . '</guid>';
            } else {
                if ($key == "pubDate") {
                    if (empty($val)) {
                        continue;
                    }
                    $ret .= "\r\n\t<pubDate>" . gmstrftime('%a, %d %b %Y %T %Z', $val) . '</pubDate>';
                } else {
                    if ($key == "description") {
                        $ret .= "\r\n\t<description><![CDATA[" . $val . ']]></description>';
                    } else {
                        $ret .= "\r\n\t<" . $key . '>' . htmlspecialchars($val, ENT_COMPAT, "UTF-8") . '</' . $key . '>';
                    }
                }
            }
        }
        $ret .= "\r\n</item>";
    }
}
ob_clean();
cachedEcho($ret . "</channel></rss>", "application/rss+xml", true);
示例#13
0
 /** Send torrent file to client
  * @param null|string name of the file (optional)
  * @return void script exit
  */
 public function send($filename = null)
 {
     if (is_null($filename)) {
         $filename = $this->info['name'] . '.torrent';
     }
     if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
         $filename = rawurlencode($filename);
     }
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     cachedEcho($this->__toString(), 'application/x-bittorrent', true);
 }
示例#14
0
<?php

require_once '../../php/util.php';
$quotafile = file_get_contents($topDirectory . "/.quotaspace");
$usedfile = file_get_contents($topDirectory . "/.useddiskspace");
$quota = (int) $quotafile * 1000 * 1000;
$used = (int) $usedfile * 1000 * 1000;
$free = $quota - $used;
cachedEcho('{ "total": ' . $quota . ', "free": ' . $free . ' }', "application/json");
示例#15
0
<?php

require_once 'cookies.php';
$cmd = '';
if (isset($_REQUEST['mode'])) {
    $cmd = $_REQUEST['mode'];
}
switch ($cmd) {
    case 'info':
        $cookies = rCookies::load();
        if (isset($_REQUEST['host'])) {
            cachedEcho(safe_json_encode($cookies->getCookiesForHost($_REQUEST['host'])), "application/json");
        } else {
            cachedEcho(safe_json_encode($cookies->getInfo()), "application/json");
        }
    case 'add':
        $cookies = rCookies::load();
        if (isset($_REQUEST['host'])) {
            $cookies->add($_REQUEST['host'], rawurldecode($_REQUEST['cookies']));
        }
        cachedEcho(safe_json_encode($cookies->getInfo()), "application/json");
    default:
        $cookies = new rCookies();
        $cookies->set();
        cachedEcho($cookies->get(), "application/javascript");
}
示例#16
0
require_once 'history.php';
if (isset($_REQUEST['cmd'])) {
    $cmd = $_REQUEST['cmd'];
    switch ($cmd) {
        case "set":
            $up = rHistory::load();
            $up->set();
            cachedEcho($up->get(), "application/javascript");
            break;
        case "get":
            $up = rHistoryData::load();
            cachedEcho(json_encode($up->get($_REQUEST['mark'])), "application/json");
            break;
        case "delete":
            $up = rHistoryData::load();
            $hashes = array();
            if (!isset($HTTP_RAW_POST_DATA)) {
                $HTTP_RAW_POST_DATA = file_get_contents("php://input");
            }
            if (isset($HTTP_RAW_POST_DATA)) {
                $vars = explode('&', $HTTP_RAW_POST_DATA);
                foreach ($vars as $var) {
                    $parts = explode("=", $var);
                    $hashes[] = $parts[1];
                }
                $up->delete($hashes);
            }
            cachedEcho(json_encode($up->get(0)), "application/json");
            break;
    }
}
 public function show()
 {
     $out = array('uh' => base64_encode(getUser()), 'list' => array());
     $out['list'] = $this->data;
     cachedEcho(json_encode($out));
 }
示例#18
0
<?php

require_once '../../php/xmlrpc.php';
if (!isset($HTTP_RAW_POST_DATA)) {
    $HTTP_RAW_POST_DATA = file_get_contents("php://input");
}
if (isset($HTTP_RAW_POST_DATA) && !preg_match("/(execute|import)\\s*=/i", $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");
    }
}
header("HTTP/1.0 500 Server Error");
cachedEcho("Link to XMLRPC failed. May be, rTorrent is down?", "text/html");
示例#19
0
<?php

require_once 'cpu.php';
$cpu = rCPU::load();
cachedEcho('{ "load": ' . $cpu->get() . ' }', "application/json");
示例#20
0
include 'xmlfix.php';
include 'conf.php';
include 'flm.class.php';
$e = new FLM();
switch ($e->postlist['action']) {
    case 'archive':
        $e->archive();
        break;
    case 'cp':
        $e->copy($e->userdir . $e->postlist['to']);
        break;
    case 'dl':
        $e->shout = FALSE;
        $sf = $e->workdir . $e->postlist['target'];
        if (!sendFile($sf, null, null, false)) {
            cachedEcho('log(theUILang.fErrMsg[6]+" - ' . $sf . ' / "+theUILang.fErrMsg[3]);', "text/html");
        }
        exit;
        break;
    case 'extract':
        $e->extract($e->postlist['target'], $e->postlist['to']);
        break;
    case 'getlog':
        $e->readlog($e->postlist['target'], $e->postlist['to']);
        break;
    case 'list':
        $e->dirlist();
        break;
    case 'kill':
        $e->kill($e->postlist['target']);
        break;
示例#21
0
<?php

require_once "../../php/util.php";
if (!isset($HTTP_RAW_POST_DATA)) {
    $HTTP_RAW_POST_DATA = file_get_contents("php://input");
}
$ret = array();
if (isset($HTTP_RAW_POST_DATA)) {
    $vars = explode('&', $HTTP_RAW_POST_DATA);
    foreach ($vars as $var) {
        $parts = explode("=", $var);
        if ($parts[0] == "hash") {
            $ret[] = $parts[1];
        }
    }
    if (count($ret)) {
        $fname = getTempDirectory() . 'rutorrent-prm-' . getUser() . time();
        file_put_contents($fname, serialize($ret));
        shell_exec(getPHP() . " -f " . escapeshellarg(dirname(__FILE__) . "/batch_check.php") . " " . escapeshellarg($fname) . " " . getUser() . " > /dev/null 2>&1 &");
        //		shell_exec( getPHP()." -f ".escapeshellarg(dirname( __FILE__)."/batch_check.php")." ".escapeshellarg($fname)." ".getUser()." > /tmp/1 2>/tmp/2 &" );
    }
}
cachedEcho('{}', "application/json");
示例#22
0
<?php

require_once './ratios.php';
cachedEcho(getRatiosStat(), "application/javascript");
示例#23
0
                        if (WAIT_AFTER_LOADING) {
                            sleep(WAIT_AFTER_LOADING);
                        }
                    }
                }
            }
            $mngr->saveHistory();
        }
        break;
}
if ($val === null) {
    $val = $mngr->get();
    $errorsReported = true;
}
if ($dataType == "text/xml") {
    cachedEcho('<?xml version="1.0" encoding="UTF-8"?><data><![CDATA[' . $val . ']]></data>', "text/xml", true, false);
} else {
    cachedEcho(safe_json_encode($val), $dataType, true, false);
}
ob_flush();
flush();
if (connection_aborted()) {
    if ($mngr->isErrorsOccured()) {
        $mngr->saveState(false);
    }
} else {
    if ($errorsReported && $mngr->hasErrors()) {
        $mngr->clearErrors();
        $mngr->saveState(false);
    }
}
示例#24
0
<?php

require_once "accounts.php";
$em = accountManager::load();
if ($em === false) {
    $em = new accountManager();
    $em->obtain("./accounts");
}
if (isset($_REQUEST['mode'])) {
    $cmd = $_REQUEST['mode'];
    switch ($cmd) {
        case "set":
            $em->set();
            cachedEcho($em->get(), "application/javascript");
            break;
        case "info":
            cachedEcho(safe_json_encode($em->getInfo()), "application/json");
            break;
    }
}
示例#25
0
<?php

require_once 'scheduler.php';
$sch = rScheduler::load();
$sch->set();
cachedEcho($sch->get(), "application/javascript");
示例#26
0
$mngr = rRatioRulesList::load();
$val = null;
switch ($cmd) {
    case "setrules":
        $mngr->set();
        break;
    case "checklabels":
        $hash = array();
        if (!isset($HTTP_RAW_POST_DATA)) {
            $HTTP_RAW_POST_DATA = file_get_contents("php://input");
        }
        if (isset($HTTP_RAW_POST_DATA)) {
            $vars = explode('&', $HTTP_RAW_POST_DATA);
            foreach ($vars as $var) {
                $parts = explode("=", $var);
                switch ($parts[0]) {
                    case "hash":
                        $hash[] = $parts[1];
                        break;
                }
            }
        }
        $mngr->checkLabels($hash);
        $val = array();
        break;
}
if (is_null($val)) {
    $val = $mngr->getContents();
}
cachedEcho(safe_json_encode($val), "application/json", true);
示例#27
0
<?php

require_once 'lookat.php';
$look = new rLook();
$look->set();
cachedEcho($look->get(), "application/javascript");
示例#28
0
    $req = new rXMLRPCRequest(new rXMLRPCCommand("f.get_frozen_path", array($_REQUEST['hash'], intval($_REQUEST['no']))));
    if ($req->success()) {
        $filename = $req->val[0];
        if ($filename == '') {
            $req = new rXMLRPCRequest(array(new rXMLRPCCommand("d.open", $_REQUEST['hash']), new rXMLRPCCommand("f.get_frozen_path", array($_REQUEST['hash'], intval($_REQUEST['no']))), new rXMLRPCCommand("d.close", $_REQUEST['hash'])));
            if ($req->success()) {
                $filename = $req->val[1];
            }
        }
        $out = '<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
	<trackList>
	<track>
		<title>' . basename($filename) . '</title>
		<location>' . SCHEME . '://' . $auth . $_SERVER['HTTP_HOST'] . dirname($_SERVER['DOCUMENT_URI']) . '/plugins/stream/stream.php?f=' . urlencode($filename) . '</location>
	</track>
	</trackList>
</playlist>';
        header("Content-type: application/vlc");
        header('Content-Disposition: attachment; filename="' . basename($filename) . '.xspf"');
        header("Content-Length: " . strlen($out));
        echo $out;
        exit;
    }
}
if (isset($_REQUEST['readable'])) {
    cachedEcho("Cant retrieve such large file, sorry", "text/html");
} else {
    header("HTTP/1.0 302 Moved Temporarily");
    header("Location: " . $_SERVER['PHP_SELF'] . '?result=0');
}
示例#29
0
<?php

require_once '../../php/util.php';
require_once '../../php/settings.php';
eval(getPluginConf('diskspace'));
cachedEcho('{ "total": ' . disk_total_space($partitionDirectory) . ', "free": ' . disk_free_space($partitionDirectory) . ' }', "application/json");
示例#30
0
                        if ($parts[0] == "move_fastresume") {
                            $move_fastresume = trim($parts[1]);
                        }
                    }
                }
            }
        }
    }
    Debug("");
    Debug("--- begin ---");
    Debug($datadir);
    Debug("\"" . ($move_addpath == '0' ? "don't " : "") . "add path\"" . ", \"" . ($move_datafiles == '0' ? "don't " : "") . "move files\"" . ", \"" . ($move_fastresume == '0' ? "don't " : "") . "fast resume\"");
    if ($hash && strlen($datadir) > 0) {
        $script_dir = rtAddTailSlash(dirname(__FILE__));
        $php = getPHP();
        Debug("script dir  : " . $script_dir);
        Debug("path to php : " . $php);
        Debug("hash        : " . $hash);
        Debug("data dir    : " . $datadir);
        Debug("add path    : " . $move_addpath);
        Debug("move files  : " . $move_datafiles);
        Debug("fast resume : " . $move_fastresume);
        $res = rtExec("execute", array("sh", "-c", escapeshellarg($php) . " " . escapeshellarg($script_dir . "setdir.php") . " " . $hash . " " . escapeshellarg($datadir) . " " . $move_addpath . " " . $move_datafiles . " " . $move_fastresume . " " . escapeshellarg(getUser()) . " & exit 0"), $datadir_debug_enabled);
        if (!$res) {
            $errors[] = array('desc' => "theUILang.datadirSetDirFail", 'prm' => $datadir);
        }
    }
}
Debug("--- end ---");
cachedEcho(safe_json_encode(array("errors" => $errors)), "application/json");