bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) override { if (sPageName == "index") { CModules& GModules = CZNC::Get().GetModules(); Tmpl["WebAdminLoaded"] = CString(GModules.FindModule("webadmin") != nullptr); MTimeMulti mmSorted; const MUsers& mUsers = CZNC::Get().GetUserMap(); for (MUsers::const_iterator uit = mUsers.begin(); uit != mUsers.end(); ++uit) { mmSorted.insert(pair<time_t, CUser*>(GetTime(uit->second), uit->second)); } for (MTimeMulti::const_iterator it = mmSorted.begin(); it != mmSorted.end(); ++it) { CUser *pUser = it->second; CTemplate& Row = Tmpl.AddRow("UserLoop"); Row["Username"] = pUser->GetUserName(); Row["IsSelf"] = CString(pUser == WebSock.GetSession()->GetUser()); Row["LastSeen"] = FormatLastSeen(pUser, "never"); } return true; } return false; }
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { if (sPageName == "index") { CModules& GModules = CZNC::Get().GetModules(); Tmpl["WebAdminLoaded"] = CString(GModules.FindModule("webadmin") != NULL); MTimeMulti mmSorted; const MUsers& mUsers = CZNC::Get().GetUserMap(); for (MUsers::const_iterator uit = mUsers.begin(); uit != mUsers.end(); ++uit) { mmSorted.insert(pair<time_t, CUser*>(GetTime(uit->second), uit->second)); } for (MTimeMulti::const_iterator it = mmSorted.begin(); it != mmSorted.end(); ++it) { CUser *pUser = it->second; CTemplate& Row = Tmpl.AddRow("UserLoop"); Row["Username"] = pUser->GetUserName(); Row["IsSelf"] = CString(pUser == WebSock.GetSession()->GetUser()); Row["LastSeen"] = FormatLastSeen(pUser, "never"); Row["Info"] = CString(pUser->GetClients().size()) + " client" + CString(pUser->GetClients().size() == 1 ? "" : "s"); if (!pUser->IsIRCConnected()) { Row["Info"] += ", not connected to IRC"; } else { unsigned int uChans = 0; const vector<CChan*>& vChans = pUser->GetChans(); for (unsigned int a = 0; a < vChans.size(); ++a) { if (vChans[a]->IsOn()) ++uChans; } unsigned int n = uChans; Row["Info"] += ", joined to " + CString(uChans); if(uChans != vChans.size()) { Row["Info"] += " out of " + CString(vChans.size()) + " configured"; n = vChans.size(); } Row["Info"] += " channel" + CString(n == 1 ? "" : "s"); } } return true; } return false; }