+ data << "<isupport>";
+ const std::vector<Numeric::Numeric>& isupport = ServerInstance->ISupport.GetLines();
+ for (std::vector<Numeric::Numeric>::const_iterator i = isupport.begin(); i != isupport.end(); ++i)
+ {
+ const Numeric::Numeric& num = *i;
+ for (std::vector<std::string>::const_iterator j = num.GetParams().begin(); j != num.GetParams().end()-1; ++j)
+ data << "<token>" << Sanitize(*j) << "</token>" << std::endl;
+ }
+ data << "</isupport></general><xlines>";
+ std::vector<std::string> xltypes = ServerInstance->XLines->GetAllTypes();
+ for (std::vector<std::string>::iterator it = xltypes.begin(); it != xltypes.end(); ++it)
+ {
+ XLineLookup* lookup = ServerInstance->XLines->GetAll(*it);
+
+ if (!lookup)
+ continue;
+ for (LookupIter i = lookup->begin(); i != lookup->end(); ++i)
+ {
+ data << "<xline type=\"" << it->c_str() << "\"><mask>"
+ << Sanitize(i->second->Displayable()) << "</mask><settime>"
+ << i->second->set_time << "</settime><duration>" << i->second->duration
+ << "</duration><reason>" << Sanitize(i->second->reason)
+ << "</reason></xline>";
+ }
+ }
+
+ data << "</xlines><modulelist>";
+ const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
+
+ for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
+ {
+ Version v = i->second->GetVersion();
+ data << "<module><name>" << i->first << "</name><description>" << Sanitize(v.description) << "</description></module>";
+ }
+ data << "</modulelist><channellist>";
+
+ const chan_hash& chans = ServerInstance->GetChans();
+ for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
+ {
+ Channel* c = i->second;
+
+ data << "<channel>";
+ data << "<usercount>" << c->GetUsers().size() << "</usercount><channelname>" << Sanitize(c->name) << "</channelname>";
+ data << "<channeltopic>";
+ data << "<topictext>" << Sanitize(c->topic) << "</topictext>";
+ data << "<setby>" << Sanitize(c->setby) << "</setby>";
+ data << "<settime>" << c->topicset << "</settime>";
+ data << "</channeltopic>";
+ data << "<channelmodes>" << Sanitize(c->ChanModes(true)) << "</channelmodes>";
+
+ const Channel::MemberMap& ulist = c->GetUsers();
+ for (Channel::MemberMap::const_iterator x = ulist.begin(); x != ulist.end(); ++x)
+ {
+ Membership* memb = x->second;
+ data << "<channelmember><uid>" << memb->user->uuid << "</uid><privs>"
+ << Sanitize(memb->GetAllPrefixChars()) << "</privs><modes>"
+ << memb->modes << "</modes>";
+ DumpMeta(data, memb);
+ data << "</channelmember>";
+ }
+
+ DumpMeta(data, c);
+
+ data << "</channel>";
+ }
+
+ data << "</channellist><userlist>";
+
+ const user_hash& users = ServerInstance->Users->GetUsers();
+ for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i)
+ {
+ User* u = i->second;
+
+ data << "<user>";
+ data << "<nickname>" << u->nick << "</nickname><uuid>" << u->uuid << "</uuid><realhost>"
+ << u->host << "</realhost><displayhost>" << u->dhost << "</displayhost><gecos>"
+ << Sanitize(u->fullname) << "</gecos><server>" << u->server->GetName() << "</server>";
+ if (u->IsAway())
+ data << "<away>" << Sanitize(u->awaymsg) << "</away><awaytime>" << u->awaytime << "</awaytime>";
+ if (u->IsOper())
+ data << "<opertype>" << Sanitize(u->oper->name) << "</opertype>";
+ data << "<modes>" << u->FormatModes() << "</modes><ident>" << Sanitize(u->ident) << "</ident>";
+ LocalUser* lu = IS_LOCAL(u);
+ if (lu)
+ data << "<port>" << lu->GetServerPort() << "</port><servaddr>"
+ << lu->server_sa.str() << "</servaddr>";
+ data << "<ipaddress>" << u->GetIPString() << "</ipaddress>";
+
+ DumpMeta(data, u);
+
+ data << "</user>";
+ }
+
+ data << "</userlist><serverlist>";
+
+ ProtocolInterface::ServerList sl;
+ ServerInstance->PI->GetServerList(sl);
+
+ for (ProtocolInterface::ServerList::const_iterator b = sl.begin(); b != sl.end(); ++b)
+ {
+ data << "<server>";
+ data << "<servername>" << b->servername << "</servername>";
+ data << "<parentname>" << b->parentname << "</parentname>";
+ data << "<gecos>" << b->gecos << "</gecos>";
+ data << "<usercount>" << b->usercount << "</usercount>";
+// This is currently not implemented, so, commented out.
+// data << "<opercount>" << b->opercount << "</opercount>";
+ data << "<lagmillisecs>" << b->latencyms << "</lagmillisecs>";
+ data << "</server>";
+ }
+
+ data << "</serverlist><commandlist>";
+
+ const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands();
+ for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i)
+ {
+ data << "<command><name>" << i->second->name << "</name><usecount>" << i->second->use_count << "</usecount></command>";
+ }
+
+ data << "</commandlist></inspircdstats>";
+
+ /* Send the document back to m_httpd */
+ HTTPDocumentResponse response(this, *http, &data, 200);
+ response.headers.SetHeader("X-Powered-By", MODNAME);
+ response.headers.SetHeader("Content-Type", "text/xml");
+ API->SendResponse(response);
+ return MOD_RES_DENY; // Handled
+ }
+ }
+ return MOD_RES_PASSTHRU;