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

rtwi-0.3.0-080216

parent a7a1edb6
requirements:
-rtorrent 0.8.0, compiled with "--with-xmlrpc-c"
-xmlrpc >= 1.07
-some webserver
-php5, with the following extensions:
-xsl (libxslt1.1)
-xmlrpc
installation:
you might need the following packages: make, libcurl-openssl-dev, pkg-config, sigc++-2.0-dev, libncurses-dev
to install xmlrpc, get the source from here: http://sourceforge.net/project/showfiles.php?group_id=16847
in my case, i could only compile the 1.11.00 version (due to a known bug, you may try to configure with --disable-cplusplus, if the compiling stops with some syntax error)
of course, you can try any version, over 1.07 (or any version over 1.00, but you'll get incorrect data for values bigger than 2^31-1, since it does not support 64bit integers)
follow the next steps, as root (this step is not needed, if you're upgrading from a pervious version):
cd /usr/src
wget http://dfn.dl.sourceforge.net/sourceforge/xmlrpc-c/xmlrpc-c-1.11.00.tgz
tar xvf xmlrpc-c-1.11.00.tgz
cd xmlrpc-c-1.11.00
./configure --disable-cplusplus
make
make install
to install libtorrent, follow the next steps, as root:
mkdir /usr/src/libtorrent
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.0.tar.gz
tar xvf libtorrent-0.12.0.tar.gz
cd /usr/src/libtorrent-0.12.0
./configure
make
make install
to install rtorrent, follow the next steps, as root:
mkdir /usr/src/rtorrent
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.0.tar.gz
tar xvf rtorrent-0.8.0.tar.gz
cd /usr/src/rtorrent-0.8.0
./configure --with-xmlrpc-c
make
make install
-if you don't have a .rtorrent.rc file, create one into your home directory
-you can find an example .rtorrent.rc file here: http://libtorrent.rakshasa.no/browser/trunk/rtorrent/doc/rtorrent.rc?rev=latest
-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 (be aware, to set different session directories for the users)
-set your download directory
-make sure, you have your session directory set and it exists, so rtorrent can continue will remember your torrents after it's restarted
= Installation guide =
* Prerequisites
* Installation
* Troubleshooting
== Prerequisites ==
* rTorrent 0.8.0
* compiled with "--with-xmlrpc-c"
* sigc++-2.0
* XMLRPC-C >= 1.00 ( >= 1.07 recommended)
* some webserver
* php5, with the following extensions:
* curl (when using an SCGI gateway)
* xml
* xsl (libxslt1.1)
* xmlrpc
== Installation ==
* rTorrent side
* Preparing the system
* Installing XMLRPC-C
* Installing libTorrent
* Installing rTorrent
* Setting up rTorrent
* rTWi side
* Installing rTWi
* Adding users
* GeoIP support (optional)
=== rTorrent side ===
==== Preparing the system ====
You'll need the following packages to install xmlrpc-c, libtorrent and rtorrent
* make
* pkg-config
* sigc++-2.0-dev
* libncurses-dev
* libcurl-openssl-dev
==== Installing XMLRPC-C ====
To install xmlrpc, get the source from The XMLRPC-C page at http://sourceforge.net/project/showfiles.php?group_id=16847
In my case, i could only compile the 1.11.00 version (due to a known bug, you may try to configure with --disable-cplusplus, if the compiling stops with some syntax error)
Of course, you can try any version, over 1.07 (or any version over 1.00, but you'll get incorrect data for values bigger than 2^31^-1, since it does not support 64bit integers)
Follow the next steps:
cd /usr/src
wget http://dfn.dl.sourceforge.net/sourceforge/xmlrpc-c/xmlrpc-c-1.11.00.tgz
tar xvf xmlrpc-c-1.11.00.tgz
cd xmlrpc-c-1.11.00
./configure
make
make install
==== Installing libTorrent ====
To install libtorrent, follow the next steps:
mkdir /usr/src/libtorrent
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.0.tar.gz
tar xvf libtorrent-0.12.0.tar.gz
cd /usr/src/libtorrent-0.12.0
./configure
make
make install
==== Installing rTorrent ====
To install rtorrent, follow the next steps:
mkdir /usr/src/rtorrent
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.0.tar.gz
tar xvf rtorrent-0.8.0.tar.gz
cd /usr/src/rtorrent-0.8.0
./configure --with-xmlrpc-c
make
make install
==== Setting up rTorrent ====
If you don't have a .rtorrent.rc file, create one into your home directory.
You can find an example .rtorrent.rc] file on the rTorrent page at http://libtorrent.rakshasa.no/browser/trunk/rtorrent/doc/rtorrent.rc?rev=latest
Edit your .rtorrent.rc (create on into your home directory, if it's a fresh install):
* set up how rtorrent should listen for connections (there are 3 ways to do this)
* to use a unix socket, add the line ''scgi_local = ~/torrent/.socket/rpc.socket'' (this is the recommended way)
* to listen for connections from localhost on port 12345 add the line ''scgi_port = :12345''
* to listen for connections from a specific interface on port 12345 add the line ''scgi_port = 123.123.123.123:12345''
* if you have more than one user, set a different scgi_port/scgi_local value in each user's .rtorrent.rc file
* set your download directory ''directory = ~/torrent/''
* absolute paths are always welcome, however rTWi should handle relative paths, like above (if it does not, submit a ticket
* make sure, you have your session directory set and it exists, so rtorrent will remember your torrents after it's restarted ''session = ~/torrent/.session'' (be aware to set different session directories for the users)
now, you can start rtorrent, and on the bottom, you should see something like this: "(20:55:52) XMLRPC initialized with 346 functions."
if everything went fine, extract the rtwi-xxxxxx.tar.gz to some place where your webserver can see it
in case, it's your first install, open the freshly extracted includes/config.php.inc, and edit the next lines:
-$abs_path (the absolute path of your webroot, i.e.: "/var/www")
-$domain (your domain, i.e.: "example.com")
-$site_path (the relative path of the rtwi-xxxx directory, or whatever you renamed it, within your webroot, i.e.: "/rtwi/", if it's absolute path is /var/www/rtwi/)
-$include_path (if you move the includes directory, or eave it untouched, i.e.: "/includes")
-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
adding users:
-find row 32, and change it:
-replace "userX" with the actual linux username
-replace "1234567890abcdef1234567890abcdef12345678" with the sha1 hash of the choosen password for the webui (you can generate the sha1 hash here => http://www.johnmaguire.us/tools/hashcalc/index.php)
-replace "12345", with the port, you've set in the user's .rtorrent.rc file
-keep the quotes in the last three steps
-if you have more than one user, you have to repeat these steps, for each one of them, so 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" ),
);
troubleshooting:
-xmlrpc 1.11 compilation stops with some syntax error
-try to configure with --disable-cplusplus
-rtorrent compilation stops with an errer, which says, i have no libtorrent installed (No package 'libtorrent' found)
-find your libtorrent.pc file (try /usr/local/lib/pkgconfig), and set the PKG_CONFIG_PATH environmental variable to it's path (export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig)
-rtorrent compilation stops with an error, which says, my libtorrent's version is an empty string (Requested 'libtorrent >= 0.11.8' but version of libtorrent is)
-upgrade you automake (you need 1.5+)
-i can see the php code in the browser
-you php settings does not allows you to to have a php file named .html - change these settings, or rename the index.html to index.php, and set the $default_ext variable to "php" in rtwi's /includes/config.inc.php
-php modul is not loaded by the webserver, take a look at your webserver's manual, to find out, how to enable it
-i get some php errors about xsl...
-install (or if it's installed, than enable) the xsl php extension
-i get some php errors about xmlrpc...
-install (or if it's installed, than enable) the xmlrpc php extension
-i've set my username and my password in the config.inc.php, ut i cannot log in
-did you use the password?> you need to use the password's sha1 hash (you can generate one here =>you can generate the sha1 hash here => http://www.johnmaguire.us/tools/hashcalc/index.php)
-enable cookies (or at least session cookies)
-i get the "No connection" message in rtwi
-set the same port in your .rtorrent.rc file, at the scgi_port=, and in the rtwi's /includes/config.inc.php at your user's line
-check, if rtottent is listening on the port, you've set (netstat -na | grep 12345)
-if it is
-check your firewall
-recheck the port set in rtwi's incudes/config.inc.php
-if it is not
-recheck your .rtorrent.rc - it should have a line like this: scgi_port = 127.0.0.1:12345
-try to set the scgi port in runtime (ctrl+x, then entre "scgi_port = 127.0.0.1:12345")
-if rtorrent stops with an error, that says xmlrpc is not supported, configure xmlrpc-c with --with-xmlrpc-c, and recompile
-the add torrent menu does not work (at all - it shows me an empty page)
-your download directory should be in your home directory
bug reports, whishlist, suggestions, anything: ghudiczius@gmail.com
p.s.: sorry, for the lot's of typo, this loosy manual, and my even worse english :)
Now, you can start rTorrent. On the bottom, you should see something like this:
(20:55:52) XMLRPC initialized with 356 functions.
=== rTWi side ===
==== Installing and setting up rTWi ====
Download the latest rTWi at http://projects.cyla.homeip.net/rtwi/downloads/rtwi-latest.tar.gz and extract it to some place where your webserver can see it.
Edit your configuration file (includes/rtwi.conf):
* set the ''base'' variable to your rTWi installation's URL (without index file, and with a trailing slash) ''base = "http://example.com/"''
* set the ''user_conf'' variable to the path of your user.conf file (it's always safe, to keep it outside your webroot)
* if your want to rename your index.php and/or input.php you need to set the ''index'' and/or ''input'' variable(s)
* If a value in the conf file contains any non-alphanumeric characters it needs to be enclosed in double-quotes (")
==== Adding users ====
Edit your users.conf file:
* create a new section for every user ''[user1]'' (this will be your login name - this must be the *nix username)
* set the address rTWi can connect to the user's rTorrent (there are 3 ways to do it)
* if you're using a unix socket enter ''address = "!unix://~/torrent/.socket/rpc.socket"''
* if you're using scgi_port enter ''address = "123.123.123.123:12345"'' (''address = ":12345"'' works for localhost)
* if you're using an SCGI gateway enter ''address = "!http://example.com/RPC2"'' (also works when Basic HTTP Authentication is on for the URL)
* enter ''pass = "1234567890abcdef1234567890abcdef12345678"'' where the right side is the sha1 hash of the choosen password for the user (you can generate the sha1 hash online at http://www.johnmaguire.us/tools/hashcalc/index.php)
* if a value in the conf file contains any non-alphanumeric characters it needs to be enclosed in double-quotes (")
* if you have more than one user, you have to repeat these steps for each one of them, so you'll get something like this:
[user1]
address = "unix://~/torrent/.socket/rpc.socket"
pass = "1234567890abcdef1234567890abcdef12345678"
[user2]
address = "123.123.123.123:12345"
pass = "1234567890abcdef1234567890abcdef12345678"
[user3]
address = "http://example.com/RPC2"
pass = "1234567890abcdef1234567890abcdef12345678"
==== GeoIP support (optional) ====
You need to install the GeoIP c library (http://www.maxmind.com/app/c), and the GeoIP PECL module (http://pecl.php.net/package/geoip)
You'll need the following packages to to add GeoIP support to rTWi
* libgeoip-dev
* php-pear
* php5-dev
If you have the packages installed, type
pecl install geoip
After you finished, you might want to add "extension=geoip.so" to php.ini
== Troubleshooting ==
XMLRPC-C 1.11 compilation stops with some syntax error
* Configure with --disable-cplusplus
* Check the XMLRPC-C site at http://xmlrpc-c.sourceforge.net/
rTorrent compilation stops with an errer, which says, i have no libtorrent installed (No package 'libtorrent' found), but i'm sure, i do
* Find your libtorrent.pc file (try /usr/local/lib/pkgconfig), and set the PKG_CONFIG_PATH environmental variable to it's path (export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig)
rTorrent compilation stops with an error, which says, my libTorrent's version is an empty string (Requested 'libtorrent >= 0.11.8' but version of libtorrent is )
* Upgrade you automake (you need 1.5 at least)
I can see the php code in the browser
* Your php settings does not allows you to to have a php file named .html - change these settings, or rename the index.html to index.php, and set the $default_ext variable to "php" in rtwi's /includes/config.inc.php
* Php modul is not loaded by the webserver, take a look at your webserver's manual, to find out, how to enable it
I get some php errors about XSL, or XSLT...
* Install (or if it's installed, than enable) the xsl php extension
I get some php errors about XMLRPC-C...
* Install (or if it's installed, than enable) the xmlrpc php extension
I've set my username and my password in the config.inc.php, but i cannot log in
* Did you use the password? You should use the sha1 hash of the password (you can generate the sha1 hash online at http://www.johnmaguire.us/tools/hashcalc/index.php)
* Enable cookies (or at least session cookies)
I get the "No connection" message in rTWi
* Set the same port in your .rtorrent.rc file, at the scgi_port=, and in the rTWi's /includes/config.inc.php at your user's line
* Check, if rTottent is listening on the port, you've set (netstat -na | grep 12345)
It is
* Check your firewall
* Recheck the port set in rtwi's incudes/config.inc.php
It is not
* Recheck your .rtorrent.rc - it should have a line like this: scgi_port = 127.0.0.1:12345
* Try to set the scgi port in runtime (Ctrl+X, then entre "scgi_port = 127.0.0.1:12345")
* If rtorrent stops with an error, that says xmlrpc is not supported, configure xmlrpc-c with --with-xmlrpc-c, and recompile
<?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 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 ) );