コード例 #1
0
 public function obtain()
 {
     if (function_exists('posix_geteuid') && function_exists('posix_getegid')) {
         $this->myuid = posix_geteuid();
         $this->mygid = posix_getegid();
     } else {
         $randName = '/tmp/rutorrent-' . rand() . '.tmp';
         @file_put_contents($randName, '');
         $ss = @stat($randName);
         if ($ss) {
             $this->mygid = $ss['gid'];
             $this->myuid = $ss['uid'];
             @unlink($randName);
         }
     }
     $req = new rXMLRPCRequest(new rXMLRPCCommand("to_kb", floatval(1024)));
     if ($req->run()) {
         $this->linkExist = true;
         if (!$req->fault) {
             $this->badXMLRPCVersion = false;
         }
         $req = new rXMLRPCRequest(array(new rXMLRPCCommand("get_directory"), new rXMLRPCCommand("get_session"), new rXMLRPCCommand("system.client_version"), new rXMLRPCCommand("system.library_version"), new rXMLRPCCommand("set_xmlrpc_size_limit", 67108863)));
         if ($req->run() && !$req->fault) {
             $this->directory = $req->val[0];
             $this->session = $req->val[1];
             $this->version = $req->val[2];
             $this->libVersion = $req->val[3];
             $parts = explode('.', $this->version);
             $this->iVersion = 0;
             for ($i = 0; $i < count($parts); $i++) {
                 $this->iVersion = ($this->iVersion << 8) + $parts[$i];
             }
             if (is_dir($this->session) && isLocalMode()) {
                 $ss = @stat($this->session . 'rtorrent.lock');
                 if (!$ss) {
                     $ss = @stat($this->session . 'rtorrent.dht_cache');
                 }
                 if (!$ss) {
                     $ss = @stat($this->session);
                 }
                 if ($ss) {
                     $this->gid = $ss['gid'];
                     $this->uid = $ss['uid'];
                     if (!empty($this->directory) && $this->directory[0] == '~') {
                         if (function_exists('posix_getpwuid')) {
                             $ui = posix_getpwuid($this->uid);
                             $this->directory = $ui["dir"] . substr($this->directory, 1);
                         } else {
                             $req = new rXMLRPCRequest(new rXMLRPCCommand("execute_capture", array("echo", "~")));
                             if ($req->run() && !$req->fault) {
                                 $this->directory = trim($req->val[0]) . substr($this->directory, 1);
                             }
                         }
                     }
                 }
             }
             $this->store();
         }
     }
 }
コード例 #2
0
    if (LFS::is_file($dir) && ($theSettings->uid < 0 || isUserHavePermission($theSettings->uid, $theSettings->gid, $dir, 0x4))) {
        $curFile = basename($dir);
        $dir = dirname($dir);
    }
    if (is_dir($dir)) {
        $dh = @opendir($dir);
        $dir = addslash($dir);
        if ($dh && (strpos($dir, $topDirectory) !== 0 || $theSettings->uid >= 0 && !isUserHavePermission($theSettings->uid, $theSettings->gid, $dir, 0x5))) {
            closedir($dh);
            $dh = false;
        }
    }
}
if (!$dh) {
    $curFile = null;
    $dir = isLocalMode() ? $theSettings->directory : $topDirectory;
    if (strpos(addslash($dir), $topDirectory) !== 0) {
        $dir = $topDirectory;
    }
    $dh = @opendir($dir);
}
$files = array();
$dirs = array();
if ($dh) {
    $dir = addslash($dir);
    while (false !== ($file = readdir($dh))) {
        $path = fullpath($dir . $file);
        if ($file == ".." && $dir == $topDirectory) {
            continue;
        }
        if (is_dir($path) && is_readable($path) && strpos(addslash($path), $topDirectory) === 0 && ($theSettings->uid < 0 || isUserHavePermission($theSettings->uid, $theSettings->gid, $path, 0x5))) {
コード例 #3
0
ファイル: getplugins.php プロジェクト: PreK/ruTorrent
         $disabled[$file] = $info;
         continue;
     }
     foreach ($info['rtorrent.php.error'] as $external) {
         $fname = $rootPath . '/plugins/' . $file . '/' . $external;
         @chmod($fname, $profileMask & 0644);
         if (!isUserHavePermission($theSettings->uid, $theSettings->gid, $fname, 0x4)) {
             $jResult .= "noty('" . $file . ": '+theUILang.rTorrentBadPHPScriptPath+' ('+'" . $fname . "'+').','error');";
             $extError = true;
         }
     }
     if ($extError) {
         $disabled[$file] = $info;
         continue;
     }
     if (!isLocalMode()) {
         if ($info["rtorrent.remote"] == "error") {
             $jResult .= "noty('" . $file . ": '+theUILang.errMustBeInSomeHost,'error');";
             $disabled[$file] = $info;
             continue;
         }
         if ($do_diagnostic && $info["rtorrent.remote"] == "warning") {
             $jResult .= "noty('" . $file . ": '+theUILang.warnMustBeInSomeHost,'error');";
         }
     }
 }
 if ($do_diagnostic) {
     if ($theSettings->linkExist) {
         foreach ($info['rtorrent.external.warning'] as $external) {
             findRemoteEXE($external, "noty('" . $file . ": '+theUILang.rTorrentExternalNotFoundWarning+' ('+'" . $external . "'+').','error');", $remoteRequests);
         }
コード例 #4
0
        if (isset($request['comment'])) {
            $comment = trim($request['comment']);
            if (strlen($comment)) {
                $torrent->comment($comment);
            }
        }
        if ($request['private']) {
            $torrent->is_private(true);
        }
        $fname = rTask::formatPath($taskNo) . '/result.torrent';
        $torrent->save($fname);
        if ($request['start_seeding']) {
            $fname = getUniqueUploadedFilename($torrent->info['name'] . '.torrent');
            $path_edit = trim($request['path_edit']);
            if (is_dir($path_edit)) {
                $path_edit = addslash($path_edit);
            }
            if (rTorrentSettings::get()->correctDirectory($path_edit)) {
                $path_edit = dirname($path_edit);
                if ($resumed = rTorrent::fastResume($torrent, $path_edit)) {
                    $torrent = $resumed;
                }
                $torrent->save($fname);
                rTorrent::sendTorrent($torrent, true, true, $path_edit, null, true, isLocalMode());
                @chmod($fname, $profileMask & 0666);
            }
        }
        exit(0);
    }
    exit(1);
}
コード例 #5
0
ファイル: conf.php プロジェクト: NetOverflow/ruTorrent
<?php

$diskUpdateInterval = 10;
// in seconds
$notifySpaceLimit = 512;
// in Mb
// If we run locally && we the download directory seems to exists
if (isLocalMode() && rTorrentSettings::get()->linkExist && file_exists(rTorrentSettings::get()->directory)) {
    $partitionDirectory = rTorrentSettings::get()->directory;
    // Then we can show the disk space of the download directory
} else {
    $partitionDirectory =& $topDirectory;
    // Else, we show $topDirectory by default as fallback
}
コード例 #6
0
ファイル: settings.php プロジェクト: chaitanya11/rtorrent
 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();
             }
         }
     }
 }
