function add_nick($nick, $ident = '', $host = '', $realname = '', $jid = '') { global $xmppparams; $this->nicks[$nick] = array(); $this->nicks[$nick]['jid'] = $jid; $this->nicks[$nick]['modes'] = array(); if ($jid) { $this->nicks[$nick]['ident'] = $xmppparams['ident']; $this->nicks[$nick]['realname'] = 'Jabber User ' . $nick; $this->nicks[$nick]['host'] = str_replace('@', '.', xmpp_bare_jid($jid)); } else { $this->nicks[$nick]['ident'] = $ident; $this->nicks[$nick]['host'] = $host; $this->nicks[$nick]['realname'] = $realname; } }
function createError($type, $tag, $add_x = false, $add_query = false) { $errtag = new CXMLTag($this->name, array('from' => xmpp_bare_jid($this->attribs['to']), 'to' => $this->attribs['from'], 'type' => 'error')); if ($this->name == 'iq') { $errtag->attribs['id'] = $this->attribs['id']; } if ($add_x) { $errtag->subtags[] = new CXMLTag('x', array('xmlns' => FEAT_MUC)); } if ($add_query && !($errtag->subtags[] = $this->firstSubtag('query'))) { return false; } $subtag = new CXMLTag('error', array('type' => $type)); $subtag->subtags[] = new CXMLTag($tag, array('xmlns' => XMLNS_ERR)); $errtag->subtags[] = $subtag; return $errtag; }
function xmpp_presence_to_all($nick, $room, $forcenick = '', $type = '', $options = array()) { global $ircdata, $xmppparams; $result = ''; // if ($nick) { if (!($jid = to_utf($ircdata->nicks[from_utf($nick)]['jid']))) { $jid = $nick . '@' . $xmppparams['componentname'] . '/irc'; } // } else $jid = $forcenick; xmpp_normalize_room($room); $addstatus = array(); $newobj = new CXMLTag('presence', array('from' => $room . '@' . $xmppparams['componentname'] . ($nick ? '/' . $nick : ''))); if ($type) { $newobj->attribs['type'] = $type; } $xtag = new CXMLTag('x', array('xmlns' => FEAT_MUC . '#user')); $affiliation = 'none'; switch ($type) { case 'unavailable': $role = 'none'; break; case 'newmode': $role = xmpp_get_role($nick, $room); unset($newobj->attribs['type']); break; case 'newnick': $newobj->attribs['type'] = 'unavailable'; $addstatus[] = '303'; $role = xmpp_get_role($nick, $room); break; case 'role': $role = $options['role']; unset($newobj->attribs['type']); break; case 'kick': $newobj->attribs['type'] = 'unavailable'; $addstatus[] = '307'; $role = 'none'; $actorjid = xmpp_bare_jid(to_utf($ircdata->nicks[from_utf($options['actor'])]['jid'])); if (!$actorjid) { $actorjid = $options['actor'] . '@' . $xmppparams['componentname']; } break; case 'ban': $newobj->attribs['type'] = 'unavailable'; $addstatus[] = '301'; $role = 'none'; $affiliation = 'outcast'; $actorjid = xmpp_bare_jid(to_utf($ircdata->nicks[from_utf($options['actor'])]['jid'])); if (!$actorjid) { $actorjid = $options['actor'] . '@' . $xmppparams['componentname']; } break; default: $role = xmpp_get_role($nick, $room); if ($forcenick) { $newobj->attribs['from'] = $room . '@' . $xmppparams['componentname'] . '/' . $forcenick; } } foreach ($ircdata->channels[from_utf($room)]['nicks'] as $ircnick => $data) { // Skip non-jabber users if (!$ircdata->nicks[$ircnick]['jid']) { continue; } $newobj->attribs['to'] = to_utf($ircdata->nicks[$ircnick]['jid']); $itemtag = new CXMLTag('item', array('affiliation' => $affiliation, 'jid' => $jid, 'role' => $role)); if ($type == 'newnick') { $itemtag->attribs['nick'] = $forcenick; } // if (($type != 'ban') && isset($options['reason'])) $itemtag->subtags[] = new CXMLTag('reason',array(),$options['reason']); // if (($type != 'ban') && isset($options['actor'])) $itemtag->subtags[] = new CXMLTag('actor',array('jid'=>$actorjid)); $xtag->subtags = array($itemtag); if (xmpp_compare_jid($jid, $newobj->attribs['to'])) { $xtag->subtags[] = new CXMLTag('status', array('code' => '110')); if (!$type) { $xtag->subtags[] = new CXMLTag('status', array('code' => '100')); } if ($forcenick && !$type) { $xtag->subtags[] = new CXMLTag('status', array('code' => '210')); } // if (in_array('307',$addstatus) && // if (($type = 'ban') && isset($options['reason'])) $itemtag->subtags[] = new CXMLTag('reason',array(),$options['reason']); // if (($type = 'ban') && isset($options['actor'])) $itemtag->subtags[] = new CXMLTag('actor',array('jid'=>$actorjid)); } if (isset($options['reason'])) { $itemtag->subtags[] = new CXMLTag('reason', array(), $options['reason']); } if (isset($options['actor'])) { $itemtag->subtags[] = new CXMLTag('actor', array('jid' => $actorjid)); } foreach ($addstatus as $status) { $xtag->subtags[] = new CXMLTag('status', array('code' => $status)); } $newobj->subtags = array($xtag); if (isset($options['status'])) { $newobj->subtags[] = new CXMLTag('status', array(), $options['status']); } $result .= $newobj->toString(); //."\n\n"; } return $result; }