Index: trunk/instant_messenger/inc/Socket.abstract.php
===================================================================
--- trunk/instant_messenger/inc/Socket.abstract.php	(revision 151)
+++ 	(revision )
@@ -1,87 +1,0 @@
-<?php
-/*
-+-------------------------------------------------------------------------+
-|                                                                         |
-| @FILE_NAME:   Socket.abstract.php                                       |
-| @CLASS_NAME:  (abstract) Jabber                                         |
-|                                                                         |
-| @DATE:        Wed May,16 2007 07:58:59                                  |
-| @LAST_CHANGE: Wed May,16 2007 08:03:28                                  |
-|                                                                         |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodsouza@celepar.pr.gov.br         |
-|                                                                         |
-| @BRIEF:       Abstract class for connect with a socket                  |
-|                                                                         |
-+-------------------------------------------------------------------------+
-*/
-
-abstract class Socket
-{
-	protected final function open( $pSocket = false, $pTimeOut = 1, $pBlockingMode = 0 )
-	{
-		if ( !$pSocket )
-			return false;
-
-		if ( $socket = @stream_socket_client($pSocket, $errno, $errstr) )
-		{
-			#stream_set_blocking($socket, $pBlockingMode);
-			#stream_set_timeout($socket, $pTimeOut);
-			stream_set_blocking($socket, 1);
-			stream_set_timeout($socket, 1);
-		}
-		return $socket;
-	}
-
-	protected final function blocking($pSocket = false, $pBlockingMode = 1)
-	{
-		if ( !$pSocket || !is_resource($pSocket) )
-			return false;
-
-		stream_set_blocking($pSocket, $pBlockingMode);
-	}
-
-
-	protected function read( $pSocket = false, $pLength = 4096 )
-	{
-		ini_set( 'track_errors', '1' );
-		$php_errormsg = '';
-
-		if ( !$pSocket || !is_resource($pSocket) )
-			return false;
-
-		set_magic_quotes_runtime(0);
-		$return = @fread($pSocket, $pLength);
-		set_magic_quotes_runtime(get_magic_quotes_gpc());
-
-
-		if ( $php_errormsg )
-			return false;
-
-		return $return;
-	}
-
-	protected function write( $pSocket = false, $pData = false )
-	{
-		ini_set( 'track_errors', '1' );
-		$php_errormsg = '';
-
-		if ( (!$pSocket || !is_resource($pSocket)) || !$pData )
-			return false;
-
-		$return = @fwrite($pSocket, $pData);
-
-		if ( $php_errormsg )
-			return false;
-
-		return $return;
-	}
-
-	protected final function close( $pSocket = false )
-	{
-		if ( !$pSocket || !is_resource($pSocket) )
-			return false;
-
-		return fclose($pSocket);
-	}
-}
-?>
Index: trunk/instant_messenger/inc/im_acl.inc.php
===================================================================
--- trunk/instant_messenger/inc/im_acl.inc.php	(revision 227)
+++ 	(revision )
@@ -1,53 +1,0 @@
-<?php
-$size_of_ACL = sizeof($GLOBALS['phpgw_info']['user']['acl']);
-
-for ( $i = 0; $i < $size_of_ACL && $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger'; $i++ );
-
-$webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
-$webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
-
-if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) )
-	$webserver_url .= '/';
-
-$webserver_url = $webserver_url . 'instant_messenger/';
-
-session_start();
-require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php';
-require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/load_lang.php';
-$_user     = $_SESSION['phpgw_info']['instant_messenger']['user'];
-$_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd'];
-$_server   = $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-$_port     = $_SESSION['phpgw_info']['instant_messenger']['port_jabber'];
-$_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'];
-session_write_close();
-
-$DOCUMENT_ROOT = PHPGW_SERVER_ROOT .'/instant_messenger/';
-
-$js = array(
-	'js/connector.js',
-	'js/xtools.js',
-	'js/jabber.js',
-	'js/client.js',
-	'js/images.js',
-	'js/dragdrop.js',
-	'js/build_win.js',
-	'js/templates.js',
-	'js/fcommon.js',
-	'js/menu_action.js',
-	'js/functions.js',
-	'js/images.js',
-	'js/cookies_im.js',
-	'js/load.js',
-);
-
-print '<script type="text/javascript">var path_im = "'.$webserver_url.'";</script>';
-
-foreach ( $js as $key => $val )
-	print '<script src="' . $webserver_url . $val . '?' . filemtime($DOCUMENT_ROOT . $val) . '"></script>';
-
-print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/window.css">';
-print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/chat.css">';
-print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/common.css">';
-
-print '<script type="text/javascript">setTimeout("client()",2000);</script>';
-?>
Index: trunk/instant_messenger/inc/Jabberd2.abstract.php
===================================================================
--- trunk/instant_messenger/inc/Jabberd2.abstract.php	(revision 227)
+++ 	(revision )
@@ -1,192 +1,0 @@
-<?php
-
-ini_set('include_path', $_SERVER['DOCUMENT_ROOT'] . '/instant_messenger/inc/');
-
-require_once 'Jabber.abstract.php';
-
-class Jabberd2 extends Jabber
-{
-	final function connect($pUser = false, $pPassword = false, $pConnectionType = false)
-	{
-		try
-		{
-			if ( $pUser && $pPassword && $pConnectionType )
-				if ( $_connect = parent::connect($pUser, $pPassword, $pConnectionType) )
-					return $_connect;
-
-			return false;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	function closeSocket()
-	{
-		$this->close($this->_socket);
-	}
-
-	function disconnect()
-	{
-		$this->_disconnect();
-	}
-
-	final function readSocket()
-	{
-		return $this->read();
-	}
-
-	final function writeSocket($pData)
-	{
-		return $this->write($pData);
-	}
-
-	/*
-	 * Jabber - Functions
-	 */
-
-	final function addContacts($pContact)
-	{
-		$jid = explode("@",$pContact['email']);
-		$jid = $jid[0]."@".$this->_server;
-		$name = $pContact['name'];
-		$group = $pContact['group'];
-
-		if(trim($jid[0]) != trim($this->_user))
-		{
-			if ( $jid )
-			{
-				$newcontact  = "<item jid='".$jid."'";
-				$newcontact .= " name='" . $name . "'";
-				$newcontact .= "><group>" . $group . "</group></item>";
-			}
-		}
-		$addid = "adduser_" . time();
-		if ( !$this->connected )
-			echo "disconnected";
-		else
-		{
-			if ( $this->writeSocket($this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact)) )
-				$this->getContacts();
-				echo "OK";
-		}
-	}
-
-	final function getContacts()
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		$this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster');
-	}
-
-	final function getVcard($pJid)
-	{
-		if ( is_array($pJid) )
-		{
-			$jid = ( trim($pJid['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pJid['jid'];
-			$vcard = (trim($pJid['jid']) == "this") ? 'vCard_user' : 'vCard';
-			
-			if ( !$this->connected )
-			{
-				echo "disconnected";
-			}
-			else
-			{
-				$this->writeSocket($this->iq('get', $vcard, $jid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>"));
-			}
-		}
-		else
-		{
-			$this->iq('get', 'vCard', $pJid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>");
-		}
-	}
-
-	final function newVcard($NewVcard)
-	{
-		$id = $this->_user;
-
-		if ( !$this->connected )
-			echo "disconnected";
-		else
-		{
-			$this->writeSocket($this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard['vcard']."</vCard>"));
-			echo "OK";
-		}
-	}
-
-	final function removeContact($pContact)
-	{
-		$delid  = 'deluser_' . time();
-		if ( !$this->isConnected() )
-			return "disconnected";
-			
-		if ( $this->writeSocket($this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>")) )
-			if ( $this->subscription($pContact['jid'],"unsubscribed") )
-				echo "OK";
-	}
-
-	final function subscription($pTo, $pType = false)
-	{
-		$jid = (is_array($pTo)) ? $pTo['jid'] : $pTo ;
-		$type = (is_array($pTo)) ? $pTo['type'] : $pType ;
-
-		if ( !$this->connected )
-			return false;
-		else
-		{
-			$this->writeSocket("<presence xmlns='jabber:client' from='".$this->_user."@".$this->_server."' type='".$type."' to='".$jid."'/>");
-			return true;
-		}
-	}
-
-	final function setPresence($pPresence = false)
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		if ( !$pPresence )
-			$this->presence();
-
-		$type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL;
-		$to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL;
-		$show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL;
-		$status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL;
-		$priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL;
-
-		$this->presence($type, $to, $show, $status, $priority);
-	}
-
-	final function setStatus()
-	{
-		$this->setPresence(array("type" => "unavailable"));
-		$this->setPresence(array("type" => "available"));	
-	}
-
-	final function updateContact($pContact)
-	{
-		$jid   = $pContact['jid'];
-		$name  = $pContact['name'];
-		$group = $pContact['group'];
-
-		if ( $jid )
-		{
-			$updatecontact  = "<item jid='$jid'";
-			$updatecontact .= " name='" . $name . "'";
-			$updatecontact .= "><group>" . $group . "</group></item>";
-		}
-
-		$upid = 'updateuser_' . time();
-		if ( !$this->connected )
-			echo "disconnected";
-		else
-		{
-			$this->writeSocket($this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact));
-			$this->getContacts();
-			echo "OK";
-		}
-	}
-}
-?>
Index: trunk/instant_messenger/inc/class.contacts_im.inc.php
===================================================================
--- trunk/instant_messenger/inc/class.contacts_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,120 +1,0 @@
-<?php
-
-require_once "class.ldap_im.inc.php";
-require_once "class.db_im.inc.php"; 
-
-class contacts_im
-{
-	private $ldap;
-	private $db_user;
-	
-	function __construct()
-	{
-		$this->ldap = new ldap_im();
-		$this->db_user = new db_im();		
-	}
-
-	private function users_auth_im()
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		
-		$search_uids = "|";
-		if(count($db_acls) > 0)
-			foreach($db_acls as $tmp)
-				$search_uids .= "(uidNumber=".$tmp['acl_account'].")";
-
-		// Busca Usuarios
-		$uids = $this->ldap->list_users_ldap($search_uids);
-		
-		$search_groups = "|";
-		if(count($db_acls) > 0)
-			foreach($db_acls as $tmp)
-				$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
- 
-		// Busca Grupos
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-	
-		$search_uids = "|";
-		if($groups)
-		{
-			foreach($groups as $tmp)
-			{
-				$members = $tmp['members'];	
-				foreach($members as $mb)		
-					$search_uids .= "(uid=".$mb.")";			
-			}
-		}
-		
-		if($uids)
-		{
-			foreach($uids as $tmp)	
-				$search_uids .= "(uid=".$tmp['uid'].")";
-		}
-		$uids_members = $this->ldap->list_users_ldap($search_uids);	
-		
-		if(count($uids_members) > 0)
-			return $uids_members;
-		else
-			return 0; 
-	}
-		
-	function list_contacts($param)
-	{
-		$users	= $this->users_auth_im();
-		$order	= array();
-		$return	= "<uids>";
-		
-		foreach($users as $tmp)
-			$order[] = $tmp['cn'].";".$tmp['mail'].";".$tmp['uid'].";".$tmp['dn'];
-					
-		natsort($order);
-		$uid_unique = @array_values(@array_unique($order));
-		
-		foreach($uid_unique as $tmp)
-		{	
-			$result = explode(";",$tmp);
-			if(strtolower($result[3]) == strtolower($param['ou']))
-			{
-				$return .= "<data>";
-				$return .= "<cn>" . $result[0] . "</cn>";
-				$return .= "<mail>" . $result[1] . "</mail>";				
-				$return .= "<uid>" . $result[2] . "</uid>";
-				$return .= "</data>";
-			}
-			unset($result);
-		}			
-		
-		$return .= "</uids>";
-		return $return;
-	}
-	
-	function UserPermission($param)
-	{
-		$db_acls = $this->db_user->get_accounts_acl();
-		$members = array();		
-		$search_uid 	= "";
-		$search_groups = "|";
-		
-		$search_uid = $this->ldap->list_users_ldap("uid=".$param['uid']);
-
-		foreach($db_acls as $tmp)
-			if($tmp['acl_account'] == $search_uid[0]['uidnumber'])
-				return 1;
-			else
-				$search_groups .= "(gidNumber=".$tmp['acl_account'].")";
-
-		$groups = $this->ldap->list_groups_ldap($search_groups);
-
-		if($groups)
-		foreach($groups as $tmp){
-			$members = $tmp['members'];	
-			foreach($members as $mb){		
-				if(trim($mb) == trim($search_uid[0]['uid']))
-					return 1;
-			}			
-		}
-		
-		return 0;
-	}
-}
-?>
Index: trunk/instant_messenger/inc/hook_admin.inc.php
===================================================================
--- trunk/instant_messenger/inc/hook_admin.inc.php	(revision 20)
+++ 	(revision )
@@ -1,22 +1,0 @@
-<?php
-	/**************************************************************************\
-	* eGroupWare                                                               *
-	* http://www.egroupware.org                                                *
-	* Written by Joseph Engo <jengo@phpgroupware.org>                          *
-	* --------------------------------------------                             *
-	*  This program is free software; you can redistribute it and/or modify it *
-	*  under the terms of the GNU General Public License as published by the   *
-	*  Free Software Foundation; either version 2 of the License, or (at your  *
-	*  option) any later version.                                              *
-	\**************************************************************************/
-
-// Only Modify the $file and $title variables.....
-	$title = 'instant_messenger';
-	$file = array(
-		'Site Configuration'	=> $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
-	);
-	
-//Do not modify below this line
-	display_section($appname,$title,$file);
-
-?>
Index: trunk/instant_messenger/inc/load_lang.php
===================================================================
--- trunk/instant_messenger/inc/load_lang.php	(revision 151)
+++ 	(revision )
@@ -1,26 +1,0 @@
-<?
-if ( !isset($_SESSION['phpgw_info']['instant_messenger']['lang']) || !is_array($_SESSION['phpgw_info']['instant_messenger']['lang']) )
-   if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) )
-      if ( ($fp = fopen($fn,'r')) )
-      {
-         while ($data = fgets($fp,16000))
-         {
-            list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1));
-            $_SESSION['phpgw_info']['instant_messenger']['lang'][$message_id] = $content;
-         }
-         fclose($fp);
-      }
-
-$script  = '<script>';
-$script .= 'var lang_im = [];';
-
-foreach ( $_SESSION['phpgw_info']['instant_messenger']['lang'] as $key => $value )
-   $script .= "lang_im['" . strtolower(addslashes($key)) . "'] = '" . addslashes($value) . "';";
-
-   #$_key = str_replace("'","\'",strtolower($key));
-   #$_val = str_replace("'","\'",$value);
-
-$script .= '</script>';
-
-echo $script;
-?>
Index: trunk/instant_messenger/inc/class.ldap_im.inc.php
===================================================================
--- trunk/instant_messenger/inc/class.ldap_im.inc.php	(revision 151)
+++ 	(revision )
@@ -1,191 +1,0 @@
-<?php
-class ldap_im
-{
-	private $ldap_host;
-	private $ldap_context;
-	private $conn;
-	private $user;
-	private $jid;
-	private $password;
-	
-	function __construct()
-	{
-		session_start();
-		$this->ldap_host 		= $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'];
-		$this->ldap_context 	= $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'];
-		$this->user 			= $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'];
-		$this->password 		= $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'];
-		$this->jid				= $_SESSION['phpgw_info']['instant_messenger']['user'];
-		$this->connect_ldap(false);
-		session_write_close();
-	}
-	
-	function __destruct()
-	{
-		ldap_close($this->conn);
-	}
-	
-	function connect_ldap($refer)
-	{
-		$this->conn = ldap_connect($this->ldap_host);
-		ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
-		ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $refer);
-		if(trim($this->user) != "")
-			@ldap_bind($this->conn,$this->user,$this->password);
-		else		
-			@ldap_bind($this->conn);
-	}
-	
-	function get_photo_ldap($pUser,$getPhoto)
-	{
-		$user = ( $pUser == "im_avatar" ) ? $this->jid : $pUser ;
-		
-		if ($this->conn) 
-		{
-			$filter="(&(uid=".$user.")(phpgwAccountType=u))";		
-			$justthese = array("jpegphoto");
-			$search = @ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = @ldap_first_entry($this->conn, $search);
-			$jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto");
-			
-			if( count($jpeg_data) > 1)
-			{
-				$photo = imagecreatefromstring($jpeg_data[0]);
-				if($photo)
-				{
-					if($getPhoto)
-					{
-						header("Content-Type: image/jpeg");
-						$width = imagesx($photo);
-						$height = imagesy($photo);
-						$twidth = 49;
-						$theight = 65;
-						$small_photo = imagecreatetruecolor ($twidth, $theight);
-						imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
-						imagejpeg($small_photo,'',100);
-						return;		
-					}else{
-						return "true";
-					}				
-				}else{
-					return "false";
-				}
-			}else{
-				return "false";
-			}
-		}
-	}
-	
-	function photo_ldap($user)
-	{
-		$uid = ( $user['uid'] == "im_avatar" ) ? $this->jid : $user['uid'] ;
-		return $this->get_photo_ldap($uid,false);
-	}
-	
-	function list_users_ldap($search)
-	{
-
-		if($this->conn){
-			$filter = "(&(".$search.")(phpgwAccountType=u))";
-			$justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn");
-			$search = ldap_search($this->conn,$this->ldap_context,$filter,$justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-		
-		if( $entry['count'] > 0){
-			$i = 0;
-			$result_user = array();
-			foreach($entry as $tmp)
-			{
-				if($tmp['uidnumber'][0] != "" && $tmp['phpgwaccountvisible'][0] != "-1"){
-					$result_user[$i]['uidnumber'] = $tmp['uidnumber'][0];			
-					$result_user[$i]['mail'] = $tmp['mail'][0];
-					$result_user[$i]['uid'] = $tmp['uid'][0];
-					$result_user[$i]['cn'] = $tmp['cn'][0];
-					$ou = explode("dc=",$tmp['dn']);
-					$ou = explode("ou=",$ou[0]);
-					$ou = array_pop($ou);
-					$result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));					
-					$i++;
-				}				
-			}
-			return $result_user;
-		}
-		return 0;
-	}
-	
-	function list_groups_ldap($search)
-	{
-	
-		if( $this->conn ){
-			$filter = "(&(".$search.")(objectClass=posixGroup))";
-			$justthese = array("gidnumber","cn","memberuid");			
-			$search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn,$search);
-		}
-
-		if($entry['count'] > 0){
-			$i = 0;
-			$result_groups = array();
-			foreach($entry as $tmpg){
-				if($tmpg['gidnumber'] != ""){
-					if(array_key_exists("memberuid", $tmpg)){
-						$result_groups[$i]['gidnumber'] = $tmpg['gidnumber'][0];						
-						@array_shift($tmpg['memberuid']);
-						foreach($tmpg['memberuid'] as $tmp)
-							$result_groups[$i]['members'][] = $tmp;					
-						$i++;
-					}
-				}
-			}	
-		}
-		
-		if(count($result_groups) > 0 ){
-			return $result_groups;
-		}else{
-			return 0;
-		}
-	}
-	
-	function list_organizations_ldap()
-	{
-		$result_org = "<organizations><ou></ou>";
-
-		if ($this->conn) 
-		{
-			$filter="ou=*";		
-			$justthese = array("ou");
-			$search = ldap_list($this->conn,$this->ldap_context, $filter, $justthese);
-			$entry = ldap_get_entries($this->conn, $search);
-		}
-		
-		foreach($entry as $tmp)
-			if($tmp['ou'][0] != "")
-				$result_org .= "<ou>" . $tmp['ou'][0] . "</ou>";  
-
-		$result_org .= "</organizations>";
-		
-		return $result_org;
-	}
-	
-	function info_user($user)
-	{
-		$uid = "uid=".$user['uid'];
-		$i= 0;
-		
-		$entry = $this->list_users_ldap($uid);
-		
-		if( count($entry) > 0 )
-			return $entry;
-		else
-			return false;	
-	}
-}
-
-if(trim($_REQUEST['user']) != "")
-{
-	$obj_img = new ldap_im();
-	$obj_img->get_photo_ldap($_REQUEST['user'],true);
-}
-
-?>
Index: trunk/instant_messenger/inc/class.download.inc.php
===================================================================
--- trunk/instant_messenger/inc/class.download.inc.php	(revision 20)
+++ 	(revision )
@@ -1,155 +1,0 @@
-<?php
-
-class download
-{
-	
-	function Decode_String($string)
-	{
-		$base64 = $string;	
-		$base64_de = base64_decode($base64);
-		$array_info = unserialize($base64_de);
-	
-		if($array_info['server'] == $_SERVER['SERVER_ADDR']){
-			$this->down_file($array_info['fileUp']);
-		}else{
-			$url = "http://".$array_info['server'].$array_info['path'].$array_info['filePhp'].$base64;
-			header("Location:" . $url);
-		}
-	}
-
-	function down_file($file)
-	{   
-		 
-		ini_set("session.save_path","/php_sessions");
-		$size = filesize(ini_get("session.save_path").'/'. $file);
-		$NameFile = explode("_IM_SendFile_",$file);
-	
-		 if (!empty($file))
-	     {
-		        if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		           $UserBrowser = "Opera";
-		        elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
-		            $UserBrowser = "IE";
-	            else
-		            $UserBrowser = '';
-
-				$strFileType = strrev(substr(strrev($NameFile),0,4));
-				$ContentType = "application/octet-stream";
-
-			   	if ($strFileType == ".asf") 
-			   		$ContentType = "video/x-ms-asf";
-			   	if ($strFileType == ".avi")
-			   		$ContentType = "video/avi";
-			   	if ($strFileType == ".doc")
-			   		$ContentType = "application/msword";
-			   	if ($strFileType == ".zip")
-			   		$ContentType = "application/zip";
-			   	if ($strFileType == ".xls")
-			   		$ContentType = "application/vnd.ms-excel";
-			   	if ($strFileType == ".gif")
-			   		$ContentType = "image/gif";
-			   	if ($strFileType == ".jpg" || $strFileType == "jpeg")
-			   		$ContentType = "image/jpeg";
-			   	if ($strFileType == ".wav")
-			   		$ContentType = "audio/wav";
-			   	if ($strFileType == ".mp3")
-			   		$ContentType = "audio/mpeg3";
-			   	if ($strFileType == ".mpg" || $strFileType == "mpeg")
-			   		$ContentType = "video/mpeg";
-			   	if ($strFileType == ".rtf")
-			   		$ContentType = "application/rtf";
-			   	if ($strFileType == ".htm" || $strFileType == "html")
-			   		$ContentType = "text/html";
-			   	if ($strFileType == ".xml") 
-			   		$ContentType = "text/xml";
-			   	if ($strFileType == ".xsl") 
-			   		$ContentType = "text/xsl";
-			   	if ($strFileType == ".css") 
-			   		$ContentType = "text/css";
-			   	if ($strFileType == ".php") 
-			   		$ContentType = "text/php";
-			   	if ($strFileType == ".asp") 
-			   		$ContentType = "text/asp";
-			   	if ($strFileType == ".pdf")
-			   		$ContentType = "application/pdf";
-			   	if ($strFileType == ".txt")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".log")
-			   		$ContentType = "text/plain";
-			   	if ($strFileType == ".wmv")
-			   		$ContentType = "video/x-ms-wmv";
-				if ($strFileType == ".sxc")
-					$ContentType = "application/vnd.sun.xml.calc";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".stc")
-					$ContentType = "application/vnd.sun.xml.calc.template";
-				if ($strFileType == ".sxd")
-					$ContentType = "application/vnd.sun.xml.draw";
-				if ($strFileType == ".std")
-					$ContentType = "application/vnd.sun.xml.draw.template";
-				if ($strFileType == ".sxi")
-					$ContentType = "application/vnd.sun.xml.impress";
-				if ($strFileType == ".sti")
-					$ContentType = "application/vnd.sun.xml.impress.template";
-				if ($strFileType == ".sxm")
-					$ContentType = "application/vnd.sun.xml.math";
-				if ($strFileType == ".sxw")
-					$ContentType = "application/vnd.sun.xml.writer";
-				if ($strFileType == ".sxq")
-					$ContentType = "application/vnd.sun.xml.writer.global";
-				if ($strFileType == ".stw")
-					$ContentType = "application/vnd.sun.xml.writer.template";
-				if ($strFileType == ".ps")
-					$ContentType = "application/postscript";
-				if ($strFileType == ".pps")
-					$ContentType = "application/vnd.ms-powerpoint";
-				if ($strFileType == ".odt")
-					$ContentType = "application/vnd.oasis.opendocument.text";
-				if ($strFileType == ".ott")
-					$ContentType = "application/vnd.oasis.opendocument.text-template";
-				if ($strFileType == ".oth")
-					$ContentType = "application/vnd.oasis.opendocument.text-web";
-				if ($strFileType == ".odm")
-					$ContentType = "application/vnd.oasis.opendocument.text-master";
-				if ($strFileType == ".odg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics";
-				if ($strFileType == ".otg")
-					$ContentType = "application/vnd.oasis.opendocument.graphics-template";
-				if ($strFileType == ".odp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation";
-				if ($strFileType == ".otp")
-					$ContentType = "application/vnd.oasis.opendocument.presentation-template";
-				if ($strFileType == ".ods")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet";
-				if ($strFileType == ".ots")
-					$ContentType = "application/vnd.oasis.opendocument.spreadsheet-template";
-				if ($strFileType == ".odc")
-					$ContentType = "application/vnd.oasis.opendocument.chart";
-				if ($strFileType == ".odf")
-					$ContentType = "application/vnd.oasis.opendocument.formula";
-				if ($strFileType == ".odi")
-					$ContentType = "application/vnd.oasis.opendocument.image";
-				if ($strFileType == ".ndl")
-					$ContentType = "application/vnd.lotus-notes";
-								
-		        $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
-	
-		        header("Content-Type: $ContentType");
-		        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
-		        header("Pragma: public");
-		        header("Expires: 0");
-		        header("Content-Disposition: attachment; filename=\"" . $NameFile[1] . "\"");
-				header("Content-length: " . $size);
-				readfile(ini_get("session.save_path") . "/" . $file); 
-				die();
-	    }
-	}
-}
-
-if(isset ($_REQUEST['file'])){
-	$obj_down = new download();
-	$obj_down->Decode_String($_REQUEST['file']);
-}
-
-?>
Index: trunk/instant_messenger/inc/im_sessions.inc.php
===================================================================
--- trunk/instant_messenger/inc/im_sessions.inc.php	(revision 164)
+++ 	(revision )
@@ -1,22 +1,0 @@
-<?php
-
-		$_SESSION['phpgw_info']['instant_messenger']['user']             = $GLOBALS['phpgw_info']['user']['account_lid'];
-		$_SESSION['phpgw_info']['instant_messenger']['user_id']			 = $GLOBALS['phpgw_info']['user']['account_id'];		
-		$_SESSION['phpgw_info']['instant_messenger']['passwd']           = $GLOBALS['phpgw_info']['user']['passwd'];
-		$_SESSION['phpgw_info']['instant_messenger']['name_jabber']      = $GLOBALS['phpgw_info']['server']['name_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['port_jabber']      = $GLOBALS['phpgw_info']['server']['port_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['resource_jabber']  = $GLOBALS['phpgw_info']['server']['resource_jabber'];
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['server_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['context_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']     = $GLOBALS['phpgw_info']['server']['user_ldap_jabber'];
-		$_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabber'];
-		
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass'];
-		$_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type'];
-
-?>
Index: trunk/instant_messenger/inc/class.Ujabber.inc.php
===================================================================
--- trunk/instant_messenger/inc/class.Ujabber.inc.php	(revision 236)
+++ 	(revision )
@@ -1,146 +1,0 @@
-<?php
-
-require_once 'Jabberd2.abstract.php';
-
-class Ujabber extends Jabberd2
-{
-	public final function __construct()
-	{
-		session_start();
-
-		$this->_user     = $_SESSION['phpgw_info']['instant_messenger']['user'];
-		$this->_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd'];
-		$this->_server   = $_SESSION['phpgw_info']['instant_messenger']['name_jabber'];
-		$this->_port     = $_SESSION['phpgw_info']['instant_messenger']['port_jabber'];
-		$this->_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'];
-
-		session_write_close();
-
-		if ( $this->connect($this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port, $this->_pass, 'read/write') )
-			$this->connected = true;
-		else
-			$this->connected = false;
-	}
-
-	public final function __destruct()
-	{
-		$this->closeSocket();
-		ob_end_flush();
-		flush();
-	}
-	
-	public final function isConnected()
-	{
-		return $this->connected;
-	}
-	
-	public final function listen()
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
-		{
-			sleep(1);
-			$xml = $this->readSocket();
-			printf("%s", $xml);
-		}
-		else
-		{
-			ob_end_clean();
-			ignore_user_abort(true);
-			ob_start();
-
-			$init = time();
-
-			while ( ( connection_aborted() === 0 ) && time() - $init < 50 )
-			{
-				# read from server and write in the client
-				$xml = $this->readSocket();
-				//var_dump($xml);
-				$xml = ( strlen($xml) ) ? $xml : ' ';
-				printf("%s", $xml);
-				ob_flush();
-				flush();
-				usleep(6000);
-			}
-		}
-	}
-
-	public final function SendMessage($pSendMessage)
-	{
-		if ( !$this->isConnected() )
-			return "disconnected";
-
-		$pSendMessage['body'] = stripslashes($pSendMessage['body']);
-
-		$patterns = array('/&nbsp;| +/i', '/<br[^>]*>/i');
-		$replace = array(' ', '<br />');
-		$pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']);
-
-		$_emotions  = '/<img emotion="(\S+)?"[^>]+>/';
-		$_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions);
-
-		foreach ( $emotions[0] as $key => $val )
-			$emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i';
-
-		$pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']);
-
-		$to = $pSendMessage['to'];
-		$type = "chat";
-		$id = "";
-		$content = array(
-			"subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "",
-			"thread"  => $pSendMessage['thread'] ? $pSendMessage['thread'] : "",
-			"body"    => $pSendMessage['body'] ? $pSendMessage['body'] : ""
-		);
-
-		$payload = "";
-
-		if ($to && is_array($content))
-		{
-			if (!$id)
-			{
-				$id = $type . "_" . time();
-			}
-
-			$xml = "<message to='$to' type='$type' id='$id'>";
-
-			if ($content['subject'])
-			{
-				$xml .= "<subject>" . $content['subject'] . "</subject>";
-			}
-
-			if ($content['thread'])
-			{
-				$xml .= "<thread>" . $content['thread'] . "</thread>";
-			}
-
-			//Linha abaixo dentro do padrão xmpp, entretanto clientes como
-			//o PSI não seguem o padrão assim ocorre problemas de comunicação
-			//descomentar e retirar a seguinte para voltar ao padrÃ£o assim
-			//que possí­vel
-			//24/10/2007 - problema verificado por usuários do SERPRO na
-			//plataforma Windows ocorrendo também no cliente Linux
-			//por Alexandre e Rodrigo
-
-			//$xml .= "<html><body>" . $content['body'] . "</body></html>";
-
-			//retirar a linha abaixo para voltar ao padrÃ£o conforme acima
-			$xml .= "<body>" . $content['body'] . "</body>";
-			$xml .= $payload;
-			$xml .= "</message>";
-			unset($id);
-
-			echo $xml;
-			$this->writeSocket($xml);
-			$this->close();
-		}
-		else
-		{
-			//$this->writeLog("ERROR: SendMessage() #2");
-			return false;
-		}
-	}
-}
-?>
Index: trunk/instant_messenger/inc/class.db_im.inc.php
===================================================================
--- trunk/instant_messenger/inc/class.db_im.inc.php	(revision 164)
+++ 	(revision )
@@ -1,105 +1,0 @@
-<?php
-define('PHPGW_INCLUDE_ROOT','../');	
-define('PHPGW_API_INC','../phpgwapi/inc');
-require_once(PHPGW_API_INC.'/class.db.inc.php');
-	
-class db_im
-{	
-	
-	var $db;
-	var $db_name;
-	var $db_host;
-	var $db_port;
-	var $db_user;
-	var $db_pass;
-	var $db_type;
-	var $user_id;
-	var $teste;
-	
-	function db_im()
-	{
-		
-		session_start();		
-		$this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
-		$this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
-		$this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
-		$this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
-		$this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
-		$this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
-		$this->user_id = $_SESSION['phpgw_info']['instant_messenger']['user_id'];
-		session_write_close();
-
-		$this->db = new db();
-		$this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);		
-	}
-
-	function get_accounts_acl()
-	{
-		$result = array();
-		$query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";	
- 		
- 		if (!$this->db->query($query))
-        	return null;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		return $result;
-	}
-	
-	function query_db($pQuery)
-	{
-		if (!$this->db->query($pQuery))
-        	return false;
-		else
-			return true;
-	}
-	
-	function set_preferences($param)
-	{
-		$preferences = $param['preferences'];
-		$user_id  = $this->user_id;
-		$app_name = $this->name_app();
-		
-		$query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')";
-		
-		if($this->query_db($query))
-		{ 
-			return "true";
-		}
-		else
-		{
-			$query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'";
-			if($this->query_db($query))
-				return "true";
-			else
-				return "false";			
-		}		
-	}
-	
-	function get_preferences()
-	{
-		$result = array();
-		$user_id  = $this->user_id;
-		$app_name = $this->name_app();
-		
-		$query = "select * from phpgw_preferences where preference_owner = '".$user_id."' and preference_app = '".$app_name."'";
-		
- 		if (!$this->db->query($query))
-        	return NULL;
-		
-		while($this->db->next_record())
-			$result[] = $this->db->row();
-
-		if(count($result) > 0)
-			return unserialize($result[0]['preference_value']);
-		else
-			return "ch_offline:true;time_xa_im:1;rd_nm:true;rd_ch:false";
-	}		
-	
-	function name_app()
-	{
-		return "instant_messenger";
-	}
-}
-?>
Index: trunk/instant_messenger/inc/Jabber.abstract.php
===================================================================
--- trunk/instant_messenger/inc/Jabber.abstract.php	(revision 239)
+++ 	(revision )
@@ -1,335 +1,0 @@
-<?php
-/*
-+---------------------------------------------------------------------------------+
-|                                                                                 |
-| @FILE:        Jabber.abstract.php                                               |
-| @ABSTRACT:    Jabber                                                            |
-| @EXTENDS:     Socket (Socket.class.php)                                         |
-|                                                                                 |
-| @DATE:        Wed May,16 2007 08:18:59                                          |
-| @LAST_CHANGE: Wed May,16 2007 09:03:28                                          |
-|                                                                                 |
-| @AUTHOR:      [NUTS] Rodrigo Souza - rodrigosouzadossantos [at] gmail [dot] com |
-|                                                                                 |
-| @BRIEF:       Abstract class for connect with any Jabber server                 |
-|                                                                                 |
-+---------------------------------------------------------------------------------+
-*/
-
-require_once 'Socket.abstract.php';
-
-abstract class Jabber extends Socket
-{
-	const J_FILE    = 'Jabber.log';
-	const J_ALL     = false;
-	const J_ERROR   = true;
-	const J_WARNING = true;
-	const J_NOTICE  = true;
-
-	const ALL     = 'ALL';
-	const ERROR   = 'ERROR';
-	const WARNING = 'WARNING';
-	const NOTICE  = 'NOTICE';
-
-	private final function _connect( $pUser = false, $pPassword = false, $pConnectionType = false )
-	{
-		try
-		{
-			if ( !preg_match('/^(.+)@(.+)\/(.+):(\d+)$/',$pUser, $matches) )
-				throw new Exception('[connect] #1 ' . $pUser . ' must be [USER]@[DOMAIN]/[RESOURCE]:[PORT] and [PORT] is integer. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			list($subject, $USER, $SERVER, $RESOURCE, $PORT) = $matches;
-
-			if ( !($socket = $this->open('tcp://' . $SERVER . ':' . $PORT, 1, 1)) )
-				throw new Exception('[connect] #2 can\'t access tcp://' . $SERVER . ':' . $PORT . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			$this->_socket = $socket;
-
-			fwrite($socket, "{$USER}@{$SERVER}##{$pPassword}##{$pConnectionType}");
-
-			$return = fread($socket, 3);
-
-			if ( $return == "new" )
-			{
-				$xml  = "<?xml version='1.0' ?>";
-				$xml .= "<stream:stream to='" . $SERVER . "' xmlns='jabber:client' ";
-				$xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-
-				if ( $this->write($xml) === false )
-					throw new Exception('[connect] #4 it isn\'t possible connect in the server because exists a client connected with same user. File: ' . __FILE__ . '  ::  ' . __LINE__);
-			}
-
-			$this->_server = $SERVER;
-			$this->_username = $USER;
-			$this->_password = $pPassword;
-			$this->_resource = $RESOURCE;
-
-			return $return;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	protected function connect($pUser = false, $pPassword = false, $pConnectionType = false)
-	{
-		try
-		{
-			$_connect = $this->_connect($pUser, $pPassword, $pConnectionType);
-
-			if ( !$_connect )
-				throw new Exception('[connect] #0. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			if ( $_connect == "new" )
-			{
-				if ( ($xml = $this->read()) === false )
-					throw new Exception('[connect] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-
-				if ( preg_match('/(<starttls .*<required\/><\/starttls>)/', $xml, $matches) )
-				{
-					if ( !$this->starttls() )
-						throw new Exception('[connect] #2 it isn\'t possible start tls. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-					# $this->writeLog('NOTICE', 'Connected TLS');
-				}
-				else
-				{
-					if ( !$this->_plain() )
-						throw new Exception('[connect] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-				}
-			}
-
-			return $_connect;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			$this->_disconnect();
-			return false;
-		}
-	}
-
-	protected final function _disconnect()
-	{
-		try
-		{
-			$xml = "</stream:stream>";
-
-			#if ( $this->write($xml) === false )
-			#	throw new Exception('[disconnect] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			#if ( ($xml = $this->read()) === false )
-			#	throw new Exception('[disconnect] #2 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	private final function starttls()
-	{
-		try
-		{
-			$xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>";
-			if ( $this->write($xml) === false )
-				throw new Exception('[starttls] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			usleep(50000);
-			fread($this->_socket, 4096);
-
-			stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
-
-			$xml  = "<?xml version='1.0' encoding='UTF-8'?>";
-			$xml .= "<stream:stream to='" . $this->_server . "' xmlns='jabber:client' ";
-			$xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>";
-
-			if ( $this->write($xml) === false )
-				throw new Exception('[starttls] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			usleep(50000);
-
-			fread($this->_socket, 4096);
-
-			usleep(50000);
-			
-			fread($this->_socket, 4096);
-			
-			if ( !$this->_plain() )
-				throw new Exception('[starttls] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	private final function _plain()
-	{
-		try
-		{
-			$this->blocking($this->_socket, 0);
-
-			if ( ($xml = $this->read()) === false )
-				throw new Exception('[_plain] #1 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			$xml  = "<username>" . $this->_username . "</username>";
-			$xml .= "<password>" . $this->_password . "</password>";
-			$xml .= "<resource>" . $this->_resource . "</resource>";
-
-			unset($this->_password);
-
-			if ( !$this->iq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) )
-				throw new Exception('[_plain] #2 it isn\'t possible carry out the verification. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			while ( !preg_match("/<iq xmlns='jabber:client' id='auth_1' type='(result|error)'/", ($readSocket = $this->read()), $matches) )
-				usleep(10000);
-
-			if($matches[1] == "error")
-				return false;
-
-			if ( ($xml = $this->read()) === false )
-				throw new Exception('[_plain] #3 it isn\'t possible read the socket. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	private final function _iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false )
-	{
-		$xml  = "<iq type='" . $pType . "' id='" . $pId . "'";
-		$xml .= ( $pTo ) ? " to='" . $pTo . "'" : "";
-		$xml .= ( $pFrom ) ? " from='" . $pFrom . "'" : "";
-
-		if ( $pXmlns == "vcard-temp" )
-		{
-			$xml .= ">";
-			$xml .= $pLoad;
-		}
-		else
-		{
-			$xml .= "><query xmlns='" . $pXmlns . "'";
-			$xml .= ( $pLoad ) ? ">" . $pLoad . "</query>" : "/>";
-		}
-
-		$xml .= "</iq>";
-
-		return $xml;
-	}
-
-	protected final function iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false)
-	{
-		try
-		{
-			if ( !preg_match("/^(get|set|result|error)$/i", $pType, $matches) )
-				throw new Exception('[iq] #1 type must be GET, SET, RESULT or ERROR. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			if ( $this->write($this->_iq($pType, $pId, $pTo, $pFrom, $pXmlns, $pLoad)) === false )
-				throw new Exception('[iq] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . '  ::  ' . __LINE__);
-			else
-				return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	protected final function presence($pType = false, $pTo = false, $pShow = false, $pStatus = false, $pPriority = false)
-	{
-		try
-		{
-			$xml  = "<presence";
-			$xml .= ($pTo)   ? " to='{$pTo}'" : '';
-			$xml .= ($pType) ? " type='{$pType}'" : '';
-
-			if ( !($pStatus || $pShow || $pPriority) )
-				$xml .= "/>";
-			else
-			{
-				$xml .= ">";
-				$xml .= ($pStatus) ? "<status>" . $pStatus . "</status>" : '';
-				$xml .= ($pShow) ? "<show>" . $pShow . "</show>" : '';
-				$xml .= ($pPriority) ? "<priority>" . $pPriority . "</priority>" : '';
-				$xml .= ($pStatus || $pShow || $pPriority) ? "</presence>" : '';
-			}
-
-			if ( $this->write($xml) === false )
-				throw new Exception('[presence] #1 it isn\'t possible send presence for ' . $this->_server . '. File: ' . __FILE__ . '  ::  ' . __LINE__);
-
-			return true;
-		}
-		catch(Exception $e)
-		{
-			$this->writeLog('ERROR', $e->getMessage());
-			return false;
-		}
-	}
-
-	protected final function read()
-	{
-		$return = NULL;
-		do
-		{
-			$line = NULL;
-			$line = utf8_decode(parent::read($this->_socket, 4096));
-
-			if ( $line === false )
-			{
-				$return = false;
-				break;
-			}
-
-			if ( $line != NULL )
-				$return .= $line;// . "\n";
-		}
-		while ( $line != NULL );
-
-		return $return;
-	}
-
-	protected final function write($pData = false)
-	{
-		if ( !$pData )
-			return false;
-
-		return parent::write($this->_socket, utf8_encode($pData));
-	}
-
-	function __destruct()
-	{
-		$this->close($this->_socket);
-	}
-
-	protected final function writeLog($pType = false, $pLog = false)
-	{
-		if ( !defined('self::'.$pType) && !$pLog )
-			return false;
-
-		if ( !(bool)constant('self::J_'.$pType) && !(bool)constant('self::J_ALL') )
-			return false;
-
-		$log  = date('m/d/Y H:i:s');
-		$log .= ' [' . constant('self::'.$pType) . '] :: ';
-		$log .= $pLog . "\n";
-		if ( $fp = fopen (self::J_FILE, "a+") )
-		{
-			fwrite($fp, $log);
-			fclose($fp);
-		}
-	}
-}
-?>
