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