]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/xline.cpp
REMOTE STATS! WOOO AND YAY!
[user/henk/code/inspircd.git] / src / xline.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include "inspircd_config.h"
20 #include "inspircd.h"
21 #include <string>
22 #include <map>
23 #include <sstream>
24 #include <vector>
25 #include <deque>
26 #include "users.h"
27 #include "ctables.h"
28 #include "globals.h"
29 #include "modules.h"
30 #include "dynamic.h"
31 #include "wildcard.h"
32 #include "message.h"
33 #include "commands.h"
34 #include "xline.h"
35 #include "inspstring.h"
36 #include "helperfuncs.h"
37 #include "hashcomp.h"
38 #include "typedefs.h"
39 #include "configreader.h"
40 #include "cull_list.h"
41
42 extern ServerConfig *Config;
43
44 extern int MODCOUNT;
45 extern std::vector<Module*> modules;
46 extern std::vector<ircd_module*> factory;
47 extern ServerConfig* Config;
48 extern user_hash clientlist;
49 extern std::vector<userrec*> local_users;
50
51 /* Version two, now with optimized expiry!
52  *
53  * Because the old way was horrendously slow, the new way of expiring xlines is very
54  * very efficient. I have improved the efficiency of the algorithm in two ways:
55  *
56  * (1) There are now two lists of items for each linetype. One list holds temporary
57  *     items, and the other list holds permanent items (ones which will expire).
58  *     Items which are on the permanent list are NEVER checked at all by the
59  *     expire_lines() function.
60  * (2) The temporary xline lists are always kept in strict numerical order, keyed by 
61  *     current time + duration. This means that the line which is due to expire the
62  *     soonest is always pointed at by vector::begin(), so a simple while loop can
63  *     very efficiently, very quickly and above all SAFELY pick off the first few
64  *     items in the vector which need zapping.
65  *
66  *     -- Brain
67  */
68
69
70
71 extern time_t TIME;
72
73 /* Lists for temporary lines with an expiry time */
74
75 std::vector<KLine> klines;
76 std::vector<GLine> glines;
77 std::vector<ZLine> zlines;
78 std::vector<QLine> qlines;
79 std::vector<ELine> elines;
80
81 /* Seperate lists for perm XLines that isnt checked by expiry functions */
82
83 std::vector<KLine> pklines;
84 std::vector<GLine> pglines;
85 std::vector<ZLine> pzlines;
86 std::vector<QLine> pqlines;
87 std::vector<ELine> pelines;
88
89
90 bool GSortComparison ( const GLine one, const GLine two );
91 bool ZSortComparison ( const ZLine one, const ZLine two );
92 bool ESortComparison ( const ELine one, const ELine two );
93 bool QSortComparison ( const QLine one, const QLine two );
94 bool KSortComparison ( const KLine one, const KLine two );
95
96 // Reads the default bans from the config file.
97 // only a very small number of bans are defined
98 // this way these days, such as qlines against 
99 // services nicks, etc.
100
101 bool InitXLine(const char* tag)
102 {
103         return true;
104 }
105
106 bool DoneXLine(const char* tag)
107 {
108         apply_lines(APPLY_ALL);
109         return true;
110 }
111
112 bool DoZLine(const char* tag, char** entries, void** values, int* types)
113 {
114         char* reason = (char*)values[0];
115         char* ipmask = (char*)values[1];
116         
117         add_zline(0,"<Config>",reason,ipmask);
118         log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason);
119         return true;
120 }
121
122 bool DoQLine(const char* tag, char** entries, void** values, int* types)
123 {
124         char* reason = (char*)values[0];
125         char* nick = (char*)values[1];
126         
127         add_qline(0,"<Config>",reason,nick);
128         log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason);
129         return true;
130 }
131
132 bool DoKLine(const char* tag, char** entries, void** values, int* types)
133 {
134         char* reason = (char*)values[0];
135         char* host = (char*)values[1];
136         
137         add_kline(0,"<Config>",reason,host);
138         log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason);
139         return true;
140 }
141
142 bool DoELine(const char* tag, char** entries, void** values, int* types)
143 {
144         char* reason = (char*)values[0];
145         char* host = (char*)values[1];
146         
147         add_eline(0,"<Config>",reason,host);
148         log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason);
149         return true;
150 }
151
152 // adds a g:line
153
154 bool add_gline(long duration, const char* source,const char* reason,const char* hostmask)
155 {
156         bool ret = del_gline(hostmask);
157         
158         GLine item;
159         item.duration = duration;
160         strlcpy(item.hostmask,hostmask,199);
161         strlcpy(item.reason,reason,MAXBUF);
162         strlcpy(item.source,source,255);
163         item.n_matches = 0;
164         item.set_time = TIME;
165         
166         if (duration)
167         {
168                 glines.push_back(item);
169                 sort(glines.begin(), glines.end(),GSortComparison);
170         }
171         else
172         {
173                 pglines.push_back(item);
174         }
175         
176         return !ret;
177 }
178
179 // adds an e:line (exception to bans)
180
181 bool add_eline(long duration, const char* source, const char* reason, const char* hostmask)
182 {
183         bool ret = del_eline(hostmask);
184         ELine item;
185         item.duration = duration;
186         strlcpy(item.hostmask,hostmask,199);
187         strlcpy(item.reason,reason,MAXBUF);
188         strlcpy(item.source,source,255);
189         item.n_matches = 0;
190         item.set_time = TIME;
191         if (duration)
192         {
193                 elines.push_back(item);
194                 sort(elines.begin(), elines.end(),ESortComparison);
195         }
196         else
197         {
198                 pelines.push_back(item);
199         }
200         return !ret;
201 }
202
203 // adds a q:line
204
205 bool add_qline(long duration, const char* source, const char* reason, const char* nickname)
206 {
207         bool ret = del_qline(nickname);
208         QLine item;
209         item.duration = duration;
210         strlcpy(item.nick,nickname,63);
211         strlcpy(item.reason,reason,MAXBUF);
212         strlcpy(item.source,source,255);
213         item.n_matches = 0;
214         item.is_global = false;
215         item.set_time = TIME;
216         if (duration)
217         {
218                 qlines.push_back(item);
219                 sort(qlines.begin(), qlines.end(),QSortComparison);
220         }
221         else
222         {
223                 pqlines.push_back(item);
224         }
225         return !ret;
226 }
227
228 // adds a z:line
229
230 bool add_zline(long duration, const char* source, const char* reason, const char* ipaddr)
231 {
232         bool ret = del_zline(ipaddr);
233         ZLine item;
234         item.duration = duration;
235         if (strchr(ipaddr,'@'))
236         {
237                 while (*ipaddr != '@')
238                         ipaddr++;
239                 ipaddr++;
240         }
241         strlcpy(item.ipaddr,ipaddr,39);
242         strlcpy(item.reason,reason,MAXBUF);
243         strlcpy(item.source,source,255);
244         item.n_matches = 0;
245         item.is_global = false;
246         item.set_time = TIME;
247         if (duration)
248         {
249                 zlines.push_back(item);
250                 sort(zlines.begin(), zlines.end(),ZSortComparison);
251         }
252         else
253         {
254                 pzlines.push_back(item);
255         }
256         return !ret;
257 }
258
259 // adds a k:line
260
261 bool add_kline(long duration, const char* source, const char* reason, const char* hostmask)
262 {
263         bool ret = del_kline(hostmask);
264         KLine item;
265         item.duration = duration;
266         strlcpy(item.hostmask,hostmask,200);
267         strlcpy(item.reason,reason,MAXBUF);
268         strlcpy(item.source,source,255);
269         item.n_matches = 0;
270         item.set_time = TIME;
271         if (duration)
272         {
273                 klines.push_back(item);
274                 sort(klines.begin(), klines.end(),KSortComparison);
275         }
276         else
277         {
278                 pklines.push_back(item);
279         }
280         return !ret;
281 }
282
283 // deletes a g:line, returns true if the line existed and was removed
284
285 bool del_gline(const char* hostmask)
286 {
287         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
288         {
289                 if (!strcasecmp(hostmask,i->hostmask))
290                 {
291                         glines.erase(i);
292                         return true;
293                 }
294         }
295         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
296         {
297                 if (!strcasecmp(hostmask,i->hostmask))
298                 {
299                         pglines.erase(i);
300                         return true;
301                 }
302         }
303         return false;
304 }
305
306 // deletes a e:line, returns true if the line existed and was removed
307
308 bool del_eline(const char* hostmask)
309 {
310         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
311         {
312                 if (!strcasecmp(hostmask,i->hostmask))
313                 {
314                         elines.erase(i);
315                         return true;
316                 }
317         }
318         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
319         {
320                 if (!strcasecmp(hostmask,i->hostmask))
321                 {
322                         pelines.erase(i);
323                         return true;
324                 }
325         }
326         return false;
327 }
328
329 // deletes a q:line, returns true if the line existed and was removed
330
331 bool del_qline(const char* nickname)
332 {
333         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
334         {
335                 if (!strcasecmp(nickname,i->nick))
336                 {
337                         qlines.erase(i);
338                         return true;
339                 }
340         }
341         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
342         {
343                 if (!strcasecmp(nickname,i->nick))
344                 {
345                         pqlines.erase(i);
346                         return true;
347                 }
348         }
349         return false;
350 }
351
352 bool qline_make_global(const char* nickname)
353 {
354         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
355         {
356                 if (!strcasecmp(nickname,i->nick))
357                 {
358                         i->is_global = true;
359                         return true;
360                 }
361         }
362         return false;
363 }
364
365 bool zline_make_global(const char* ipaddr)
366 {
367         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
368         {
369                 if (!strcasecmp(ipaddr,i->ipaddr))
370                 {
371                         i->is_global = true;
372                         return true;
373                 }
374         }
375         return false;
376 }
377
378 // deletes a z:line, returns true if the line existed and was removed
379
380 bool del_zline(const char* ipaddr)
381 {
382         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
383         {
384                 if (!strcasecmp(ipaddr,i->ipaddr))
385                 {
386                         zlines.erase(i);
387                         return true;
388                 }
389         }
390         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
391         {
392                 if (!strcasecmp(ipaddr,i->ipaddr))
393                 {
394                         pzlines.erase(i);
395                         return true;
396                 }
397         }
398         return false;
399 }
400
401 // deletes a k:line, returns true if the line existed and was removed
402
403 bool del_kline(const char* hostmask)
404 {
405         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
406         {
407                 if (!strcasecmp(hostmask,i->hostmask))
408                 {
409                         klines.erase(i);
410                         return true;
411                 }
412         }
413         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
414         {
415                 if (!strcasecmp(hostmask,i->hostmask))
416                 {
417                         pklines.erase(i);
418                         return true;
419                 }
420         }
421         return false;
422 }
423
424 // returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
425
426 char* matches_qline(const char* nick)
427 {
428         if ((qlines.empty()) && (pqlines.empty()))
429                 return NULL;
430         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
431                 if (match(nick,i->nick))
432                         return i->reason;
433         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
434                 if (match(nick,i->nick))
435                         return i->reason;
436         return NULL;
437 }
438
439 // returns a pointer to the reason if a host matches a gline, NULL if it didnt match
440
441 char* matches_gline(const char* host)
442 {
443         if ((glines.empty()) && (pglines.empty()))
444                 return NULL;
445         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
446                 if (match(host,i->hostmask))
447                         return i->reason;
448         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
449                 if (match(host,i->hostmask))
450                         return i->reason;
451         return NULL;
452 }
453
454 char* matches_exception(const char* host)
455 {
456         if ((elines.empty()) && (pelines.empty()))
457                 return NULL;
458         char host2[MAXBUF];
459         snprintf(host2,MAXBUF,"*@%s",host);
460         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
461                 if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
462                         return i->reason;
463         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
464                 if ((match(host,i->hostmask)) || (match(host2,i->hostmask)))
465                         return i->reason;
466         return NULL;
467 }
468
469
470 void gline_set_creation_time(const char* host, time_t create_time)
471 {
472         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
473         {
474                 if (!strcasecmp(host,i->hostmask))
475                 {
476                         i->set_time = create_time;
477                         return;
478                 }
479         }
480         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
481         {
482                 if (!strcasecmp(host,i->hostmask))
483                 {
484                         i->set_time = create_time;
485                         return;
486                 }
487         }
488         return ;        
489 }
490
491 void eline_set_creation_time(const char* host, time_t create_time)
492 {
493         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
494         {
495                 if (!strcasecmp(host,i->hostmask))
496                 {
497                         i->set_time = create_time;
498                         return;
499                 }
500         }
501         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++) 
502         {
503                 if (!strcasecmp(host,i->hostmask))
504                 {
505                         i->set_time = create_time;
506                         return;
507                 }
508         }
509         return;
510 }
511
512 void qline_set_creation_time(const char* nick, time_t create_time)
513 {
514         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
515         {
516                 if (!strcasecmp(nick,i->nick))
517                 {
518                         i->set_time = create_time;
519                         return;
520                 }
521         }
522         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
523         {
524                 if (!strcasecmp(nick,i->nick))
525                 {
526                         i->set_time = create_time;
527                         return;
528                 }
529         }
530         return;
531 }
532
533 void zline_set_creation_time(const char* ip, time_t create_time)
534 {
535         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
536         {
537                 if (!strcasecmp(ip,i->ipaddr))
538                 {
539                         i->set_time = create_time;
540                         return;
541                 }
542         }
543         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
544         {
545                 if (!strcasecmp(ip,i->ipaddr))
546                 {
547                         i->set_time = create_time;
548                         return;
549                 }
550         }
551         return;
552 }
553
554 // returns a pointer to the reason if an ip address matches a zline, NULL if it didnt match
555
556 char* matches_zline(const char* ipaddr)
557 {
558         if ((zlines.empty()) && (pzlines.empty()))
559                 return NULL;
560         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
561                 if (match(ipaddr,i->ipaddr))
562                         return i->reason;
563         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
564                 if (match(ipaddr,i->ipaddr))
565                         return i->reason;
566         return NULL;
567 }
568
569 // returns a pointer to the reason if a host matches a kline, NULL if it didnt match
570
571 char* matches_kline(const char* host)
572 {
573         if ((klines.empty()) && (pklines.empty()))
574                 return NULL;
575         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
576                 if (match(host,i->hostmask))
577                         return i->reason;
578         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
579                 if (match(host,i->hostmask))
580                         return i->reason;
581         return NULL;
582 }
583
584 bool GSortComparison ( const GLine one, const GLine two )
585 {
586         return (one.duration + one.set_time) < (two.duration + two.set_time);
587 }
588
589 bool ESortComparison ( const ELine one, const ELine two )
590 {
591         return (one.duration + one.set_time) < (two.duration + two.set_time);
592 }
593
594 bool ZSortComparison ( const ZLine one, const ZLine two )
595 {
596         return (one.duration + one.set_time) < (two.duration + two.set_time);
597 }
598
599 bool KSortComparison ( const KLine one, const KLine two )
600 {
601         return (one.duration + one.set_time) < (two.duration + two.set_time);
602 }
603
604 bool QSortComparison ( const QLine one, const QLine two )
605 {
606         return (one.duration + one.set_time) < (two.duration + two.set_time);
607 }
608
609 // removes lines that have expired
610
611 void expire_lines()
612 {
613         time_t current = TIME;
614
615         /* Because we now store all our XLines in sorted order using (i->duration + i->set_time) as a key, this
616          * means that to expire the XLines we just need to do a while, picking off the top few until there are
617          * none left at the head of the queue that are after the current time.
618          */
619
620         while ((glines.size()) && (current > (glines.begin()->duration + glines.begin()->set_time)))
621         {
622                 std::vector<GLine>::iterator i = glines.begin();
623                 WriteOpers("*** Expiring timed G-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
624                 glines.erase(i);
625         }
626
627         while ((elines.size()) && (current > (elines.begin()->duration + elines.begin()->set_time)))
628         {
629                 std::vector<ELine>::iterator i = elines.begin();
630                 WriteOpers("*** Expiring timed E-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
631                 elines.erase(i);
632         }
633
634         while ((zlines.size()) && (current > (zlines.begin()->duration + zlines.begin()->set_time)))
635         {
636                 std::vector<ZLine>::iterator i = zlines.begin();
637                 WriteOpers("*** Expiring timed Z-Line %s (set by %s %d seconds ago)",i->ipaddr,i->source,i->duration);
638                 zlines.erase(i);
639         }
640
641         while ((klines.size()) && (current > (klines.begin()->duration + klines.begin()->set_time)))
642         {
643                 std::vector<KLine>::iterator i = klines.begin();
644                 WriteOpers("*** Expiring timed K-Line %s (set by %s %d seconds ago)",i->hostmask,i->source,i->duration);
645                 klines.erase(i);
646         }
647
648         while ((qlines.size()) && (current > (qlines.begin()->duration + qlines.begin()->set_time)))
649         {
650                 std::vector<QLine>::iterator i = qlines.begin();
651                 WriteOpers("*** Expiring timed Q-Line %s (set by %s %d seconds ago)",i->nick,i->source,i->duration);
652                 qlines.erase(i);
653         }
654         
655 }
656
657 // applies lines, removing clients and changing nicks etc as applicable
658
659 void apply_lines(const int What)
660 {
661         char reason[MAXBUF];
662         char host[MAXBUF];
663
664         if ((!glines.size()) && (!klines.size()) && (!zlines.size()) && (!qlines.size()) &&
665         (!pglines.size()) && (!pklines.size()) && (!pzlines.size()) && (!pqlines.size()))
666                 return;
667
668         CullList* Goners = new CullList();
669         char* check = NULL;
670         for (std::vector<userrec*>::const_iterator u2 = local_users.begin(); u2 != local_users.end(); u2++)
671         {
672                 userrec* u = (userrec*)(*u2);
673                 u->MakeHost(host);
674                 if (elines.size() || pelines.size())
675                 {
676                         // ignore people matching exempts
677                         if (matches_exception(host))
678                                 continue;
679                 }
680                 if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
681                 {
682                         if ((check = matches_gline(host)))
683                         {
684                                 snprintf(reason,MAXBUF,"G-Lined: %s",check);
685                                 Goners->AddItem(u,reason);
686                         }
687                 }
688                 if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
689                 {
690                         if ((check = matches_kline(host)))
691                         {
692                                 snprintf(reason,MAXBUF,"K-Lined: %s",check);
693                                 Goners->AddItem(u,reason);
694                         }
695                 }
696                 if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
697                 {
698                         if ((check = matches_qline(u->nick)))
699                         {
700                                 snprintf(reason,MAXBUF,"Q-Lined: %s",check);
701                                 Goners->AddItem(u,reason);
702                         }
703                 }
704                 if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
705                 {
706                         if ((check = matches_zline((char*)inet_ntoa(u->ip4))))
707                         {
708                                 snprintf(reason,MAXBUF,"Z-Lined: %s",check);
709                                 Goners->AddItem(u,reason);
710                         }
711                 }
712         }
713
714         Goners->Apply();
715         DELETE(Goners);
716 }
717
718 void stats_k(userrec* user, string_list &results)
719 {
720         std::string sn = Config->ServerName;
721         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
722                 results.push_back(sn+" 216 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
723         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
724                 results.push_back(sn+" 216 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
725 }
726
727 void stats_g(userrec* user, string_list &results)
728 {
729         std::string sn = Config->ServerName;
730         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
731                 results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
732         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
733                 results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
734 }
735
736 void stats_q(userrec* user, string_list &results)
737 {
738         std::string sn = Config->ServerName;
739         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
740                 results.push_back(sn+" 217 "+user->nick+" :"+i->nick+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
741         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
742                 results.push_back(sn+" 217 "+user->nick+" :"+i->nick+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
743 }
744
745 void stats_z(userrec* user, string_list &results)
746 {
747         std::string sn = Config->ServerName;
748         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
749                 results.push_back(sn+" 223 "+user->nick+" :"+i->ipaddr+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
750         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
751                 results.push_back(sn+" 223 "+user->nick+" :"+i->ipaddr+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
752 }
753
754 void stats_e(userrec* user, string_list &results)
755 {
756         std::string sn = Config->ServerName;
757         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
758                 results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
759         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
760                 results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
761 }