From 3a014d927e393b889f074113c0a398ddb04807b2 Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 1 Dec 2007 12:42:33 +0000 Subject: - sync ptt2 local modification - refine post/vote restriction magic code - color in making recommend git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3603 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/voteboard.c | 56 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'mbbsd/voteboard.c') diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 10594079..1e983391 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -2,6 +2,45 @@ #include "bbs.h" #define VOTEBOARD "NewBoard" + +// user +int CheckVoteRestriction(int bid) +{ + if ((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP)) + return 1; + + // check first-login + if (cuser.firstlogin > (now - (time4_t)bcache[bid - 1].vote_limit_regtime * 2592000)) + return 0; + if (cuser.numlogins / 10 < (unsigned int)bcache[bid - 1].vote_limit_logins) + return 0; + if (cuser.numposts / 10 < (unsigned int)bcache[bid - 1].vote_limit_posts) + return 0; + if (cuser.badpost > (255 - (unsigned int)bcache[bid - 1].vote_limit_badpost)) + return 0; + + return 1; +} + +// article +int CheckVoteRestrictionFile(const fileheader_t * fhdr) +{ + if ((currmode & MODE_BOARD) || HasUserPerm(PERM_SYSOP)) + return 1; + + // check first-login + if (cuser.firstlogin > (now - (time4_t)fhdr->multi.vote_limits.regtime * 2592000)) + return 0; + if (cuser.numlogins / 10 < (unsigned int)fhdr->multi.vote_limits.logins) + return 0; + if (cuser.numposts / 10 < (unsigned int)fhdr->multi.vote_limits.posts) + return 0; + if (cuser.badpost > (255 - (unsigned int)fhdr->multi.vote_limits.badpost)) + return 0; + + return 1; +} + void do_voteboardreply(const fileheader_t * fhdr) { @@ -24,11 +63,10 @@ do_voteboardreply(const fileheader_t * fhdr) vmsg("對不起,您目前無法在此發表文章!"); return; } - if (cuser.firstlogin > (now - (time4_t)fhdr->multi.vote_limits.regtime * 2592000) || - cuser.badpost > (255 - (unsigned int)(fhdr->multi.vote_limits.badpost)) || - cuser.numlogins < ((unsigned int)(fhdr->multi.vote_limits.logins) * 10) || - cuser.numposts < ((unsigned int)(fhdr->multi.vote_limits.posts) * 10) ) { - move(5, 10); + + if (!CheckVoteRestrictionFile(fhdr)) + { + move(5, 10); // why move (5, 10)? vmsg("你不夠資深喔! (可按大寫 I 查看限制)"); return; } @@ -169,11 +207,9 @@ do_voteboard(int type) vmsg("對不起,您目前無法在此發表文章!"); return FULLUPDATE; } - if ( cuser.firstlogin > (now - (time4_t)bcache[currbid - 1].vote_limit_regtime * 2592000) || - cuser.badpost > (255 - (unsigned int)(bcache[currbid - 1].vote_limit_badpost)) || - cuser.numlogins < ((unsigned int)(bcache[currbid - 1].vote_limit_logins) * 10) || - cuser.numposts < ((unsigned int)(bcache[currbid - 1].vote_limit_posts) * 10) ) { - move(5, 10); + if (!CheckVoteRestriction(currbid)) + { + move(5, 10); // why move (5, 10)? vmsg("你不夠資深喔! (可按大寫 I 查看限制)"); return FULLUPDATE; } -- cgit v1.2.3