Fixed group stat counter for user posted messages

This commit is contained in:
Michiel Broek 2004-05-11 13:23:31 +00:00
parent 76d22550a1
commit 0119dbe0f2
4 changed files with 67 additions and 4 deletions

View File

@ -72,6 +72,8 @@ v0.51.4 11-Apr-2004
used if configured with --enable-experiment.
The users tag directory wasn't properly cleaned before a new
download session.
The message group stat counters were not updated when a user
posted a message at the bbs.
mball:
Added new experimental files database code which will only be
@ -88,6 +90,7 @@ v0.51.4 11-Apr-2004
without a file header.
Added new experimental files database code which will only be
used if configured with --enable-experiment.
Message group setup now sets mode 660 for ~/etc/mgroups.data.
mbtask:
Removed debug logging for the disk thread.

View File

@ -64,7 +64,7 @@ static int removereturnto;
*/
extern char *replyaddr;
extern int do_mailout;
extern int grecno;
/*
@ -129,6 +129,7 @@ int rfc2ftn(FILE *fp)
int sot_kludge = FALSE, eot_kludge = FALSE, tinyorigin = FALSE;
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders;
time_t Now;
struct tm *l_date;
temp = calloc(4097, sizeof(char));
Syslog('m', "Entering rfc2ftn");
@ -670,16 +671,52 @@ int rfc2ftn(FILE *fp)
Syslog('+', "Msg (%ld) to \"%s\", \"%s\"", Msg.Id, Msg.To, Msg.Subject);
do_mailout = TRUE;
/*
* Create fast scan index
*/
sprintf(temp, "%s/tmp/echomail.jam", getenv("MBSE_ROOT"));
if ((qfp = fopen(temp, "a")) != NULL) {
fprintf(qfp, "%s %lu\n", msgs.Base, Msg.Id);
fclose(qfp);
}
/*
* Link messages
*/
rc = Msg_Link(msgs.Base, TRUE, CFG.slow_util);
if (rc != -1)
Syslog('+', "Linked %d message%s", rc, (rc != 1) ? "s":"");
else
Syslog('+', "Could not link messages");
/*
* Update statistical counters
*/
Now = time(NULL);
l_date = localtime(&Now);
msgs.LastPosted = time(NULL);
msgs.Posted.total++;
msgs.Posted.tweek++;
msgs.Posted.tdow[l_date->tm_wday]++;
msgs.Posted.month[l_date->tm_mon]++;
mgroup.LastDate = time(NULL);
mgroup.MsgsSent.total++;
mgroup.MsgsSent.tweek++;
mgroup.MsgsSent.tdow[l_date->tm_wday]++;
mgroup.MsgsSent.month[l_date->tm_mon]++;
UpdateMsgs();
sprintf(temp, "%s/etc/users.data", getenv("MBSE_ROOT"));
if ((qfp = fopen(temp, "r+"))) {
fread(&usrconfighdr, sizeof(usrconfighdr), 1, qfp);
fseek(qfp, usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize), SEEK_SET);
if (fread(&usrconfig, usrconfighdr.recsize, 1, qfp) == 1) {
usrconfig.iPosted++;
fseek(qfp, usrconfighdr.hdrsize + (grecno * usrconfighdr.recsize), SEEK_SET);
fwrite(&usrconfig, usrconfighdr.recsize, 1, qfp);
}
fclose(qfp);
}
}
Msg_Close();
}

View File

@ -854,6 +854,29 @@ int Save_Msg(int IsReply, faddr *Dest)
fclose(fp);
}
if (strlen(msgs.Group)) {
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r+")) != NULL) {
fread(&mgrouphdr, sizeof(mgrouphdr), 1, fp);
while ((fread(&mgroup, mgrouphdr.recsize, 1, fp)) == 1) {
if (!strcmp(msgs.Group, mgroup.Name)) {
mgroup.LastDate = time(NULL);
mgroup.MsgsSent.total++;
mgroup.MsgsSent.tweek++;
mgroup.MsgsSent.tdow[l_date->tm_wday]++;
mgroup.MsgsSent.month[l_date->tm_mon]++;
fseek(fp, - mgrouphdr.recsize, SEEK_CUR);
fwrite(&mgroup, mgrouphdr.recsize, 1, fp);
break;
}
}
fclose(fp);
} else {
WriteError("$Save_Msg(): Can't open %s", temp);
}
}
/*
* Add quick mailscan info
*/

View File

@ -72,7 +72,7 @@ int CountMGroup(void)
mgroup.Active = TRUE;
fwrite(&mgroup, sizeof(mgroup), 1, fil);
fclose(fil);
chmod(ffile, 0640);
chmod(ffile, 0660);
return 2;
} else
return -1;
@ -205,7 +205,7 @@ void CloseMGroup(int force)
fclose(fi);
fclose(fo);
unlink(fout);
chmod(fin, 0640);
chmod(fin, 0660);
disk_reset();
Syslog('+', "Updated \"mgroups.data\"");
if (!force)
@ -213,7 +213,7 @@ void CloseMGroup(int force)
return;
}
}
chmod(fin, 0640);
chmod(fin, 0660);
working(1, 0, 0);
unlink(fout);
}