From 63db1fa55aa27cb2db9105a311444c832239427a Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 28 Jul 2005 01:48:35 +0000 Subject: some users complained about restricting fast recommendation will make them not able to recommend different articles. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2968 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/bbs.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 3c12308f..e8314879 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -1847,6 +1847,8 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) int type, maxlength; boardheader_t *bp; static time4_t lastrecommend = 0; + static int lastrecommend_bid = -1; + static char lastrecommend_fname[FNLEN] = ""; bp = getbcache(currbid); if (bp->brdattr & BRD_NORECOMMEND || @@ -1858,12 +1860,26 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) vmsg("您權限不足, 無法推薦!"); return FULLUPDATE; } - if ( (bp->brdattr & BRD_NOFASTRECMD) && - (now - lastrecommend < FASTRECMD_LIMIT)) + + if (bp->brdattr & BRD_NOFASTRECMD) { - vmsg("本板禁止快速連續推文,請再等 %d 秒", - (FASTRECMD_LIMIT - now+lastrecommend)); - return FULLUPDATE; + int d = FASTRECMD_LIMIT - (now - lastrecommend); + const char *s = "推薦同篇文章"; + + if( d > 0 && + !(strncmp(lastrecommend_fname, fhdr->filename, FNLEN) == 0 && + lastrecommend_bid == currbid)) + { + /* not same article, apply 1/10 */ + d = FASTRECMD_LIMIT/10 - (now - lastrecommend); + s = ""; + } + + if (d > 0) + { + vmsg("本板禁止快速連續推文,%s請再等 %d 秒", s, d); + return FULLUPDATE; + } } #ifdef SAFE_ARTICLE_DELETE if (fhdr->filename[0] == '.') { @@ -1971,6 +1987,8 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) inc_goodpost(fhdr->owner, 1); #endif lastrecommend = now; + lastrecommend_bid = currbid; + strncpy(lastrecommend_fname, fhdr->filename, FNLEN); return FULLUPDATE; } -- cgit v1.2.3