]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_admin.c
Add some ircd-seven love to CREDITS.
[irc/rqf/shadowircd.git] / modules / m_admin.c
CommitLineData
212380e3 1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_admin.c: Sends administrative information to a user.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
88520303 24 * $Id: m_admin.c 3368 2007-04-03 10:11:06Z nenolod $
212380e3 25 */
26
27#include "stdinc.h"
28#include "client.h"
29#include "ircd.h"
30#include "numeric.h"
31#include "s_conf.h"
32#include "s_serv.h"
33#include "send.h"
34#include "msg.h"
35#include "parse.h"
36#include "hook.h"
37#include "modules.h"
38
39static int m_admin(struct Client *, struct Client *, int, const char **);
40static int mr_admin(struct Client *, struct Client *, int, const char **);
41static int ms_admin(struct Client *, struct Client *, int, const char **);
42static void do_admin(struct Client *source_p);
43
44static void admin_spy(struct Client *);
45
46struct Message admin_msgtab = {
47 "ADMIN", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
48 {{mr_admin, 0}, {m_admin, 0}, {ms_admin, 0}, mg_ignore, mg_ignore, {ms_admin, 0}}
49};
50
51int doing_admin_hook;
52
53mapi_clist_av1 admin_clist[] = { &admin_msgtab, NULL };
54mapi_hlist_av1 admin_hlist[] = {
55 { "doing_admin", &doing_admin_hook },
56 { NULL, NULL }
57};
58
88520303 59DECLARE_MODULE_AV1(admin, NULL, NULL, admin_clist, admin_hlist, NULL, "$Revision: 3368 $");
212380e3 60
61/*
62 * mr_admin - ADMIN command handler
212380e3 63 * parv[1] = servername
64 */
65static int
66mr_admin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
67{
68 static time_t last_used = 0L;
69
9f6bbe3c 70 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
212380e3 71 {
72 sendto_one(source_p, form_str(RPL_LOAD2HI),
73 me.name,
74 EmptyString(source_p->name) ? "*" : source_p->name,
75 "ADMIN");
76 return 0;
77 }
78 else
9f6bbe3c 79 last_used = rb_current_time();
212380e3 80
81 do_admin(source_p);
82
83 return 0;
84}
85
86/*
87 * m_admin - ADMIN command handler
212380e3 88 * parv[1] = servername
89 */
90static int
91m_admin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
92{
93 static time_t last_used = 0L;
94
95 if(parc > 1)
96 {
9f6bbe3c 97 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
212380e3 98 {
99 sendto_one(source_p, form_str(RPL_LOAD2HI),
100 me.name, source_p->name, "ADMIN");
101 return 0;
102 }
103 else
9f6bbe3c 104 last_used = rb_current_time();
212380e3 105
106 if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
107 return 0;
108 }
109
110 do_admin(source_p);
111
112 return 0;
113}
114
115
116/*
117 * ms_admin - ADMIN command handler, used for OPERS as well
212380e3 118 * parv[1] = servername
119 */
120static int
121ms_admin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
122{
123 if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
124 return 0;
125
126 do_admin(source_p);
127
128 return 0;
129}
130
131
132/*
133 * do_admin
134 *
135 * inputs - pointer to client to report to
136 * output - none
137 * side effects - admin info is sent to client given
138 */
139static void
140do_admin(struct Client *source_p)
141{
212380e3 142 if(IsPerson(source_p))
143 admin_spy(source_p);
144
88520303 145 sendto_one_numeric(source_p, RPL_ADMINME, form_str(RPL_ADMINME), me.name);
212380e3 146 if(AdminInfo.name != NULL)
88520303 147 sendto_one_numeric(source_p, RPL_ADMINLOC1, form_str(RPL_ADMINLOC1), AdminInfo.name);
212380e3 148 if(AdminInfo.description != NULL)
88520303 149 sendto_one_numeric(source_p, RPL_ADMINLOC2, form_str(RPL_ADMINLOC2), AdminInfo.description);
212380e3 150 if(AdminInfo.email != NULL)
88520303 151 sendto_one_numeric(source_p, RPL_ADMINEMAIL, form_str(RPL_ADMINEMAIL), AdminInfo.email);
212380e3 152}
153
154/* admin_spy()
155 *
156 * input - pointer to client
157 * output - none
158 * side effects - event doing_admin is called
159 */
160static void
161admin_spy(struct Client *source_p)
162{
163 hook_data hd;
164
165 hd.client = source_p;
166 hd.arg1 = hd.arg2 = NULL;
167
168 call_hook(doing_admin_hook, &hd);
169}