1 |
/* |
2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
* m_users.c: Gives some basic user statistics. |
4 |
* |
5 |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
* USA |
21 |
* |
22 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#include "stdinc.h" |
26 |
#include "client.h" |
27 |
#include "ircd.h" |
28 |
#include "numeric.h" |
29 |
#include "s_serv.h" |
30 |
#include "conf.h" |
31 |
#include "send.h" |
32 |
#include "parse.h" |
33 |
#include "modules.h" |
34 |
|
35 |
|
36 |
/* |
37 |
* m_users |
38 |
* parv[0] = sender prefix |
39 |
* parv[1] = servername |
40 |
*/ |
41 |
static void |
42 |
m_users(struct Client *client_p, struct Client *source_p, |
43 |
int parc, char *parv[]) |
44 |
{ |
45 |
static time_t last_used = 0; |
46 |
|
47 |
if (last_used + ConfigFileEntry.pace_wait_simple > CurrentTime) |
48 |
{ |
49 |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
50 |
me.name, source_p->name); |
51 |
return; |
52 |
} |
53 |
|
54 |
last_used = CurrentTime; |
55 |
|
56 |
if (!ConfigServerHide.disable_remote_commands) |
57 |
if (hunt_server(client_p, source_p, ":%s USERS :%s", 1, |
58 |
parc, parv) != HUNTED_ISME) |
59 |
return; |
60 |
|
61 |
sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name, |
62 |
ConfigServerHide.hide_servers ? Count.total : Count.local, |
63 |
ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc); |
64 |
sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name, |
65 |
Count.total, Count.max_tot); |
66 |
} |
67 |
|
68 |
/* |
69 |
* mo_users |
70 |
* parv[0] = sender prefix |
71 |
* parv[1] = servername |
72 |
*/ |
73 |
static void |
74 |
mo_users(struct Client *client_p, struct Client *source_p, |
75 |
int parc, char *parv[]) |
76 |
{ |
77 |
if (hunt_server(client_p, source_p, ":%s USERS :%s", 1, |
78 |
parc, parv) != HUNTED_ISME) |
79 |
return; |
80 |
|
81 |
if (!HasUMode(source_p, UMODE_OPER) && ConfigServerHide.hide_servers) |
82 |
sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name, |
83 |
Count.total, Count.max_tot); |
84 |
else |
85 |
sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name, |
86 |
Count.local, Count.max_loc); |
87 |
|
88 |
sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name, |
89 |
Count.total, Count.max_tot); |
90 |
} |
91 |
|
92 |
static struct Message users_msgtab = { |
93 |
"USERS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
94 |
{ m_unregistered, m_users, mo_users, m_ignore, mo_users, m_ignore } |
95 |
}; |
96 |
|
97 |
static void |
98 |
module_init(void) |
99 |
{ |
100 |
mod_add_cmd(&users_msgtab); |
101 |
} |
102 |
|
103 |
static void |
104 |
module_exit(void) |
105 |
{ |
106 |
mod_del_cmd(&users_msgtab); |
107 |
} |
108 |
|
109 |
struct module module_entry = { |
110 |
.node = { NULL, NULL, NULL }, |
111 |
.name = NULL, |
112 |
.version = "$Revision$", |
113 |
.handle = NULL, |
114 |
.modinit = module_init, |
115 |
.modexit = module_exit, |
116 |
.flags = 0 |
117 |
}; |