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