]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 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); | |
94e4d2f4 CP |
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. | |
1dd6d55d | 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); | |
4d3a2e5b | 23 | reguser *dbrup, *trup; |
a49c6c1c | 24 | int i, seewhom; |
1dd6d55d | 25 | unsigned int count=0; |
b7eebdcc | 26 | char buf[TIMELEN], buf2[TIMELEN], *bywhom; |
4d3a2e5b | 27 | time_t now=time(NULL); |
1dd6d55d | 28 | |
29 | if (!rup) | |
30 | return CMD_ERROR; | |
31 | ||
32 | if (cargc < 1) { | |
33 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspenduserlist"); | |
34 | return CMD_ERROR; | |
35 | } | |
36 | ||
a49c6c1c CP |
37 | seewhom = cs_privcheck(QPRIV_VIEWSUSPENDEDBY, sender); |
38 | if(!seewhom) | |
39 | bywhom = "(hidden)"; | |
40 | ||
b7eebdcc | 41 | /* @TIMELEN */ |
1dd6d55d | 42 | chanservstdmessage(sender, QM_SUSPENDUSERLISTHEADER); |
43 | for (i=0;i<REGUSERHASHSIZE;i++) { | |
44 | for (dbrup=regusernicktable[i]; dbrup; dbrup=dbrup->nextbyname) { | |
45 | if (!UHasSuspension(dbrup)) | |
46 | continue; | |
47 | ||
4d3a2e5b | 48 | if (!match(cargv[0], dbrup->username)) { |
1dd6d55d | 49 | char suspendtype[100]; |
1dd6d55d | 50 | |
1dd6d55d | 51 | if (UIsDelayedGline(dbrup)) |
52 | strcpy(suspendtype, "delayed gline"); | |
53 | else if (UIsGline(dbrup)) | |
54 | strcpy(suspendtype, "instant gline"); | |
55 | else if (UIsSuspended(dbrup)) | |
56 | strcpy(suspendtype, "suspended"); | |
57 | else | |
58 | strcpy(suspendtype, "not used"); | |
59 | ||
a49c6c1c CP |
60 | if(seewhom) { |
61 | trup=findreguserbyID(dbrup->suspendby); | |
62 | if (trup) | |
63 | bywhom=trup->username; | |
64 | else | |
65 | bywhom="(unknown)"; | |
66 | } | |
67 | ||
b7eebdcc CP |
68 | if (dbrup->suspendexp) |
69 | q9strftime(buf,sizeof(buf),dbrup->suspendexp); | |
1dd6d55d | 70 | |
b7eebdcc | 71 | q9strftime(buf2,sizeof(buf2),dbrup->suspendtime); |
c1e6c982 | 72 | |
1dd6d55d | 73 | count++; |
b7eebdcc CP |
74 | |
75 | /* @TIMELEN */ | |
76 | chanservsendmessage(sender, "%-15s %-13s %-15s %-19s %-19s %s", dbrup->username, suspendtype, bywhom, buf2, (dbrup->suspendexp)?((now >= dbrup->suspendexp)?"next auth":buf):"never", dbrup->suspendreason?dbrup->suspendreason->content:"(none)"); | |
1dd6d55d | 77 | if (count >= 2000) { |
78 | chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "users"); | |
79 | return CMD_ERROR; | |
80 | } | |
81 | } | |
82 | } | |
83 | } | |
84 | chanservstdmessage(sender, QM_RESULTCOUNT, count, "user", (count==1)?"":"s"); | |
85 | ||
86 | return CMD_OK; | |
87 | } |