summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2014-02-03 21:04:00 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2014-02-03 21:04:00 +0800
commit36c001ebb6ba62097cbba8f0be86f908b706c7db (patch)
tree269945d32e18dec6ccf474ecc1f95734350c119f
parentf3fbf00396d45eac9e73e53626c628e8e9d68808 (diff)
downloadpttbbs-36c001ebb6ba62097cbba8f0be86f908b706c7db.tar
pttbbs-36c001ebb6ba62097cbba8f0be86f908b706c7db.tar.gz
pttbbs-36c001ebb6ba62097cbba8f0be86f908b706c7db.tar.bz2
pttbbs-36c001ebb6ba62097cbba8f0be86f908b706c7db.tar.lz
pttbbs-36c001ebb6ba62097cbba8f0be86f908b706c7db.tar.xz
pttbbs-36c001ebb6ba62097cbba8f0be86f908b706c7db.tar.zst
pttbbs-36c001ebb6ba62097cbba8f0be86f908b706c7db.zip
Enable the minimal badpost duration when set by admins. #1Ixd6K1O (PttBug)
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5910 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/mbbsd/assess.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/pttbbs/mbbsd/assess.c b/pttbbs/mbbsd/assess.c
index ebc54881..ddf585f4 100644
--- a/pttbbs/mbbsd/assess.c
+++ b/pttbbs/mbbsd/assess.c
@@ -14,22 +14,30 @@ inline static void inc(unsigned char *num, int n)
(*num) += n;
}
+static time4_t
+adjust_badpost_time(time4_t timeremovebadpost) {
+ time4_t min_timer;
+
+ // reset timer to at least some days to prevent user directly
+ // canceling his badpost.
+ syncnow();
+ min_timer = (now - (BADPOST_CLEAR_DURATION - BADPOST_MIN_CLEAR_DURATION) *
+ DAY_SECONDS);
+ if (timeremovebadpost < min_timer)
+ timeremovebadpost = min_timer;
+
+ return timeremovebadpost;
+}
+
int
inc_badpost(const char *userid, int num) {
userec_t xuser;
int uid = getuser(userid, &xuser);
- time4_t min_timer;
if (uid <= 0)
return 0;
- // reset timer to at least some days to prevent user directly
- // canceling his badpost.
- min_timer = now - (BADPOST_CLEAR_DURATION - BADPOST_MIN_CLEAR_DURATION) *
- DAY_SECONDS;
- if (xuser.timeremovebadpost < min_timer)
- xuser.timeremovebadpost = min_timer;
-
+ xuser.timeremovebadpost = adjust_badpost_time(xuser.timeremovebadpost);
xuser.badpost += num;
passwd_sync_update(uid, &xuser);
return xuser.badpost;
@@ -185,6 +193,9 @@ reassign_badpost(const char *userid) {
// something changed.
u.badpost = atoi(buf);
+ if (u.badpost > orig_badpost) {
+ u.timeremovebadpost = adjust_badpost_time(u.timeremovebadpost);
+ }
prints("\n使用者 %s 的劣文即將由 %d 改為 %d。請輸入理由(會寄給使用者)\n",
userid, orig_badpost, u.badpost);
if (!getdata(7, 0, "理由: ", reason, sizeof(reason), DOECHO)) {