Commit 686303f1 authored by Gabor Hudiczius's avatar Gabor Hudiczius
Browse files

rtwi-070830

parent e11e175f
requirements:
-rtorrent 0.7.7
-rtorrent 0.7.8, compiled with "--with-xmlrpc-c"
-xmlrpc >= 1.07
-some webserver
-php5, with the following extensions:
-xsl
......@@ -7,23 +8,58 @@ requirements:
installation:
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)
of course, you can try any version, over 1.07
follow the next steps, as root:
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 get the svn for libtorrent, and rtorrent, you have to previously installed svn (apt-get install svn, ford debian, ubuntu)
to install libtorrent, follow the next steps, as a root:
mkdir /usr/src/libtorrent
svn co svn://rakshasa.no/libtorrent/trunk/libtorrent /usr/src/libtorrent
cd /usr/src/libtorrent
./autogen.sh
./configure
make
make install
to install rtorrent, follow the next steps, as a root:
mkdir /usr/src/rtorrent
svn co svn://rakshasa.no/libtorrent/trunk/rtorrent /usr/src/rtorrent
cd /usr/src/rtorrent
./autogen.sh
./configure --with-xmlrpc-c
make
make install
now, after everything's done
-extract the rtwi-xxxxxx.tar.gz to some place where your webserver can see it
-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)
-$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
-you can find an example .rtorrent.rc file here: http://libtorrent.rakshasa.no/browser/trunk/rtorrent/doc/rtorrent.rc?rev=latest
-if you don't have a .rtorrent.rc file, create one in each user's home directory
-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
-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)
-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
-replace "userX" with the actual linux username (keep the quotes)
-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 do these steps, for each one of them, sop you'll get something like this:
$users = array(
"user1" => array( "pass" => "1234567890abcdef1234567890abcdef12345678", "port" => "12345" ),
......@@ -35,4 +71,4 @@ installation:
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
p.s.: sorry, for this loosy manual, and my even worse english :)
<?php
class db_handler {
var $db_host;
var $db_database;
var $db_user;
var $db_pass;
var $db_charset;
var $db_debugmode;
var $db_connection;
var $db_lasterrorcode = 0;
var $db_lastquery = "";
var $db_result;
var $db_numrows;
function __construct( &$db ) {
$this->db_host = $db["host"];
$this->db_database = $db["database"];
$this->db_user = $db["user"];
$this->db_pass = $db["pass"];
$this->db_charset = $db["charset"];
$this->db_debugmode = $db["debugmode"];
}
function db_connect() {
$this->db_connection = mysql_connect( $this->db_host, $this->db_user, $this->db_pass );
if ( $this->db_connection !== false ) {
if ( mysql_select_db( $this->db_database, $this->db_connection ) !== false ) {
mysql_query( "SET CHARACTER SET '{$this->db_charset}';", $this->db_connection );
mysql_query( "SET NAMES '{$this->db_charset}';", $this->db_connection );
return $this->db_connection;
} else {
$this->db_lasterrorcode = 3;
}
$this->db_lasterrorcode = 2;
} else {
$this->db_lasterrorcode = 1;
return false;
}
}
function db_info() {
$ret = mysql_info( $this->db_connection );
if ( $ret !== false ) {
return $ret;
} else {
$this->db_lasterrorcode = 4;
return false;
}
}
function db_query( &$db_query ) {
//print "{$db_query}<br />\r\n";
if ( $this->db_debugmode ) {
print "{$db_query}<br />\r\n";
}
//$st = getmicrotime();
$this->db_result = mysql_query( $db_query, $this->db_connection );
//$tt = getmicrotime();
//printf( "<br />\r\nQuery time: %0.6f sec", $tt - $st );
if ( $this->db_result !== false ) {
if ( strtolower( substr( $db_query, 0, 6 ) ) == "select" ) {
$this->numrows = mysql_num_rows( $this->db_result );
return $this->numrows;
} else {
$this->numrows = mysql_affected_rows( $this->db_connection );
if ( strtolower( substr( $db_query, 0, 6 ) ) == "insert" ) {
return mysql_insert_id( $this->db_connection );
} else {
return $this->numrows;
}
}
} else {
//print mysql_error();
$this->db_lasterrorcode = 5;
$this->db_lastquery = $db_query;
return false;
}
}
function db_fetch( &$xml, &$node, &$nodename ) {
if ( is_resource( $this->db_result ) ) {
$i = 0;
while ( $value = mysql_fetch_assoc( $this->db_result ) ) {
$nnode = $node->appendChild( $xml->createElement( $nodename ) );
$item = $nnode->appendChild( $xml->createElement( "db_counter" ) );
$text = $item->appendChild( $xml->createTextNode( ++$i ) );
foreach ( $value as $key => $val ) {
$item = $nnode->appendChild( $xml->createElement( $key ) );
$text = $item->appendChild( $xml->createTextNode( $val ) );
}
}
if ( mysql_free_result( $this->db_result ) === false ) {
$this->db_lasterrorcode = 6;
}
return true;
} else {
$this->db_lasterrorcode = 7;
return false;
}
}
function __destruct() {
if ( mysql_close( $this->db_connection ) !== false ) {
return true;
} else {
$this->db_lasterrorcode = 8;
return false;
}
}
}
?>
<?php
/*
2 info
1 error
0 none
*/
class net_handler {
private $net_host;
private $net_url;
private $net_port;
private $net_tmpfile;
private $net_cookie;
private $net_charset;
private $net_errno;
private $net_errmsg;
private $net_debugmode;
private $net_reply;
private $net_connection;
private $net_lasterrorcode = 0;
function net_handler( &$net ) {
if ( $net["allownameres"] === true ) {
$this->net_host = gethostbyname( $net["host"] );
} else {
$this->net_host = $net["host"];
}
$this->net_port = $net["port"];
$this->net_tmpfile = $net["tmpfile"];
$this->net_timeout = $net["timeout"];
$this->net_url = $net["url"];
$this->net_cookie = $net["cookie"];
$this->net_debugmode = $net["debugmode"];
}
function net_connect() {
if ( $this->net_debugmode === 2 ) {
print "Connecting to {$this->net_host} on port {$this->net_port} (timeout: {$this->net_timeout}).";
}
do {
if ( $this->net_debugmode === 2 ) {
print "\r\nTrying...";
}
$this->net_connection = @pfsockopen( $this->net_host, $this->net_port, $this->net_errno, $this->net_errstr, $this->net_timeout );
if ( $this->net_connection === false && $this->net_debugmode > 0 ) {
print trim( $this->net_errstr );
}
} while ( $this->net_connection === false );
if ( $this->net_debugmode === 2 ) {
print "done.\r\n";
}
return true;
}
function net_seturl( $url ) {
$this->net_url = $url;
return true;
}
function net_request() {
if ( $this->net_debugmode === 2 ) {
print "Sending data...";
}
$out = "GET {$this->net_url} HTTP/1.1\r\n";
$out .= "Host: {$this->net_host}\r\n";
$out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20060918 Firefox/2.0\r\n";
$out .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*;\r\n";
$out .= "Accept-Language: hu,en-us,en;q=0.5\r\n";
$out .= "Accept-Encoding: gzip,deflate\r\n";
$out .= "Accept-Charset: ISO-8859-2,utf-8;*\r\n";
$out .= "Keep-Alive: 300\r\n";
$out .= "Connection: keep-alive\r\n";
if ( $this->net_cookie !== "" ) {
$out .= "Cookie: {$this->net_cookie}\r\n";
}
$out .= "\r\n";
$ret = fwrite( $this->net_connection, $out );
if ( $this->net_debugmode === 2 ) {
print "done, {$ret} byte(s) sent.\r\n";
}
fflush( $this->net_connection );
if ( $this->net_debugmode === 2 ) {
print "Data flushed.\r\n";
}
}
function net_readreply() {
if ( $this->net_debugmode === 2 ) {
print "Recieving reply...";
}
if ( isset( $this->net_reply ) ) {
unset( $this->net_reply );
}
$ret = 0;
$this->net_reply["status"] = fgets( $this->net_connection );
$ret += strlen( $this->net_reply["status"] );
$this->net_reply["status"] = trim( $this->net_reply["status"] );
do {
$content = fgets( $this->net_connection );
$ret += strlen( $content );
$content = trim( $content );
$contents = split( ": ", $content );
if( $content !== "" ) {
$this->net_reply["header"][strtolower( $contents[0] )] = $contents[1];
}
} while ( $content !== "" );
if ( $this->net_debugmode === 2 ) {
print "done, {$ret} byte(s) recieved for headers.\r\n";
print_r( $this->net_reply );
}
return $ret;
}
function net_readcontent( $file = "" ) {
if ( $file == "" ) {
$file = $this->net_tmpfile;
}
if ( $this->net_reply["status"] === "HTTP/1.1 200 OK" ) {
if ( $this->net_debugmode === 2 ) {
print "Reading message body.\r\n";
}
if ( isset ( $this->net_reply["header"]["transfer-encoding"] ) && $this->net_reply["header"]["transfer-encoding"] === "chunked" ) {
$ret = $this->net_readchunkedcontent( $file );
} else {
$ret = $this->net_readsimplecontent( $file );
}
if ( $this->net_debugmode === 2 ) {
print "\r\nDone, {$ret} byte(s) was recieved for message body, and has been written to file.\r\n\r\n";
}
}
}
function net_disconnect() {
if ( $this->net_debugmode === 2 ) {
print "Closing connection...";
}
fclose( $this->net_connection );
if ( $this->net_debugmode === 2 ) {
print "done.\r\n";
}
}
private function net_readsimplecontent( &$file ) {
if ( $this->net_debugmode === 2 ) {
print "\r\nOpening file...";
}
$filehandle = fopen( $file, "wb+" );
if ( $this->net_debugmode === 2 ) {
print "done.\r\n";
print "Trying to read data as 8192 byte blocks in \"simple\" mode...\r\n";
}
if ( isset ( $this->net_reply["header"]["content-length"] ) ) {
settype( $this->net_reply["header"]["content-length"], "int" );
$block = $this->net_reply["header"]["content-length"];
$ret = 0;
$done = false;
while ( $done === false ) {
if ( $block < 8192 ) {
$content = fread( $this->net_connection, $block );
} else {
$content = fread( $this->net_connection, 8192 );
}
$len = fwrite( $filehandle, $content );
$ret += $len;
if ( $block < 8192 ) {
$block -= $len;
}
if ( $this->net_debugmode === 2 ) {
print "{$len} byte(s) was recieved, and has been written to file.\r\n";
}
fflush( $filehandle );
if ( $this->net_debugmode === 2 ) {
print "File flushed.\r\n";
}
if ( $block === 0 || feof( $this->net_connection ) ) {
$done = true;
}
}
} else {
$ret = 0;
while ( !feof( $this->net_connection ) ) {
$content = fread( $this->net_connection, 8192 );
$len = fwrite( $filehandle, $content );
$ret += $len;
if ( $this->net_debugmode === 2 ) {
print "{$len} byte(s) was recieved, and has been written to file.\r\n";
}
fflush( $filehandle );
if ( $this->net_debugmode === 2 ) {
print "File flushed.\r\n";
}
}
}
if ( $this->net_debugmode === 2 ) {
print "Closing file...";
}
fclose( $filehandle );
if ( $this->net_debugmode === 2 ) {
print "done.\r\n";
}
return $ret;
}
private function net_readchunkedcontent( &$file ) {
if ( $this->net_debugmode === 2 ) {
print "\r\nOpening file...";
}
$filehandle = fopen( $file, "wb+" );
if ( $this->net_debugmode === 2 ) {
print "done.\r\n";
}
$ret = 0;
$done = false;
while ( $done === false ) {
$chunklength = hexdec( trim( fgets( $this->net_connection ) ) );
if ( $chunklength === 0 ) {
fgets( $this->net_connection );
$done = true;
} else {
if ( $this->net_debugmode === 2 ) {
print "Trying to read {$chunklength} byte(s) in \"chunked\" mode...";
}
$contents = "";
$len = 0;
$flen = 0;
while ( $chunklength > 0 ) {
$content = fread( $this->net_connection, $chunklength );
//if ( $content === false ) { exit; };
$contents .= $content;
$len = strlen( $content );
$chunklength -= $len;
$flen += $len;
$ret += $len;
if ( $this->net_debugmode === 2 ) {
if ( $chunklength === 0 ) {
print "done.\r\n";
} else {
print "recieved {$len} byte(s).\r\nNeed to get another {$chunklength} byte(s)....";
}
}
}
fgets( $this->net_connection );
fwrite( $filehandle, $contents );
if ( $this->net_debugmode === 2 ) {
print "{$flen} byte(s) has been written to file.\r\n";
}
fflush( $filehandle );
if ( $this->net_debugmode === 2 ) {
print "File flushed.\r\n";
}
}
}
if ( $this->net_debugmode === 2 ) {
print "Closing file...";
}
fclose( $filehandle );
if ( $this->net_debugmode === 2 ) {
print "done.\r\n";
}
return $ret;
}
}
?>
\ No newline at end of file
<?php
class sql_handler {
var $sql_host;
var $sql_db;
var $sql_user;
var $sql_pass;
var $data;
var $result;
function __construct( &$sql ) {
$this->data = new db_handler( $sql );
$this->data->db_connect();
}
function get_info() {
return $this->data->db_info();
}
function load_content( &$sel_array ) {
$query = "SELECT {$sel_array["sel_what"]} FROM {$sel_array["sel_table"]}";
if ( isset( $sel_array["sel_where"] ) ) {
$query .= " WHERE {$sel_array["sel_where"]}";
}
if ( isset( $sel_array["sel_orderby"] ) ) {
$query .= " ORDER BY {$sel_array["sel_orderby"]}";
if ( isset( $sel_array["sel_how"] ) ) {
$query .= " {$sel_array["sel_how"]}";
} else {
$query .= " ASC";
}
}
if ( isset( $sel_array["sel_limit"] ) ) {
$query .= " LIMIT {$sel_array["sel_limit"]}";
}
$query .= ";";
$this->result = $this->data->db_query( $query );
return $this->result;
}
function add_content( &$add_array ) {
$query = "INSERT INTO {$add_array["add_table"]} ({$add_array["add_fields"]}) VALUES ({$add_array["add_what"]});";
$this->result = $this->data->db_query( $query );
return $this->result;
}
function set_content( &$set_array ) {
$query = "UPDATE {$set_array["set_table"]} SET {$set_array["set_changes"]} WHERE {$set_array["set_where"]};";
$this->result = $this->data->db_query( $query );
return $this->result;
}
function del_content( &$del_array ) {
$query = "DELETE FROM {$del_array["del_table"]} WHERE {$del_array["del_where"]};";
$this->result = $this->data->db_query( $query );
return $this->result;
}
function describe_table( &$desc_array ) {
$query = "DESCRIBE {$desc_array["desc_table"]} {$desc_array["desc_field"]};";
$this->result = $this->data->db_query( $query );
return $this->result;
}
function alter_table( &$alt_array ) {
$query = "ALTER TABLE {$alt_array["alt_table"]} CHANGE {$alt_array["alt_field"]} {$alt_array["alt_field"]} {$alt_array["alt_value"]} CHARACTER SET {$alt_array["alt_charset"]} COLLATE {$alt_array["alt_collate"]} {$alt_array["alt_null"]};";
$this->result = $this->data->db_query( $query );
return $this->result;
}
function get_content( &$xml, &$node, $nodename ) {
$this->content = $this->data->db_fetch( $xml, $node, $nodename );
return $this->content;
}
function __destruct() {
}
}
?>
......@@ -8,15 +8,14 @@
$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)
$abs_path = "/var/www"; // webroot (with heading slash) -- change this, if neccessary
$domain = "rtwi.cyla.homelinux.net"; // site domain (or ip) -- change this, if neccessary