Changeset 305 for trunk/instant_messenger/inc/class.Ujabber.inc.php
- Timestamp:
- 06/06/08 13:54:09 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/inc/class.Ujabber.inc.php
r287 r305 1 1 <?php 2 2 #error_reporting(E_ALL); 3 3 require_once 'Jabberd2.abstract.php'; 4 4 5 5 class Ujabber extends Jabberd2 6 6 { 7 private $set_presence;8 9 7 public final function __construct($pConnectionType = 'write') 10 { 11 session_start(); 8 { 9 /*session_start(); 10 12 11 $this->_user = $_SESSION['phpgw_info']['instant_messenger']['user']; 12 //$this->_user = 'niltonneto';//$_SESSION['phpgw_info']['instant_messenger']['user']; 13 //$this->_pass = 'nine59ever';//$_SESSION['phpgw_info']['instant_messenger']['passwd']; 14 //$this->_pass = 'senha';//$_SESSION['phpgw_info']['instant_messenger']['passwd']; 13 15 $this->_pass = $_SESSION['phpgw_info']['instant_messenger']['passwd']; 14 16 $this->_server = $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; 15 $this->_port = $_SESSION['phpgw_info']['instant_messenger']['port_jabber'];17 $this->_port = '8883';//$_SESSION['phpgw_info']['instant_messenger']['port_jabber']; 16 18 $this->_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']; 17 $webjabber =$_SESSION['phpgw_info']['instant_messenger']['webjabber'];18 session_write_close();19 //$webjabber = 'im.pr.gov.br';//$_SESSION['phpgw_info']['instant_messenger']['webjabber']; 20 $webjabber = '10.15.22.236';//$_SESSION['phpgw_info']['instant_messenger']['webjabber']; 19 21 20 if ( $this->connect($this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port, $this->_pass, $pConnectionType, $webjabber) ) 21 $this->connected = true; 22 else 22 session_write_close();*/ 23 24 try 25 { 26 if ( !file_exists(dirname(__FILE__) . '/../instant_messenger.define.php') ) 27 throw new Exception(__CLASS__ . '[ ERROR #1 ] : Not found configuration file'); 28 29 require_once dirname(__FILE__) . '/../instant_messenger.define.php'; 30 31 if ( !(defined('JABBER_URL') && defined('JABBER_RESOURCE')) ) 32 throw new Exception(__CLASS__ . '[ ERROR #2 ] : Jabber server is not cofigured'); 33 34 if ( !(defined('WEBJABBER_URL') && defined('WEBJABBER_PORT')) ) 35 throw new Exception(__CLASS__ . '[ ERROR #3 ] : Webabber server is not cofigured'); 36 37 $this->_server = constant('JABBER_URL'); 38 $this->_resource = constant('JABBER_RESOURCE'); 39 40 $this->_port = constant('WEBJABBER_PORT'); 41 42 session_start(); 43 $this->_user = $_SESSION['phpgw_info']['instant_messenger']['user']; 44 $this->_pass = $_SESSION['phpgw_info']['instant_messenger']['passwd']; 45 session_write_close(); 46 47 $access_string = $this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port; 48 23 49 $this->connected = false; 50 if ( $this->connect($access_string, $this->_pass, $pConnectionType, constant('WEBJABBER_URL')) ) 51 $this->connected = true; 52 } 53 catch(Exception $e) 54 { 55 echo $e->getMessage(); 56 } 24 57 } 25 58 … … 30 63 flush(); 31 64 } 32 65 33 66 public final function isConnected() 34 67 { … … 40 73 if ( !$this->isConnected() ) 41 74 return "disconnected"; 42 43 $this->get_last_access_user(array("jid" => "this"));44 75 45 76 if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) … … 56 87 57 88 $init = time(); 89 $buffer = ''; 58 90 59 91 while ( ( connection_aborted() === 0 ) && time() - $init < 50 ) 60 92 { 61 if( isset($xml) )62 unset($xml);63 64 93 # read from server and write in the client 65 94 $xml = $this->readSocket(); 95 //var_dump($xml); 96 if ( strlen($xml) && $xml != ' ' ) 97 { 98 if ( $xml[strlen($xml) - 1 ] != '>' ) 99 { 100 $buffer .= $xml; 101 $xml = ''; 102 } 103 else 104 { 105 $xml = $buffer . $xml; 106 $buffer = ''; 107 //var_dump($xml); 108 //strlen($xml); 109 //exit; 110 } 111 } 66 112 $xml = ( strlen($xml) ) ? $xml : ' '; 67 //$xml = ( strlen($xml) ) ? $xml : '_##_';68 113 printf("%s", $xml); 69 114 ob_flush(); … … 85 130 $pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']); 86 131 87 $_emotions = '/<img[^>]*emotion="(\S+)?"[^>]*>/'; 132 $_emotions = '/<img emotion="(\S+)?"[^>]+>/'; 88 133 $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions); 89 134 … … 134 179 135 180 //retirar a linha abaixo para voltar ao padrão conforme acima 136 $xml .= "<body><![CDATA[" . htmlentities($content['body']). "]]></body>";181 $xml .= "<body><![CDATA[" . $content['body'] . "]]></body>"; 137 182 $xml .= $payload; 138 183 $xml .= "</message>";
Note: See TracChangeset
for help on using the changeset viewer.