/* +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * * InspIRCd: (C) 2002-2009 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ #include "inspircd.h" #include "socket.h" #include "xline.h" #include "../transport.h" #include "socketengine.h" #include "main.h" #include "utils.h" #include "treeserver.h" #include "treesocket.h" /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ bool TreeSocket::Time(const std::string &prefix, parameterlist ¶ms) { // :source.server TIME remote.server sendernick // :remote.server TIME source.server sendernick TS if (params.size() == 2) { // someone querying our time? if (this->ServerInstance->Config->ServerName == params[0] || this->ServerInstance->Config->GetSID() == params[0]) { User* u = this->ServerInstance->FindNick(params[1]); if (u) { params.push_back(ConvToStr(ServerInstance->Time())); params[0] = prefix; Utils->DoOneToOne(this->ServerInstance->Config->GetSID(),"TIME",params,params[0]); } } else { // not us, pass it on User* u = this->ServerInstance->FindNick(params[1]); if (u) Utils->DoOneToOne(prefix,"TIME",params,params[0]); } } else if (params.size() == 3) { // a response to a previous TIME User* u = this->ServerInstance->FindNick(params[1]); if ((u) && (IS_LOCAL(u))) { std::string sourceserv = Utils->FindServer(prefix)->GetName(); time_t rawtime = atol(params[2].c_str()); struct tm * timeinfo; timeinfo = localtime(&rawtime); char tms[26]; snprintf(tms,26,"%s",asctime(timeinfo)); tms[24] = 0; u->WriteNumeric(RPL_TIME, "%s %s :%s",u->nick.c_str(),sourceserv.c_str(),tms); } else { if (u) Utils->DoOneToOne(prefix,"TIME",params,u->server); } } return true; }