Changeset 151 for trunk/instant_messenger/inc/class.Ujabber.inc.php
- Timestamp:
- 01/18/08 15:17:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 ?>
Note: See TracChangeset
for help on using the changeset viewer.