]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/xline.cpp
Review and optimize
[user/henk/code/inspircd.git] / src / xline.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2005 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 "inspircd_io.h"
22 #include <unistd.h>
23 #include <fcntl.h>
24 #include <sys/errno.h>
25 #include <time.h>
26 #include <string>
27 #ifdef GCC3
28 #include <ext/hash_map>
29 #else
30 #include <hash_map>
31 #endif
32 #include <map>
33 #include <sstream>
34 #include <vector>
35 #include <deque>
36 #include "users.h"
37 #include "ctables.h"
38 #include "globals.h"
39 #include "modules.h"
40 #include "dynamic.h"
41 #include "wildcard.h"
42 #include "message.h"
43 #include "commands.h"
44 #include "xline.h"
45 #include "inspstring.h"
46 #include "helperfuncs.h"
47 #include "hashcomp.h"
48 #include "typedefs.h"
49 #include "cull_list.h"
50
51 extern ServerConfig *Config;
52
53 extern int MODCOUNT;
54 extern std::vector<Module*> modules;
55 extern std::vector<ircd_module*> factory;
56 extern ServerConfig* Config;
57 extern user_hash clientlist;
58
59 /* Version two, now with optimized expiry!
60  *
61  * Because the old way was horrendously slow, the new way of expiring xlines is very
62  * very efficient. I have improved the efficiency of the algorithm in two ways:
63  *
64  * (1) There are now two lists of items for each linetype. One list holds temporary
65  *     items, and the other list holds permenant items (ones which will expire).
66  *     Items which are on the permenant list are NEVER checked at all by the
67  *     expire_lines() function.
68  * (2) The temporary xline lists are always kept in strict numerical order, keyed by 
69  *     current time + duration. This means that the line which is due to expire the
70  *     soonest is always pointed at by vector::begin(), so a simple while loop can
71  *     very efficiently, very quickly and above all SAFELY pick off the first few
72  *     items in the vector which need zapping.
73  *
74  *     -- Brain
75  */
76
77
78
79 extern time_t TIME;
80
81 /* Lists for temporary lines with an expiry time */
82
83 std::vector<KLine> klines;
84 std::vector<GLine> glines;
85 std::vector<ZLine> zlines;
86 std::vector<QLine> qlines;
87 std::vector<ELine> elines;
88
89 /* Seperate lists for perm XLines that isnt checked by expiry functions */
90
91 std::vector<KLine> pklines;
92 std::vector<GLine> pglines;
93 std::vector<ZLine> pzlines;
94 std::vector<QLine> pqlines;
95 std::vector<ELine> pelines;
96
97
98 bool GSortComparison ( const GLine one, const GLine two );
99 bool ZSortComparison ( const ZLine one, const ZLine two );
100 bool ESortComparison ( const ELine one, const ELine two );
101 bool QSortComparison ( const QLine one, const QLine two );
102 bool KSortComparison ( const KLine one, const KLine two );
103
104 // Reads the default bans from the config file.
105 // only a very small number of bans are defined
106 // this way these days, such as qlines against 
107 // services nicks, etc.
108
109 void read_xline_defaults()
110 {
111         char ipmask[MAXBUF];
112         char nick[MAXBUF];
113         char host[MAXBUF];
114         char reason[MAXBUF];
115
116         for (int i = 0; i < Config->ConfValueEnum("badip",&Config->config_f); i++)
117         {
118                 Config->ConfValue("badip","ipmask",i,ipmask,&Config->config_f);
119                 Config->ConfValue("badip","reason",i,reason,&Config->config_f);
120                 add_zline(0,"<Config>",reason,ipmask);
121                 log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason);
122         }
123         
124         for (int i = 0; i < Config->ConfValueEnum("badnick",&Config->config_f); i++)
125         {
126                 Config->ConfValue("badnick","nick",i,nick,&Config->config_f);
127                 Config->ConfValue("badnick","reason",i,reason,&Config->config_f);
128                 add_qline(0,"<Config>",reason,nick);
129                 log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason);
130         }
131         
132         for (int i = 0; i < Config->ConfValueEnum("badhost",&Config->config_f); i++)
133         {
134                 Config->ConfValue("badhost","host",i,host,&Config->config_f);
135                 Config->ConfValue("badhost","reason",i,reason,&Config->config_f);
136                 add_kline(0,"<Config>",reason,host);
137                 log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason);
138         }
139         for (int i = 0; i < Config->ConfValueEnum("exception",&Config->config_f); i++)
140         {
141                 Config->ConfValue("exception","host",i,host,&Config->config_f);
142                 Config->ConfValue("exception","reason",i,reason,&Config->config_f);
143                 add_eline(0,"<Config>",reason,host);
144                 log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason);
145         }
146 }
147
148 // adds a g:line
149
150 void add_gline(long duration, const char* source,const char* reason,const char* hostmask)
151 {
152         del_gline(hostmask);
153         GLine item;
154         item.duration = duration;
155         strlcpy(item.hostmask,hostmask,199);
156         strlcpy(item.reason,reason,MAXBUF);
157         strlcpy(item.source,source,255);
158         item.n_matches = 0;
159         item.set_time = TIME;
160         if (duration)
161         {
162                 glines.push_back(item);
163                 sort(glines.begin(), glines.end(),GSortComparison);
164         }
165         else
166         {
167                 pglines.push_back(item);
168         }
169 }
170
171 // adds an e:line (exception to bans)
172
173 void add_eline(long duration, const char* source, const char* reason, const char* hostmask)
174 {
175         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 }
193
194 // adds a q:line
195
196 void add_qline(long duration, const char* source, const char* reason, const char* nickname)
197 {
198         del_qline(nickname);
199         QLine item;
200         item.duration = duration;
201         strlcpy(item.nick,nickname,63);
202         strlcpy(item.reason,reason,MAXBUF);
203         strlcpy(item.source,source,255);
204         item.n_matches = 0;
205         item.is_global = false;
206         item.set_time = TIME;
207         if (duration)
208         {
209                 qlines.push_back(item);
210                 sort(qlines.begin(), qlines.end(),QSortComparison);
211         }
212         else
213         {
214                 pqlines.push_back(item);
215         }
216 }
217
218 // adds a z:line
219
220 void add_zline(long duration, const char* source, const char* reason, const char* ipaddr)
221 {
222         del_zline(ipaddr);
223         ZLine item;
224         item.duration = duration;
225         if (strchr(ipaddr,'@'))
226         {
227                 while (*ipaddr != '@')
228                         ipaddr++;
229                 ipaddr++;
230         }
231         strlcpy(item.ipaddr,ipaddr,39);
232         strlcpy(item.reason,reason,MAXBUF);
233         strlcpy(item.source,source,255);
234         item.n_matches = 0;
235         item.is_global = false;
236         item.set_time = TIME;
237         if (duration)
238         {
239                 zlines.push_back(item);
240                 sort(zlines.begin(), zlines.end(),ZSortComparison);
241         }
242         else
243         {
244                 pzlines.push_back(item);
245         }
246 }
247
248 // adds a k:line
249
250 void add_kline(long duration, const char* source, const char* reason, const char* hostmask)
251 {
252         del_kline(hostmask);
253         KLine item;
254         item.duration = duration;
255         strlcpy(item.hostmask,hostmask,200);
256         strlcpy(item.reason,reason,MAXBUF);
257         strlcpy(item.source,source,255);
258         item.n_matches = 0;
259         item.set_time = TIME;
260         if (duration)
261         {
262                 klines.push_back(item);
263                 sort(klines.begin(), klines.end(),KSortComparison);
264         }
265         else
266         {
267                 pklines.push_back(item);
268         }
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))
435                         return i->reason;
436         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
437                 if (match(host,i->hostmask))
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)))
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)))
453                         return i->reason;
454         return NULL;
455 }
456
457
458 void gline_set_creation_time(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(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(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(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))
550                         return i->reason;
551         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
552                 if (match(ipaddr,i->ipaddr))
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))
565                         return i->reason;
566         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
567                 if (match(host,i->hostmask))
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 = 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                 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                 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                 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                 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                 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();
657         
658         for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
659         {
660                 if (u->second->fd > -1)
661                 {
662                         snprintf(host,MAXBUF,"%s@%s",u->second->ident,u->second->host);
663                         if (elines.size())
664                         {
665                                 // ignore people matching exempts
666                                 if (matches_exception(host))
667                                         continue;
668                         }
669                         if ((What & APPLY_GLINES) && (glines.size() || pglines.size()))
670                         {
671                                 char* check = matches_gline(host);
672                                 if (check)
673                                 {
674                                         snprintf(reason,MAXBUF,"G-Lined: %s",check);
675                                         Goners->AddItem(u->second,reason);
676                                 }
677                         }
678                         if ((What & APPLY_KLINES) && (klines.size() || pklines.size()))
679                         {
680                                 char* check = matches_kline(host);
681                                 if (check)
682                                 {
683                                         snprintf(reason,MAXBUF,"K-Lined: %s",check);
684                                         Goners->AddItem(u->second,reason);
685                                 }
686                         }
687                         if ((What & APPLY_QLINES) && (qlines.size() || pqlines.size()))
688                         {
689                                 char* check = matches_qline(u->second->nick);
690                                 if (check)
691                                 {
692                                         snprintf(reason,MAXBUF,"Matched Q-Lined nick: %s",check);
693                                         Goners->AddItem(u->second,reason);
694                                 }
695                         }
696                         if ((What & APPLY_ZLINES) && (zlines.size() || pzlines.size()))
697                         {
698                                 char* check = matches_zline(u->second->ip);
699                                 if (check)
700                                 {
701                                         snprintf(reason,MAXBUF,"Z-Lined: %s",check);
702                                         Goners->AddItem(u->second,reason);
703                                 }
704                         }
705                 }
706         }
707
708         Goners->Apply();
709         delete Goners;
710 }
711
712 void stats_k(userrec* user)
713 {
714         for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
715                 WriteServ(user->fd,"216 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
716         for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
717                 WriteServ(user->fd,"216 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
718 }
719
720 void stats_g(userrec* user)
721 {
722         for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
723                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
724         for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
725                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
726 }
727
728 void stats_q(userrec* user)
729 {
730         for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
731                 WriteServ(user->fd,"217 %s :%s %d %d %s %s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
732         for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
733                 WriteServ(user->fd,"217 %s :%s %d %d %s %s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
734 }
735
736 void stats_z(userrec* user)
737 {
738         for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
739                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
740         for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
741                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
742 }
743
744 void stats_e(userrec* user)
745 {
746         for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
747                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
748         for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
749                 WriteServ(user->fd,"223 %s :%s %d %d %s %s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
750 }