Commit e11e175f authored by Gabor Hudiczius's avatar Gabor Hudiczius
Browse files

rtwi-070821

parents
requirements:
-rtorrent 0.7.7
-some webserver
-php5, with the following extensions:
-xsl
-xmlrpc
installation:
-open the includes/config.php.inc, and edit the next lines:
-$abs_path
-$domain
-$subdomain
-$site_path
-$include_path (if you move the includes directory)
-if your php interpreter does not handle .html files (only .php) set the $default_ext variable to "php", and rename the index.html to index.php
-open .rtorrent.rc, and edit them (for each user)
-add this line to your .rtorrent.rc "scgi_port = 127.0.0.1:12345" where 12345 can be replaced by your choice, and restart rtorrent
-if you have more than one user, set a different port for each user's .rtorrent.rc file
-adding users:
-find row 44, and change it:
-replace "username" with the actual linux username
-replace "sha1has of the password" with thre hash of the choosen password for the webui (you can generate the sha1 hash here => http://www.johnmaguire.us/tools/hashcalc/index.php)
-replace "36100", with the port, you've set in the .rtorrent.rc file
-if you have more than one user, you have to do these steps, for each one of them, sop you'll get something like this:
$users = array(
"user1" => array( "pass" => "1234567890abcdef1234567890abcdef12345678", "port" => "12345" ),
"user2" => array( "pass" => "1234567890abcdef1234567890abcdef12345678", "port" => "12346" ),
"user3" => array( "pass" => "1234567890abcdef1234567890abcdef12345678", "port" => "12347" ),
);
-all users, using this webui will need an "!rtwi_files" directory into their download directory (set by "directory = some/path" in the .rtorrent.rc) with 0777 rights
bug reports, whishlist, suggestions, anything: ghudiczius@gmail.com
p.s.: sorry, for this loosy manual, and my even worse english :)
\ No newline at end of file
<?php
class bittorrent_handler {
var $bt_data;
var $bt_content;
function __construct( $bt_data, $bt_content ) {
$this->bt_data = $bt_data;
$this->bt_content = $bt_content;
}
private function encode_string( $content ) {
$len = strlen( $content );
$ret = "{$len}:{$content}";
return $ret;
}
private function encode_integer( $content ) {
$ret = "i{$content}e";
return $ret;
}
private function encode_list( $content ) {
$ret = "l";
foreach ( $content as $val ) {
$ret .= $this->encode( $val );
}
$ret .= "e";
return $ret;
}
private function encode_dictionary( $content ) {
$ret = "d";
$keys = array_keys( $content );
sort( $keys );
foreach ( $keys as $val ) {
$value = $content[$val];
$ret .= $this->encode_string( $val );
$ret .= $this->encode( $value );
}
$ret .= "e";
return $ret;
}
private function encode( $content ) {
if ( is_array( $content ) && isset( $content["type"] ) && isset( $content["value"] ) ) {
$value = $content["value"];
switch ( $content["type"] ) {
case "string" : {
$ret = $this->encode_string( $value );
break;
}
case "integer" : {
$ret = $this->encode_integer( $value );
break;
}
case "list" : {
$ret = $this->encode_list( $value );
break;
}
case "dictionary" : {
$ret = $this->encode_dictionary( $value );
break;
}
default : {
$ret = "XX";
break;
}
}
} else {
$ret = "";
}
return $ret;
}
private function decode_list( $data ) {
$len = strlen( $data );
$i = 1;
$value = array();
$text = "l";
for (;;) {
if ( $i >= $len )
return;
if ( $data[$i] == "e" )
break;
$ret = $this->decode( substr( $data, $i ) );
if ( !isset( $ret ) || !is_array( $ret ) )
return;
$value[] = $ret;
$i += $ret["strlen"];
$text .= $ret["string"];
}
$text .= "e";
$ret = array( "type" => "list", "value" => $value, "strlen" => strlen( $text ), "string" => $text );
return $ret;
}
private function decode_dictionary( $data ) {
$len = strlen( $data );
$i = 1;
$value = array();
$text = "d";
for ( ; ; ) {
if ( $i < $len ) {
if ( $data[$i] == "e" ) {
break;
} else {
$ret = $this->decode( substr( $data, $i ) );
if ( isset( $ret ) && is_array( $ret ) && $ret["type"] == "string" ) {
$subval = $ret["value"];
$i += $ret["strlen"];
$text .= $ret["string"];
if ( $i < $len ) {
$ret = $this->decode( substr( $data, $i ) );
if ( isset( $ret ) && is_array( $ret ) ) {
$value[$subval] = $ret;
$i += $ret["strlen"];
$text .= $ret["string"];
}
}
}
}
}
}
$text .= "e";
$ret = array( "type" => "dictionary", "value" => $value, "strlen" => strlen( $text ), "string" => $text );
return $ret;
}
private function decode( $data ) {
switch ( $data[0] ) {
case "l" : {
$ret = $this->decode_list( $data );
break;
}
case "d" : {
$ret = $this->decode_dictionary( $data );
break;
}
default : {
if ( preg_match( "/^(\d+):/", $data, $match ) ) {
$valuelen = $match[1];
$headlen = strlen( $valuelen ) + 1;
$value = substr( $data, $headlen, $valuelen );
$text = substr( $data, 0, $headlen + $valuelen );
if ( strlen( $value ) == $valuelen ) {
$ret = array( "type" => "string", "value" => $value, "strlen" => strlen( $text ), "string" => $text );
} else {
$ret = "";
}
} elseif ( preg_match( "/^i(\d+)e/", $data, $match ) ) {
$value = $match[1];
$text = "i{$value}e";
if ( $value !== "-0" && ( $value[0] != "0" || strlen( $value ) == 1 ) ) {
$ret = array( "type" => "integer", "value" => $value, "strlen" => strlen( $text ), "string" => $text );
} else {
$ret = "";
}
} else {
$ret = "";
}
break;
}
}
return $ret;
}
function decode_data() {
$this->bt_content = $this->decode( $this->bt_data );
}
function encode_content() {
$this->bt_data = $this->encode( $this->bt_content );
}
function fetch_data() {
return $this->bt_data;
}
function fetch_content() {
return $this->bt_content;
}
}
?>
<?php
class page_handler {
var $content;
var $page_data;
var $main_file;
var $theme;
var $xml_data;
function __construct( $theme, $main_file, $page_data ) {
$this->page_data = $page_data;
$this->main_file = $main_file;
$this->theme = $theme;
}
function parse() {
$xsl = new DOMDocument;
$xsl->load( "themes/{$this->theme}/{$this->main_file}" );
$this->content = new XSLTprocessor();
$this->content->importStyleSheet( $xsl );
//print $this->page_data->saveXML(); exit;
$this->xml_data = $this->content->transformToXML( $this->page_data );
}
function fetch() {
$this->xml_data = preg_replace( "/\<\?xml( version=\"[\d\.]+\")*( encoding=\".*\")*\?\>[\\r\\n]*/", "", $this->xml_data );
$this->xml_data = preg_replace( "/\<\!\[CDATA\[(.*?)\]\]\>/", "\r\n\\1", $this->xml_data );
return $this->xml_data;
}
}
?>
<?php
/*******************************
* path settings
*******************************/
// default extension for php files (html/php)
$default_ext = "html";
// paths
$abs_path = "/var/www"; // webroot (with heading slash)
$domain = "cyla.homelinux.net"; // site domain (or ip)
$subdomain = "rtwi"; // subdomain (if exists)
$site_path = "/"; // site path (with heading and trailing slash)
$include_path = "includes"; // include path (include files can be found here)
// URLs
$url = array(
"base" => "http://{$subdomain}.{$domain}{$site_path}", // base url (if you do not have a subdomain, you might want to edit this line)
"index" => "index.{$default_ext}", // index page
"input" => "input.php", // input file (for forms)
);
$url["full"] = "{$url["base"]}/index.{$default_ext}"; // absolute url, of the index page
/*******************************
* xmlrpc settings
*******************************/
$xmlrpc_array = array(
"host" => "127.0.0.1", // ip address of the rtorrent
"port" => 0, // scgi port - we will set this depending on the user's settings
"timeout" => 10, // connection timeout
);
/*******************************
* user settings
*******************************/
// home directories (with heading and trailing slash)
$home_path = "/home/";
// array of users, each, with the sha1 hash of the password, and the scgi port of the rtorrent
$users = array(
"username" => array( "pass" => "sha1has of the password", "port" => "36100" ),
);
/*******************************
* other settings
*******************************/
// language (only english is available atm)
$lang = "en";
// site theme (look for themes in the "themes" directory)
$site_theme = "default_ajax";
?>
<?php
$message = array(
"badlogin" => "Username or password is incorrect",
"succlogin" => "You have been logged in successfully",
"succlogout" => "You have been logged out successfully",
"nohashfound" => "No torrents found for this hash",
"noidfound" => "No id was given",
"notanurl" => "Not valid URL was given",
"notrtfdircreated" => "You MUST have an \"!rtwi_files\" (without quotes) directory with 0777 rights in your rTorrent download directory",
"notrtfdirwriteright" => "The \"!rtwi_files\" directory in your rTorrent download directory MUST have 0777 rights",
"badrtdirectory" => "rTorrent download directry is not set correctly",
"badatpath" => "Invalid path was given",
"novaluefound" => "No value was given",
"badvaluefound" => "Bad value was given",
"nopriorityfound" => "No priority was given",
"badpriorityfound" => "Bad priority was given",
"badviewtype" => "Bad view was given",
"badrefreshrate" => "Bad refresh rate was given",
"succtorrentload" => "Torrent loaded",
"succtorrentstart" => "Torrent started",
"succtorrentopen" => "Torrent opened",
"succtorrentstop" => "Torrent stopped",
"succtorrentclose" => "Torrent closed",
"succtorrentcheckhash" => "Torrent hash check started",
"succtorrenterase" => "Torrent erased",
"succprioritychange" => "Torrent priority changed",
"succfileprioritychange" => "File priority changed",
"succtrackerenabledchange" => "Tracker availablity changed",
"succviewchange" => "View changed",
"succrefreshchange" => "Refresh rate changed",
"viewtype_main" => "Main",
"viewtype_name" => "Name",
"viewtype_started" => "Started",
"viewtype_stopped" => "Stopped",
"viewtype_complete" => "Complete",
"viewtype_incomplete" => "Incomplete",
"viewtype_hashing" => "Hashing",
"viewtype_seeding" => "Seeding",
"refreshrate_0" => "Off",
"refreshrate_5" => "5 secs",
"refreshrate_10" => "10 secs",
"refreshrate_30" => "30 secs",
"refreshrate_60" => "1 minute",
"refreshrate_120" => "2 minutes",
"refreshrate_180" => "3 minutes",
"refreshrate_300" => "5 minutes",
"refreshrate_600" => "10 minutes",
"refreshrate_1200" => "20 minutes",
"refreshrate_1800" => "30 minutes",
"refreshrate_3600" => "1 hour",
"no" => "No",
"yes" => "Yes",
"d_connection_current_leech" => "Leeching",
"d_connection_current_seed" => "Seeding",
"d_ignore_commands_0" => "Not ignoring commands",
"d_ignore_commands_1" => "Ignoring commands",
"d_is_active_0" => "Stopped",
"d_is_active_1" => "Started",
"d_is_hash_checked_0" => "Hash not checked",
"d_is_hash_checked_1" => "Hash checked",
"d_is_multi_file_multi" => "Multi",
"d_is_multi_file_single" => "Single",
"d_is_open_0" => "Closed",
"d_is_open_1" => "Open",
"d_complete_0" => "Incomplete",
"d_complete_1" => "Completed",
"d_hashing_0" => "Not hashing",
"d_hashing_1" => "Normal hashing",
"d_hashing_2" => "Download finished, hashing",
"d_hashing_3" => "Re-hashing",
"d_priority_0" => "Off",
"d_priority_1" => "Low",
"d_priority_2" => "Normal",
"d_priority_3" => "High",
"d_state_0" => "Stopped",
"d_state_1" => "Started",
"f_is_open_0" => "Closed",
"f_is_open_1" => "Open",
"f_priority_0" => "Off",
"f_priority_1" => "Normal",
"f_priority_2" => "High",
"safe_sync_0" => "No",
"safe_sync_1" => "Yes",
"t_enabled_0" => "Disabled",
"t_enabled_1" => "Enabled",
"t_is_open_0" => "Closed",
"t_is_open_1" => "Open",
"t_type_1" => "TCP",
"t_type_2" => "UDP",
"pics" => "rTWi - The rTorrent Web interface",
);
$label = array(
"title" => "rTWi - The rTorrent Web interface",
"description" => "rTWi - The rTorrent Web interface",
"keywords" => "rTWi - The rTorrent Web interface",
"author" => "Gabor Hudiczius",
"mailto" => "ghudiczius@gmail.com?subject=rTWi - The rTorrent Web interface",
"torrents" => "Torrents",
"peerlist" => "Peer list",
"info" => "Info",
"filelist" => "File list",
"trackerlist" => "Tracker list",
"chunksseen" => "Chunks seen",
"transferlist" => "Transfer list",
"addtorrent" => "Add torrent",
"logout" => "Logout",
"clicktohide" => "Click to hide",
"clicktoopen" => "Click to open",
"openfrom" => "Open from",
"fileupload" => "File upload",
"url" => "URL",
"torrentfile" => "Torrent file",
"torrenturl" => "Torrent URL",
"starttorrent" => "Start torrent",
"starttorrentafteradded" => "Start torrent after added",
"downloadto" => "Download to",
"throttle" => "Throttle",
"off" => "off",
"uploadlimit" => "Upload limit",
"nouploadlimit" => "No upload limit",
"downloadlimit" => "Download limit",
"nodownloadlimit" => "No download limit",
"rate" => "Rate",
"view" => "View",
"selectviewtype" => "Select view type",
"refresh" => "Refresh",
"selectrefreshrate" => "Select refresh rate",
);
?>
\ No newline at end of file
<?php
function getmicrotime() {
list( $usec, $sec ) = explode( " ", microtime() );
return ( ( float ) $usec + ( float ) $sec );
}
?>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
function loadcontent( hash, page ) {
var xmlHttp;
try {
xmlHttp = new XMLHttpRequest();
}
catch ( e ) {
try {
xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP" );
}
catch ( e ) {
try {
xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
} catch ( e ) {
alert( "Your browser does not support AJAX!" );
return false;
}
}
}
xmlHttp.onreadystatechange = function() {
switch ( xmlHttp.readyState ) {
case 0 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 0;
break;
}
case 1 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 'Requesting...';
break;
}
case 2 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 2;
break;
}
case 3 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 'Processing...';
break;
}
case 4 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = xmlHttp.responseText;
break;
}
default : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = '.';
break;
}
}
}
xmlHttp.open( 'GET', '?mod=torrent&hash=' + hash + '&page=' + page + '&ajax=true', true );
xmlHttp.send( null );
}
function loadcontent_filepriority( iurl, hash, id, filepriority ) {
var xmlHttp;
try {
xmlHttp = new XMLHttpRequest();
}
catch ( e ) {
try {
xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP" );
}
catch ( e ) {
try {
xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
} catch ( e ) {
alert( "Your browser does not support AJAX!" );
return false;
}
}
}
xmlHttp.onreadystatechange = function() {
switch ( xmlHttp.readyState ) {
case 0 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 0;
break;
}
case 1 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 'Requesting...';
break;
}
case 2 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 2;
break;
}
case 3 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = 'Processing...';
break;
}
case 4 : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = xmlHttp.responseText;
break;
}
default : {
document.getElementById( 'torrent_' + hash + '_content' ).innerHTML = '.';
break;
}
}
}
xmlHttp.open( 'GET', iurl + '?mod=changefilepriority&hash=' + hash + '&id=' + id + '&filepriority=' + filepriority + '&ajax=true', true );
xmlHttp.send( null );
}
function loadcontent_trackerenabled( iurl, hash, id, trackerenabled ) {
var xmlHttp;
try {
xmlHttp = new XMLHttpRequest();
}
catch ( e ) {
try {
xmlHttp = new Active