]>
Commit | Line | Data |
---|---|---|
1151d736 P |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <stdarg.h> | |
4 | #include <string.h> | |
5 | #include <time.h> | |
6 | #include <assert.h> | |
7 | #include <sys/socket.h> | |
8 | #include <netinet/in.h> | |
9 | #include <arpa/inet.h> | |
10 | ||
11 | #include "../control/control.h" | |
12 | #include "../nick/nick.h" | |
13 | #include "../localuser/localuserchannel.h" | |
14 | #include "../core/hooks.h" | |
15 | #include "../server/server.h" | |
16 | #include "../parser/parser.h" | |
17 | #include "../core/schedule.h" | |
18 | #include "../lib/array.h" | |
19 | #include "../lib/base64.h" | |
20 | #include "../lib/irc_string.h" | |
21 | #include "../lib/splitline.h" | |
22 | ||
23 | #include "gline.h" | |
24 | ||
25 | void _init() { | |
26 | registercontrolhelpcmd("glstats",NO_OPER,0,&gline_glstats,"Usage: glstats."); | |
27 | } | |
28 | ||
29 | void _fini() { | |
30 | deregistercontrolcmd("glstats", gline_glstats); | |
31 | } | |
32 | ||
33 | int gline_glstats(void* source, int cargc, char** cargv) { | |
34 | nick* sender = (nick*)source; | |
35 | gline* g; | |
36 | gline* sg; | |
37 | time_t curtime = time(0); | |
38 | int glinecount = 0, hostglinecount = 0, ipglinecount = 0, badchancount = 0, rnglinecount = 0; | |
39 | int deactivecount =0, activecount = 0; | |
40 | ||
41 | for (g = glinelist; g; g = sg) { | |
42 | sg = g->next; | |
43 | ||
44 | if (g->lifetime <= curtime) | |
45 | continue; | |
46 | ||
47 | if (g->flags & GLINE_ACTIVE) { | |
48 | activecount++; | |
49 | } else { | |
50 | deactivecount++; | |
51 | } | |
52 | ||
53 | if(g->flags & GLINE_IPMASK) | |
54 | ipglinecount++; | |
55 | else if (g->flags & (GLINE_HOSTMASK | GLINE_HOSTEXACT)) | |
56 | hostglinecount++; | |
57 | else if (g->flags & GLINE_REALNAME) | |
58 | rnglinecount++; | |
59 | else if (g->flags & GLINE_BADCHAN) | |
60 | badchancount++; | |
61 | glinecount++; | |
62 | } | |
63 | ||
64 | controlreply(sender, "Total G-Lines set: %d", glinecount); | |
65 | controlreply(sender, "Hostmask G-Lines: %d", hostglinecount); | |
66 | controlreply(sender, "IPMask G-Lines: %d", ipglinecount); | |
67 | controlreply(sender, "Channel G-Lines: %d", badchancount); | |
68 | controlreply(sender, "Realname G-Lines: %d", rnglinecount); | |
69 | ||
70 | controlreply(sender, "Active G-Lines: %d", activecount); | |
71 | controlreply(sender, "De-Active G-Lines: %d", deactivecount); | |
72 | ||
73 | /* TODO show top 10 creators here */ | |
74 | /* TODO show unique creators count */ | |
75 | /* TODO show glines per create %8.1f", ccount?((float)gcount/(float)ccount):0 */ | |
76 | return CMD_OK; | |
77 | } | |
78 |