Index: !install.txt
===================================================================
--- !install.txt	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ !install.txt	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -16,5 +16,4 @@
    * xml
    * xsl (libxslt1.1)
-   * xmlrpc
 
 == Installation ==
Index: includes/classes/xmlrpc_handler.inc.php
===================================================================
--- includes/classes/xmlrpc_handler.inc.php	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ includes/classes/xmlrpc_handler.inc.php	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -81,4 +81,201 @@
 	}
 
+	function set_type( &$value, $xmlrpc_type ) {
+		switch ( $xmlrpc_type ) {
+			case "base64" : {
+				$value = (object)$value;
+				$value->xmlrpc_type = $xmlrpc_type;
+				break;
+			}
+			case "datetime" : {
+				$value = (object)$value;
+				$value->xmlrpc_type = $xmlrpc_type;
+				$value->timestamp = strtotime( $value->scalar );
+				$value->timestamp = $value->timestamp === false ? -1 : $value->timestamp;
+				break;
+			}
+		}
+	}
+
+	private function decode_rec( $inode ) {
+		$ntype = $inode->nodeName;
+		$nvalue = $inode->nodeValue;
+		switch ( $ntype ) {
+			case "string" : {
+				$response = $nvalue;
+				break;
+			}
+			case "i4" :
+			case "int" : {
+				$response = (int)$nvalue;
+				break;
+			}
+			case "struct" : {
+				$mnode = $inode->firstChild;
+				while ( $mnode != NULL ) {
+					$nname = $mnode->firstChild->nodeValue;
+					$response[$nname] = $this->decode_rec( $mnode->lastChild->firstChild );
+					$mnode = $mnode->nextSibling;
+				}
+			}
+			case "array" : {
+				$vnode = $inode->firstChild->firstChild;
+				while ( $vnode != NULL ) {
+					$response[] = $this->decode_rec( $vnode->firstChild );
+					$vnode = $vnode->nextSibling;
+				}
+			}
+		}
+		return $response;
+	}
+
+	private function decode( $str ) {
+		$str = preg_replace( "%<(/{0,1})(i8|ex\.i8)>%", "<\\1string>", $str );
+		$str = preg_replace( "/>\s*?</s", "><", $str );
+		$xml = new DOMDocument( "1.0", "utf-8" );
+		$xml->formatOutput = true;
+		$xml->loadXML( $str );
+
+		$root = $xml->firstChild;
+		$root->nodeName;
+
+		if ( $root->firstChild->nodeName == "fault" ) {
+			$response[faultCode] = (int)$root->firstChild->firstChild->firstChild->firstChild->lastChild->firstChild->nodeValue;
+			$response[faultString] = $root->firstChild->firstChild->firstChild->lastChild->lastChild->firstChild->nodeValue;
+		} else {
+			$vnode = $root->firstChild->firstChild->firstChild;
+			$inode = $vnode->firstChild;
+			$ntype = $inode->nodeName;
+			$nvalue = $inode->nodeValue;
+			switch ( $ntype ) {
+				case "string" : {
+					$response = $nvalue;
+					break;
+				}
+				case "i4" :
+				case "int" : {
+					$response = (int)$nvalue;
+					break;
+				}
+				case "struct" : {
+					$mnode = $inode->firstChild;
+					while ( $mnode != NULL ) {
+						$nname = $mnode->firstChild->nodeValue;
+						$response[$nname] = $this->decode_rec( $mnode->lastChild->firstChild );
+						$mnode = $mnode->nextSibling;
+					}
+				}
+				case "array" : {
+					$vnode = $inode->firstChild->firstChild;
+					while ( $vnode != NULL ) {
+						$response[] = $this->decode_rec( $vnode->firstChild );
+						$vnode = $vnode->nextSibling;
+					}
+				}
+			}
+		}
+
+		return $response;
+	}
+
+	private function encode_request_rec( $method, $param, &$xml, $pnode ) {
+		$vnode = $pnode->appendChild( $xml->createElement( "value" ) );
+		switch ( gettype( $param ) ) {
+			case "integer" : {
+				$inode = $vnode->appendChild( $xml->createElement( "int", $param ) );
+				break;
+			}
+			case "double" : {
+				$inode = $vnode->appendChild( $xml->createElement( "double", $param ) );
+				break;
+			}
+			case "string" : {
+				$inode = $vnode->appendChild( $xml->createElement( "string", $param ) );
+				break;
+			}
+			case "array" : {
+				$assoc = false;
+				foreach ( array_keys( $param ) as $key => $val ) {
+					if ( !preg_match( "/^[0-9]*$/", $val ) ) {
+						$assoc = true;
+					}
+				}
+				if ( $assoc ) {
+					$anode = $vnode->appendChild( $xml->createElement( "struct" ) );
+					foreach ( $param as $key => $val ) {
+						$mnode = $anode->appendChild( $xml->createElement( "member" ) );
+						$nnode = $mnode->appendChild( $xml->createElement( "name", $key ) );
+						$this->encode_request_rec( $method, $val, $xml, $mnode );
+					}
+				} else {
+					$anode = $vnode->appendChild( $xml->createElement( "array" ) );
+					$dnode = $anode->appendChild( $xml->createElement( "data" ) );
+					foreach ( $param as $key => $val ) {
+						$this->encode_request_rec( $method, $val, $xml, $dnode );
+					}
+				}
+				break;
+			}
+			case "object" : {
+				switch ( $param->xmlrpc_type ) {
+					case "base64" : {
+						$inode = $vnode->appendChild( $xml->createElement( "base64", base64_encode( $param->scalar ) ) );
+						break;
+					}
+					case "datetime" : {
+						$inode = $vnode->appendChild( $xml->createElement( "datetime", $param->timestamp ) );
+						break;
+					}
+				}
+				break;
+			}
+			default : {
+				print "Bibi: ".gettype( $param );
+				exit;
+				break;
+			}
+		}
+	}
+
+	private function encode_request( $method, $params ) {
+		$xml = new DOMDocument( "1.0", "utf-8" );
+		$xml->formatOutput = true;
+
+		$root = $xml->appendChild( $xml->createElement( "methodCall" ) );
+		$mnode = $root->appendChild( $xml->createElement( "methodName", $method ) );
+		
+		if ( !empty( $params ) ) {
+			$psnode = $root->appendChild( $xml->createElement( "params" ) );
+			if ( is_array( $params ) ) {
+				$assoc = false;
+				foreach ( array_keys( $params ) as $key => $val ) {
+					if ( !preg_match( "/^[0-9]*$/", $val ) ) {
+						$assoc = true;
+					}
+				}
+				if ( $assoc ) {
+					$pnode = $psnode->appendChild( $xml->createElement( "param" ) );
+					$vnode = $pnode->appendChild( $xml->createElement( "value" ) );
+					$anode = $vnode->appendChild( $xml->createElement( "struct" ) );
+					foreach ( $params as $key => $val ) {
+						$mnode = $anode->appendChild( $xml->createElement( "member" ) );
+						$nnode = $mnode->appendChild( $xml->createElement( "name", $key ) );
+						$this->encode_request_rec( $method, $val, $xml, $mnode );
+					}
+				} else {
+					foreach ( $params as $key => $val ) {
+						$pnode = $psnode->appendChild( $xml->createElement( "param" ) );
+						$this->encode_request_rec( $method, $val, $xml, $pnode );
+					}
+				}
+			} else {
+				$pnode = $psnode->appendChild( $xml->createElement( "param" ) );
+				$this->encode_request_rec( $method, $params, $xml, $pnode );
+			}
+		}
+
+		return $xml->saveXML();
+	}
+
 	function getconntype() {
 		return $this->conntype;
@@ -95,5 +292,5 @@
 			$this->request[] = array( "methodName" => $methodval, "params" => $params );
 		}
