1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
15 #include "configreader.h"
20 #include "command_parse.h"
22 bool InspIRCd::ULine(const char* server)
29 return (find(Config->ulines.begin(),Config->ulines.end(),server) != Config->ulines.end());
32 int InspIRCd::OperPassCompare(const char* data,const char* input, int tagnum)
35 FOREACH_RESULT_I(this,I_OnOperCompare,OnOperCompare(data, input, tagnum))
40 return strcmp(data,input);
43 long InspIRCd::Duration(const char* str)
49 if ((!strchr(str,'s')) && (!strchr(str,'m')) && (!strchr(str,'h')) && (!strchr(str,'d')) && (!strchr(str,'w')) && (!strchr(str,'y')))
53 return Duration(n.c_str());
56 for (char* i = (char*)str; *i; i++)
58 // if we have digits, build up a string for the value in n_field,
59 // up to 10 digits in size.
60 if ((*i >= '0') && (*i <= '9'))
62 strlcat(n_field,i,10);
66 // we dont have a digit, check for numeric tokens
70 total += atoi(n_field);
74 total += (atoi(n_field)*duration_m);
78 total += (atoi(n_field)*duration_h);
82 total += (atoi(n_field)*duration_d);
86 total += (atoi(n_field)*duration_w);
90 total += (atoi(n_field)*duration_y);
96 // add trailing seconds
97 total += atoi(n_field);
102 /* All other ircds when doing this check usually just look for a string of *@* or *. We're smarter than that, though. */
104 bool InspIRCd::HostMatchesEveryone(const std::string &mask, userrec* user)
106 char itrigger[MAXBUF];
109 if (!Config->ConfValue(Config->config_data, "insane","trigger", 0, itrigger, MAXBUF))
110 strlcpy(itrigger,"95.5",MAXBUF);
112 if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0))
115 for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++)
117 if ((match(u->second->MakeHost(),mask.c_str(),true)) || (match(u->second->MakeHostIP(),mask.c_str(),true)))
126 float percent = ((float)matches / (float)clientlist->size()) * 100;
127 if (percent > (float)atof(itrigger))
129 WriteOpers("*** \2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent);
135 bool InspIRCd::IPMatchesEveryone(const std::string &ip, userrec* user)
137 char itrigger[MAXBUF];
140 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
141 strlcpy(itrigger,"95.5",MAXBUF);
143 if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0))
146 for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++)
148 if (match(u->second->GetIPString(),ip.c_str(),true))
155 float percent = ((float)matches / (float)clientlist->size()) * 100;
156 if (percent > (float)atof(itrigger))
158 WriteOpers("*** \2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
164 bool InspIRCd::NickMatchesEveryone(const std::string &nick, userrec* user)
166 char itrigger[MAXBUF];
169 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
170 strlcpy(itrigger,"95.5",MAXBUF);
172 if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0))
175 for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++)
177 if (match(u->second->nick,nick.c_str()))
184 float percent = ((float)matches / (float)clientlist->size()) * 100;
185 if (percent > (float)atof(itrigger))
187 WriteOpers("*** \2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);