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