summaryrefslogtreecommitdiffstats
path: root/mbbsd/voteboard.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-12-01 20:42:33 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-12-01 20:42:33 +0800
commit3a014d927e393b889f074113c0a398ddb04807b2 (patch)
treef439934fd5b732020126453d88ba3648070ff778 /mbbsd/voteboard.c
parent4c256182f70ad244e0ec40af45c0c0857abb0a01 (diff)
downloadpttbbs-3a014d927e393b889f074113c0a398ddb04807b2.tar
pttbbs-3a014d927e393b889f074113c0a398ddb04807b2.tar.gz
pttbbs-3a014d927e393b889f074113c0a398ddb04807b2.tar.bz2
pttbbs-3a014d927e393b889f074113c0a398ddb04807b2.tar.lz
pttbbs-3a014d927e393b889f074113c0a398ddb04807b2.tar.xz
pttbbs-3a014d927e393b889f074113c0a398ddb04807b2.tar.zst
pttbbs-3a014d927e393b889f074113c0a398ddb04807b2.zip
- 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
Diffstat (limited to 'mbbsd/voteboard.c')
-rw-r--r--mbbsd/voteboard.c56
1 files changed, 46 insertions, 10 deletions
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;
}