-		$this->request = xmlrpc_encode_request( "system.multicall", array( $this->request ) );
+		$this->request = $this->encode_request( "system.multicall", array( $this->request ) );
 	}
 
@@ -104,9 +301,9 @@
 			$this->request[] = array( "methodName" => $methods[$i], "params" => $params[$i] );
 		}
-		$this->request = xmlrpc_encode_request( "system.multicall", array( $this->request ) );
+		$this->request = $this->encode_request( "system.multicall", array( $this->request ) );
 	}
 
 	function setrequest( $method, $attributes ) {
-		$this->request = xmlrpc_encode_request( $method, $attributes );
+		$this->request = $this->encode_request( $method, $attributes );
 	}
 
@@ -200,6 +397,5 @@
 
 	function parse() {
-		$this->response = preg_replace( "/i8|ex\.i8/", "string", $this->response );
-		if ( ( $this->response = xmlrpc_decode( $this->response ) ) !== false ) {
+		if ( ( $this->response = $this->decode( $this->response ) ) !== false ) {
 			return true;
 		} else {
@@ -211,5 +407,4 @@
 		$r = -1;
 		$responses = array();
-//print_r( $this->response );
 		foreach ( $methods as $methodkey => $methodval ) {
 			if ( $methodval[1] == "." ) {
Index: includes/messages.en.inc.php
===================================================================
--- includes/messages.en.inc.php	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ includes/messages.en.inc.php	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -256,5 +256,5 @@
 	"stopedsince"				=> "Stoped since",
 	"openedsince"				=> "Opened since",
-	"closedsince"				=> "Closeed since",
+	"closedsince"				=> "Closed since",
 	"finishedsince"				=> "Finished since",
 	"hashingsince"				=> "Hashing since",
Index: includes/rtwi.conf
===================================================================
--- includes/rtwi.conf	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
+++ includes/rtwi.conf	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -0,0 +1,54 @@
+; full url of the rTWi (with a trailing slash)
+base =		http://example.com/
+
+; change, if you've renamed the index.html file
+index =		index.php
+
+; change, if you've renamed the input.php file
+input =		input.php
+
+; path to home directory of users (with heading and trailing slash)
+home_path =	/home/
+
+; path to the file which keeps the user related informations
+user_conf =	/etc/rtorrent/users.conf
+
+; language (english and hungarian is available)
+lang =		en
+
+; site theme (look for themes in the "themes" directory)
+site_theme = 	default_ajax
+
+; do a directory tree, which can be expanded/collapsed
+; set to "false" (without the quotes),
+; if your webserver is running on a slow machine
+; and you have torrents with a lots of files
+; (a few hundreds of files in a single torrent, and more)
+dodirtree =	true
+
+; true if ajax is allowed
+ajax =		true
+
+; true if dht is enabled
+dht =		true
+
+; true if users are allowed to download finished files from the webui
+download =	true
+
+; true if users are allowed to erase downloaded data from the webui
+erase =		true
+
+; true if flags are allowed in peers page
+flags =		true
+
+; true if hiding the filelist is allowed
+hidedirtree =	true
+
+; true if users are allowed to set the language of the web interface
+language =	true
+
+; true if users are allowed to set a meta-refresh interval
+refresh =	true
+
+; true if users are allowed to set throttle
+throttle =	true
Index: includes/rtwi.conf.sample
===================================================================
--- includes/rtwi.conf.sample	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ includes/rtwi.conf.sample	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -40,5 +40,5 @@
 
 ; true if flags are allowed in peers page
-flags =		false
+flags =		true
 
 ; true if hiding the filelist is allowed
Index: includes/users.conf.sample
===================================================================
--- includes/users.conf.sample	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ includes/users.conf.sample	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -14,2 +14,6 @@
 address =	123.123.123.123:123456
 pass =		7e240de74fb1ed08fa08d38063f6a6a91462a815
+
+[user1]
+address =	unix:///home/cyla/torrent/.socket/rpc.socket
+pass =		5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
Index: index.php
===================================================================
--- index.php	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ index.php	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -446,11 +446,4 @@
 }
 
-/*
-$lang = parse_ini_file( "includes/{$_SESSION["rtwi_language"]}.lang", true );
-print "<pre>";
-print_r( $lang );
-print "</pre>";
-*/
-
 // including neccessary files
 require_once( "includes/classes/xmlrpc_handler.inc.php" );
@@ -538,6 +531,4 @@
 }
 
-//print_r( $_COOKIE );
-
 // checking if user is logged in
 if ( ( isset( $_SESSION["rtwi_auth"] ) && $_SESSION["rtwi_auth"] === 1 ) || ( isset( $_COOKIE["rtwi_auth"] ) && $_COOKIE["rtwi_auth"] == 1 && isset( $_COOKIE["rtwi_nick"] ) && array_key_exists( $_COOKIE["rtwi_nick"], $users ) ) ) {
@@ -606,7 +597,4 @@
 }
 $labels->getElementsByTagName( "mailto" )->item( 0 )->nodeValue = str_rot13( base64_encode( str_rot13( $labels->getElementsByTagName( "mailto" )->item( 0 )->nodeValue ) ) );
-
-//print_r( $_SESSION );
-//print_r( $_REQUEST );
 
 // deciding what to do
@@ -1078,7 +1066,4 @@
 
 $tt = getmicrotime();
-//printf( "Total time: %0.6f sec\r\n", $tt - $st );
-
-//print $xml->saveXML();exit;
 
 // displaying the page
@@ -1090,5 +1075,5 @@
 	$len = strlen( $text );
 
-//	@header( "content-length: {$len}" );
+	@header( "content-length: {$len}" );
 	@header( "content-type: text/html; charset=utf-8" );
 	@header( "content-language: hu" );
@@ -1107,8 +1092,8 @@
 
 	// sending headers
-	//@header( "Content-Description: File Transfer" );
-	//@header( "Content-Type: application/force-download" );
-	//@header( "Content-Length: {$filesize}" );
-	//@header( "Content-Disposition: attachment; filename={$response["f_path"]}" );
+	@header( "Content-Description: File Transfer" );
+	@header( "Content-Type: application/force-download" );
+	@header( "Content-Length: {$filesize}" );
+	@header( "Content-Disposition: attachment; filename={$response["f_path"]}" );
 	
 	// sending the file
@@ -1117,12 +1102,4 @@
 
 $tt = getmicrotime();
-/*
-printf( "<br />\r\nXMLRPC calls: %d", $callnum );
-printf( "<br />\r\nXMLRPC time: %0.6f sec", $calltime );
-if( isset( $fst ) && isset( $ftt ) ) {
-	printf( "<br />\r\nFiles time: %0.6f sec", $ftt - $fst );
-}
-printf( "<br />\r\nTotal time: %0.6f sec", $tt - $st );
-*/
 
 ?>
Index: input.php
===================================================================
--- input.php	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ input.php	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -281,5 +281,5 @@
 					if ( is_uploaded_file( $_FILES["torrentfile"]["tmp_name"] ) ) {
 						$torrent = file_get_contents( $_FILES["torrentfile"]["tmp_name"] );
-						xmlrpc_set_type( &$torrent, "base64" ); 
+						$xmlrpc->set_type( &$torrent, "base64" );
 					} else {
 						$_SESSION["rtwi_err"] = "rtfileattack";
@@ -753,5 +753,5 @@
 		$xmlrpc->call();
 		$xmlrpc->parse();
-		$torrents = $xmlrpc->fetch();
+		$response = $xmlrpc->fetch();
 
 		if ( $id < 0 || $id > $response ) {
@@ -778,6 +778,4 @@
 		$xmlrpc->setrequest( "f.set_priority", array( $hash, $id, $filepriority ) );
 		$xmlrpc->call();
-		$xmlrpc->parse();
-		$torrents = $xmlrpc->fetch();
 
 		$xmlrpc->setrequest( "d.update_priorities", $hash );
Index: themes/default_ajax/layout.main.index.xsl
===================================================================
--- themes/default_ajax/layout.main.index.xsl	(revision b804c919f8493f5a45f01334128a0f17daad4565)
+++ themes/default_ajax/layout.main.index.xsl	(revision 5cd1e7c9c662a8d7ad6a990c80c935f03cfc410b)
@@ -182,5 +182,7 @@
     <div class="clr"></div>
    </li>
-   <xsl:apply-templates select="torrent" />
+   <xsl:apply-templates select="torrent">
+    <xsl:sort select="d_name" lang="utf-8" data-type="text" order="ascending" />
+   </xsl:apply-templates>
    <xsl:apply-templates select="torrent_info_root" />
    <xsl:apply-templates select="torrent_files_root" />
