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)
107 char itrigger[MAXBUF];
110 if (!Config->ConfValue(Config->config_data, "insane","trigger", 0, itrigger, MAXBUF))
111 strlcpy(itrigger,"95.5",MAXBUF);
113 if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0))
116 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
118 strlcpy(buffer,u->second->ident,MAXBUF);
119 charlcat(buffer,'@',MAXBUF);
120 strlcat(buffer,u->second->host,MAXBUF);
121 if (match(buffer,mask.c_str()))
124 float percent = ((float)matches / (float)clientlist.size()) * 100;
125 if (percent > (float)atof(itrigger))
127 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);
133 bool InspIRCd::IPMatchesEveryone(const std::string &ip, userrec* user)
135 char itrigger[MAXBUF];
138 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
139 strlcpy(itrigger,"95.5",MAXBUF);
141 if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0))
144 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
146 if (match(u->second->GetIPString(),ip.c_str(),true))
150 float percent = ((float)matches / (float)clientlist.size()) * 100;
151 if (percent > (float)atof(itrigger))
153 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);
159 bool InspIRCd::NickMatchesEveryone(const std::string &nick, userrec* user)
161 char itrigger[MAXBUF];
164 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
165 strlcpy(itrigger,"95.5",MAXBUF);
167 if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0))
170 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
172 if (match(u->second->nick,nick.c_str()))
176 float percent = ((float)matches / (float)clientlist.size()) * 100;
177 if (percent > (float)atof(itrigger))
179 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);