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