コード例 #7
0
ファイル: rtorrent.php プロジェクト: NetOverflow/ruTorrent
 public static function sendTorrent($fname, $isStart, $isAddPath, $directory, $label, $saveTorrent, $isFast, $isNew = true, $addition = null)
 {
     $hash = false;
     $torrent = is_object($fname) ? $fname : new Torrent($fname);
     if (!$torrent->errors()) {
         if ($isFast && ($resume = self::fastResume($torrent, $directory, $isAddPath))) {
             $torrent = $resume;
         } else {
             if ($isNew) {
                 if (isset($torrent->{'libtorrent_resume'})) {
                     unset($torrent->{'libtorrent_resume'});
                 }
             }
         }
         if ($isNew) {
             if (isset($torrent->{'rtorrent'})) {
                 unset($torrent->{'rtorrent'});
             }
         }
         $raw_value = base64_encode($torrent->__toString());
         $filename = is_object($fname) ? $torrent->getFileName() : $fname;
         if (strlen($raw_value) < self::RTORRENT_PACKET_LIMIT || is_null($filename) || !isLocalMode()) {
             $cmd = new rXMLRPCCommand($isStart ? 'load_raw_start' : 'load_raw');
             $cmd->addParameter($raw_value, "base64");
             if (!is_null($filename) && !$saveTorrent) {
                 @unlink($filename);
             }
         } else {
             $cmd = new rXMLRPCCommand($isStart ? 'load_start' : 'load');
             $cmd->addParameter($filename);
         }
         if (!is_null($filename) && rTorrentSettings::get()->iVersion >= 0x805) {
             $cmd->addParameter(getCmd("d.set_custom") . "=x-filename," . rawurlencode(getFileName($filename)));
         }
         $req = new rXMLRPCRequest();
         if ($directory && strlen($directory) > 0) {
             if (!rTorrentSettings::get()->correctDirectory($directory)) {
                 return false;
             }
             $req->addCommand(new rXMLRPCCommand('execute', array('mkdir', '-p', $directory)));
             $cmd->addParameter(($isAddPath ? getCmd("d.set_directory=") . "\"" : getCmd("d.set_directory_base=") . "\"") . $directory . "\"");
         }
         $comment = $torrent->comment();
         if ($comment) {
             if (isInvalidUTF8($comment)) {
                 $comment = win2utf($comment);
             }
             if (strlen($comment) > 0) {
                 $comment = "VRS24mrker" . rawurlencode($comment);
                 if (strlen($comment) <= 4096) {
                     $cmd->addParameter(getCmd("d.set_custom2=") . $comment);
                 }
             }
         }
         if ($label && strlen($label) > 0) {
             $label = rawurlencode($label);
             if (strlen($label) <= 4096) {
                 $cmd->addParameter(getCmd("d.set_custom1=") . $label);
             }
         }
         if (is_array($addition)) {
             foreach ($addition as $key => $prm) {
                 $cmd->addParameter($prm, 'string');
             }
         }
         $req->addCommand($cmd);
         if ($req->run() && !$req->fault) {
             $hash = $torrent->hash_info();
         }
     }
     return $hash;
 }
コード例 #8
0
ファイル: init.php プロジェクト: NetOverflow/ruTorrent
<?php

eval(getPluginConf($plugin["name"]));
$st = getSettingsPath();
makeDirectory(array($st . '/rss', $st . '/rss/cache'));
$needStart = isLocalMode() && $theSettings->linkExist;
if ($needStart) {
    require_once $rootPath . '/plugins/rss/rss.php';
    $mngr = new rRSSManager();
    if ($mngr->setHandlers()) {
        $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]);
    } else {
        $jResult .= "plugin.disable(); noty('rss: '+theUILang.pluginCantStart,'error');";
    }
} else {
    $theSettings->registerPlugin($plugin["name"], $pInfo["perms"]);
}