]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/cleanupdb.c
Various changes to bring us into 2008
[irc/quakenet/newserv.git] / chanserv / usercmds / cleanupdb.c
1 /* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: cleanupdb
5 * CMDLEVEL: QCMD_OPER
6 * CMDARGS: 0
7 * CMDDESC: Clean Up Db
8 * CMDFUNC: csu_docleanupdb
9 * CMDPROTO: int csu_docleanupdb(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_docleanupdb(void *source, int cargc, char **cargv) {
18 nick *sender=source;
19 reguser *vrup, *srup;
20 authname *anp;
21 int i;
22 long to_age = 0L;
23 struct tm *tmp;
24 char buf[200];
25 int j = 0;
26 to_age = time(NULL) - (80 * 3600 * 24);
27
28 for (i=0;i<REGUSERHASHSIZE;i++) {
29 for (vrup=regusernicktable[i]; vrup; vrup=srup) {
30 srup=vrup->nextbyname;
31 if (!(anp=findauthname(vrup->ID)))
32 continue; /* should maybe raise hell instead */
33
34 if(!anp->nicks && vrup->lastauth < to_age && !UHasHelperPriv(vrup) && !UIsCleanupExempt(vrup)) {
35 tmp=gmtime(&(vrup->lastauth));
36 strftime(buf,15,"%d/%m/%y %H:%M",tmp);
37
38 cs_removeuser(vrup);
39 j++;
40 }
41 }
42 }
43
44 chanservsendmessage(sender, "Removed %d Accounts (not used for 80 days)", j);
45 return CMD_OK;
46 }