m_check.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "inspircd.h"
00015
00016
00017
00020 class CommandCheck : public Command
00021 {
00022 public:
00023 CommandCheck (InspIRCd* Instance) : Command(Instance,"CHECK", "o", 1)
00024 {
00025 this->source = "m_check.so";
00026 syntax = "<nickname>|<ip>|<hostmask>|<channel>";
00027 }
00028
00029 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
00030 {
00031 User *targuser;
00032 Channel *targchan;
00033 std::string checkstr;
00034 std::string chliststr;
00035
00036 char timebuf[60];
00037 struct tm *mytime;
00038
00039
00040 checkstr = "304 " + std::string(user->nick) + " :CHECK";
00041
00042 targuser = ServerInstance->FindNick(parameters[0]);
00043 targchan = ServerInstance->FindChan(parameters[0]);
00044
00045
00046
00047
00048
00049
00050
00051
00052 user->WriteServ(checkstr + " START " + parameters[0]);
00053
00054 if (targuser)
00055 {
00056
00057 user->WriteServ(checkstr + " nuh " + targuser->GetFullHost());
00058 user->WriteServ(checkstr + " realnuh " + targuser->GetFullRealHost());
00059 user->WriteServ(checkstr + " realname " + targuser->fullname);
00060 user->WriteServ(checkstr + " modes +" + targuser->FormatModes());
00061 user->WriteServ(checkstr + " snomasks +" + targuser->FormatNoticeMasks());
00062 user->WriteServ(checkstr + " server " + targuser->server);
00063
00064 if (IS_AWAY(targuser))
00065 {
00066
00067 user->WriteServ(checkstr + " awaymsg " + targuser->awaymsg);
00068 }
00069
00070 if (IS_OPER(targuser))
00071 {
00072
00073 user->WriteServ(checkstr + " opertype " + irc::Spacify(targuser->oper.c_str()));
00074 }
00075
00076 if (IS_LOCAL(targuser))
00077 {
00078
00079 user->WriteServ(checkstr + " onport " + ConvToStr(targuser->GetPort()));
00080 }
00081
00082 chliststr = targuser->ChannelList(targuser);
00083 std::stringstream dump(chliststr);
00084
00085 ServerInstance->DumpText(user,checkstr + " onchans ", dump);
00086 }
00087 else if (targchan)
00088 {
00089
00090 time_t creation_time = targchan->created;
00091 time_t topic_time = targchan->topicset;
00092
00093 mytime = gmtime(&creation_time);
00094 strftime(timebuf, 59, "%Y/%m/%d - %H:%M:%S", mytime);
00095 user->WriteServ(checkstr + " created " + timebuf);
00096
00097 if (targchan->topic[0] != 0)
00098 {
00099
00100 user->WriteServ(checkstr + " topic " + targchan->topic);
00101 user->WriteServ(checkstr + " topic_setby " + targchan->setby);
00102 mytime = gmtime(&topic_time);
00103 strftime(timebuf, 59, "%Y/%m/%d - %H:%M:%S", mytime);
00104 user->WriteServ(checkstr + " topic_setat " + timebuf);
00105 }
00106
00107 user->WriteServ(checkstr + " modes " + targchan->ChanModes(true));
00108 user->WriteServ(checkstr + " membercount " + ConvToStr(targchan->GetUserCounter()));
00109
00110
00111
00112 CUList *ulist= targchan->GetUsers();
00113
00114
00115 for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
00116 {
00117 char tmpbuf[MAXBUF];
00118
00119
00120
00121 snprintf(tmpbuf, MAXBUF, "%lu %s%s (%s@%s) %s ", ServerInstance->Users->GlobalCloneCount(i->first), targchan->GetAllPrefixChars(i->first), i->first->nick.c_str(), i->first->ident.c_str(), i->first->dhost.c_str(), i->first->fullname.c_str());
00122 user->WriteServ(checkstr + " member " + tmpbuf);
00123 }
00124 }
00125 else
00126 {
00127
00128 long x = 0;
00129
00130
00131 for (user_hash::const_iterator a = ServerInstance->Users->clientlist->begin(); a != ServerInstance->Users->clientlist->end(); a++)
00132 {
00133 if (InspIRCd::Match(a->second->host, parameters[0]) || InspIRCd::Match(a->second->dhost, parameters[0]))
00134 {
00135
00136 user->WriteServ(checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost());
00137 }
00138
00139 else if (InspIRCd::MatchCIDR(a->second->GetIPString(), parameters[0]))
00140 {
00141
00142 user->WriteServ(checkstr + " match " + ConvToStr(++x) + " " + a->second->GetFullRealHost());
00143 }
00144 }
00145
00146 user->WriteServ(checkstr + " matches " + ConvToStr(x));
00147 }
00148
00149 user->WriteServ(checkstr + " END " + parameters[0]);
00150
00151 return CMD_LOCALONLY;
00152 }
00153 };
00154
00155
00156 class ModuleCheck : public Module
00157 {
00158 private:
00159 CommandCheck *mycommand;
00160 public:
00161 ModuleCheck(InspIRCd* Me) : Module(Me)
00162 {
00163
00164 mycommand = new CommandCheck(ServerInstance);
00165 ServerInstance->AddCommand(mycommand);
00166
00167 }
00168
00169 virtual ~ModuleCheck()
00170 {
00171 }
00172
00173 virtual Version GetVersion()
00174 {
00175 return Version("$Id: m_check.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_VENDOR, API_VERSION);
00176 }
00177
00178
00179 };
00180
00181 MODULE_INIT(ModuleCheck)