Changeset 287 for trunk/instant_messenger/inc
- Timestamp:
- 05/26/08 11:45:16 (16 years ago)
- Location:
- trunk/instant_messenger/inc
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/inc/Jabber.abstract.php
r265 r287 79 79 } 80 80 81 protected function connect($pUser = false, $pPassword = false, $pConnectionType = false )81 protected function connect($pUser = false, $pPassword = false, $pConnectionType = false, $pWebjabber = false ) 82 82 { 83 83 try 84 84 { 85 $_connect = $this->_connect($pUser, $pPassword, $pConnectionType );85 $_connect = $this->_connect($pUser, $pPassword, $pConnectionType, $pWebjabber ); 86 86 87 87 if ( !$_connect ) -
trunk/instant_messenger/inc/Jabberd2.abstract.php
r275 r287 69 69 else 70 70 { 71 if ( $this-> writeSocket($this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact)) )71 if ( $this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact) ) 72 72 $this->getContacts(); 73 73 echo "OK"; 74 74 } 75 75 } … … 96 96 else 97 97 { 98 $this-> writeSocket($this->iq('get', $vcard, $jid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>"));98 $this->iq('get', $vcard, $jid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>"); 99 99 } 100 100 } … … 113 113 else 114 114 { 115 $this-> writeSocket($this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard['vcard']."</vCard>"));115 $this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard['vcard']."</vCard>"); 116 116 echo "OK"; 117 117 } … … 124 124 return "disconnected"; 125 125 126 if ( $this-> writeSocket($this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>")) )126 if ( $this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>") ) 127 127 if ( $this->subscription($pContact['jid'],"unsubscribed") ) 128 128 echo "OK"; … … 141 141 return true; 142 142 } 143 } 144 145 final function compression() 146 { 147 $compress = "<compress xmlns='http://jabber.org/protocol/compress'><method>zlib</method></compress>"; 148 $this->writeSocket($compress); 143 149 } 144 150 … … 164 170 $id = "last_time_user"; 165 171 $jid = ( trim($pUser['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pUser['jid']; 166 $this-> writeSocket($this->iq('get', $id, $jid, NULL, "jabber:iq:last"));172 $this->iq('get', $id, $jid, NULL, "jabber:iq:last"); 167 173 } 168 174 … … 191 197 else 192 198 { 193 $this-> writeSocket($this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact));199 $this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact); 194 200 $this->getContacts(); 195 201 echo "OK"; -
trunk/instant_messenger/inc/Socket.abstract.php
r260 r287 52 52 set_magic_quotes_runtime(0); 53 53 $return = @fread($pSocket, $pLength); 54 54 55 set_magic_quotes_runtime(get_magic_quotes_gpc()); 55 56 56 57 57 if ( $php_errormsg ) -
trunk/instant_messenger/inc/class.Ujabber.inc.php
r275 r287 7 7 private $set_presence; 8 8 9 public final function __construct( )9 public final function __construct($pConnectionType = 'write') 10 10 { 11 11 session_start(); 12 13 12 $this->_user = $_SESSION['phpgw_info']['instant_messenger']['user']; 14 13 $this->_pass = $_SESSION['phpgw_info']['instant_messenger']['passwd']; … … 17 16 $this->_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']; 18 17 $webjabber = $_SESSION['phpgw_info']['instant_messenger']['webjabber']; 19 20 18 session_write_close(); 21 19 22 if ( $this->connect($this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port, $this->_pass, 'read/write', $webjabber) )20 if ( $this->connect($this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port, $this->_pass, $pConnectionType, $webjabber) ) 23 21 $this->connected = true; 24 22 else … … 61 59 while ( ( connection_aborted() === 0 ) && time() - $init < 50 ) 62 60 { 63 61 if( isset($xml) ) 62 unset($xml); 63 64 64 # read from server and write in the client 65 65 $xml = $this->readSocket(); 66 //var_dump($xml);67 66 $xml = ( strlen($xml) ) ? $xml : ' '; 67 //$xml = ( strlen($xml) ) ? $xml : '_##_'; 68 68 printf("%s", $xml); 69 69 ob_flush(); … … 74 74 } 75 75 76 77 76 public final function SendMessage($pSendMessage) 77 { 78 78 if ( !$this->isConnected() ) 79 79 return "disconnected"; … … 85 85 $pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']); 86 86 87 $_emotions = '/<img emotion="(\S+)?"[^>]+>/'; 87 $_emotions = '/<img[^>]*emotion="(\S+)?"[^>]*>/'; 88 88 $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions); 89 89 … … 134 134 135 135 //retirar a linha abaixo para voltar ao padrão conforme acima 136 $xml .= "<body> " . $content['body'] . "</body>";136 $xml .= "<body><![CDATA[" . htmlentities($content['body']) . "]]></body>"; 137 137 $xml .= $payload; 138 138 $xml .= "</message>"; -
trunk/instant_messenger/inc/class.db_im.inc.php
r260 r287 19 19 function db_im() 20 20 { 21 22 21 session_start(); 23 22 $this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name']; -
trunk/instant_messenger/inc/class.ldap_im.inc.php
r275 r287 13 13 session_start(); 14 14 $this->ldap_host = $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']; 15 $this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'];15 $this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']; 16 16 $this->user = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 17 17 $this->password = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 18 $this->jid 18 $this->jid = $_SESSION['phpgw_info']['instant_messenger']['user']; 19 19 $this->connect_ldap(true); 20 20 session_write_close(); -
trunk/instant_messenger/inc/im_acl.inc.php
r262 r287 1 1 <?php 2 2 3 $size_of_ ACL= sizeof($GLOBALS['phpgw_info']['user']['acl']);3 $size_of_acl = sizeof($GLOBALS['phpgw_info']['user']['acl']); 4 4 5 for ( $i = 0; $i < sizeof($GLOBALS['phpgw_info']['user']['acl']); $i++ ) 5 # percorre a ACL até o fim ou até encontrar a entrada para o módulo de mensagem instantânea 6 for ( $i = 0; $i < $size_of_acl && $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] != 'instant_messenger'; $i++ ); 7 8 # verifica se foi encontrada a permissão para o módulo de mensagem instantânea 9 if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger' ) 6 10 { 7 if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger') 8 { 9 $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 10 $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/'; 11 12 if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) ) 13 $webserver_url .= '/'; 14 15 $webserver_url = $webserver_url . 'instant_messenger/'; 16 17 session_start(); 18 require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php'; 19 require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/load_lang.php'; 20 $_user = $_SESSION['phpgw_info']['instant_messenger']['user']; 21 $_pass = $_SESSION['phpgw_info']['instant_messenger']['passwd']; 22 $_server = $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; 23 $_port = $_SESSION['phpgw_info']['instant_messenger']['port_jabber']; 24 $_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']; 25 session_write_close(); 26 27 $js = array( 28 'connector', 29 'xtools', 30 'jabber', 31 'client', 32 'images', 33 'dragdrop', 34 'build_win', 35 'templates', 36 'fcommon', 37 'menu_action', 38 'functions', 39 'images', 40 'cookies_im', 41 'load', 42 ); 43 44 print '<script type="text/javascript">var path_im = "'.$webserver_url.'";</script>'; 45 46 foreach ( $js as $key => $val ) 47 print '<script src="' . $webserver_url . 'controller.php?act=j.' . $val . '"></script>'; 48 49 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/window.css">'; 50 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/chat.css">'; 51 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/common.css">'; 52 53 print '<script type="text/javascript">setTimeout("client()",2000);</script>'; 54 } 11 $webserver_url_im = $GLOBALS['phpgw_info']['server']['webserver_url']; 12 $webserver_url_im = ( !empty($webserver_url_im) ) ? $webserver_url_im : '/'; 13 14 if ( strrpos($webserver_url_im, '/') === false || strrpos($webserver_url_im, '/') != (strlen($webserver_url_im) - 1) ) 15 $webserver_url_im .= '/'; 16 17 $webserver_url_im = $webserver_url_im . 'instant_messenger/'; 18 19 require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php'; 20 require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/load_lang.php'; 21 22 $js = array( 23 'connector', 24 'jabber', 25 'xtools', 26 'client', 27 'images', 28 'dragdrop', 29 'build_win', 30 'templates', 31 'fcommon', 32 'menu_action', 33 'functions', 34 'images', 35 'cookies_im', 36 'load', 37 ); 38 39 print '<script type="text/javascript">var path_im = "'.$webserver_url_im.'";</script>'; 40 41 42 require_once dirname(__FILE__) . '/Controller.class.php'; 43 44 $controller = new Controller; 45 $script = ''; 46 foreach ( $js as $key => $val ) 47 { 48 $val = array('act' => 'j.' . $val); 49 $script .= $controller->exec($val); 50 } 51 52 printf("<script type=\"text/javascript\">%s</script>", $script); 53 54 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url_im . 'templates/default/css/window.css">'; 55 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url_im . 'templates/default/css/chat.css">'; 56 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url_im . 'templates/default/css/common.css">'; 57 58 # trecho de código javascript utilizado para 59 # controle de possível erro no load do script 60 # feito acima e está sendo inserido via PHP 61 # pois é um complemento do procedimento acima 62 $init_client = '<script type="text/javascript">'; 63 $init_client .= ' function im_init(pTimes)'; 64 $init_client .= ' {'; 65 $init_client .= ' if ( !pTimes )'; 66 $init_client .= ' pTimes = 0;'; 67 $init_client .= ' if ( pTimes == 5 )'; 68 $init_client .= ' return false;'; 69 $init_client .= ' if ( window.client )'; 70 $init_client .= ' client();'; 71 $init_client .= ' else'; 72 $init_client .= ' setTimeout("im_init("+(++pTimes)+")", (pTimes + 1) * 2000);'; 73 $init_client .= ' }'; 74 $init_client .= ' im_init();'; 75 $init_client .= '</script>'; 76 printf("%s", $init_client); 55 77 } 56 78 ?> -
trunk/instant_messenger/inc/im_sessions.inc.php
r265 r287 1 1 <?php 2 2 3 3 $_SESSION['phpgw_info']['instant_messenger']['user'] = $GLOBALS['phpgw_info']['user']['account_lid']; 4 $_SESSION['phpgw_info']['instant_messenger']['user_id'] 4 $_SESSION['phpgw_info']['instant_messenger']['user_id'] = $GLOBALS['phpgw_info']['user']['account_id']; 5 5 $_SESSION['phpgw_info']['instant_messenger']['passwd'] = $GLOBALS['phpgw_info']['user']['passwd']; 6 6 $_SESSION['phpgw_info']['instant_messenger']['name_jabber'] = $GLOBALS['phpgw_info']['server']['name_jabber']; 7 7 $_SESSION['phpgw_info']['instant_messenger']['port_jabber'] = $GLOBALS['phpgw_info']['server']['port_jabber']; 8 8 $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'] = $GLOBALS['phpgw_info']['server']['resource_jabber']; 9 $_SESSION['phpgw_info']['instant_messenger']['tls_jabber'] = $GLOBALS['phpgw_info']['server']['tls_jabber'];10 9 11 $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'] 12 $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'] 13 $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'] 14 $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] 15 $_SESSION['phpgw_info']['instant_messenger']['webjabber'] = $GLOBALS['phpgw_info']['server']['wejabber'];10 $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['server_ldap_jabber']; 11 $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['context_ldap_jabber']; 12 $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['user_ldap_jabber']; 13 $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabber']; 14 $_SESSION['phpgw_info']['instant_messenger']['webjabber'] = $GLOBALS['phpgw_info']['server']['webjabber']; 16 15 17 16 $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name']; … … 21 20 $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; 22 21 $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type']; 23 22 24 23 ?> -
trunk/instant_messenger/inc/load_lang.php
r260 r287 1 1 <? 2 if ( !isset($_SESSION['phpgw_info']['instant_messenger']['lang']) || !is_array($_SESSION['phpgw_info']['instant_messenger']['lang']) ) 3 4 5 6 7 8 9 $_SESSION['phpgw_info']['instant_messenger']['lang'][$message_id] = $content;10 11 12 2 3 if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) ) 4 if ( ($fp = fopen($fn,'r')) ) 5 { 6 while ($data = fgets($fp,16000)) 7 { 8 list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1)); 9 $LANG_IM[$message_id] = $content; 10 } 11 fclose($fp); 12 } 13 13 14 14 $script = '<script>'; 15 15 $script .= 'var lang_im = [];'; 16 16 17 foreach ( $ _SESSION['phpgw_info']['instant_messenger']['lang']as $key => $value )17 foreach ( $LANG_IM as $key => $value ) 18 18 $script .= "lang_im['" . strtolower(addslashes($key)) . "'] = '" . addslashes($value) . "';"; 19 20 #$_key = str_replace("'","\'",strtolower($key));21 #$_val = str_replace("'","\'",$value);22 19 23 20 $script .= '</script>'; 24 21 25 22 echo $script; 23 24 unset($LANG_IM); 26 25 ?>
Note: See TracChangeset
for help on using the changeset viewer.