Changeset 151 for trunk/instant_messenger/inc
- Timestamp:
- 01/18/08 15:17:58 (16 years ago)
- Location:
- trunk/instant_messenger/inc
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/inc/Jabber.abstract.php
r64 r151 1 1 <?php 2 2 /* 3 +------------------------------------------------------------------------- +4 | |5 | @FILE: Jabber.abstract.php |6 | @ABSTRACT: Jabber |7 | @EXTENDS: Socket (Socket.class.php) |8 | |9 | @DATE: Wed May,16 2007 08:18:59 |10 | @LAST_CHANGE: Wed May,16 2007 09:03:28 |11 | |12 | @AUTHOR: [NUTS] Rodrigo Souza - rod souza@celepar.pr.gov.br|13 | |14 | @BRIEF: Abstract class for connect with any Jabber server |15 | |16 +------------------------------------------------------------------------- +3 +---------------------------------------------------------------------------------+ 4 | | 5 | @FILE: Jabber.abstract.php | 6 | @ABSTRACT: Jabber | 7 | @EXTENDS: Socket (Socket.class.php) | 8 | | 9 | @DATE: Wed May,16 2007 08:18:59 | 10 | @LAST_CHANGE: Wed May,16 2007 09:03:28 | 11 | | 12 | @AUTHOR: [NUTS] Rodrigo Souza - rodrigosouzadossantos [at] gmail [dot] com | 13 | | 14 | @BRIEF: Abstract class for connect with any Jabber server | 15 | | 16 +---------------------------------------------------------------------------------+ 17 17 */ 18 18 … … 21 21 abstract class Jabber extends Socket 22 22 { 23 const J_FILE = '/var/log/expresso/Jabber.log'; 24 const J_ALL = false; 25 const J_ERROR = true; 26 const J_WARNING = true; 27 const J_NOTICE = true; 28 29 const ALL = 'ALL'; 30 const ERROR = 'ERROR'; 31 const WARNING = 'WARNING'; 32 const NOTICE = 'NOTICE'; 33 34 private final function _connect( $pUser = false, $pPassword = false ) 35 { 36 try 37 { 38 if ( !preg_match('/^(.+)@(.+)\/(.+):(\d+)$/',$pUser, $matches) ) 39 throw new Exception('[connect] #1 ' . $pUser . ' must be [USER]@[DOMAIN]/[RESOURCE]:[PORT] and [PORT] is integer. File: ' . __FILE__ . ' :: ' . __LINE__); 40 41 list($subject, $USER, $SERVER, $RESOURCE, $PORT) = $matches; 42 43 if ( !($socket = $this->open('tcp://' . $SERVER . ':' . $PORT, 1, 1)) ) 44 throw new Exception('[connect] #2 can\'t access tcp://' . $SERVER . ':' . $PORT . '. File: ' . __FILE__ . ' :: ' . __LINE__); 45 46 $this->_socket = $socket; 47 48 $xml = "<?xml version='1.0' encoding='UTF-8'?>"; 49 $xml .= "<stream:stream to='" . $SERVER . "' xmlns='jabber:client' "; 50 $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"; 51 52 if ( $this->write($xml) === false ) 53 throw new Exception('[connect] #3 it isn\'t possible write in the socket ' . $socket . '. File: ' . __FILE__ . ' :: ' . __LINE__); 54 55 $this->_server = $SERVER; 56 $this->_username = $USER; 57 $this->_password = $pPassword; 58 $this->_resource = $RESOURCE; 59 } 60 catch(Exception $e) 61 { 62 $this->writeLog('ERROR', $e->getMessage()); 63 return false; 64 } 65 } 66 67 protected function connect( $pUser = false, $pPassword = false ) 68 { 69 try 70 { 71 $this->_connect($pUser, $pPassword); 23 const J_FILE = 'Jabber.log'; 24 const J_ALL = false; 25 const J_ERROR = true; 26 const J_WARNING = true; 27 const J_NOTICE = true; 28 29 const ALL = 'ALL'; 30 const ERROR = 'ERROR'; 31 const WARNING = 'WARNING'; 32 const NOTICE = 'NOTICE'; 33 34 private final function _connect( $pUser = false, $pPassword = false ) 35 { 36 try 37 { 38 if ( !preg_match('/^(.+)@(.+)\/(.+):(\d+)$/',$pUser, $matches) ) 39 throw new Exception('[connect] #1 ' . $pUser . ' must be [USER]@[DOMAIN]/[RESOURCE]:[PORT] and [PORT] is integer. File: ' . __FILE__ . ' :: ' . __LINE__); 40 41 list($subject, $USER, $SERVER, $RESOURCE, $PORT) = $matches; 42 43 if ( !($socket = $this->open('tcp://' . $SERVER . ':' . $PORT, 1, 1)) ) 44 throw new Exception('[connect] #2 can\'t access tcp://' . $SERVER . ':' . $PORT . '. File: ' . __FILE__ . ' :: ' . __LINE__); 45 46 $this->_socket = $socket; 47 48 $return = fread($socket, 4096); 49 fwrite($socket, $pUser); 50 51 $return = fread($socket, 4096); 52 fwrite($socket, $pPassword); 53 54 $return = fread($socket, 4096); 55 #echo __FUNCTION__ . "<br>\n"; 56 #var_dump($return); 57 #exit; 58 59 if ( $return == "new" ) 60 { 61 $xml = "<?xml version='1.0' encoding='UTF-8'?>"; 62 $xml .= "<stream:stream to='" . $SERVER . "' xmlns='jabber:client' "; 63 $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"; 64 65 if ( $this->write($xml) === false ) 66 throw new Exception('[connect] #4 it isn\'t possible connect in the server becase exists a client connected with same user. File: ' . __FILE__ . ' :: ' . __LINE__); 67 } 68 69 $this->_server = $SERVER; 70 $this->_username = $USER; 71 $this->_password = $pPassword; 72 $this->_resource = $RESOURCE; 73 74 #var_dump($return); 75 #exit; 76 return $return; 77 } 78 catch(Exception $e) 79 { 80 $this->writeLog('ERROR', $e->getMessage()); 81 return false; 82 } 83 } 84 85 protected function connect( $pUser = false, $pPassword = false ) 86 { 87 try 88 { 89 $_connect = $this->_connect($pUser, $pPassword); 72 90 73 if ( ($xml = $this->read()) === false ) 74 throw new Exception('[connect] #1 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 75 76 if ( preg_match('/(<starttls .*<required\/><\/starttls>)/', $xml, $matches) ) 77 { 78 if ( !$this->starttls() ) 79 throw new Exception('[connect] #2 it isn\'t possible start tls. File: ' . __FILE__ . ' :: ' . __LINE__); 80 81 # $this->writeLog('NOTICE', 'Connected TLS'); 82 } 83 else 84 { 85 if ( !$this->_plain() ) 86 throw new Exception('[connect] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__); 87 } 88 89 return true; 90 } 91 catch(Exception $e) 92 { 93 $this->writeLog('ERROR', $e->getMessage()); 94 $this->_disconnect(); 95 return false; 96 } 97 } 98 99 protected final function _disconnect() 100 { 101 try 102 { 103 $xml = "</stream:stream>"; 104 105 if ( $this->write($xml) === false ) 106 throw new Exception('[disconnect] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__); 107 108 if ( ($xml = $this->read()) === false ) 109 throw new Exception('[disconnect] #2 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 110 } 111 catch(Exception $e) 112 { 113 $this->writeLog('ERROR', $e->getMessage()); 114 return false; 115 } 116 } 117 118 private final function starttls() 119 { 120 try 121 { 122 $xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"; 123 if ( $this->write($xml) === false ) 124 throw new Exception('[starttls] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__); 125 126 if ( ($xml = $this->read()) === false ) 127 throw new Exception('[starttls] #2 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 128 129 if ( !preg_match('/<proceed.*\/>/', $xml, $matches) ) 130 throw new Exception('[starttls] #3 can\'t start tls in the socket ' .$this->_socket . '. File: ' . __FILE__ . ' :: ' . __LINE__); 131 132 stream_socket_enable_crypto($this->_socket, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); 133 134 $xml = "<?xml version='1.0' encoding='UTF-8'?>"; 135 $xml .= "<stream:stream to='" . $this->_server . "' xmlns='jabber:client' "; 136 $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"; 137 if ( $this->write($xml) === false ) 138 throw new Exception('[starttls] #4 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__); 139 140 usleep(90000); 141 $this->blocking($this->_socket, 0); 142 143 if ( ($xml = $this->read()) === false ) 144 throw new Exception('[starttls] #5 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 145 146 if ( !$this->_plain() ) 147 throw new Exception('[starttls] #6 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__); 148 149 return true; 150 } 151 catch(Exception $e) 152 { 153 $this->writeLog('ERROR', $e->getMessage()); 154 return false; 155 } 156 } 157 158 private final function _plain() 159 { 160 try 161 { 162 $this->blocking($this->_socket, 0); 163 164 if ( ($xml = $this->read()) === false ) 165 throw new Exception('[_plain] #1 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 166 167 $xml = "<username>" . $this->_username . "</username>"; 168 $xml .= "<password>" . $this->_password . "</password>"; 169 $xml .= "<resource>" . $this->_resource . "</resource>"; 170 171 unset($this->_password); 172 173 if ( !$this->iq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) ) 174 throw new Exception('[_plain] #2 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__); 175 176 while ( !preg_match("/<iq xmlns='jabber:client' id='auth_1' type='(result|error)'/", ($readSocket = $this->read()), $matches) ) 177 usleep(10000); 91 if ( !$_connect ) 92 throw new Exception('[connect] #0. File: ' . __FILE__ . ' :: ' . __LINE__); 93 94 if ( $_connect == "new" ) 95 { 96 if ( ($xml = $this->read()) === false ) 97 throw new Exception('[connect] #1 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 98 99 if ( preg_match('/(<starttls .*<required\/><\/starttls>)/', $xml, $matches) ) 100 { 101 if ( !$this->starttls() ) 102 throw new Exception('[connect] #2 it isn\'t possible start tls. File: ' . __FILE__ . ' :: ' . __LINE__); 103 104 # $this->writeLog('NOTICE', 'Connected TLS'); 105 } 106 else 107 { 108 if ( !$this->_plain() ) 109 throw new Exception('[connect] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__); 110 } 111 } 112 113 return $_connect; 114 } 115 catch(Exception $e) 116 { 117 $this->writeLog('ERROR', $e->getMessage()); 118 $this->_disconnect(); 119 return false; 120 } 121 } 122 123 protected final function _disconnect() 124 { 125 try 126 { 127 $xml = "</stream:stream>"; 128 129 if ( $this->write($xml) === false ) 130 throw new Exception('[disconnect] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__); 131 132 if ( ($xml = $this->read()) === false ) 133 throw new Exception('[disconnect] #2 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 134 } 135 catch(Exception $e) 136 { 137 $this->writeLog('ERROR', $e->getMessage()); 138 return false; 139 } 140 } 141 142 private final function starttls() 143 { 144 try 145 { 146 $xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"; 147 if ( $this->write($xml) === false ) 148 throw new Exception('[starttls] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__); 149 150 if ( ($xml = $this->read()) === false ) 151 throw new Exception('[starttls] #2 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 152 153 if ( !preg_match('/<proceed.*\/>/', $xml, $matches) ) 154 throw new Exception('[starttls] #3 can\'t start tls in the socket ' .$this->_socket . '. File: ' . __FILE__ . ' :: ' . __LINE__); 155 156 stream_socket_enable_crypto($this->_socket, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); 157 158 $xml = "<?xml version='1.0' encoding='UTF-8'?>"; 159 $xml .= "<stream:stream to='" . $this->_server . "' xmlns='jabber:client' "; 160 $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"; 161 if ( $this->write($xml) === false ) 162 throw new Exception('[starttls] #4 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__); 163 164 usleep(90000); 165 $this->blocking($this->_socket, 0); 166 167 if ( ($xml = $this->read()) === false ) 168 throw new Exception('[starttls] #5 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 169 170 if ( !$this->_plain() ) 171 throw new Exception('[starttls] #6 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__); 172 173 return true; 174 } 175 catch(Exception $e) 176 { 177 $this->writeLog('ERROR', $e->getMessage()); 178 return false; 179 } 180 } 181 182 private final function _plain() 183 { 184 try 185 { 186 $this->blocking($this->_socket, 0); 187 188 if ( ($xml = $this->read()) === false ) 189 throw new Exception('[_plain] #1 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 190 191 $xml = "<username>" . $this->_username . "</username>"; 192 $xml .= "<password>" . $this->_password . "</password>"; 193 $xml .= "<resource>" . $this->_resource . "</resource>"; 194 195 unset($this->_password); 196 197 if ( !$this->iq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) ) 198 throw new Exception('[_plain] #2 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__); 199 200 while ( !preg_match("/<iq xmlns='jabber:client' id='auth_1' type='(result|error)'/", ($readSocket = $this->read()), $matches) ) 201 usleep(10000); 178 202 179 203 if($matches[1] == "error") 180 204 return false; 181 205 182 183 184 185 186 187 188 189 190 191 192 206 if ( ($xml = $this->read()) === false ) 207 throw new Exception('[_plain] #3 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__); 208 209 return true; 210 } 211 catch(Exception $e) 212 { 213 $this->writeLog('ERROR', $e->getMessage()); 214 return false; 215 } 216 } 193 217 194 218 private final function _iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false ) … … 199 223 200 224 if ( $pXmlns == "vcard-temp" ) 201 225 { 202 226 $xml .= ">"; 203 227 $xml .= $pLoad; 204 228 } 205 206 229 else 230 { 207 231 $xml .= "><query xmlns='" . $pXmlns . "'"; 208 232 $xml .= ( $pLoad ) ? ">" . $pLoad . "</query>" : "/>"; … … 210 234 211 235 $xml .= "</iq>"; 212 213 return $xml; 214 } 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 236 237 return $xml; 238 } 239 240 protected final function iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false) 241 { 242 try 243 { 244 if ( !preg_match("/^(get|set|result|error)$/i", $pType, $matches) ) 245 throw new Exception('[iq] #1 type must be GET, SET, RESULT or ERROR. File: ' . __FILE__ . ' :: ' . __LINE__); 246 247 if ( $this->write($this->_iq($pType, $pId, $pTo, $pFrom, $pXmlns, $pLoad)) === false ) 248 throw new Exception('[iq] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__); 249 else 250 return true; 251 } 252 catch(Exception $e) 253 { 254 $this->writeLog('ERROR', $e->getMessage()); 255 return false; 256 } 257 } 234 258 235 259 protected final function presence($pType = false, $pTo = false, $pShow = false, $pStatus = false, $pPriority = false) 236 260 { 237 try 238 { 239 $xml = "<presence"; 240 $xml .= ($pTo) ? " to='{$pTo}'" : ''; 241 $xml .= ($pType) ? " type='{$pType}'" : ''; 242 243 //$xml .= ($pStatus || $pShow || $pPriority) ? ">" : "/>"; 244 if ( !($pStatus || $pShow || $pPriority) ) 261 try 262 { 263 $xml = "<presence"; 264 $xml .= ($pTo) ? " to='{$pTo}'" : ''; 265 $xml .= ($pType) ? " type='{$pType}'" : ''; 266 267 if ( !($pStatus || $pShow || $pPriority) ) 245 268 $xml .= "/>"; 246 269 else 247 270 { 248 249 250 251 252 271 $xml .= ">"; 272 $xml .= ($pStatus) ? "<status>" . $pStatus . "</status>" : ''; 273 $xml .= ($pShow) ? "<show>" . $pShow . "</show>" : ''; 274 $xml .= ($pPriority) ? "<priority>" . $pPriority . "</priority>" : ''; 275 $xml .= ($pStatus || $pShow || $pPriority) ? "</presence>" : ''; 253 276 } 254 255 256 257 258 259 260 261 262 263 264 265 } 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 277 278 if ( $this->write($xml) === false ) 279 throw new Exception('[presence] #1 it isn\'t possible send presence for ' . $this->_server . '. File: ' . __FILE__ . ' :: ' . __LINE__); 280 281 return true; 282 } 283 catch(Exception $e) 284 { 285 $this->writeLog('ERROR', $e->getMessage()); 286 return false; 287 } 288 } 289 290 protected final function read() 291 { 292 $return = NULL; 293 do 294 { 295 $line = NULL; 296 $line = utf8_decode(parent::read($this->_socket, 4096)); 297 298 if ( $line === false ) 299 { 300 $return = false; 301 break; 302 } 303 304 if ( $line != NULL ) 305 $return .= $line;// . "\n"; 306 } 307 while ( $line != NULL ); 308 309 return $return; 310 } 288 311 289 312 protected final function write($pData = false) 290 { 291 if ( !$pData ) 292 return false; 293 294 return parent::write($this->_socket, utf8_encode($pData)); 295 } 296 297 protected final function writeLog($pType = false, $pLog = false) 298 { 299 if ( !defined('self::'.$pType) && !$pLog ) 300 return false; 301 302 if ( !(bool)constant('self::J_'.$pType) && !(bool)constant('self::J_ALL') ) 303 return false; 304 305 $log = date('m/d/Y H:i:s'); 306 $log .= ' [' . constant('self::'.$pType) . '] :: '; 307 $log .= $pLog . "\n"; 308 if ( $fp = fopen (self::J_FILE, "a+") ) 309 { 310 fwrite($fp, $log); 311 fclose($fp); 312 } 313 } 313 { 314 if ( !$pData ) 315 return false; 316 317 return parent::write($this->_socket, utf8_encode($pData)); 318 } 319 320 function __destruct() 321 { 322 $this->close($this->_socket); 323 } 324 325 protected final function writeLog($pType = false, $pLog = false) 326 { 327 if ( !defined('self::'.$pType) && !$pLog ) 328 return false; 329 330 if ( !(bool)constant('self::J_'.$pType) && !(bool)constant('self::J_ALL') ) 331 return false; 332 333 $log = date('m/d/Y H:i:s'); 334 $log .= ' [' . constant('self::'.$pType) . '] :: '; 335 $log .= $pLog . "\n"; 336 if ( $fp = fopen (self::J_FILE, "a+") ) 337 { 338 fwrite($fp, $log); 339 fclose($fp); 340 } 341 } 314 342 } 315 316 343 ?> -
trunk/instant_messenger/inc/Jabberd2.abstract.php
r55 r151 7 7 class Jabberd2 extends Jabber 8 8 { 9 final function connect($pUser = false, $pPassword = false) 10 { 11 try 12 { 13 if ( parent::connect($pUser, $pPassword) ) 14 if ( $this->presence() ) 15 return true; 9 final function connect($pUser = false, $pPassword = false) 10 { 11 try 12 { 13 if ( $_connect = parent::connect($pUser, $pPassword) ) 14 return $_connect; 16 15 17 18 19 20 21 22 23 24 16 return false; 17 } 18 catch(Exception $e) 19 { 20 $this->writeLog('ERROR', $e->getMessage()); 21 return false; 22 } 23 } 25 24 26 function disconnect()27 28 $this->_disconnect();29 25 function closeSocket() 26 { 27 $this->close($this->_socket); 28 } 30 29 31 final function readSocket()32 33 return $this->read();34 30 function disconnect() 31 { 32 $this->_disconnect(); 33 } 35 34 36 final function writeSocket($pData) 37 { 38 return $this->write($pData); 39 } 35 final function readSocket() 36 { 37 return $this->read(); 38 } 39 40 final function writeSocket($pData) 41 { 42 return $this->write($pData); 43 } 44 45 /* 46 * Jabber - Functions 47 */ 48 49 final function addContacts($pContact) 50 { 51 $jid = explode("@",$pContact['email']); 52 $jid = $jid[0]."@".$this->_server; 53 $name = $pContact['name']; 54 $group = $pContact['group']; 55 56 if(trim($jid[0]) != trim($this->_user)) 57 { 58 if ( $jid ) 59 { 60 $newcontact = "<item jid='".$jid."'"; 61 $newcontact .= " name='" . $name . "'"; 62 $newcontact .= "><group>" . $group . "</group></item>"; 63 } 64 } 65 $addid = "adduser_" . time(); 66 if ( !$this->connected ) 67 echo "disconnected"; 68 else 69 { 70 if($this->writeSocket($this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact))) 71 { 72 $this->getContacts(); 73 if($this->subscription($pContact['jid'],"subscribe")) 74 echo "OK"; 75 } 76 } 77 } 78 79 final function getContacts() 80 { 81 $this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster'); 82 } 83 84 final function getVcard($pJid) 85 { 86 if(is_array($pJid)) 87 { 88 $jid = (trim($pJid['jid']) == "this") ? $this->_user . '@' . $this->_server : $pJid['jid']; 89 90 if ( !$this->connected ) 91 echo "disconnected"; 92 else 93 { 94 $this->writeSocket($this->iq('get', 'vCard', $jid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>")); 95 echo "OK"; 96 } 97 } 98 else 99 { 100 $this->iq('get', 'vCard', $pJid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>"); 101 } 102 } 103 104 final function newVcard($NewVcard) 105 { 106 $id = $this->_user; 107 108 if ( !$this->connected ) 109 echo "disconnected"; 110 else 111 { 112 $this->writeSocket($this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard['vcard']."</vCard>")); 113 echo "OK"; 114 } 115 } 40 116 41 final function setPresence($pPresence)117 final function removeContact($pContact) 42 118 { 119 $delid = 'deluser_' . time(); 120 if( !$this->connected ) 121 echo "disconnected"; 122 else 123 { 124 if($this->writeSocket($this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>"))) 125 { 126 $this->getContacts(); 127 if($this->subscription($pContact['jid'],"unsubscribed")) 128 echo "OK"; 129 } 130 } 131 } 132 133 final function subscription($pTo, $pType = false) 134 { 135 $jid = (is_array($pTo)) ? $pTo['jid'] : $pTo ; 136 $type = (is_array($pTo)) ? $pTo['type'] : $pType ; 137 138 if ( !$this->connected ) 139 return false; 140 else 141 { 142 $this->writeSocket("<presence xmlns='jabber:client' from='".$this->_user."@".$this->_server."' type='".$type."' to='".$jid."'/>"); 143 return true; 144 } 145 } 146 147 final function setPresence($pPresence = false) 148 { 149 150 if ( !$pPresence ) 151 $this->presence(); 152 43 153 $type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL; 44 154 $to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL; … … 46 156 $status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL; 47 157 $priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL; 48 158 49 159 $this->presence($type, $to, $show, $status, $priority); 50 }51 /*52 * Vcard53 */54 160 55 final function getVcard($pVcard)56 {57 $this->iq('get', $pVcard, $pVcard, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>");58 }59 60 final function newVcard($NewVcard)61 {62 $id = $_SESSION['phpgw_info']['instant_messenger']['user'];63 $this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard."</vCard>");64 }65 66 /*67 * Contacts68 */69 70 final function getContacts()71 {72 $this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster');73 }74 75 final function addContacts($pContact)76 {77 $addid = "adduser_" . time();78 $this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $pContact);79 }80 81 final function removeContact($pContact)82 {83 $delid = 'deluser_' . time();84 $this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact."' subscription='remove'/>");85 }86 87 final function updateContact($pContact)88 {89 $upid = 'updateuser_' . time();90 $this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $pContact);91 }92 93 /*94 * Presence95 */96 97 final function SubscriptionAcceptRequest($to = NULL)98 {99 $this->presence("subscribed", $to);100 161 } 101 162 102 final function SubscriptionDenyRequest($to = NULL)163 final function updateContact($pContact) 103 164 { 104 $this->presence("unsubscribed", $to); 105 } 165 $jid = $pContact['jid']; 166 $name = $pContact['name']; 167 $group = $pContact['group']; 106 168 107 final function Subscribe($to = NULL) 108 { 109 $this->presence("subscribe", $to); 110 } 169 if ( $jid ) 170 { 171 $updatecontact = "<item jid='$jid'"; 172 $updatecontact .= " name='" . $name . "'"; 173 $updatecontact .= "><group>" . $group . "</group></item>"; 174 } 111 175 112 final function Unsubscribe($to = NULL) 113 { 114 $this->presence("unsubscribe", $to); 176 $upid = 'updateuser_' . time(); 177 if ( !$this->connected ) 178 echo "disconnected"; 179 else 180 { 181 $this->writeSocket($this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact)); 182 $this->getContacts(); 183 echo "OK"; 184 } 115 185 } 116 186 } -
trunk/instant_messenger/inc/Socket.abstract.php
r63 r151 20 20 protected final function open( $pSocket = false, $pTimeOut = 1, $pBlockingMode = 0 ) 21 21 { 22 23 22 if ( !$pSocket ) 23 return false; 24 24 25 if ( $socket = @stream_socket_client($pSocket, $errno, $errstr) ) 26 { 27 stream_set_blocking($socket, $pBlockingMode); 28 stream_set_timeout($socket, $pTimeOut); 29 } 30 return $socket; 25 if ( $socket = @stream_socket_client($pSocket, $errno, $errstr) ) 26 { 27 #stream_set_blocking($socket, $pBlockingMode); 28 #stream_set_timeout($socket, $pTimeOut); 29 stream_set_blocking($socket, 1); 30 stream_set_timeout($socket, 1); 31 } 32 return $socket; 31 33 } 32 34 33 34 35 36 35 protected final function blocking($pSocket = false, $pBlockingMode = 1) 36 { 37 if ( !$pSocket || !is_resource($pSocket) ) 38 return false; 37 39 38 39 40 stream_set_blocking($pSocket, $pBlockingMode); 41 } 40 42 41 43 42 44 protected function read( $pSocket = false, $pLength = 4096 ) 43 45 { 44 45 46 ini_set( 'track_errors', '1' ); 47 $php_errormsg = ''; 46 48 47 48 49 if ( !$pSocket || !is_resource($pSocket) ) 50 return false; 49 51 50 51 52 52 set_magic_quotes_runtime(0); 53 $return = @fread($pSocket, $pLength); 54 set_magic_quotes_runtime(get_magic_quotes_gpc()); 53 55 54 56 55 56 57 if ( $php_errormsg ) 58 return false; 57 59 58 60 return $return; 59 61 } 60 62 61 63 protected function write( $pSocket = false, $pData = false ) 62 64 { 63 ini_set( 'track_errors', '1' ); 64 $php_errormsg = ''; 65 66 if ( (!$pSocket || !is_resource($pSocket)) || !$pData ) 67 return false; 65 ini_set( 'track_errors', '1' ); 66 $php_errormsg = ''; 68 67 69 $return = @fwrite($pSocket, $pData); 70 71 if ( $php_errormsg ) 72 return false; 68 if ( (!$pSocket || !is_resource($pSocket)) || !$pData ) 69 return false; 73 70 74 return $return; 71 $return = @fwrite($pSocket, $pData); 72 73 if ( $php_errormsg ) 74 return false; 75 76 return $return; 75 77 } 76 78 77 79 protected final function close( $pSocket = false ) 78 80 { 79 80 81 if ( !$pSocket || !is_resource($pSocket) ) 82 return false; 81 83 82 84 return fclose($pSocket); -
trunk/instant_messenger/inc/class.Ujabber.inc.php
r89 r151 1 1 <?php 2 2 3 class Ujabber 3 require_once 'Jabberd2.abstract.php'; 4 5 class Ujabber extends Jabberd2 4 6 { 5 /* 6 * Listen 7 */ 8 9 final function listen() 10 { 11 $return = null; 7 public final function __construct() 8 { 9 session_start(); 12 10 13 if($_SESSION['phpgw_info']['instant_messenger']['IM_disconnect']) 11 $_user = $_SESSION['phpgw_info']['instant_messenger']['user']; 12 $_pass = $_SESSION['phpgw_info']['instant_messenger']['passwd']; 13 $_server = $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; 14 $_port = $_SESSION['phpgw_info']['instant_messenger']['port_jabber']; 15 $_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']; 16 17 session_write_close(); 18 19 if ( $this->connect($_user . '@' . $_server . '/' . $_resource . ':' . $_port, $_pass) ) 20 $this->connected = true; 21 else 22 $this->connected = false; 23 24 25 } 26 27 public final function __destruct() 28 { 29 $this->closeSocket(); 30 } 31 32 public final function listen() 33 { 34 if ( !$this->connected ) 35 return "disconnected"; 36 37 if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) 14 38 { 15 $_SESSION['phpgw_info']['instant_messenger']['IM_disconnect'] = false; 16 return "disconnected"; 17 } 18 19 $_SESSION['phpgw_info']['instant_messenger']['timeClient'] = time(); 20 $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = true; 21 $xml = $_SESSION['phpgw_info']['instant_messenger']['socket']['in']; 22 //str_replace inserido por problemas com clientes que inserem 23 //quebra de linha no XML descomentar e retirar a seguinte para 24 //voltar ao padrão assim que possível 25 //24/10/2007 - problema verificado por usuários do SERPRO na 26 //plataforma Windows ocorrendo também no cliente Linux 27 //por Alexandre e Rodrigo 28 $xml = str_replace("\n","",$xml); 29 $xml = str_replace("\r","",$xml); 30 31 unset($_SESSION['phpgw_info']['instant_messenger']['socket']['in']); 32 $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = false; 33 34 ### Arranjo Tecnico ### 35 $vkrd = $xml; 36 37 if(isset($_SESSION['phpgw_info']['instant_messenger']['contacts'])) 38 unset($_SESSION['phpgw_info']['instant_messenger']['contacts']); 39 40 ### - messages - ### 41 //Linha abaixo dentro do padrão xmpp, entretanto clientes como 42 //o PSI não seguem o padrão assim ocorre problemas de comunicação 43 //descomentar e retirar a seguinte para voltar ao padrão assim 44 //que possível 45 //24/10/2007 - problema verificado por usuários do SERPRO na 46 //plataforma Windows ocorrendo também no cliente Linux 47 //por Alexandre e Rodrigo 48 //$_messages = "/<message[^>]+from='(\S+)'[^>]*>(?(?=.*?<composing |.*?<paused ).*?<(composing|paused) )(?(?=.*?<html).*?<html[^>]*><body[^>]*>(.*?)<\/body><\/html>).*?<\/message>/s"; 49 //retirar a linha abaixo para voltar ao padrão conforme acima 50 $_messages = "/<message[^>]+from='(\S+)'[^>]*>(?(?=.*?<composing |.*?<paused ).*?<(composing|paused) )(?(?=.*?<body).*?<body[^>]*>(.*?)<\/body>).*?<\/message>/s"; 51 $_messages = preg_match_all($_messages, $xml, $messages); 52 if ( $_messages !== false && $_messages > 0 ) 53 { 54 $xml = preg_replace("/<message.*?<\/message>/", "", $xml); 55 $return .= $this->getMessages($messages); 56 } 57 ### - Fim messages - ### 58 59 ### - contacts - ### 60 $_contacts = "/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/"; 61 $_contacts = preg_match_all($_contacts, $xml, $_xml); 62 63 $_contacts = "/<item.*?(?(?=[^>]+name)[^>]+name='(.*?)')[^>]+subscription='(.*?)'[^>]+jid='(.*?)'"; 64 $_contacts .= "(?(?=[^>]*\/>)[^>]*\/>|[^>]*><group>(.*?)<\/group><\/item>)/"; 65 $_contacts = preg_match_all($_contacts, $_xml[0][0], $contacts); 66 if ( $_contacts !== false && $_contacts > 0 ) 67 { 68 $xml = preg_replace("/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/", "", $xml); 69 $return .= rawurldecode(urldecode($this->getContacts($contacts))); 70 } 71 ### - Fim contacts - ### 72 73 ### - presence - ### 74 $xml = $_SESSION['phpgw_info']['instant_messenger']['presences'] . $xml; 75 76 $_presence = "/<presence(?(?=[^>]+\/>)[^>]+\/>|[^>]+>.*?<\/presence>)/"; 77 $_presence = preg_match_all($_presence, $xml, $presence); 78 79 $patterns[0] = '/<priority>[^<]*<\/priority>|<(\S) (?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/\1>)/'; 80 $patterns[1] = '/ xmlns=\'.*?\'| to=\'.*?\'/'; 81 $patterns[2] = '/> +</'; 82 $replacements[0] = ''; 83 $replacements[1] = ''; 84 $replacements[2] = '><'; 85 $_xml = preg_replace($patterns, $replacements, implode('', $presence[0])); 86 87 $_presence = "/<presence[^>]+from='(\S+)'[^>]*type='(unavailable)'(?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/presence>)|"; 88 $_presence .= "<presence[^>]+from='(\S+)'(?(?=[^>]+type)[^>]+type='(\S+)')[^>]*"; 89 $_presence .= "(?(?=\/>)\/>|>"; 90 $_presence .= "(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>))"; 91 $_presence .= "<\/presence>)/"; 92 $_presence = preg_match_all($_presence, $_xml, $presence); 93 if ( $_presence !== false && $_presence > 0 ) 94 { 95 foreach ( $presence[5] as $key => $val ) 96 { 97 if ( !empty($presence[1][$key]) && (strpos($presence[1][$key], '/') !== false) ) 98 $presence[1][$key] = substr($presence[1][$key], 0, strpos($presence[1][$key], '/')); 99 100 if ( !empty($presence[3][$key]) && strpos($presence[3][$key], '/') !== false ) 101 $presence[3][$key] = substr($presence[3][$key], 0, strpos($presence[3][$key], '/')); 102 103 if ( !empty($val) && !preg_match("/^(away|chat|dnd|xa)$/", $val) ) 104 if ( preg_match("/^(away|chat|dnd|xa)$/", $presence[6][$key]) ) 105 { 106 $aux = $presence[5][$key]; 107 $presence[5][$key] = $presence[6][$key]; 108 $presence[6][$key] = $aux; 109 } 110 else 111 { 112 if ( empty($presence[6][$key]) ) 113 $presence[6][$key] = $presence[5][$key]; 114 $presence[5][$key] = ''; 115 } 116 } 117 $xml = preg_replace("/<presence[^>]\/?>|<presence[^>]>.*?<\/presence>/", "", $xml); 118 119 $return .= $this->getPresence($presence); 120 } 121 ### - Fim presence - ### 122 123 124 ### - vcard - ### 125 ### - Arranjo Tecnico - ### 126 $_xml = $vkrd; 127 $_vcard = "/<iq.*? id='(.*?)' .*?(<vCard [^>]+\/>|<vCard.*?<\/vCard>)<\/iq>/"; 128 $_vcard = preg_match_all($_vcard, $_xml, $vcard); 129 if( $_vcard !== false && $_vcard > 0) 130 { 131 $xml = preg_replace("/<iq.*?<vCard.*?<\/iq>/", "", $xml); 132 $return .= urldecode($this->getVcard($vcard)); 133 } 134 ### - Fim vcard - ### 135 ## Final do Listen; 136 137 return $return; 138 } 139 140 function reconnect() 141 { 142 require_once("IMConfigure.php"); 143 144 $_transport = TRANSPORT_NON_SECURITY; 145 $_port = PORT_NON_SECURITY; 146 147 $SERVER = "127.0.0.1"; 148 149 $fp = ""; 150 @$fp = stream_socket_client($_transport . "://" . $SERVER . ":" . $_port, $errno, $errstr, 10); 151 152 if ( $fp ) 153 { 154 fwrite($fp, "GET /" . CONNECT . ";" . session_id() . " HTTP/1.1\r\nHost: " . $SERVER . ":" . $_port . "\r\nAccept: */*\r\n\r\n"); 155 return 'true'; 39 sleep(1); 40 $xml = $this->readSocket(); 41 printf("%s", $xml); 156 42 } 157 43 else 158 return 'false'; 159 } 160 161 /* 162 * Contacts 163 */ 44 { 45 ob_end_clean(); 46 ignore_user_abort(true); 47 ob_start(); 164 48 165 function getContacts(array $pContacts) 166 { 167 $_group = array(); 168 $return = NULL; 169 $jid = array_unique($pContacts[3]); 170 171 foreach ( $jid as $key => $val ) 172 { 173 $_SESSION['phpgw_info']['instant_messenger']['contacts'][] = $val; 49 $init = time(); 174 50 175 $item = NULL; 176 $item .= '<item name="' . (( !empty($pContacts[1][$key]) ) ? $pContacts[1][$key] : $val); 177 $item .= '" jid="' . $val; 178 $item .= '" subscription="' . $pContacts[2][$key]; 179 $item .= '" />'; 51 while ( !connection_aborted() && time() - $init < 10 ) 52 { 53 # read from server and write in the client 54 $xml = $this->readSocket(); 55 $xml = ( strlen($xml) ) ? $xml : ' '; 56 printf("%s", $xml ); 180 57 181 $_group[utf8_decode(strtolower(!empty($pContacts[4][$key]) ? $pContacts[4][$key] : 'default'))][] = $item;182 } 183 184 ksort($_group); 58 ob_flush(); 59 flush(); 60 usleep(6000); 61 } 185 62 186 foreach ( $_group as $key => $val ) 187 $return .= '<group name="' . $key . '">' . implode('', $val) . '</group>'; 63 ob_end_flush(); 64 } 65 } 188 66 189 return '<contacts>' . $return . '</contacts>'; 190 } 67 public final function SendMessage($pSendMessage) 68 { 69 $pSendMessage['body'] = stripslashes($pSendMessage['body']); 191 70 192 function requireContacts() 193 { 194 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['getContacts'] = NULL; 195 } 196 197 /* 198 * Presence 199 */ 71 $patterns = array('/ | +/i', '/<br[^>]*>/i'); 72 $replace = array(' ', '<br />'); 73 $pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']); 200 74 201 function setPresence($pPresence) 202 { 203 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['setPresence'] = $pPresence; 204 foreach($pPresence as $key=>$presence) 205 if($key == 'show' || $key == 'type') 206 { 207 $_SESSION['phpgw_info']['instant_messenger']['MyPresence'] = $presence; 208 } 209 } 210 211 function MyPresence() 212 { 213 if(isset($_SESSION['phpgw_info']['instant_messenger']['MyPresence'])) 214 return $_SESSION['phpgw_info']['instant_messenger']['MyPresence']; 215 } 216 217 function getPresence(array $pPresence) 218 { 219 $offline = array(); 220 foreach ( $pPresence[1] as $key => $val ) 221 { 222 if ( empty($val) ) 223 continue; 75 $_emotions = '/<img emotion="(\S+)?"[^>]+>/'; 76 $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions); 224 77 225 $_offline = true; 226 for ( $i = $key; $i < sizeof($pPresence[1]); $i++ ) 227 if ( $pPresence[1][$key] == $pPresence[3][$i] || $pPresence[1][$key] == $pPresence[5][$i] ) 228 $_offline = false; 78 foreach ( $emotions[0] as $key => $val ) 79 $emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i'; 229 80 230 if ( $_offline ) 231 $offline[$key] = $val; 232 } 81 $pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']); 233 82 234 $online = array(); 235 foreach ( $pPresence[3] as $key => $val ) 236 { 237 if ( empty($val) ) 238 continue; 83 $to = $pSendMessage['to']; 84 $type = "chat"; 85 $id = ""; 86 $content = array( 87 "subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "", 88 "thread" => $pSendMessage['thread'] ? $pSendMessage['thread'] : "", 89 "body" => $pSendMessage['body'] ? $pSendMessage['body'] : "" 90 ); 239 91 240 $_online = true; 241 for ( $i = ($key + 1); $i < sizeof($pPresence[3]); $i++ ) 242 if ( in_array($val, $offline) || $pPresence[3][$key] == $pPresence[3][$i] ) 243 $_online = false; 92 $payload = ""; 244 93 245 if ( $_online ) 246 $online[$key] = $val; 247 } 94 if ($to && is_array($content)) 95 { 96 if (!$id) 97 { 98 $id = $type . "_" . time(); 99 } 248 100 249 $return = NULL;101 $xml = "<message to='$to' type='$type' id='$id'>"; 250 102 251 foreach ( $offline as $key => $val ) 252 { 253 $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val; 254 $return .= "<presence from='" . $val . "' type='unavailable' />"; 255 } 256 257 foreach ( $online as $key => $val ) 258 { 259 $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val; 103 if ($content['subject']) 104 { 105 $xml .= "<subject>" . $content['subject'] . "</subject>"; 106 } 260 107 261 if ( empty($pPresence[4][$key]) ) 262 $pPresence[4][$key] = ( empty($pPresence[5][$key]) ) ? 263 'available' : $pPresence[5][$key]; 108 if ($content['thread']) 109 { 110 $xml .= "<thread>" . $content['thread'] . "</thread>"; 111 } 264 112 265 $return .= "<presence from='" . $val . "' type='" . $pPresence[4][$key]; 266 if ( empty($pPresence[6][$key]) ) 267 $return .= "' />"; 268 else 269 $return .= "'>" . $pPresence[6][$key] . "</presence>"; 113 //Linha abaixo dentro do padrão xmpp, entretanto clientes como 114 //o PSI não seguem o padrão assim ocorre problemas de comunicação 115 //descomentar e retirar a seguinte para voltar ao padrão assim 116 //que possÃvel 117 //24/10/2007 - problema verificado por usuários do SERPRO na 118 //plataforma Windows ocorrendo também no cliente Linux 119 //por Alexandre e Rodrigo 270 120 271 if ( strpos($pPresence[4][$key], 'subscribe') === false ) 272 { 273 $session .= "<presence from='" . $val . "'><show>" . $pPresence[4][$key] . "</show>"; 274 if ( !empty($pPresence[6][$key]) ) 275 $session .= "<status>" . $pPresence[6][$key] . "</status>"; 276 $session .= "</presence>"; 277 } 278 } 121 //$xml .= "<html><body>" . $content['body'] . "</body></html>"; 279 122 280 $_SESSION['phpgw_info']['instant_messenger']['presences'] = $session; 123 //retirar a linha abaixo para voltar ao padrão conforme acima 124 $xml .= "<body>" . $content['body'] . "</body>"; 125 $xml .= $payload; 126 $xml .= "</message>"; 127 unset($id); 281 128 282 return $return; 283 } 284 285 /* 286 * GetMessage 287 */ 288 289 function getMessages(array $pMessages) 290 { 291 $_messages = array(); 292 $return = NULL; 293 294 foreach ( $pMessages[1] as $key => $val ) 295 { 296 trim($pMessages[3][$key]); 297 if ( !empty($pMessages[3][$key]) ) 298 $_messages[$val][] = $pMessages[3][$key]; 299 300 if ( !empty($pMessages[2][$key]) ) 301 { 302 $return .= '<' . $pMessages[2][$key] . ' from="'; 303 $return .= ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val; 304 $return .= '" />'; 305 } 306 } 307 308 foreach ( $_messages as $key => $val ) 309 { 310 $return .= '<messages from="' . $key . '">'; 311 foreach ( $val as $msg ) 312 $return .= '<message>' . $msg . '</message>'; 313 $return .= '</messages>'; 314 } 315 316 return $return; 317 } 318 319 /* 320 * SendMessage 321 */ 322 323 function SendMessage($pSendMessage) 324 { 325 $pSendMessage['body'] = stripslashes($pSendMessage['body']); 326 $_emotions = '/<img emotion="(\S+)?"[^>]+>/'; 327 $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions); 328 329 foreach ( $emotions[0] as $key => $val ) 330 $emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i'; 331 332 $pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']); 333 334 $to = $pSendMessage['to']; 335 $type = "chat"; 336 $id = ""; 337 $content = array( 338 "subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "", 339 "thread" => $pSendMessage['thread'] ? $pSendMessage['thread'] : "", 340 "body" => $pSendMessage['body'] ? $pSendMessage['body'] : "" 341 ); 342 343 $payload = ""; 344 345 if ($to && is_array($content)) 346 { 347 if (!$id) 348 { 349 $id = $type . "_" . time(); 350 } 351 352 $xml = "<message to='$to' type='$type' id='$id'>"; 353 354 if ($content['subject']) 355 { 356 $xml .= "<subject>" . $content['subject'] . "</subject>"; 357 } 358 359 if ($content['thread']) 360 { 361 $xml .= "<thread>" . $content['thread'] . "</thread>"; 362 } 363 364 //Linha abaixo dentro do padrão xmpp, entretanto clientes como 365 //o PSI não seguem o padrão assim ocorre problemas de comunicação 366 //descomentar e retirar a seguinte para voltar ao padrão assim 367 //que possível 368 //24/10/2007 - problema verificado por usuários do SERPRO na 369 //plataforma Windows ocorrendo também no cliente Linux 370 //por Alexandre e Rodrigo 371 //$xml .= "<html><body>" . $content['body'] . "</body></html>"; 372 //retirar a linha abaixo para voltar ao padrão conforme acima 373 $xml .= "<body>" . $content['body'] . "</body>"; 374 $xml .= $payload; 375 $xml .= "</message>"; 376 unset($id); 377 378 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml; 379 } 380 else 381 { 382 $this->writeLog("ERROR: SendMessage() #2"); 383 return FALSE; 384 } 385 } 386 387 /* 388 * Composing / Paused Message 389 */ 390 391 function composingMessage($pComposing) 392 { 393 394 $xml = "<message xmlns='jabber:client' to='".$pComposing['to']."' id='".time()."' type='chat'>"; 395 $xml .= "<x xmlns='jabber:x:event'>"; 396 $xml .= "<composing/>"; 397 $xml .= "</x>"; 398 $xml .= "<composing xmlns='http://jabber.org/protocol/chatstates'/>"; 399 $xml .= "</message>"; 400 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml; 401 } 402 403 function pausedMessage($pComposing) 404 { 405 $xml = "<message xmlns='jabber:client' to='".$pComposing['to']."' id='".time()."' type='chat'>"; 406 $xml .= "<x xmlns='jabber:x:event'/>"; 407 $xml .= "<paused xmlns='http://jabber.org/protocol/chatstates'/>"; 408 $xml .= "</message>"; 409 410 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml; 411 } 412 413 /* 414 * UpdateContact 415 */ 416 417 function updateContact($pUser) 418 { 419 $jid = $pUser['jid']; 420 $name = $pUser['name']; 421 $group = $pUser['group']; 422 423 if ( $jid ) 424 { 425 $updatecontact = "<item jid='$jid'"; 426 $updatecontact .= " name='" . $name . "'"; 427 $updatecontact .= "><group>" . $group . "</group></item>"; 428 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['updateContact'] = $updatecontact; 429 } 430 $this->requireContacts(); 431 } 432 433 /* 434 * AddContact 435 */ 436 437 function addContacts($pUser) 438 { 439 $jid = explode("@",$pUser['email']); 440 $pJid = $jid[0]."@".$_SESSION['phpgw_info']['instant_messenger']['name_jabber']; 441 $pName = $pUser['name']; 442 $pGroup = $pUser['group']; 443 444 if(trim($jid[0]) != trim($this->username)) 445 { 446 if ( $pJid ) 447 { 448 $newcontact = "<item jid='$pJid'"; 449 $newcontact .= " name='" . $pName . "'"; 450 $newcontact .= "><group>" . $pGroup . "</group></item>"; 451 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['addContacts'] = $newcontact; 452 $this->subscribe($pJid); 453 $this->requireContacts(); 454 } 455 } 456 } 457 458 /* 459 * RemoveContact 460 */ 461 462 function removeContact($pUser) 463 { 464 $pJid = $pUser['jid']; 465 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['removeContact'] = $pJid; 466 $this->unsubscribed($pJid); 467 $this->requireContacts(); 468 } 469 470 /* 471 * Vcard 472 */ 473 474 function newVcard($pVcardUser) 475 { 476 $pVcard = explode("_vkrd_", $pVcardUser['vcard']); 477 478 $xmlVcard = "<FN>".$pVcard[0]."</FN>"; 479 $xmlVcard .= "<NICKNAME>".$pVcard[1]."</NICKNAME>"; 480 $xmlVcard .= "<ORG>"; 481 $xmlVcard .= "<ORGNAME>".$pVcard[2]."</ORGNAME>"; 482 $xmlVcard .= "<ORGUNIT>".$pVcard[3]."</ORGUNIT>"; 483 $xmlVcard .= "</ORG>"; 484 $xmlVcard .= "<ROLE>".$pVcard[4]."</ROLE>"; 485 $xmlVcard .= "<BDAY>".$pVcard[5]."</BDAY>"; 486 $xmlVcard .= "<DESC>".$pVcard[6]."</DESC>"; 487 488 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['newVcard'] = $xmlVcard; 489 490 } 491 492 function getVcard(array $Vcard) 493 { 494 $div = ""; 495 $_expr = "/<[^<vCard xmlns=\'vcard\-temp\'>].*[^<\/vCard>]>/"; 496 array_shift($Vcard); 497 $div = '<vcard>'; 498 $jid_user = $_SESSION['phpgw_info']['instant_messenger']['user']; 499 $jid_user .= "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; 500 for($i = 0 ; $i < count($Vcard[0]) ; $i++) 501 { 502 preg_match($_expr,$Vcard[1][$i],$div_vcard); 503 $div_new[] = $div_vcard; 504 505 if ( $jid_user == $Vcard[0][$i] ) 506 $_SESSION['phpgw_info']['instant_messenger']['vcard'] = $div_new[$i][0]; 507 508 $div .= '<div id="vcard_'.$Vcard[0][$i].'">'.urldecode($div_new[$i][0]).'</div>'; 509 } 510 $div .= '</vcard>'; 511 512 return $div; 513 } 514 515 function Vcard() 516 { 517 $contacts = array(); 518 $contacts = $_SESSION['phpgw_info']['instant_messenger']['contacts']; 519 $jid_user = $this->getJid(); 520 521 if( count($contacts) > 0 ) 522 { 523 array_unshift($contacts,$jid_user); 524 525 foreach($contacts as $user) 526 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][] = $user; 527 return "true"; 528 }else{ 529 return "false"; 530 } 531 } 532 533 function VcardUser() 534 { 535 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][] = $this->getJid();; 536 } 537 538 function getJid() 539 { 540 $jid = $_SESSION['phpgw_info']['instant_messenger']['user'] . "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; 541 return $jid; 542 } 543 544 function subscribe($pJid) 545 { 546 $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; 547 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Subscribe'] = $jid; 548 } 549 550 function subscribed($pJid) 551 { 552 $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; 553 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionAcceptRequest'] = $jid; 554 } 555 556 function unsubscribe($pJid) 557 { 558 $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; 559 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Unsubscribe'] = $jid; 560 } 561 562 function unsubscribed($pJid) 563 { 564 $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; 565 $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionDenyRequest'] = $jid; 566 } 129 echo $xml; 130 $this->writeSocket($xml); 131 $this->close(); 132 } 133 else 134 { 135 //$this->writeLog("ERROR: SendMessage() #2"); 136 return false; 137 } 138 } 567 139 } 568 140 ?> -
trunk/instant_messenger/inc/class.contacts_im.inc.php
r86 r151 20 20 21 21 $search_uids = "|"; 22 foreach($db_acls as $tmp) 23 $search_uids .= "(uidNumber=".$tmp['acl_account'].")"; 22 if(count($db_acls) > 0) 23 foreach($db_acls as $tmp) 24 $search_uids .= "(uidNumber=".$tmp['acl_account'].")"; 24 25 25 26 // Busca Usuarios … … 27 28 28 29 $search_groups = "|"; 29 foreach($db_acls as $tmp) 30 $search_groups .= "(gidNumber=".$tmp['acl_account'].")"; 30 if(count($db_acls) > 0) 31 foreach($db_acls as $tmp) 32 $search_groups .= "(gidNumber=".$tmp['acl_account'].")"; 31 33 32 34 // Busca Grupos … … 59 61 function list_contacts($param) 60 62 { 61 $users = $this->users_auth_im(); 62 $ordenar = array(); 63 $return = array(); 64 $i = 0; 63 $users = $this->users_auth_im(); 64 $order = array(); 65 $return = "<uids>"; 65 66 66 67 foreach($users as $tmp) 67 $orde nar[] = $tmp['cn'].";".$tmp['mail'].";".$tmp['uid'].";".$tmp['dn'];68 $order[] = $tmp['cn'].";".$tmp['mail'].";".$tmp['uid'].";".$tmp['dn']; 68 69 69 natsort($orde nar);70 $uid_unique = @array_values(@array_unique($orde nar));70 natsort($order); 71 $uid_unique = @array_values(@array_unique($order)); 71 72 72 73 foreach($uid_unique as $tmp) … … 75 76 if(strtolower($result[3]) == strtolower($param['ou'])) 76 77 { 77 $return[$i]['cn'] = $result[0]; 78 $return[$i]['mail'] = $result[1]; 79 $return[$i]['uid'] = $result[2]; 80 $i++; 78 $return .= "<data>"; 79 $return .= "<cn>" . $result[0] . "</cn>"; 80 $return .= "<mail>" . $result[1] . "</mail>"; 81 $return .= "<uid>" . $result[2] . "</uid>"; 82 $return .= "</data>"; 81 83 } 82 84 unset($result); 83 85 } 84 85 if(count($return) > 0) 86 return $return; 87 else 88 return 0; 86 87 $return .= "</uids>"; 88 return $return; 89 89 } 90 90 -
trunk/instant_messenger/inc/class.db_im.inc.php
r55 r151 14 14 var $db_pass; 15 15 var $db_type; 16 var $user_id; 16 17 var $teste; 17 18 18 function db_im(){ 19 function db_im() 20 { 21 session_start(); 19 22 $this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name']; 20 23 $this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host']; … … 23 26 $this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass']; 24 27 $this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type']; 28 $this->user_id = $_SESSION['phpgw_info']['instant_messenger']['user_id']; 25 29 26 $this->db = new db(); 30 $this->db = new db(); 27 31 $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type); 32 session_write_close(); 28 33 } 29 34 … … 53 58 { 54 59 $preferences = $param['preferences']; 55 $user_id = $ _SESSION['phpgw_info']['instant_messenger']['user_id'];60 $user_id = $this->user_id; 56 61 $app_name = $this->name_app(); 57 62 58 63 $query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')"; 59 64 60 if($this->query_db($query)) 65 if($this->query_db($query)) 66 { 61 67 return "true"; 62 else{ 68 } 69 else 70 { 63 71 $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'"; 64 72 if($this->query_db($query)) … … 72 80 { 73 81 $result = array(); 74 $user_id = $ _SESSION['phpgw_info']['instant_messenger']['user_id'];82 $user_id = $this->user_id; 75 83 $app_name = $this->name_app(); 76 84 … … 83 91 $result[] = $this->db->row(); 84 92 85 if(count($result) > 0) {93 if(count($result) > 0) 86 94 return unserialize($result[0]['preference_value']); 87 }else{ 88 return "ch_offline:true;in_time:1;rd_nm:true;rd_ch:false"; 89 } 90 } 95 else 96 return "ch_offline:true;time_xa_im:1;rd_nm:true;rd_ch:false"; 97 } 91 98 92 99 function name_app() -
trunk/instant_messenger/inc/class.ldap_im.inc.php
r68 r151 6 6 private $conn; 7 7 private $user; 8 private $jid; 8 9 private $password; 9 10 10 11 function __construct() 11 12 { 12 $this->ldap_host = $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']; 13 $this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']; 14 $this->user = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 15 $this->password = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 13 session_start(); 14 $this->ldap_host = $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']; 15 $this->ldap_context = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']; 16 $this->user = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 17 $this->password = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 18 $this->jid = $_SESSION['phpgw_info']['instant_messenger']['user']; 16 19 $this->connect_ldap(false); 20 session_write_close(); 17 21 } 18 22 … … 33 37 } 34 38 35 function get_photo_ldap($ user,$getPhoto)39 function get_photo_ldap($pUser,$getPhoto) 36 40 { 37 $user = ( $ user == "user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user'] : $user ;41 $user = ( $pUser == "im_avatar" ) ? $this->jid : $pUser ; 38 42 39 if ($this->conn) { 43 if ($this->conn) 44 { 40 45 $filter="(&(uid=".$user.")(phpgwAccountType=u))"; 41 46 $justthese = array("jpegphoto"); 42 $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);43 $entry = ldap_first_entry($this->conn, $search);47 $search = @ldap_search($this->conn,$this->ldap_context, $filter, $justthese); 48 $entry = @ldap_first_entry($this->conn, $search); 44 49 $jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto"); 45 50 46 if( count($jpeg_data) > 1) {47 51 if( count($jpeg_data) > 1) 52 { 48 53 $photo = imagecreatefromstring($jpeg_data[0]); 49 if($photo){ 50 if($getPhoto){ 54 if($photo) 55 { 56 if($getPhoto) 57 { 51 58 header("Content-Type: image/jpeg"); 52 59 $width = imagesx($photo); … … 59 66 return; 60 67 }else{ 61 return 1;68 return "true"; 62 69 } 63 70 }else{ 64 return 0;71 return "false"; 65 72 } 66 73 }else{ 67 return 0;74 return "false"; 68 75 } 69 76 } … … 72 79 function photo_ldap($user) 73 80 { 74 $uid = ( $user['uid'] == " user" ) ? $_SESSION['phpgw_info']['instant_messenger']['user']: $user['uid'] ;81 $uid = ( $user['uid'] == "im_avatar" ) ? $this->jid : $user['uid'] ; 75 82 return $this->get_photo_ldap($uid,false); 76 83 } … … 143 150 function list_organizations_ldap() 144 151 { 145 $result_org = array(); 146 $i = 0; 147 if ($this->conn) { 152 $result_org = "<organizations><ou></ou>"; 153 154 if ($this->conn) 155 { 148 156 $filter="ou=*"; 149 157 $justthese = array("ou"); … … 152 160 } 153 161 154 foreach($entry as $tmp){ 155 if($tmp['ou'][0] != ""){ 156 $result_org[$i] = $tmp['ou'][0]; 157 $i++; 158 } 159 } 160 sort($result_org); 162 foreach($entry as $tmp) 163 if($tmp['ou'][0] != "") 164 $result_org .= "<ou>" . $tmp['ou'][0] . "</ou>"; 165 166 $result_org .= "</organizations>"; 167 161 168 return $result_org; 162 169 } … … 176 183 } 177 184 178 if(trim($_REQUEST['user']) != ""){ 185 if(trim($_REQUEST['user']) != "") 186 { 179 187 $obj_img = new ldap_im(); 180 188 $obj_img->get_photo_ldap($_REQUEST['user'],true); -
trunk/instant_messenger/inc/im_acl.inc.php
r75 r151 4 4 if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger') 5 5 { 6 require_once("im_sessions.inc.php"); 7 6 session_start(); 8 7 $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 9 $wz_dragdrop = $webserver_url."/phpgwapi/js/wz_dragdrop/";10 8 $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/'; 11 12 9 if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) ) 13 10 $webserver_url .= '/'; 14 11 15 12 $webserver_url = $webserver_url . 'instant_messenger/'; 16 13 17 require_once("IMConfigure.php"); 14 require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php'; 15 require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/load_lang.php'; 16 17 $DOCUMENT_ROOT = PHPGW_SERVER_ROOT .'/instant_messenger/'; 18 19 $js = array( 20 'js/connector.js', 21 'js/xtools.js', 22 'js/jabber.js', 23 'js/client.js', 24 'js/images.js', 25 'js/dragdrop.js', 26 'js/build_win.js', 27 'js/templates.js', 28 'js/fcommon.js', 29 'js/menu_action.js', 30 'js/functions.js', 31 'js/images.js', 32 'js/cookies_im.js', 33 'js/load.js', 34 ); 18 35 19 $_transport = TRANSPORT_NON_SECURITY; 20 $_port = PORT_NON_SECURITY; 36 print '<script type="text/javascript">var path_im = "'.$webserver_url.'";</script>'; 37 foreach ( $js as $key => $val ) 38 print '<script src="' . $webserver_url . $val . '?' . filemtime($DOCUMENT_ROOT . $val) . '"></script>'; 39 40 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/window.css">'; 41 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/chat.css">'; 42 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/common.css">'; 43 print '<script type="text/javascript">setTimeout("client()",1000);</script>'; 21 44 22 $SERVER = "127.0.0.1"; 23 24 $fp = ""; 25 @$fp = stream_socket_client($_transport . "://" . $SERVER . ":" . $_port, $errno, $errstr, 10); 26 27 if ( $fp ) 28 { 29 fwrite($fp, "GET /" . CONNECT . ";" . session_id() . " HTTP/1.1\r\nHost: " . $SERVER . ":" . $_port . "\r\nAccept: */*\r\n\r\n"); 30 31 $js = array( 32 $webserver_url . 'js/XMLTools.js', 33 $webserver_url . 'js/im_functions.js', 34 $webserver_url . 'js/im_fcommon.js', 35 $webserver_url . 'js/im_var_globals.js', 36 $webserver_url . 'js/im_images.js', 37 $webserver_url . 'js/im_smiles.js', 38 $webserver_url . 'js/im_templates.js', 39 $webserver_url . 'js/im_win.js', 40 $webserver_url . 'js/im_menu_action.js', 41 $webserver_url . 'js/im_conf_font.js', 42 $webserver_url . 'js/im_preferences.js', 43 $webserver_url . 'js/im_init.js', 44 $webserver_url . 'js/im_subscription.js', 45 ); 46 47 require_once('load_lang.php'); 48 49 print ' 50 <link rel="stylesheet" href="' . $webserver_url . 'templates/default/css.css" /> 51 <link rel="stylesheet" href="' . $webserver_url . 'templates/default/messenger.css" /> 52 <script> 53 var im_path="' . $webserver_url . '"; 54 var ini_wzdd = false; 55 if ( !window.dd ) 56 { 57 ini_wzdd = true; 58 document.write(\'\<script src="' . $wz_dragdrop . 'wz_dragdrop.js"\>\<\/script\>\'); 59 var im_path="' . $webserver_url . '"; 60 } 61 </script>'; 62 63 print ' 64 <script> 65 if ( ini_wzdd ) 66 SET_DHTML("backFantom"+NO_DRAG); 67 </script>'; 68 69 foreach ( $js as $key => $val ) 70 print '<script src="' . $val . '?' . filemtime($_SERVER['DOCUMENT_ROOT'] . '/' . $val) . '"></script>'; 71 72 } 73 break; 45 session_write_close(); 74 46 } 75 47 } -
trunk/instant_messenger/inc/im_sessions.inc.php
r67 r151 1 1 <?php 2 2 3 $_SESSION['phpgw_info']['instant_messenger']['user'] = $GLOBALS['phpgw_info']['user']['account_lid']; 4 $_SESSION['phpgw_info']['instant_messenger']['user_id'] = $GLOBALS['phpgw_info']['user']['account_id']; 5 $_SESSION['phpgw_info']['instant_messenger']['passwd'] = $GLOBALS['phpgw_info']['user']['passwd']; 6 $_SESSION['phpgw_info']['instant_messenger']['name_jabber'] = $GLOBALS['phpgw_info']['server']['name_jabber']; 7 $_SESSION['phpgw_info']['instant_messenger']['port_jabber'] = $GLOBALS['phpgw_info']['server']['port_jabber']; 8 $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'] = $GLOBALS['phpgw_info']['server']['resource_jabber']; 9 10 # Conf. Ldap 11 $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['server_ldap_jabber']; 12 $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['context_ldap_jabber']; 13 $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['user_ldap_jabber']; 14 $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabber']; 15 $_SESSION['phpgw_info']['instant_messenger']['size_file_jabber'] = $GLOBALS['phpgw_info']['server']['size_file_jabber']; 16 17 $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name']; 18 $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host']; 19 $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port']; 20 $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user']; 21 $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; 22 $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type']; 3 $_SESSION['phpgw_info']['instant_messenger']['user'] = $GLOBALS['phpgw_info']['user']['account_lid']; 4 $_SESSION['phpgw_info']['instant_messenger']['user_id'] = $GLOBALS['phpgw_info']['user']['account_id']; 5 $_SESSION['phpgw_info']['instant_messenger']['passwd'] = $GLOBALS['phpgw_info']['user']['passwd']; 6 $_SESSION['phpgw_info']['instant_messenger']['name_jabber'] = $GLOBALS['phpgw_info']['server']['name_jabber']; 7 $_SESSION['phpgw_info']['instant_messenger']['port_jabber'] = $GLOBALS['phpgw_info']['server']['port_jabber']; 8 $_SESSION['phpgw_info']['instant_messenger']['resource_jabber'] = $GLOBALS['phpgw_info']['server']['resource_jabber']; 9 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 15 $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name']; 16 $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host']; 17 $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port']; 18 $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user']; 19 $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; 20 $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type']; 23 21 24 22 ?>
Note: See TracChangeset
for help on using the changeset viewer.