]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/time.cpp
Always deny invite to users below halfop status, move OnUserPreInvite up to above...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / time.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "wildcard.h"
19 #include "xline.h"
20 #include "transport.h"
21 #include "socketengine.h"
22
23 #include "m_spanningtree/main.h"
24 #include "m_spanningtree/utils.h"
25 #include "m_spanningtree/treeserver.h"
26 #include "m_spanningtree/treesocket.h"
27
28 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
29
30 bool TreeSocket::Time(const std::string &prefix, std::deque<std::string> &params)
31 {
32         // :source.server TIME remote.server sendernick
33         // :remote.server TIME source.server sendernick TS
34         if (params.size() == 2)
35         {
36                 // someone querying our time?
37                 if (this->Instance->Config->ServerName == params[0] || this->Instance->Config->GetSID() == params[0])
38                 {
39                         User* u = this->Instance->FindNick(params[1]);
40                         if (u)
41                         {
42                                 params.push_back(ConvToStr(Instance->Time()));
43                                 params[0] = prefix;
44                                 Utils->DoOneToOne(this->Instance->Config->GetSID(),"TIME",params,params[0]);
45                         }
46                 }
47                 else
48                 {
49                         // not us, pass it on
50                         User* u = this->Instance->FindNick(params[1]);
51                         if (u)
52                                 Utils->DoOneToOne(prefix,"TIME",params,params[0]);
53                 }
54         }
55         else if (params.size() == 3)
56         {
57                 // a response to a previous TIME
58                 User* u = this->Instance->FindNick(params[1]);
59                 if ((u) && (IS_LOCAL(u)))
60                 {
61                         time_t rawtime = atol(params[2].c_str());
62                         struct tm * timeinfo;
63                         timeinfo = localtime(&rawtime);
64                         char tms[26];
65                         snprintf(tms,26,"%s",asctime(timeinfo));
66                         tms[24] = 0;
67                         u->WriteNumeric(RPL_TIME, "%s %s :%s",u->nick.c_str(),prefix.c_str(),tms);
68                 }
69                 else
70                 {
71                         if (u)
72                                 Utils->DoOneToOne(prefix,"TIME",params,u->server);
73                 }
74         }
75         return true;
76 }
77