diff --git a/src/sbbs3/download.cpp b/src/sbbs3/download.cpp index 63effc0d95a6f931b4d05ef7f4c8c99e24416d21..8e62acc77217fc137873a2a989353cec4ef2f800 100644 --- a/src/sbbs3/download.cpp +++ b/src/sbbs3/download.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -67,8 +67,7 @@ void sbbs_t::downloadfile(file_t* f) /****************************/ /* Update Downloader's Info */ /****************************/ - useron.dls=(ushort)adjustuserrec(&cfg,useron.number,U_DLS,5,1); - useron.dlb=adjustuserrec(&cfg,useron.number,U_DLB,10,length); + user_downloaded(&cfg, &useron, 1, length); if(!is_download_free(&cfg,f->dir,&useron)) subtract_cdt(&cfg,&useron,f->cdt); /**************************/ diff --git a/src/sbbs3/email.cpp b/src/sbbs3/email.cpp index 4952a8855e81116e21408abc74b4ad10e563c2fb..17b0c830cf41cd0a3ccb7148306fa5aac4e2277f 100644 --- a/src/sbbs3/email.cpp +++ b/src/sbbs3/email.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -301,16 +301,11 @@ bool sbbs_t::email(int usernumber, char *top, char *subj, long mode) return(false); } - if(usernumber==1) { - useron.fbacks++; + if(usernumber==1) logon_fbacks++; - putuserrec(&cfg,useron.number,U_FBACKS,5,ultoa(useron.fbacks,tmp,10)); } - else { - useron.emails++; + else logon_emails++; - putuserrec(&cfg,useron.number,U_EMAILS,5,ultoa(useron.emails,tmp,10)); } - useron.etoday++; - putuserrec(&cfg,useron.number,U_ETODAY,5,ultoa(useron.etoday,tmp,10)); + user_sent_email(&cfg, &useron, usernumber, 1); bprintf(text[Emailed],username(&cfg,usernumber,tmp),usernumber); sprintf(str,"%s sent e-mail to %s #%d" ,useron.alias,username(&cfg,usernumber,tmp),usernumber); diff --git a/src/sbbs3/ftpsrvr.c b/src/sbbs3/ftpsrvr.c index c0414f18ecaf72c95ab9ab44f35a8d0790a279d8..8d67ff3341d2873bacbcf800f643632b459b44b5 100644 --- a/src/sbbs3/ftpsrvr.c +++ b/src/sbbs3/ftpsrvr.c @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -1566,8 +1566,7 @@ static void send_thread(void* arg) } if(xfer.credits) { - xfer.user->dls=(ushort)adjustuserrec(&scfg, xfer.user->number,U_DLS,5,1); - xfer.user->dlb=adjustuserrec(&scfg, xfer.user->number,U_DLB,10,total); + user_downloaded(&scfg, xfer.user, 1, total); if(xfer.dir>=0 && !is_download_free(&scfg,xfer.dir,xfer.user)) subtract_cdt(&scfg, xfer.user, xfer.credits); } @@ -1837,9 +1836,7 @@ static void receive_thread(void* arg) /**************************/ /* Update Uploader's Info */ /**************************/ - if(!xfer.append && xfer.filepos==0) - xfer.user->uls=(short)adjustuserrec(&scfg, xfer.user->number,U_ULS,5,1); - xfer.user->ulb=adjustuserrec(&scfg, xfer.user->number,U_ULB,10,total); + user_uploaded(&scfg, xfer.user, (!xfer.append && xfer.filepos==0) ? 1:0, total); if(scfg.dir[f.dir]->up_pct && scfg.dir[f.dir]->misc&DIR_CDTUL) { /* credit for upload */ if(scfg.dir[f.dir]->misc&DIR_CDTMIN && cps) /* Give min instead of cdt */ xfer.user->min=adjustuserrec(&scfg,xfer.user->number,U_MIN,10 diff --git a/src/sbbs3/postmsg.cpp b/src/sbbs3/postmsg.cpp index 89e900d1bbe9cd6d8215aa17abe40fff8fb85f1d..a6fa399e40ebafd583c4c425c2fa0d2484e182ff 100644 --- a/src/sbbs3/postmsg.cpp +++ b/src/sbbs3/postmsg.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -382,11 +382,8 @@ bool sbbs_t::postmsg(uint subnum, smbmsg_t *remsg, long wm_mode) return(false); } - useron.ptoday++; - useron.posts++; logon_posts++; - putuserrec(&cfg,useron.number,U_POSTS,5,ultoa(useron.posts,str,10)); - putuserrec(&cfg,useron.number,U_PTODAY,5,ultoa(useron.ptoday,str,10)); + user_posted_msg(&cfg, &useron, 1); bprintf(text[Posted],cfg.grp[cfg.sub[subnum]->grp]->sname ,cfg.sub[subnum]->lname); sprintf(str,"%s posted on %s %s" diff --git a/src/sbbs3/un_rep.cpp b/src/sbbs3/un_rep.cpp index befc1cb423860f587bade4abec79e0c17b6d34ec..e8d6a254641d6414d84de374a10ab2d5ba12b863 100644 --- a/src/sbbs3/un_rep.cpp +++ b/src/sbbs3/un_rep.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -447,11 +447,8 @@ bool sbbs_t::unpack_rep(char* repfile) if(!qwktomsg(rep,block,0,n,0)) continue; - useron.ptoday++; - useron.posts++; logon_posts++; - putuserrec(&cfg,useron.number,U_POSTS,5,ultoa(useron.posts,str,10)); - putuserrec(&cfg,useron.number,U_PTODAY,5,ultoa(useron.ptoday,str,10)); + user_posted_msg(&cfg, &useron, 1); bprintf(text[Posted],cfg.grp[cfg.sub[n]->grp]->sname ,cfg.sub[n]->lname); sprintf(str,"%s posted on %s %s" diff --git a/src/sbbs3/upload.cpp b/src/sbbs3/upload.cpp index d28dcd172d892860e4571e7ed0eb8f4ca2190652..d1690ae7a81651c86891bb5855f8d3df2c0c9512 100644 --- a/src/sbbs3/upload.cpp +++ b/src/sbbs3/upload.cpp @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -223,8 +223,7 @@ bool sbbs_t::uploadfile(file_t *f) /**************************/ /* Update Uploader's Info */ /**************************/ - useron.uls=(ushort)adjustuserrec(&cfg,useron.number,U_ULS,5,1); - useron.ulb=(ushort)adjustuserrec(&cfg,useron.number,U_ULB,10,length); + user_uploaded(&cfg, &useron, 1, length); if(cfg.dir[f->dir]->up_pct && cfg.dir[f->dir]->misc&DIR_CDTUL) { /* credit for upload */ if(cfg.dir[f->dir]->misc&DIR_CDTMIN && cur_cps) /* Give min instead of cdt */ useron.min=adjustuserrec(&cfg,useron.number,U_MIN,10 diff --git a/src/sbbs3/userdat.c b/src/sbbs3/userdat.c index abd778201634d6009eda0d869bf7f7de008d15b5..a8b45ab7571ee93a7575405b8e9bb7d7d68ed8d9 100644 --- a/src/sbbs3/userdat.c +++ b/src/sbbs3/userdat.c @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -1875,6 +1875,76 @@ void DLLCALL subtract_cdt(scfg_t* cfg, user_t* user, long amt) user->cdt=adjustuserrec(cfg, user->number,U_CDT,10,-amt); } +BOOL DLLCALL user_posted_msg(scfg_t* cfg, user_t* user, int count) +{ + if(user==NULL) + return(FALSE); + + user->posts =(ushort)adjustuserrec(cfg, user->number, U_POSTS, 5, count); + user->ptoday=(ushort)adjustuserrec(cfg, user->number, U_PTODAY, 5, count); + + return(TRUE); +} + +BOOL DLLCALL user_sent_email(scfg_t* cfg, user_t* user, unsigned to_user, int count) +{ + if(user==NULL) + return(FALSE); + + if(to_user==1) + user->fbacks=(ushort)adjustuserrec(cfg, user->number, U_FBACKS, 5, count); + else + user->emails=(ushort)adjustuserrec(cfg, user->number, U_EMAILS, 5, count); + user->etoday=(ushort)adjustuserrec(cfg, user->number, U_ETODAY, 5, count); + + return(TRUE); +} + +BOOL DLLCALL user_downloaded(scfg_t* cfg, user_t* user, int files, long bytes) +{ + if(user==NULL) + return(FALSE); + + user->dls=(ushort)adjustuserrec(cfg, user->number, U_DLS, 5, files); + user->dlb=adjustuserrec(cfg, user->number, U_DLB, 10, bytes); + + return(TRUE); +} + +BOOL DLLCALL user_uploaded(scfg_t* cfg, user_t* user, int files, long bytes) +{ + if(user==NULL) + return(FALSE); + + user->uls=(ushort)adjustuserrec(cfg, user->number, U_ULS, 5, files); + user->ulb=adjustuserrec(cfg, user->number, U_ULB, 10, bytes); + + return(TRUE); +} + +BOOL DLLCALL user_credits_adjusted(scfg_t* cfg, user_t* user, long amount) +{ + if(user==NULL) + return(FALSE); + + if(amount<0) /* subtract */ + subtract_cdt(cfg, user, -amount); + else /* add */ + user->cdt=adjustuserrec(cfg, user->number, U_CDT, 10, amount); + + return(TRUE); +} + +BOOL DLLCALL user_minutes_adjusted(scfg_t* cfg, user_t* user, long amount) +{ + if(user==NULL) + return(FALSE); + + user->min=adjustuserrec(cfg, user->number, U_MIN, 10, amount); + + return(TRUE); +} + /****************************************************************************/ /****************************************************************************/ BOOL DLLCALL logoutuserdat(scfg_t* cfg, user_t* user, time_t now, time_t logontime) diff --git a/src/sbbs3/userdat.h b/src/sbbs3/userdat.h index 5346aee44dd4d357858a57a7197e29b9e2fed175..05113094eb118d08af7327f86ba1a8b765695d96 100644 --- a/src/sbbs3/userdat.h +++ b/src/sbbs3/userdat.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -109,6 +109,14 @@ DLLEXPORT int DLLCALL user_rec_len(int offset); DLLEXPORT BOOL DLLCALL is_download_free(scfg_t* cfg, uint dirnum, user_t* user); DLLEXPORT BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* host, char* ip_addr, char* username, char* fname); +/* New atomic numeric user field adjustment functions: */ +DLLEXPORT BOOL DLLCALL user_posted_msg(scfg_t* cfg, user_t* user, int count); +DLLEXPORT BOOL DLLCALL user_sent_email(scfg_t* cfg, user_t* user, unsigned to_user, int count); +DLLEXPORT BOOL DLLCALL user_downloaded(scfg_t* cfg, user_t* user, int files, long bytes); +DLLEXPORT BOOL DLLCALL user_uploaded(scfg_t* cfg, user_t* user, int files, long bytes); +DLLEXPORT BOOL DLLCALL user_credits_adjusted(scfg_t* cfg, user_t* user, long amount); +DLLEXPORT BOOL DLLCALL user_minutes_adjusted(scfg_t* cfg, user_t* user, long amount); + #ifdef __cplusplus } #endif