]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/suspenduser.c
0d2b32abffe017146b3e9f2543f1c264c92e056b
1 /* Automatically generated by refactor.pl.
7 * CMDDESC: Suspend/Delay GLINE/Instantly GLINE a user.
8 * CMDFUNC: csu_dosuspenduser
9 * CMDPROTO: int csu_dosuspenduser(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: suspenduser <username> [<duration>] <reason>
11 * CMDHELP: -nokill <username> [<duration>] <reason>
12 * CMDHELP: -gline <username> [<duration>] <reason>
13 * CMDHELP: -instantgline <username> [<duration>] <reason>
14 * CMDHELP: -password <password> [<duration>] <reason>
15 * CMDHELP: -email <email address> [<duration>] <reason>
16 * CMDHELP: Suspends one or more users, either based on username, email
17 * CMDHELP: address or password.
18 * CMDHELP: By default the user will be immediately disconnected unless
19 * CMDHELP: nokill is specified.
20 * CMDHELP: gline will gline the user at some random period of time after
21 * CMDHELP: they auth, instantgline will gline them the moment they auth.
24 #include "../chanserv.h"
25 #include "../../lib/irc_string.h"
29 static int killtheusers(nick
*sender
, reguser
*rup
) {
33 if (!(anp
=findauthname(rup
->ID
)))
37 chanservstdmessage(sender
, QM_DISCONNECTINGUSER
, anp
->nicks
->nick
, rup
->username
);
38 chanservkillstdmessage(anp
->nicks
, QM_SUSPENDKILL
);
45 int csu_dosuspenduser(void *source
, int cargc
, char **cargv
) {
47 reguser
*rup
=getreguserfromnick(sender
);
53 int kill
=1, gline
=0, email
=0, password
=0, hitcount
=0;
56 char expiresbuf
[TIMELEN
]="";
63 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
67 if (cargv
[0][0] == '-') {
69 if (!(victim
=strchr(flag
, ' '))) {
70 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
74 if (!(dur_p
=strchr(victim
, ' '))) {
75 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
79 if ((reason
=strchr(dur_p
, ' '))) {
81 if ((duration
=durationtolong(dur_p
))) {
82 if ((duration
< 86400) || (duration
> 2592000)) {
83 chanservstdmessage(sender
, QM_INVALIDDURATION
);
86 expires
=time(0)+duration
;
99 if (!ircd_strcmp(flag
, "-nokill")) {
102 else if (!ircd_strcmp(flag
, "-gline")) {
105 else if (!ircd_strcmp(flag
, "-instantgline")) {
108 else if (!ircd_strcmp(flag
, "-email")) {
111 else if (!ircd_strcmp(flag
, "-password")) {
115 chanservstdmessage(sender
, QM_INVALIDCHANLEVCHANGE
);
121 if (!(dur_p
=strchr(victim
, ' '))) {
122 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "suspenduser");
126 if ((reason
=strchr(dur_p
, ' '))) {
128 if ((duration
=durationtolong(dur_p
))) {
129 if ((duration
< 86400) || (duration
> 2592000)) {
130 chanservstdmessage(sender
, QM_INVALIDDURATION
);
133 expires
=time(0)+duration
;
147 if(!checkreason(sender
, reason
))
151 q9strftime(expiresbuf
,sizeof(expiresbuf
),expires
);
156 for (i
=0;i
<REGUSERHASHSIZE
;i
++) {
157 for (vrup
=regusernicktable
[i
]; vrup
; vrup
=vrup
->nextbyname
) {
158 if (!strcasecmp(vrup
->email
->content
, victim
)) {
159 if (UHasSuspension(vrup
))
162 if (UHasStaffPriv(vrup
))
166 vrup
->flags
|=QUFLAG_SUSPENDED
;
167 vrup
->suspendby
=rup
->ID
;
168 vrup
->suspendexp
=expires
;
169 vrup
->suspendtime
=time(NULL
);
170 vrup
->suspendreason
=getsstring(reason
, strlen(reason
)+1);
172 killtheusers(sender
,vrup
);
173 csdb_updateuser(vrup
);
178 chanservwallmessage("%s (%s) bulk suspended <%s>, hit %d account/s (expires: %s), reason: %s", sender
->nick
, rup
->username
, victim
, hitcount
, expires
?expiresbuf
:"never", reason
);
179 cs_log(sender
, "SUSPENDUSER (bulk by email: %s, hit: %d) expires: %s, reason: %s", victim
, hitcount
, expires
?expiresbuf
:"never", reason
);
184 for (i
=0;i
<REGUSERHASHSIZE
;i
++) {
185 for (vrup
=regusernicktable
[i
]; vrup
; vrup
=vrup
->nextbyname
) {
186 if (!strcmp(vrup
->password
, victim
)) {
187 if (UHasSuspension(vrup
))
190 if (UHasStaffPriv(vrup
))
194 vrup
->flags
|=QUFLAG_SUSPENDED
;
195 vrup
->suspendby
=rup
->ID
;
196 vrup
->suspendexp
=expires
;
197 vrup
->suspendtime
=time(NULL
);
198 vrup
->suspendreason
=getsstring(reason
, strlen(reason
)+1);
200 killtheusers(sender
,vrup
);
201 csdb_updateuser(vrup
);
206 chanservwallmessage("%s (%s) bulk suspended password \"%s\", hit %d account/s (expires: %s), reason: %s", sender
->nick
, rup
->username
, victim
, hitcount
, expires
?expiresbuf
:"never", reason
);
207 cs_log(sender
, "SUSPENDUSER (bulk by password: %s, hit: %d) expires: %s, reason: %s", victim
, hitcount
, expires
?expiresbuf
:"never", reason
);
210 if (!(vrup
=findreguser(sender
, victim
)))
213 if (!ircd_strcmp(vrup
->username
, rup
->username
)) {
214 chanservsendmessage(sender
, "You can't suspend yourself, silly.");
218 if (UHasSuspension(vrup
)) {
219 chanservstdmessage(sender
, QM_USERALREADYSUSPENDED
);
223 if (UHasStaffPriv(vrup
)) {
225 snprintf(buf
, sizeof(buf
), "suspenduser on %s (reason: %s)", vrup
->username
, reason
);
226 chanservstdmessage(sender
, QM_NOACCESS
, buf
);
227 chanservwallmessage("%s (%s) FAILED to suspend %s (reason: %s)", sender
->nick
, rup
->username
, vrup
->username
, reason
);
232 vrup
->flags
|=QUFLAG_GLINE
;
234 vrup
->flags
|=QUFLAG_DELAYEDGLINE
;
236 vrup
->flags
|=QUFLAG_SUSPENDED
;
237 vrup
->suspendby
=rup
->ID
;
238 vrup
->suspendexp
=expires
;
239 vrup
->suspendtime
=time(NULL
);
240 vrup
->suspendreason
=getsstring(reason
, strlen(reason
)+1);
242 chanservwallmessage("%s (%s) %s %s (expires: %s), reason: %s", sender
->nick
, rup
->username
, (gline
)?((gline
== 2)?"instantly glined":"delayed glined"):"suspended", vrup
->username
, expires
?expiresbuf
:"never", reason
);
243 cs_log(sender
, "SUSPENDUSER %s %s (expires: %s), reason: %s", (gline
)?((gline
== 2)?"instantly glined":"delayed glined"):"suspended", vrup
->username
, expires
?expiresbuf
:"never", reason
);
246 dgwait
=(gline
==2)?0:rand()%900
;
247 chanservsendmessage(sender
, "Scheduling delayed GLINE for account %s in %d %s",
248 vrup
->username
, (dgwait
>60)?(dgwait
/60):dgwait
, (dgwait
>60)?"minutes":"seconds");
249 deleteschedule(NULL
, &chanservdgline
, (void*)vrup
);
250 scheduleoneshot(time(NULL
)+dgwait
, &chanservdgline
, (void*)vrup
);
253 hitcount
+= killtheusers(sender
,vrup
);
256 csdb_updateuser(vrup
);