Exemplo n.º 1
0
function do_list($dir, $type)
{
    $output = rtorrent_xmlrpc('execute_capture', array('find', $dir, '-mindepth', '1', '-maxdepth', '1', '-type', $type));
    if ($output === false) {
        return false;
    }
    $output = trim($output, "\n");
    if ($output === '') {
        return array();
    }
    $to_return = explode("\n", $output);
    // The find command prefixes its output as follows:
    // find /dir   -> /dir/
    // find /dir/  -> /dir/
    // find /dir// -> /dir//
    $to_remove = substr($dir, strlen($dir) - 1, 1) == '/' ? $dir : $dir . '/';
    for ($i = 0; $i < count($to_return); $i++) {
        $to_return[$i] = rtrim(substr($to_return[$i], strlen($to_remove)), '/');
    }
    natcasesort($to_return);
    return $to_return;
}
Exemplo n.º 2
0
/** rtorrent_xmlrpc_cached
 *
 * rtorrent_xmlrpc() with caching.
 * TODO: rename?
 */
function rtorrent_xmlrpc_cached($command)
{
    if (!is_array($_SESSION['rpc_cache'])) {
        $_SESSION['rpc_cache'] = array();
    }
    if (!$_SESSION['rpc_cache'][$command]) {
        $_SESSION['rpc_cache'][$command] = rtorrent_xmlrpc($command);
    }
    return $_SESSION['rpc_cache'][$command];
}
Exemplo n.º 3
0
        //     - $r_newdir exists but is not a directory, OR:
        //     - $r_newdir does not exist but moving to it fails
        //  - neither $old_path nor $r_newdir exist (??)
        rtorrent_xmlrpc('execute', array('mv', '-u', $old_path, "{$r_newdir}/"));
        rtorrent_xmlrpc('d.set_directory', array($r_hash, $r_newdir));
        rtorrent_xmlrpc('d.check_hash', array($r_hash));
    }
}
switch ($r_cmd) {
    case 'stop':
        $response = do_xmlrpc(xmlrpc_encode_request('d.stop', array($r_hash)));
        break;
    case 'start':
        $response = do_xmlrpc(xmlrpc_encode_request('d.start', array($r_hash)));
        break;
    case 'delete':
    case 'purge':
        if ($r_cmd == 'purge') {
            $path = rtorrent_xmlrpc('d.get_base_path', array($r_hash));
            $response = rtorrent_xmlrpc('execute', array('rm', '-r', $path));
        }
        $response = do_xmlrpc(xmlrpc_encode_request('d.erase', array($r_hash)));
        break;
    case 'hashcheck':
        $response = do_xmlrpc(xmlrpc_encode_request('d.check_hash', array($r_hash)));
        break;
}
if (!$r_ajax) {
    $hash = $r_tab ? "#{$r_tab}" : '';
    @header('Location: ' . $_SERVER['HTTP_REFERER'] . $hash);
}
Exemplo n.º 4
0
//  You should have received a copy of the GNU General Public License
//  along with rtGui.  If not, see <http://www.gnu.org/licenses/>.
require_once 'config.php';
require_once 'functions.php';
rtgui_session_start();
extract($_REQUEST, EXTR_PREFIX_ALL, 'r');
if ($r_operation == 'save_settings') {
    set_user_setting('refresh_interval', $r_set_refresh);
    rtorrent_xmlrpc('set_upload_rate', array($r_set_max_up));
    rtorrent_xmlrpc('set_download_rate', array($r_set_max_down));
    set_user_setting('theme', $r_set_theme);
    set_user_setting('use_dialogs', $r_set_use_dialogs ? 'yes' : 'no');
    set_user_setting('show_hidden', $r_set_show_hidden ? 'yes' : 'no');
}
$download_cap = rtorrent_xmlrpc('get_download_rate');
$upload_cap = rtorrent_xmlrpc('get_upload_rate');
if (isset($r_submit)) {
    if ($r_dialog) {
        echo <<<JS
<script type="text/javascript">
window.top.reloadUserSettings();
window.top.hideDialog(true);
</script>
JS;
    } else {
        header('Location: .');
    }
    die;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Exemplo n.º 5
0
function smooth_pliers($params)
{
    return !@xmlrpc_is_fault(rtorrent_xmlrpc('execute', $params, true));
}