[20] | 1 | <?php |
---|
| 2 | |
---|
[55] | 3 | class Ujabber |
---|
[20] | 4 | { |
---|
[55] | 5 | /* |
---|
| 6 | * Listen |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | final function listen() |
---|
| 10 | { |
---|
| 11 | $return = null; |
---|
[20] | 12 | |
---|
[63] | 13 | $_SESSION['phpgw_info']['instant_messenger']['time'] = time(); |
---|
[55] | 14 | $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = true; |
---|
| 15 | $xml = $_SESSION['phpgw_info']['instant_messenger']['socket']['in']; |
---|
| 16 | |
---|
| 17 | unset($_SESSION['phpgw_info']['instant_messenger']['socket']['in']); |
---|
| 18 | $_SESSION['phpgw_info']['instant_messenger']['socket']['block'] = false; |
---|
[41] | 19 | |
---|
[55] | 20 | ### Arranjo Tecnico ### |
---|
| 21 | $vkrd = $xml; |
---|
| 22 | |
---|
| 23 | if(isset($_SESSION['phpgw_info']['instant_messenger']['contacts'])) |
---|
| 24 | unset($_SESSION['phpgw_info']['instant_messenger']['contacts']); |
---|
[41] | 25 | |
---|
[55] | 26 | ### - messages - ### |
---|
| 27 | $_messages = "/<message[^>]+from='(\S+)'[^>]*>(?(?=.*?<composing |.*?<paused ).*?<(composing|paused) )(?(?=.*?<html).*?<html[^>]*><body[^>]*>(.*?)<\/body><\/html>).*?<\/message>/s"; |
---|
| 28 | $_messages = preg_match_all($_messages, $xml, $messages); |
---|
| 29 | if ( $_messages !== false && $_messages > 0 ) |
---|
| 30 | { |
---|
| 31 | $xml = preg_replace("/<message.*?<\/message>/", "", $xml); |
---|
| 32 | $return .= $this->getMessages($messages); |
---|
| 33 | } |
---|
| 34 | ### - Fim messages - ### |
---|
[41] | 35 | |
---|
[55] | 36 | ### - contacts - ### |
---|
| 37 | $_contacts = "/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/"; |
---|
| 38 | $_contacts = preg_match_all($_contacts, $xml, $_xml); |
---|
[41] | 39 | |
---|
[55] | 40 | $_contacts = "/<item.*?(?(?=[^>]+name)[^>]+name='(.*?)')[^>]+subscription='(.*?)'[^>]+jid='(.*?)'"; |
---|
| 41 | $_contacts .= "(?(?=[^>]*\/>)[^>]*\/>|[^>]*><group>(.*?)<\/group><\/item>)/"; |
---|
| 42 | $_contacts = preg_match_all($_contacts, $_xml[0][0], $contacts); |
---|
| 43 | if ( $_contacts !== false && $_contacts > 0 ) |
---|
| 44 | { |
---|
| 45 | $xml = preg_replace("/<iq[^>]+id='contacts'[^>]*>.*?<\/iq>/", "", $xml); |
---|
| 46 | $return .= rawurldecode(urldecode($this->getContacts($contacts))); |
---|
| 47 | } |
---|
| 48 | ### - Fim contacts - ### |
---|
[41] | 49 | |
---|
[55] | 50 | ### - presence - ### |
---|
| 51 | $xml = $_SESSION['phpgw_info']['instant_messenger']['presences'] . $xml; |
---|
[41] | 52 | |
---|
[55] | 53 | $_presence = "/<presence(?(?=[^>]+\/>)[^>]+\/>|[^>]+>.*?<\/presence>)/"; |
---|
| 54 | $_presence = preg_match_all($_presence, $xml, $presence); |
---|
[41] | 55 | |
---|
[55] | 56 | $patterns[0] = '/<priority>[^<]*<\/priority>|<(\S) (?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/\1>)/'; |
---|
| 57 | $patterns[1] = '/ xmlns=\'.*?\'| to=\'.*?\'/'; |
---|
| 58 | $patterns[2] = '/> +</'; |
---|
| 59 | $replacements[0] = ''; |
---|
| 60 | $replacements[1] = ''; |
---|
| 61 | $replacements[2] = '><'; |
---|
| 62 | $_xml = preg_replace($patterns, $replacements, implode('', $presence[0])); |
---|
[20] | 63 | |
---|
[55] | 64 | $_presence = "/<presence[^>]+from='(\S+)'[^>]*type='(unavailable)'(?(?=[^>]*\/>)[^>]*\/>|[^>]*>.*?<\/presence>)|"; |
---|
| 65 | $_presence .= "<presence[^>]+from='(\S+)'(?(?=[^>]+type)[^>]+type='(\S+)')[^>]*"; |
---|
| 66 | $_presence .= "(?(?=\/>)\/>|>"; |
---|
| 67 | $_presence .= "(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>(?(?=<s[^>]*?>)<s[^>]*?>(.*?)<\/s[^>]*?>))"; |
---|
| 68 | $_presence .= "<\/presence>)/"; |
---|
| 69 | $_presence = preg_match_all($_presence, $_xml, $presence); |
---|
| 70 | if ( $_presence !== false && $_presence > 0 ) |
---|
| 71 | { |
---|
| 72 | foreach ( $presence[5] as $key => $val ) |
---|
| 73 | { |
---|
| 74 | if ( !empty($presence[1][$key]) && (strpos($presence[1][$key], '/') !== false) ) |
---|
| 75 | $presence[1][$key] = substr($presence[1][$key], 0, strpos($presence[1][$key], '/')); |
---|
| 76 | |
---|
| 77 | if ( !empty($presence[3][$key]) && strpos($presence[3][$key], '/') !== false ) |
---|
| 78 | $presence[3][$key] = substr($presence[3][$key], 0, strpos($presence[3][$key], '/')); |
---|
| 79 | |
---|
| 80 | if ( !empty($val) && !preg_match("/^(away|chat|dnd|xa)$/", $val) ) |
---|
| 81 | if ( preg_match("/^(away|chat|dnd|xa)$/", $presence[6][$key]) ) |
---|
| 82 | { |
---|
| 83 | $aux = $presence[5][$key]; |
---|
| 84 | $presence[5][$key] = $presence[6][$key]; |
---|
| 85 | $presence[6][$key] = $aux; |
---|
| 86 | } |
---|
| 87 | else |
---|
| 88 | { |
---|
| 89 | if ( empty($presence[6][$key]) ) |
---|
| 90 | $presence[6][$key] = $presence[5][$key]; |
---|
| 91 | $presence[5][$key] = ''; |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | $xml = preg_replace("/<presence[^>]\/?>|<presence[^>]>.*?<\/presence>/", "", $xml); |
---|
[20] | 95 | |
---|
[55] | 96 | $return .= $this->getPresence($presence); |
---|
| 97 | } |
---|
| 98 | ### - Fim presence - ### |
---|
[41] | 99 | |
---|
[55] | 100 | |
---|
| 101 | ### - vcard - ### |
---|
| 102 | ### - Arranjo Tecnico - ### |
---|
| 103 | $_xml = $vkrd; |
---|
| 104 | $_vcard = "/<iq.*? id='(.*?)' .*?(<vCard [^>]+\/>|<vCard.*?<\/vCard>)<\/iq>/"; |
---|
| 105 | $_vcard = preg_match_all($_vcard, $_xml, $vcard); |
---|
| 106 | if( $_vcard !== false && $_vcard > 0) |
---|
| 107 | { |
---|
| 108 | $xml = preg_replace("/<iq.*?<vCard.*?<\/iq>/", "", $xml); |
---|
| 109 | $return .= urldecode($this->getVcard($vcard)); |
---|
| 110 | } |
---|
| 111 | ### - Fim vcard - ### |
---|
| 112 | |
---|
| 113 | ## Final do Listen; |
---|
[41] | 114 | |
---|
[55] | 115 | return $return; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | /* |
---|
| 119 | * Contacts |
---|
| 120 | */ |
---|
[41] | 121 | |
---|
[55] | 122 | function getContacts(array $pContacts) |
---|
| 123 | { |
---|
| 124 | $_group = array(); |
---|
| 125 | $return = NULL; |
---|
| 126 | $jid = array_unique($pContacts[3]); |
---|
| 127 | |
---|
| 128 | foreach ( $jid as $key => $val ) |
---|
| 129 | { |
---|
| 130 | $_SESSION['phpgw_info']['instant_messenger']['contacts'][] = $val; |
---|
[41] | 131 | |
---|
[55] | 132 | $item = NULL; |
---|
| 133 | $item .= '<item name="' . (( !empty($pContacts[1][$key]) ) ? $pContacts[1][$key] : $val); |
---|
| 134 | $item .= '" jid="' . $val; |
---|
| 135 | $item .= '" subscription="' . $pContacts[2][$key]; |
---|
| 136 | $item .= '" />'; |
---|
[20] | 137 | |
---|
[55] | 138 | $_group[utf8_decode(strtolower(!empty($pContacts[4][$key]) ? $pContacts[4][$key] : 'default'))][] = $item; |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | ksort($_group); |
---|
[41] | 142 | |
---|
[55] | 143 | foreach ( $_group as $key => $val ) |
---|
| 144 | $return .= '<group name="' . $key . '">' . implode('', $val) . '</group>'; |
---|
[41] | 145 | |
---|
[55] | 146 | return '<contacts>' . $return . '</contacts>'; |
---|
| 147 | } |
---|
[41] | 148 | |
---|
[55] | 149 | function requireContacts() |
---|
| 150 | { |
---|
| 151 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['getContacts'] = NULL; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | /* |
---|
| 155 | * Presence |
---|
| 156 | */ |
---|
[41] | 157 | |
---|
[55] | 158 | function setPresence($pPresence) |
---|
| 159 | { |
---|
| 160 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['setPresence'] = $pPresence; |
---|
| 161 | foreach($pPresence as $key=>$presence) |
---|
| 162 | if($key == 'show' || $key == 'type') |
---|
[57] | 163 | { |
---|
[55] | 164 | $_SESSION['phpgw_info']['instant_messenger']['MyPresence'] = $presence; |
---|
[57] | 165 | } |
---|
[55] | 166 | } |
---|
| 167 | |
---|
| 168 | function MyPresence() |
---|
| 169 | { |
---|
| 170 | if(isset($_SESSION['phpgw_info']['instant_messenger']['MyPresence'])) |
---|
| 171 | return $_SESSION['phpgw_info']['instant_messenger']['MyPresence']; |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | function getPresence(array $pPresence) |
---|
| 175 | { |
---|
| 176 | $offline = array(); |
---|
| 177 | foreach ( $pPresence[1] as $key => $val ) |
---|
| 178 | { |
---|
| 179 | if ( empty($val) ) |
---|
| 180 | continue; |
---|
[41] | 181 | |
---|
[55] | 182 | $_offline = true; |
---|
| 183 | for ( $i = $key; $i < sizeof($pPresence[1]); $i++ ) |
---|
| 184 | if ( $pPresence[1][$key] == $pPresence[3][$i] || $pPresence[1][$key] == $pPresence[5][$i] ) |
---|
| 185 | $_offline = false; |
---|
[20] | 186 | |
---|
[55] | 187 | if ( $_offline ) |
---|
| 188 | $offline[$key] = $val; |
---|
| 189 | } |
---|
[41] | 190 | |
---|
[55] | 191 | $online = array(); |
---|
| 192 | foreach ( $pPresence[3] as $key => $val ) |
---|
| 193 | { |
---|
| 194 | if ( empty($val) ) |
---|
| 195 | continue; |
---|
[20] | 196 | |
---|
[55] | 197 | $_online = true; |
---|
| 198 | for ( $i = ($key + 1); $i < sizeof($pPresence[3]); $i++ ) |
---|
| 199 | if ( in_array($val, $offline) || $pPresence[3][$key] == $pPresence[3][$i] ) |
---|
| 200 | $_online = false; |
---|
[41] | 201 | |
---|
[55] | 202 | if ( $_online ) |
---|
| 203 | $online[$key] = $val; |
---|
| 204 | } |
---|
[41] | 205 | |
---|
[55] | 206 | $return = NULL; |
---|
[41] | 207 | |
---|
[55] | 208 | foreach ( $offline as $key => $val ) |
---|
| 209 | { |
---|
| 210 | $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val; |
---|
| 211 | $return .= "<presence from='" . $val . "' type='unavailable' />"; |
---|
| 212 | } |
---|
| 213 | |
---|
| 214 | foreach ( $online as $key => $val ) |
---|
| 215 | { |
---|
| 216 | $val = ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val; |
---|
[41] | 217 | |
---|
[55] | 218 | if ( empty($pPresence[4][$key]) ) |
---|
| 219 | $pPresence[4][$key] = ( empty($pPresence[5][$key]) ) ? |
---|
| 220 | 'available' : $pPresence[5][$key]; |
---|
[41] | 221 | |
---|
[55] | 222 | $return .= "<presence from='" . $val . "' type='" . $pPresence[4][$key]; |
---|
| 223 | if ( empty($pPresence[6][$key]) ) |
---|
| 224 | $return .= "' />"; |
---|
| 225 | else |
---|
| 226 | $return .= "'>" . $pPresence[6][$key] . "</presence>"; |
---|
[41] | 227 | |
---|
[55] | 228 | if ( strpos($pPresence[4][$key], 'subscribe') === false ) |
---|
| 229 | { |
---|
| 230 | $session .= "<presence from='" . $val . "'><show>" . $pPresence[4][$key] . "</show>"; |
---|
| 231 | if ( !empty($pPresence[6][$key]) ) |
---|
| 232 | $session .= "<status>" . $pPresence[6][$key] . "</status>"; |
---|
| 233 | $session .= "</presence>"; |
---|
| 234 | } |
---|
| 235 | } |
---|
[41] | 236 | |
---|
[55] | 237 | $_SESSION['phpgw_info']['instant_messenger']['presences'] = $session; |
---|
[41] | 238 | |
---|
[55] | 239 | return $return; |
---|
| 240 | } |
---|
[41] | 241 | |
---|
[55] | 242 | /* |
---|
| 243 | * GetMessage |
---|
| 244 | */ |
---|
| 245 | |
---|
| 246 | function getMessages(array $pMessages) |
---|
| 247 | { |
---|
| 248 | $_messages = array(); |
---|
| 249 | $return = NULL; |
---|
[41] | 250 | |
---|
[55] | 251 | foreach ( $pMessages[1] as $key => $val ) |
---|
| 252 | { |
---|
| 253 | trim($pMessages[3][$key]); |
---|
| 254 | if ( !empty($pMessages[3][$key]) ) |
---|
| 255 | $_messages[$val][] = $pMessages[3][$key]; |
---|
| 256 | |
---|
| 257 | if ( !empty($pMessages[2][$key]) ) |
---|
| 258 | { |
---|
| 259 | $return .= '<' . $pMessages[2][$key] . ' from="'; |
---|
| 260 | $return .= ( strpos($val, '/') ) ? substr($val, 0, strpos($val, '/')) : $val; |
---|
| 261 | $return .= '" />'; |
---|
| 262 | } |
---|
| 263 | } |
---|
[41] | 264 | |
---|
[55] | 265 | foreach ( $_messages as $key => $val ) |
---|
| 266 | { |
---|
| 267 | $return .= '<messages from="' . $key . '">'; |
---|
| 268 | foreach ( $val as $msg ) |
---|
| 269 | $return .= '<message>' . $msg . '</message>'; |
---|
| 270 | $return .= '</messages>'; |
---|
| 271 | } |
---|
[20] | 272 | |
---|
[55] | 273 | return $return; |
---|
| 274 | } |
---|
[20] | 275 | |
---|
[55] | 276 | /* |
---|
| 277 | * SendMessage |
---|
| 278 | */ |
---|
[41] | 279 | |
---|
[55] | 280 | function SendMessage($pSendMessage) |
---|
| 281 | { |
---|
| 282 | $pSendMessage['body'] = stripslashes($pSendMessage['body']); |
---|
| 283 | $_emotions = '/<img emotion="(\S+)?"[^>]+>/'; |
---|
| 284 | $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions); |
---|
[20] | 285 | |
---|
[55] | 286 | foreach ( $emotions[0] as $key => $val ) |
---|
| 287 | $emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i'; |
---|
[41] | 288 | |
---|
[55] | 289 | $pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']); |
---|
[41] | 290 | |
---|
[55] | 291 | $to = $pSendMessage['to']; |
---|
| 292 | $type = "normal"; |
---|
| 293 | $id = ""; |
---|
| 294 | $content = array( |
---|
| 295 | "subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "", |
---|
| 296 | "thread" => $pSendMessage['thread'] ? $pSendMessage['thread'] : "", |
---|
| 297 | "body" => $pSendMessage['body'] ? $pSendMessage['body'] : "" |
---|
| 298 | ); |
---|
[20] | 299 | |
---|
[55] | 300 | $payload = ""; |
---|
[41] | 301 | |
---|
[55] | 302 | if ($to && is_array($content)) |
---|
| 303 | { |
---|
| 304 | if (!$id) |
---|
| 305 | { |
---|
| 306 | $id = $type . "_" . time(); |
---|
| 307 | } |
---|
[32] | 308 | |
---|
[55] | 309 | $xml = "<message to='$to' type='$type' id='$id'>"; |
---|
[41] | 310 | |
---|
[55] | 311 | if ($content['subject']) |
---|
| 312 | { |
---|
| 313 | $xml .= "<subject>" . $content['subject'] . "</subject>"; |
---|
| 314 | } |
---|
[32] | 315 | |
---|
[55] | 316 | if ($content['thread']) |
---|
| 317 | { |
---|
| 318 | $xml .= "<thread>" . $content['thread'] . "</thread>"; |
---|
| 319 | } |
---|
[41] | 320 | |
---|
[55] | 321 | $xml .= "<html><body>" . $content['body'] . "</body></html>"; |
---|
| 322 | $xml .= $payload; |
---|
| 323 | $xml .= "</message>"; |
---|
| 324 | unset($id); |
---|
[20] | 325 | |
---|
[55] | 326 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['message'] .= $xml; |
---|
| 327 | } |
---|
| 328 | else |
---|
[27] | 329 | { |
---|
[55] | 330 | $this->writeLog("ERROR: SendMessage() #2"); |
---|
| 331 | return FALSE; |
---|
| 332 | } |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | /* |
---|
| 336 | * UpdateContact |
---|
| 337 | */ |
---|
| 338 | |
---|
| 339 | function updateContact($pUser) |
---|
| 340 | { |
---|
| 341 | $jid = $pUser['jid']; |
---|
| 342 | $name = $pUser['name']; |
---|
| 343 | $group = $pUser['group']; |
---|
| 344 | |
---|
| 345 | if ( $jid ) |
---|
| 346 | { |
---|
| 347 | $updatecontact = "<item jid='$jid'"; |
---|
| 348 | $updatecontact .= " name='" . $name . "'"; |
---|
| 349 | $updatecontact .= "><group>" . $group . "</group></item>"; |
---|
| 350 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['updateContact'] = $updatecontact; |
---|
| 351 | } |
---|
| 352 | $this->requireContacts(); |
---|
| 353 | } |
---|
| 354 | |
---|
| 355 | /* |
---|
| 356 | * AddContact |
---|
| 357 | */ |
---|
| 358 | |
---|
| 359 | function addContacts($pUser) |
---|
| 360 | { |
---|
| 361 | $jid = explode("@",$pUser['email']); |
---|
| 362 | $pJid = $jid[0]."@".$_SESSION['phpgw_info']['instant_messenger']['name_jabber']; |
---|
| 363 | $pName = $pUser['name']; |
---|
| 364 | $pGroup = $pUser['group']; |
---|
[27] | 365 | |
---|
[55] | 366 | if(trim($jid[0]) != trim($this->username)) |
---|
| 367 | { |
---|
| 368 | if ( $pJid ) |
---|
| 369 | { |
---|
| 370 | $newcontact = "<item jid='$pJid'"; |
---|
| 371 | $newcontact .= " name='" . $pName . "'"; |
---|
| 372 | $newcontact .= "><group>" . $pGroup . "</group></item>"; |
---|
| 373 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['addContacts'] = $newcontact; |
---|
| 374 | $this->subscribe($pJid); |
---|
| 375 | $this->requireContacts(); |
---|
| 376 | } |
---|
| 377 | } |
---|
| 378 | } |
---|
| 379 | |
---|
| 380 | /* |
---|
| 381 | * RemoveContact |
---|
| 382 | */ |
---|
| 383 | |
---|
| 384 | function removeContact($pUser) |
---|
[20] | 385 | { |
---|
[55] | 386 | $pJid = $pUser['jid']; |
---|
| 387 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['removeContact'] = $pJid; |
---|
| 388 | $this->unsubscribed($pJid); |
---|
| 389 | $this->requireContacts(); |
---|
[20] | 390 | } |
---|
[41] | 391 | |
---|
[55] | 392 | /* |
---|
| 393 | * Vcard |
---|
| 394 | */ |
---|
[41] | 395 | |
---|
[55] | 396 | function newVcard($pVcardUser) |
---|
| 397 | { |
---|
| 398 | $pVcard = explode("_vkrd_", $pVcardUser['vcard']); |
---|
[20] | 399 | |
---|
[55] | 400 | $xmlVcard = "<FN>".$pVcard[0]."</FN>"; |
---|
| 401 | $xmlVcard .= "<NICKNAME>".$pVcard[1]."</NICKNAME>"; |
---|
| 402 | $xmlVcard .= "<ORG>"; |
---|
| 403 | $xmlVcard .= "<ORGNAME>".$pVcard[2]."</ORGNAME>"; |
---|
| 404 | $xmlVcard .= "<ORGUNIT>".$pVcard[3]."</ORGUNIT>"; |
---|
| 405 | $xmlVcard .= "</ORG>"; |
---|
| 406 | $xmlVcard .= "<ROLE>".$pVcard[4]."</ROLE>"; |
---|
| 407 | $xmlVcard .= "<BDAY>".$pVcard[5]."</BDAY>"; |
---|
| 408 | $xmlVcard .= "<DESC>".$pVcard[6]."</DESC>"; |
---|
| 409 | |
---|
| 410 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['newVcard'] = $xmlVcard; |
---|
[20] | 411 | |
---|
[55] | 412 | } |
---|
| 413 | |
---|
| 414 | function getVcard(array $Vcard) |
---|
| 415 | { |
---|
| 416 | $div = ""; |
---|
| 417 | $_expr = "/<[^<vCard xmlns=\'vcard\-temp\'>].*[^<\/vCard>]>/"; |
---|
| 418 | array_shift($Vcard); |
---|
| 419 | $div = '<vcard>'; |
---|
| 420 | $jid_user = $_SESSION['phpgw_info']['instant_messenger']['user']; |
---|
| 421 | $jid_user .= "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; |
---|
| 422 | for($i = 0 ; $i < count($Vcard[0]) ; $i++) |
---|
| 423 | { |
---|
| 424 | preg_match($_expr,$Vcard[1][$i],$div_vcard); |
---|
| 425 | $div_new[] = $div_vcard; |
---|
[20] | 426 | |
---|
[55] | 427 | if ( $jid_user == $Vcard[0][$i] ) |
---|
| 428 | $_SESSION['phpgw_info']['instant_messenger']['vcard'] = $div_new[$i][0]; |
---|
| 429 | |
---|
| 430 | $div .= '<div id="vcard_'.$Vcard[0][$i].'">'.urldecode($div_new[$i][0]).'</div>'; |
---|
| 431 | } |
---|
| 432 | $div .= '</vcard>'; |
---|
| 433 | |
---|
| 434 | return $div; |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | function requireVcard() |
---|
[41] | 438 | { |
---|
[55] | 439 | $contacts = array(); |
---|
| 440 | $contacts = $_SESSION['phpgw_info']['instant_messenger']['contacts']; |
---|
| 441 | $jid_user = $_SESSION['phpgw_info']['instant_messenger']['user']; |
---|
| 442 | $jid_user .= "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; |
---|
| 443 | |
---|
| 444 | if( count($contacts) > 0 ) |
---|
[41] | 445 | { |
---|
[55] | 446 | array_unshift($contacts,$jid_user); |
---|
| 447 | |
---|
| 448 | foreach($contacts as $user) |
---|
| 449 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['vcard'][] = $user; |
---|
| 450 | return "true"; |
---|
| 451 | }else{ |
---|
| 452 | return "false"; |
---|
[41] | 453 | } |
---|
| 454 | } |
---|
[55] | 455 | |
---|
| 456 | function getJid() |
---|
| 457 | { |
---|
| 458 | $jid = $_SESSION['phpgw_info']['instant_messenger']['user'] . "@" . $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; |
---|
| 459 | return $jid; |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | function subscribe($pJid) |
---|
| 463 | { |
---|
| 464 | $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; |
---|
| 465 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Subscribe'] = $jid; |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | function subscribed($pJid) |
---|
| 469 | { |
---|
| 470 | $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; |
---|
| 471 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionAcceptRequest'] = $jid; |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | function unsubscribe($pJid) |
---|
| 475 | { |
---|
| 476 | $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; |
---|
| 477 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['Unsubscribe'] = $jid; |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | function unsubscribed($pJid) |
---|
| 481 | { |
---|
| 482 | $jid = (is_array($pJid)) ? $pJid['jid'] : $pJid ; |
---|
| 483 | $_SESSION['phpgw_info']['instant_messenger']['socket']['out']['SubscriptionDenyRequest'] = $jid; |
---|
| 484 | } |
---|
[20] | 485 | } |
---|
| 486 | ?> |
---|