]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/suspenduserlist.c
5e6b27d842fae700592c3f9dfc398d8ac0a93b26
[irc/quakenet/newserv.git] / chanserv / usercmds / suspenduserlist.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: suspenduserlist
5 * CMDLEVEL: QCMD_HELPER
6 * CMDARGS: 1
7 * CMDDESC: Lists suspended/locked users.
8 * CMDFUNC: csu_dosuspenduserlist
9 * CMDPROTO: int csu_dosuspenduserlist(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: suspenduserlist <username or pattern>
11 * CMDHELP: Displays all suspend users with usernames matching the specified pattern,
12 * CMDHELP: or the single user with the specified username.
13 */
14
15 #include "../chanserv.h"
16 #include "../../lib/irc_string.h"
17 #include <stdio.h>
18 #include <string.h>
19
20 int csu_dosuspenduserlist(void *source, int cargc, char **cargv) {
21 nick *sender=source;
22 reguser *rup=getreguserfromnick(sender);
23 reguser *vrup;
24 reguser *dbrup;
25 int i;
26 unsigned int count=0;
27 struct tm *tmp;
28 char buf[200], buf2[200];
29
30 if (!rup)
31 return CMD_ERROR;
32
33 if (cargc < 1) {
34 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspenduserlist");
35 return CMD_ERROR;
36 }
37
38 vrup=findreguserbynick(cargv[0]);
39
40 chanservstdmessage(sender, QM_SUSPENDUSERLISTHEADER);
41 for (i=0;i<REGUSERHASHSIZE;i++) {
42 for (dbrup=regusernicktable[i]; dbrup; dbrup=dbrup->nextbyname) {
43 if (!UHasSuspension(dbrup))
44 continue;
45
46 /*if (!ircd_strcmp(dbrup->username, cargv[0]) || (dbrup->suspendby == vrup->ID)) {*/
47 if ((vrup && (dbrup->suspendby == vrup->ID))) {
48 char suspendtype[100];
49 char *bywhom=0;
50
51 if ((UIsGline(dbrup) || UIsDelayedGline(dbrup)) && !UHasOperPriv(rup))
52 continue;
53
54 if (UIsDelayedGline(dbrup))
55 strcpy(suspendtype, "delayed gline");
56 else if (UIsGline(dbrup))
57 strcpy(suspendtype, "instant gline");
58 else if (UIsSuspended(dbrup))
59 strcpy(suspendtype, "suspended");
60 else
61 strcpy(suspendtype, "not used");
62
63 if (vrup && (dbrup->suspendby == vrup->ID)) {
64 bywhom=vrup->username;
65 }
66 else {
67 reguser* trup=findreguserbyID(dbrup->suspendby);
68 if (trup)
69 bywhom=trup->username;
70 }
71
72 if (dbrup->suspendexp) {
73 tmp=gmtime(&(dbrup->suspendexp));
74 strftime(buf,15,"%d/%m/%y %H:%M",tmp);
75 }
76
77 tmp=gmtime(&(dbrup->suspendtime));
78 strftime(buf2,15,"%d/%m/%y %H:%M",tmp);
79
80 count++;
81 chanservsendmessage(sender, "%-15s %-13s %-15s %-15s %-15s %s", dbrup->username, suspendtype, UHasOperPriv(rup)?(bywhom?bywhom:"unknown"):"not shown", buf2, (dbrup->suspendexp)?((time(0) >= dbrup->suspendexp)?"next auth":buf):"never", dbrup->suspendreason?dbrup->suspendreason->content:"(none)");
82 if (count >= 2000) {
83 chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "users");
84 return CMD_ERROR;
85 }
86 }
87 }
88 }
89 chanservstdmessage(sender, QM_RESULTCOUNT, count, "user", (count==1)?"":"s");
90
91 return CMD_OK;
92 }