]>
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); | |
10 | */ | |
11 | ||
12 | #include "../chanserv.h" | |
13 | #include "../../lib/irc_string.h" | |
14 | #include <stdio.h> | |
15 | #include <string.h> | |
16 | ||
17 | int csu_dosuspenduserlist(void *source, int cargc, char **cargv) { | |
18 | nick *sender=source; | |
19 | reguser *rup=getreguserfromnick(sender); | |
20 | reguser *vrup; | |
21 | reguser *dbrup; | |
22 | int i; | |
23 | unsigned int count=0; | |
24 | struct tm *tmp; | |
25 | char buf[200]; | |
26 | ||
27 | if (!rup) | |
28 | return CMD_ERROR; | |
29 | ||
30 | if (cargc < 1) { | |
31 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "suspenduserlist"); | |
32 | return CMD_ERROR; | |
33 | } | |
34 | ||
35 | vrup=findreguserbynick(cargv[0]); | |
36 | ||
37 | chanservstdmessage(sender, QM_SUSPENDUSERLISTHEADER); | |
38 | for (i=0;i<REGUSERHASHSIZE;i++) { | |
39 | for (dbrup=regusernicktable[i]; dbrup; dbrup=dbrup->nextbyname) { | |
40 | if (!UHasSuspension(dbrup)) | |
41 | continue; | |
42 | ||
43 | /*if (!ircd_strcmp(dbrup->username, cargv[0]) || (dbrup->suspendby == vrup->ID)) {*/ | |
44 | if (!match(cargv[0], dbrup->username) || (vrup && (dbrup->suspendby == vrup->ID))) { | |
45 | char suspendtype[100]; | |
46 | char *bywhom=0; | |
47 | ||
48 | if ((UIsGline(dbrup) || UIsDelayedGline(dbrup)) && !UHasOperPriv(rup)) | |
49 | continue; | |
50 | ||
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 | ||
60 | if (vrup && (dbrup->suspendby == vrup->ID)) { | |
61 | bywhom=vrup->username; | |
62 | } | |
63 | else { | |
64 | reguser* trup=findreguserbyID(dbrup->suspendby); | |
65 | if (trup) | |
66 | bywhom=trup->username; | |
67 | } | |
68 | ||
69 | if (dbrup->suspendexp) { | |
70 | tmp=gmtime(&(dbrup->suspendexp)); | |
71 | strftime(buf,15,"%d/%m/%y %H:%M",tmp); | |
72 | } | |
73 | ||
74 | count++; | |
75 | chanservsendmessage(sender, "%-15s %-13s %-15s %-15s %s", dbrup->username, suspendtype, UHasOperPriv(rup)?(bywhom?bywhom:"unknown"):"not shown", (dbrup->suspendexp)?((time(0) >= dbrup->suspendexp)?"next auth":buf):"never", dbrup->suspendreason->content); | |
76 | if (count >= 2000) { | |
77 | chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "users"); | |
78 | return CMD_ERROR; | |
79 | } | |
80 | } | |
81 | } | |
82 | } | |
83 | chanservstdmessage(sender, QM_RESULTCOUNT, count, "user", (count==1)?"":"s"); | |
84 | ||
85 | return CMD_OK; | |
86 | } |