]>
Commit | Line | Data |
---|---|---|
1 | /* Automatically generated by refactor.pl. | |
2 | * | |
3 | * | |
4 | * CMDNAME: spewpassword | |
5 | * CMDALIASES: spewpass | |
6 | * CMDLEVEL: QCMD_OPER | |
7 | * CMDARGS: 2 | |
8 | * CMDDESC: Search for a password in the database. | |
9 | * CMDFUNC: csu_dospewpass | |
10 | * CMDPROTO: int csu_dospewpass(void *source, int cargc, char **cargv); | |
11 | * CMDHELP: Usage: @UCOMMAND@ <pattern> <reason> | |
12 | * CMDHELP: Displays all users with the specified password. | |
13 | */ | |
14 | ||
15 | #include "../chanserv.h" | |
16 | #include "../../lib/irc_string.h" | |
17 | #include <stdio.h> | |
18 | #include <string.h> | |
19 | ||
20 | int csu_dospewpass(void *source, int cargc, char **cargv) { | |
21 | nick *sender=source; | |
22 | reguser *rup=getreguserfromnick(sender); | |
23 | reguser *dbrup; | |
24 | int i; | |
25 | unsigned int count=0; | |
26 | char *reason; | |
27 | ||
28 | if (!rup) | |
29 | return CMD_ERROR; | |
30 | ||
31 | if (cargc < 2) { | |
32 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "spewpassword"); | |
33 | return CMD_ERROR; | |
34 | } | |
35 | ||
36 | reason = cargv[1]; | |
37 | if(!checkreason(sender, reason)) | |
38 | return CMD_ERROR; | |
39 | ||
40 | cs_log(sender, "SPEWPASSWORD %s (reason: %s)", cargv[0], reason); | |
41 | chanservwallmessage("%s (%s) using SPEWPASSWORD (see log for password), reason: %s", sender->nick, rup->username, reason); | |
42 | ||
43 | chanservstdmessage(sender, QM_SPEWHEADER); | |
44 | for (i=0;i<REGUSERHASHSIZE;i++) { | |
45 | for (dbrup=regusernicktable[i]; dbrup; dbrup=dbrup->nextbyname) { | |
46 | if (!UHasStaffPriv(dbrup) && !strcmp(cargv[0], dbrup->password)) { | |
47 | chanservsendmessage(sender, "%-15s %-10s %-30s %s", dbrup->username, UHasSuspension(dbrup)?"yes":"no", dbrup->email?dbrup->email->content:"none set", dbrup->lastuserhost?dbrup->lastuserhost->content:"none"); | |
48 | count++; | |
49 | if (count >= 2000) { | |
50 | chanservstdmessage(sender, QM_TOOMANYRESULTS, 2000, "users"); | |
51 | return CMD_ERROR; | |
52 | } | |
53 | } | |
54 | } | |
55 | } | |
56 | chanservstdmessage(sender, QM_RESULTCOUNT, count, "user", (count==1)?"":"s"); | |
57 | ||
58 | return CMD_OK; | |
59 | } |