1 /* Automatically generated by refactor.pl.
4 * CMDNAME: accounthistory
7 * CMDDESC: View password/email history for an account.
8 * CMDFUNC: csa_doaccounthistory
9 * CMDPROTO: int csa_doaccounthistory(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: accounthistory <account>
11 * CMDHELP: Shows password/email history for the specified account.
14 #include "../chanserv.h"
15 #include "../../lib/irc_string.h"
16 #include "../../dbapi/dbapi.h"
21 void csdb_doaccounthistory_real(DBConn
*dbconn
, void *arg
) {
22 nick
*np
=getnickbynumeric((unsigned long)arg
);
25 char *oldpass
, *newpass
, *oldemail
, *newemail
;
26 time_t changetime
, authtime
;
34 pgres
=dbgetresult(dbconn
);
36 if (!dbquerysuccessful(pgres
)) {
37 Error("chanserv", ERR_ERROR
, "Error loading account history data.");
41 if (dbnumfields(pgres
) != 7) {
42 Error("chanserv", ERR_ERROR
, "Account history data format error.");
52 if (!(rup
=getreguserfromnick(np
)) || !UHasOperPriv(rup
)) {
53 Error("chanserv", ERR_ERROR
, "No reguser pointer or oper privs in account history.");
59 chanservsendmessage(np
, "Number: Time: Old password: New password: Old email: New email:");
60 while(dbfetchrow(pgres
)) {
61 userID
=strtoul(dbgetvalue(pgres
, 0), NULL
, 10);
62 changetime
=strtoul(dbgetvalue(pgres
, 1), NULL
, 10);
63 authtime
=strtoul(dbgetvalue(pgres
, 2), NULL
, 10);
64 oldpass
=dbgetvalue(pgres
, 3);
65 newpass
=dbgetvalue(pgres
, 4);
66 oldemail
=dbgetvalue(pgres
, 5);
67 newemail
=dbgetvalue(pgres
, 6);
68 q9strftime(tbuf
, sizeof(tbuf
), changetime
);
69 chanservsendmessage(np
, "#%-6d %-19s %-14s %-14s %-30s %s", ++count
, tbuf
, oldpass
, newpass
, oldemail
, newemail
); /* @TIMELEN */
71 chanservstdmessage(np
, QM_ENDOFLIST
);
76 void csdb_retreiveaccounthistory(nick
*np
, reguser
*rup
, int limit
) {
77 q9u_asyncquery(csdb_doaccounthistory_real
, (void *)np
->numeric
,
78 "SELECT userID, changetime, authtime, oldpassword, newpassword, oldemail, newemail from chanserv.accounthistory where "
79 "userID=%u order by changetime desc limit %d", rup
->ID
, limit
);
82 int csa_doaccounthistory(void *source
, int cargc
, char **cargv
) {
86 if (!(rup
=getreguserfromnick(sender
)))
90 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "accounthistory");
94 if (!(trup
=findreguser(sender
, cargv
[0])))
97 if ((rup
!= trup
) && UHasOperPriv(trup
) && !UHasAdminPriv(rup
)) {
98 chanservstdmessage(sender
, QM_NOACCESS
, "accounthistory", cargv
[0]);
102 csdb_retreiveaccounthistory(sender
, trup
, 10);