int users_not_purged;
char *users_corrupt_msg = NULL;
char *users_zero_msg = NULL;
-
struct ctdlroomref *rr = NULL;
-
extern struct CitContext *ContextList;
+int force_purge_now = 0; /* set to nonzero to force a run right now */
/*
return;
}
+
/* If the room is set to expire by count, do that */
if (epbuf.expire_mode == EXPIRE_NUMMSGS) {
if (num_msgs > epbuf.expire_value) {
/* The default rule is to not purge. */
purge = 0;
+
+ /* don't attempt to purge system users. */
+ if (!strncmp(us->fullname, "SYS_", 4))
+ goto skip_all_this;
/* If the user hasn't called in two months and expiring of accounts is turned on, his/her account
* has expired, so purge the record.
}
}
-
+skip_all_this:
+
if (purge == 1) {
pptr = (struct PurgeList *) malloc(sizeof(struct PurgeList));
pptr->next = UserPurgeList;
ForEachUser(do_uid_user_purge, NULL);
break;
default:
- CtdlLogPrintf(CTDL_DEBUG, "Unknown authentication mode!\n");
+ CtdlLogPrintf(CTDL_DEBUG, "User purge for auth mode %d is not implemented.\n",
+ config.c_auth_mode);
break;
}
char *deleteme = NULL;
long len;
void *Value;
- char *Key;
+ const char *Key;
int num_deleted = 0;
keys = NewHash(1, NULL);
/* Go through the hash list, deleting keys we stored in it */
- HashPos = GetNewHashPos();
+ HashPos = GetNewHashPos(keys, 0);
while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
{
CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n", Value);
*/
now = time(NULL);
localtime_r(&now, &tm);
- if ((tm.tm_hour != config.c_purge_hour) || ((now - last_purge) < 43200)) {
+ if (
+ ((tm.tm_hour != config.c_purge_hour) || ((now - last_purge) < 43200))
+ && (force_purge_now == 0)
+ ) {
CtdlThreadSleep(60);
continue;
}
{
CtdlLogPrintf(CTDL_INFO, "Auto-purger: finished.\n");
last_purge = now; /* So we don't do it again soon */
+ force_purge_now = 0;
}
else
CtdlLogPrintf(CTDL_INFO, "Auto-purger: STOPPED.\n");
/*****************************************************************************/
+/* The FSCK command has been removed because people were misusing it */
+
+#if 0
+
void do_fsck_msg(long msgnum, void *userdata) {
struct ctdlroomref *ptr;
}
+#endif /* end of commented-out fsck cmd */
+/*
+ * Manually initiate a run of The Dreaded Auto-Purger (tm)
+ */
+void cmd_tdap(char *argbuf) {
+ if (CtdlAccessCheck(ac_aide)) return;
+ force_purge_now = 1;
+ cprintf("%d Manually initiating a purger run now.\n", CIT_OK);
+}
/*****************************************************************************/
{
if (!threading)
{
- CtdlRegisterProtoHook(cmd_fsck, "FSCK", "Check message ref counts");
+ /* CtdlRegisterProtoHook(cmd_fsck, "FSCK", "Check message ref counts"); */
+ CtdlRegisterProtoHook(cmd_tdap, "TDAP", "Manually initiate auto-purger");
}
else
CtdlThreadCreate("Auto Purger", CTDLTHREAD_BIGSTACK, purge_databases, NULL);