Ignore:
Timestamp:
06/06/08 13:54:09 (16 years ago)
Author:
niltonneto
Message:

Correçoes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/instant_messenger/inc/class.Ujabber.inc.php

    r287 r305  
    11<?php 
    2  
     2#error_reporting(E_ALL); 
    33require_once 'Jabberd2.abstract.php'; 
    44 
    55class Ujabber extends Jabberd2 
    66{ 
    7         private $set_presence; 
    8          
    97        public final function __construct($pConnectionType = 'write') 
    10         {        
    11                 session_start(); 
     8        { 
     9                /*session_start(); 
     10 
    1211                $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']; 
    1315                $this->_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd']; 
    1416                $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']; 
    1618                $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']; 
    1921 
    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 
    2349                        $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                } 
    2457        } 
    2558 
     
    3063                flush(); 
    3164        } 
    32          
     65 
    3366        public final function isConnected() 
    3467        { 
     
    4073                if ( !$this->isConnected() ) 
    4174                        return "disconnected"; 
    42  
    43                 $this->get_last_access_user(array("jid" => "this"));     
    4475 
    4576                if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) 
     
    5687 
    5788                        $init = time(); 
     89                        $buffer = ''; 
    5890 
    5991                        while ( ( connection_aborted() === 0 ) && time() - $init < 50 ) 
    6092                        { 
    61                                 if( isset($xml) )        
    62                                         unset($xml); 
    63                          
    6493                                # read from server and write in the client 
    6594                                $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                                } 
    66112                                $xml = ( strlen($xml) ) ? $xml : ' '; 
    67                                 //$xml = ( strlen($xml) ) ? $xml : '_##_'; 
    68113                                printf("%s", $xml); 
    69114                                ob_flush(); 
     
    85130                $pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']); 
    86131 
    87                 $_emotions  = '/<img[^>]*emotion="(\S+)?"[^>]*>/';  
     132                $_emotions  = '/<img emotion="(\S+)?"[^>]+>/'; 
    88133                $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions); 
    89134 
     
    134179 
    135180                        //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>"; 
    137182                        $xml .= $payload; 
    138183                        $xml .= "</message>"; 
Note: See TracChangeset for help on using the changeset viewer.