]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: whois | |
5 | * CMDLEVEL: QCMD_AUTHED | |
6 | * CMDARGS: 1 | |
7 | * CMDDESC: Displays information about a user. | |
8 | * CMDFUNC: csu_dowhois | |
9 | * CMDPROTO: int csu_dowhois(void *source, int cargc, char **cargv); | |
50cd26d6 | 10 | * CMDHELP: Usage: WHOIS <user> |
11 | * CMDHELP: Displays information about a user, where: | |
12 | * CMDHELP: user - user to request information for, either the nickname of an active user on | |
13 | * CMDHELP: the network or #accountname. | |
1dd6d55d | 14 | */ |
15 | ||
16 | #include "../chanserv.h" | |
17 | #include "../../lib/irc_string.h" | |
18 | #include <stdio.h> | |
19 | #include <string.h> | |
20 | ||
21 | int csu_dowhois(void *source, int cargc, char **cargv) { | |
22 | nick *sender=source; | |
23 | reguser *rup=getreguserfromnick(sender), *target; | |
24 | char buf[200]; | |
25 | char nbpos=0; | |
1dd6d55d | 26 | struct tm *tmp; |
27 | regchanuser *rcup, *rcup2; | |
28 | flag_t flagmask, flags; | |
29 | int doneheader=0; | |
23b85e10 | 30 | authname *anp; |
31 | nick *tnp; | |
1dd6d55d | 32 | |
33 | if (!(rup=getreguserfromnick(sender))) | |
34 | return CMD_ERROR; | |
35 | ||
36 | if (cargc<1) { | |
37 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "whois"); | |
38 | return CMD_ERROR; | |
39 | } | |
40 | ||
41 | if (!(target=findreguser(sender, cargv[0]))) { | |
23b85e10 | 42 | nick *np; |
1dd6d55d | 43 | |
8ae8bd45 | 44 | if (cs_privcheck(QPRIV_VIEWFULLWHOIS, sender) && (np=getnickbynick(cargv[0]))) { |
23b85e10 | 45 | activeuser *aup=getactiveuserfromnick(np); |
1dd6d55d | 46 | chanservsendmessage(sender, "%s has attempted to auth %d time%s.", np->nick, aup->authattempts, |
47 | aup->authattempts==1?"":"s"); | |
48 | } | |
49 | return CMD_ERROR; | |
50 | } | |
51 | ||
52 | if (cargv[0][0]=='#') { | |
53 | chanservstdmessage(sender, QM_WHOISHEADER_AUTH, target->username); | |
54 | } else { | |
55 | chanservstdmessage(sender, QM_WHOISHEADER_NICK, cargv[0], target->username); | |
56 | } | |
57 | ||
58 | if (rup==target || cs_privcheck(QPRIV_VIEWFULLWHOIS, sender)) { | |
59 | chanservstdmessage(sender, QM_WHOIS_USERID, target->ID); | |
60 | } | |
61 | ||
62 | if (cs_privcheck(QPRIV_VIEWUSERFLAGS, sender)) { | |
63 | flagmask=QUFLAG_ALL; | |
64 | } else { | |
65 | if (UIsAdmin(target)) | |
66 | chanservstdmessage(sender, QM_USERISADMIN, target->username); | |
67 | else if (UIsOper(target)) | |
68 | chanservstdmessage(sender, QM_USERISOPER, target->username); | |
69 | else if (UIsHelper(target)) | |
70 | chanservstdmessage(sender, QM_USERISHELPER, target->username); | |
71 | ||
72 | if (UIsDev(target)) | |
73 | chanservstdmessage(sender, QM_USERISDEV, target->username); | |
74 | ||
75 | flagmask=0; | |
76 | } | |
77 | ||
78 | if (rup==target) | |
79 | flagmask|=(QUFLAG_OPER | QUFLAG_DEV | QUFLAG_HELPER | | |
80 | QUFLAG_ADMIN | QUFLAG_INFO | QUFLAG_NOTICE); | |
81 | ||
82 | if (flagmask & target->flags) | |
43583524 | 83 | chanservstdmessage(sender, QM_WHOIS_FLAGS, printflagsornone(flagmask & target->flags, ruflags)); |
1dd6d55d | 84 | |
23b85e10 | 85 | if (!(anp=findauthname(target->ID)) || !anp->nicks) { |
1dd6d55d | 86 | chanservstdmessage(sender, QM_WHOIS_USERS, "(none)"); |
87 | } else { | |
23b85e10 | 88 | for (tnp=anp->nicks; ;tnp=tnp->nextbyauthname) { |
89 | if (nbpos>0 && (!tnp || nbpos+strlen(tnp->nick) > 60)) { | |
1dd6d55d | 90 | chanservstdmessage(sender, QM_WHOIS_USERS, buf); |
91 | nbpos=0; | |
92 | } | |
93 | ||
23b85e10 | 94 | if (!tnp) |
1dd6d55d | 95 | break; |
96 | ||
23b85e10 | 97 | nbpos+=sprintf(buf+nbpos,"%s ",tnp->nick); |
1dd6d55d | 98 | } |
99 | } | |
100 | ||
101 | if (target->created) { | |
102 | tmp=gmtime(&(target->created)); | |
103 | strftime(buf,15,"%d/%m/%y %H:%M",tmp); | |
104 | ||
105 | chanservstdmessage(sender, QM_WHOIS_CREATED, buf); | |
106 | } | |
107 | ||
cf50e022 CP |
108 | if (target->lastauth == 0) { |
109 | snprintf(buf,sizeof(buf),"(never)"); | |
110 | } else { | |
111 | tmp=gmtime(&(target->lastauth)); | |
112 | strftime(buf,15,"%d/%m/%y %H:%M",tmp); | |
113 | } | |
1dd6d55d | 114 | chanservstdmessage(sender, QM_WHOIS_LASTAUTH, buf); |
115 | ||
116 | if (target->lastuserhost && (rup==target || cs_privcheck(QPRIV_VIEWFULLWHOIS, sender))) { | |
50cd26d6 | 117 | /* Commenting out language until we implement some - splidge |
1dd6d55d | 118 | chanservstdmessage(sender, QM_WHOIS_USERLANG, cslanguages[target->languageid] ? |
50cd26d6 | 119 | cslanguages[target->languageid]->name->content : "(unknown)"); */ |
1dd6d55d | 120 | chanservstdmessage(sender, QM_WHOIS_LASTUSERHOST, target->lastuserhost->content); |
121 | } | |
122 | ||
123 | if (target->email && (rup==target || cs_privcheck(QPRIV_VIEWEMAIL, sender))) { | |
124 | chanservstdmessage(sender, QM_WHOIS_EMAIL, target->email->content); | |
125 | ||
126 | tmp=gmtime(&(target->lastemailchange)); | |
127 | strftime(buf,15,"%d/%m/%y %H:%M",tmp); | |
128 | ||
129 | chanservstdmessage(sender, QM_WHOIS_EMAILSET, buf); | |
130 | } | |
131 | ||
132 | if (target->info) { | |
133 | chanservstdmessage(sender, QM_WHOIS_INFO, target->info->content); | |
134 | } | |
135 | ||
136 | if (target->comment && (cs_privcheck(QPRIV_VIEWCOMMENTS, sender))) { | |
137 | chanservstdmessage(sender, QM_WHOIS_COMMENT, target->comment->content); | |
138 | } | |
139 | ||
140 | for (rcup=target->knownon;rcup;rcup=rcup->nextbyuser) { | |
a19424d6 | 141 | if (!UHasHelperPriv(rup) || (UHasOperPriv(target) && UHasHelperPriv(rup) && !UHasOperPriv(rup))) { |
1dd6d55d | 142 | if (!(rcup2=findreguseronchannel(rcup->chan,rup))) |
143 | continue; | |
144 | ||
145 | if (!CUHasVoicePriv(rcup2)) | |
146 | continue; | |
147 | ||
148 | flagmask = (QCUFLAG_OWNER | QCUFLAG_MASTER | QCUFLAG_OP | QCUFLAG_VOICE | QCUFLAG_AUTOVOICE | | |
72ca906c | 149 | QCUFLAG_AUTOOP | QCUFLAG_TOPIC); |
1dd6d55d | 150 | |
151 | if (CUHasMasterPriv(rcup2)) | |
152 | flagmask |= (QCUFLAG_DENY | QCUFLAG_QUIET | QCUFLAG_BANNED); | |
153 | } else { | |
154 | flagmask=QCUFLAG_ALL; | |
155 | } | |
156 | ||
157 | if (!(flags=rcup->flags & flagmask)) | |
158 | continue; | |
159 | ||
160 | if (!doneheader) { | |
161 | doneheader=1; | |
162 | chanservstdmessage(sender, QM_WHOIS_CHANHEADER, target->username); | |
163 | } | |
164 | ||
165 | chanservsendmessage(sender, " %-30s %s",rcup->chan->index->name->content,printflags(flags, rcuflags)); | |
166 | } | |
167 | ||
168 | chanservstdmessage(sender, QM_ENDOFLIST); | |
169 | ||
170 | return CMD_OK; | |
171 | } |