Index: trunk/instant_messenger/bkp/instant_messenger_32/IMManager.php
===================================================================
--- trunk/instant_messenger/bkp/instant_messenger_32/IMManager.php	(revision 151)
+++ 	(revision )
@@ -1,263 +1,0 @@
-#!/usr/bin/php -Cq
-<?php
-
-   require_once('inc/IMConfigure.php');
-	require_once('inc/Jabberd2.abstract.php');
-
-	## limit to indefinite execution
-	set_time_limit (0);
-   
-   ###
-   # definitions of socket - BEGIN
-   #
-      define('URI', '0.0.0.0');
-      define('TARGET_NON_SECURITY', TRANSPORT_NON_SECURITY . '://' . URI  . ':' . PORT_NON_SECURITY);
-      define('SOCKET_NON_SECURITY', stream_socket_server(TARGET_NON_SECURITY, $errno_non_security, $errstr_non_security, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN));
-   #
-   # definitions of socket - END
-   ###
-
-
-   if ( !SOCKET_NON_SECURITY )
-   {
-      printf("NON SECURITY:\n(%d) %s", $errno_non_security, $errstr_non_security);
-      exit(0);
-   }
-
-   $master = array(SOCKET_NON_SECURITY);
-   $users = array();
-   $send = false;
-
-   while ( true )
-   {
-      $read = $master;
-      $_w = NULL;
-      $_e = NULL;
-       
-      $mod_fd = @stream_select($read, $_w , $_e , READ_SOCKET_AFTER_OF );
-		
-      if ( $mod_fd === FALSE )
-      {
-         break;
-      }
-
-      for ( $i = 0; $i < $mod_fd; ++$i )
-      {
-         if ( $read[$i] === SOCKET_NON_SECURITY )
-         {
-            $conn_non_security = stream_socket_accept(SOCKET_NON_SECURITY);
-            $master[] = &$conn_non_security;
-         }
-         else
-         {
-            $sock_data = fread($read[$i], 1024);
-            if ( strlen($sock_data) === 0 )
-            {
-               $key_to_del = array_search($read[$i], $master, TRUE);
-               fclose($read[$i]);
-               unset($master[$key_to_del]);
-            }
-            else if ( $sock_data === FALSE )
-            {
-               $key_to_del = array_search($read[$i], $master, TRUE);
-               unset($master[$key_to_del]);
-            }
-            else
-            {
-               $headers = (split("\n", $sock_data));
-
-               preg_match('/^(GET|POST) \/(.+) HTTP\/1\.\d/U', $headers[0], $request);
-               preg_match('/^Host: \w*:(.+)/', $headers[1], $host);
-
-               $conn = &$conn_non_security;
-
-               $request = explode(';', $request[2]);
-
-               if ( $request[0] == CONNECT && isset($request[1]) && !isset($users[$request[1]]) )
-               {
-                  connect($users, $request[1]);
-               }
-
-               if ( $request[0] == CLOSE && isset($request[1]) && isset($users[$request[1]]) )
-               {   
-               	close($request[1]);
-               }
-
-               fclose($read[$i]);
-               unset($master[array_search($read[$i], $master)]);
-            }
-         }
-      }	
-      
-      foreach ( $users as $key => $val )
-      {
-   		$time_now = time();
-   		if ( ( $time_now - $users[$key]['timeClient'] ) < DISCONNECT_AFTERWARDS_OF )         
-         {
-         	readSocket($users, $key);
-         }
-         else
-         {
-				if((($time_now - $users[$key]['timeClient']) / DISCONNECT_AFTERWARDS_OF) > 2 )
-				{
-     				$users[$key]['jabber']->disconnect();
-     				unset($users[$key]);     				
-				}
-				else
-				{
-					readSocket($users, $key);
-				}         	
-         }
-      }
-   }
-	
-   exit(0);
-
-   function connect(&$pUsers, $pSession)
-   {
-		global $users;
-		      
-      $sessionpath = explode(';', session_save_path());
-      foreach ( $sessionpath as $path )
-      {
-         $path = ( strrpos($path, '/') == strlen($path) - 1 ) ? $path : $path . '/';
-
-         if ( file_exists($path . 'sess_' . $pSession) )
-         {
-            session_id($pSession);
-
-            ob_start();
-            session_start();
-            ob_clean();
-            ob_end_flush();
-
-            $is_user = isset($_SESSION['phpgw_info']['instant_messenger']['user']) and isset($_SESSION['phpgw_info']['instant_messenger']['passwd']);
-            if ( $is_user )
-            {
-               $_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'];
-               $_time     = time();
-               $_SESSION['phpgw_info']['instant_messenger']['timeClient'] = $_time;
-					$_SESSION['phpgw_info']['instant_messenger']['timeServer'] = $_time;               
-               $_SESSION['phpgw_info']['instant_messenger']['socket'] = NULL;
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['in'] = NULL;
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['out'] = array();
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] = NULL;
-               $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = false;
-
-               session_write_close();
-
-               $a = new Jabberd2;
-               if ( ($a->connect($_user . '@' . $_server . '/' . $_resource . ':' . $_port, $_pass)) )
-               {
-                  $pUsers[$pSession] = array();
-                  $pUsers[$pSession]['jabber'] = $a;
-                  $pUsers[$pSession]['timeClient'] = $_time;
-               }
-               else
-               {
-                  unset($a);
-               }
-               break;
-            }
-            session_write_close();
-         }
-      }
-   }
-
-   function close($pUser)
-   {
-      global $users;
-      $users[$pUser]['jabber']->disconnect();
-      unset($users[$pUser]);
-   }
-
-   function readSocket(&$pUsers, $pSession)
-   {
-      global $send;
-      $sessionpath = explode(';', session_save_path());
-      foreach ( $sessionpath as $path )
-      {
-         $path = ( strrpos($path, '/') == strlen($path) - 1 ) ? $path : $path . '/';
-
-         if ( file_exists($path . 'sess_' . $pSession) )
-         {
-            session_id($pSession);
-
-            ob_start();
-            session_start();
-            ob_clean();
-            ob_end_flush();
-
-            $is_user = isset($_SESSION['phpgw_info']['instant_messenger']['user']) and isset($_SESSION['phpgw_info']['instant_messenger']['passwd']);
-            if ( $is_user )
-            {
-               $pUsers[$pSession]['timeClient'] = $_SESSION['phpgw_info']['instant_messenger']['timeClient'];
-               $_SESSION['phpgw_info']['instant_messenger']['timeServer'] = time();
-               
-					$readSocket = @$pUsers[$pSession]['jabber']->readSocket();
-               
-               $connection_close_timeout = strpos($readSocket, "<stream:error");
-               $connection_close_server = strpos($readSocket,"</stream:stream>");
-               
-               if ( ($readSocket !== false) && ($connection_close_timeout === false ) && ($connection_close_server === false ))
-               {
-                  $_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'] = false;
-                  if ( !empty($readSocket) )
-                  {
-                     $_SESSION['phpgw_info']['instant_messenger']['socket']['in'] .= $readSocket;
-                  }
-
-						if ( $_SESSION['phpgw_info']['instant_messenger']['socket']['out'] )
-							foreach ( $_SESSION['phpgw_info']['instant_messenger']['socket']['out'] as $action => $value )
-							{
-								if ( $action === 'message' )
-								{
-									if ( !is_null($value) )
-									{
-										$pUsers[$pSession]['jabber']->writeSocket($value);
-										$_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] = NULL;
-									}
-								}
-								else if ( $action === 'vcard' )
-								{
-									if ( !empty($value) )
-									{
-										foreach ( $value as $key => $val )
-										{
-											$pUsers[$pSession]['jabber']->getVcard($val);
-											unset($_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][$key]);
-										}
-									}
-								}
-								else
-								{
-									if ( method_exists($pUsers[$pSession]['jabber'], $action) )
-										if ( $value )
-											$pUsers[$pSession]['jabber']->$action($value);
-										else
-											$pUsers[$pSession]['jabber']->$action();
-									unset($_SESSION['phpgw_info']['instant_messenger']['socket']['out'][$action]);
-								}
-							}
-               }
-               else
-               {
-               	$_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'] = true;
-               	close($pSession);               	
-               }
-               break;
-            }
-            else
-            {
-               close($pSession);
-            }
-            break;
-         }
-      }
-      session_write_close();
-   }
-?>
Index: trunk/instant_messenger/bkp/instant_messenger_32/controller.php
===================================================================
--- trunk/instant_messenger/bkp/instant_messenger_32/controller.php	(revision 151)
+++ 	(revision )
@@ -1,103 +1,0 @@
-<?php
-	//	Explode action from cExecuteForm function
-	$cExecuteFormReturn = false;
-   $returnMode = $_REQUEST['returnMode'];
- 	if($_POST['_action']) {
- 		if($_FILES) {
- 			$count_files = $_POST['countFiles'];
-			$array_files = array();
- 			for($idx = 1; $idx <= $count_files; $idx++) {
- 				if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
- 					$array_files[] = $_FILES['file_'.$idx];
- 			}
- 			$_POST['FILES'] = $array_files;
- 		}
- 		list($app,$class,$method) = explode('.',@$_POST['_action']);
- 		$cExecuteFormReturn = true;
- 	}
- 	//	Explode action from cExecute function
- 	else if($_GET['action'])
-   {
-      unset($_GET['returnMode']);
-		list($app,$class,$method) = explode('.',@$_GET['action']);
-   }
-	// NO ACTION
-	else
-		return $_SESSION['response'] = 'false';
-
-	// Load dinamically class file.
-	if($app == '$this')
-		$filename = 'inc/class.'.$class.'.inc.php';
-	else
-		$filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
-
-	include_once($filename);
-
-	// Create new Object  (class loaded).
-	$obj = new $class;
-
-	// Prepare parameters for execution.
-	$params = array();
-
-	// If array $_POST is not null , the submit method is POST.
-	if($_POST) {
-		$params = $_POST;
-	}
-	// If array $_POST is null , and the array $_GET > 1, the submit method is GET.
-	else if(count($_GET) > 1)	{
-		array_shift($_GET);
-		$params = $_GET;
-	}
-
-	$result = array();
-
-
-	// if params is not empty, then class method with parameters.
-	if($params)
-		$result = $obj -> $method($params);
-	else
-		$result = $obj -> $method();
-
-	// Return result json string into xml object.
-	if(!$cExecuteFormReturn)
-   {
-      $dom = new DOMDocument;//('1.0', 'UTF-8');
-
-      if ( $returnMode == 'JSON')
-      {
-         $root = $dom->appendChild(new DOMElement('retorno'));
-         encode($result, 'encode');
-         $result = ( !is_object($result) && !is_array($result) ) ? $result : json_encode($result);
-
-         $root->appendChild($dom->createCDATASection($result));
-      }
-      else
-		{
-			$_SESSION['phpgw_info']['instant_messenger']['debug2'] = $result;
-			$dom->loadXML('<retorno>' . utf8_encode($result) . '</retorno>');
-		}
-
-      $dom->normalizeDocument();
-		$retorno = $dom->saveXML();
-      header('Pragma: anytextexeptno-cache', true);
-      header('Content-type: text/xml, charset=UTF-8');
-		print $retorno;
-   }
-	else
-		$_SESSION['response'] = $result;
-
-   function encode(&$item, $val = 'encode')
-   {
-      switch( gettype($item) )
-      {
-         case 'object' :
-                     $item = get_object_vars($item);
-                     encode($item);
-         break;
-         case 'array' :
-                     array_walk_recursive($item, 'encode');
-         break;
-         default : $item = utf8_encode($item);
-      }
-   }
-?>
Index: trunk/instant_messenger/bkp/instant_messenger_32/index.php
===================================================================
--- trunk/instant_messenger/bkp/instant_messenger_32/index.php	(revision 151)
+++ 	(revision )
@@ -1,45 +1,0 @@
-<?php
-	/****************************************************\
-	 *													*
-	 * 	 			Im - Instant Messenger				*
-	 *													*
-	\****************************************************/
-	
-	$GLOBALS['phpgw_info']['flags'] = array(
-		'currentapp' => 'instant_messenger',
-		'im_version'	=> '0.2'
-	);
-	
-	include("../header.inc.php");
-    $im_version = $GLOBALS['phpgw_info']['flags']['im_version'];
-
-	// Template  
-	$template_1 = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-	$template_1->set_file(Array('instant_messenger' => 'index.tpl'));
-	$template_1->set_block('instant_messenger','index');
-	$template_1->pfp('out','index');
-	
-	// Session
-	$_SESSION['phpgw_info']['instant_messenger']['user'] 			      	= $GLOBALS['phpgw_info']['user']['account_lid'];
-	$_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'];
-
-	// Conf. Ldap
-	$_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']['size_file_jabber']  	 = $GLOBALS['phpgw_info']['server']['size_file_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'];
-
-	// Footer
-	$GLOBALS['phpgw']->common->phpgw_footer();
-?>
