summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pttbbs/include/proto.h1
-rw-r--r--pttbbs/include/pttstruct.h3
-rw-r--r--pttbbs/mbbsd/admin.c2
-rw-r--r--pttbbs/mbbsd/board.c26
-rw-r--r--pttbbs/mbbsd/cache.c19
-rw-r--r--pttbbs/mbbsd/stuff.c25
-rw-r--r--pttbbs/mbbsd/user.c3
-rw-r--r--pttbbs/mbbsd/voteboard.c2
8 files changed, 44 insertions, 37 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index 3315a3bc..f9fe7e3f 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -118,6 +118,7 @@ char*getuserid(int num);
int getuser(const char *userid, userec_t *xuser);
int searchnewuser(int mode);
int count_logins(int uid, int show);
+int is_BM_expired(time4_t user_firstlogin, time4_t BMexpire);
int is_BM_cache(int);
int apply_boards(int (*func)(boardheader_t *));
int haspostperm(const char *bname);
diff --git a/pttbbs/include/pttstruct.h b/pttbbs/include/pttstruct.h
index 77a32abf..9a04ea10 100644
--- a/pttbbs/include/pttstruct.h
+++ b/pttbbs/include/pttstruct.h
@@ -200,7 +200,8 @@ typedef struct boardheader_t { /* 256 bytes */
uint8_t post_limit_badpost; /* 發表文章 : 劣文上限 */
char pad3[3];
time4_t SRexpire; /* SR Records expire time */
- char pad4[40];
+ time4_t BMexpire; /* 最後設定板主的時間 */
+ char pad4[36];
} PACKSTRUCT boardheader_t;
// TODO BRD 快爆了,怎麼辦? 準備從 pad3 偷一個來當 attr2 吧...
diff --git a/pttbbs/mbbsd/admin.c b/pttbbs/mbbsd/admin.c
index 854477b6..b7d58b4f 100644
--- a/pttbbs/mbbsd/admin.c
+++ b/pttbbs/mbbsd/admin.c
@@ -646,6 +646,7 @@ m_mod_board(char *bname)
bh.BM)) {
trim(genbuf);
strlcpy(newbh.BM, genbuf, sizeof(newbh.BM));
+ newbh.BMexpire = now;
}
#ifdef CHESSCOUNTRY
if (HasUserPerm(PERM_SYSOP)) {
@@ -994,6 +995,7 @@ m_newbrd(int whatclass, int recover)
newboard.level = 0;
getdata(11, 0, "板主名單:", newboard.BM, sizeof(newboard.BM), DOECHO);
+ newboard.BMexpire = now;
#ifdef CHESSCOUNTRY
if (getdata_str(12, 0, "設定棋國 (0)無 (1)五子棋 (2)象棋 (3)圍棋", ans,
sizeof(ans), LCECHO, "0")){
diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c
index a24f0dc2..1eb3b293 100644
--- a/pttbbs/mbbsd/board.c
+++ b/pttbbs/mbbsd/board.c
@@ -1382,16 +1382,26 @@ show_brdlist(int head, int clsflag, int newflag)
}
static void
-set_menu_BM(char *BM)
+set_menu_BM(char *BM, time4_t expire)
{
- if (!HasUserPerm(PERM_NOCITIZEN) && (HasUserPerm(PERM_ALLBOARD) || is_uBM(BM, cuser.userid))) {
- currmode |= MODE_GROUPOP;
-
- // XXX 不是很確定是否該在這邊 save level?
- if (!HasUserPerm(PERM_SYSSUBOP) || !HasUserPerm(PERM_BM))
- pwcuBitEnableLevel(PERM_SYSSUBOP | PERM_BM);
+ int is_bm = 0;
+ if (HasUserPerm(PERM_NOCITIZEN))
+ return;
+ if (HasUserPerm(PERM_ALLBOARD)) {
+ is_bm = 1;
+ } else if (!is_BM_expired(expire, cuser.firstlogin) && is_uBM(BM, cuser.userid)) {
+ // XXX 小組長是否也該使用 is_BM_expired 呢
+ is_bm = 1;
}
+ if (!is_bm)
+ return;
+
+ currmode |= MODE_GROUPOP;
+ // XXX 不是很確定是否該在這邊 save level?
+ if (!HasUserPerm(PERM_SYSSUBOP) || !HasUserPerm(PERM_BM))
+ pwcuBitEnableLevel(PERM_SYSSUBOP | PERM_BM);
+
}
static void replace_link_by_target(boardstat_t *board)
@@ -1763,7 +1773,7 @@ choose_board(int newflag)
class_bid = -1; /* 熱門群組用 */
if (!GROUPOP()) /* 如果還沒有小組長權限 */
- set_menu_BM(B_BH(ptr)->BM);
+ set_menu_BM(B_BH(ptr)->BM, B_BH(ptr)->BMexpire);
if (now < B_BH(ptr)->bupdate) {
int mr = 0;
diff --git a/pttbbs/mbbsd/cache.c b/pttbbs/mbbsd/cache.c
index 41cb0859..be426743 100644
--- a/pttbbs/mbbsd/cache.c
+++ b/pttbbs/mbbsd/cache.c
@@ -140,10 +140,25 @@ apply_boards(int (*func) (boardheader_t *))
return 0;
}
-int is_BM_cache(int bid) /* bid starts from 1 */
+int
+is_BM_expired(time4_t user_firstlogin, time4_t BMexpire)
+{
+ // XXX 為了解決有人挑過期的帳號註冊以取得 BM 權
+ // 這是很笨很笨而且相關 bug 可能一堆的 workaround,
+ // 不過在全面改寫前看來也只有這樣改最快 (有比沒有好)
+ if (BMexpire)
+ return user_firstlogin > BMexpire;
+ // for legacy boards, allow BMexpire = 0 as 'skip'.
+ return 1;
+}
+
+int
+is_BM_cache(int bid) /* bid starts from 1 */
{
assert(0<=bid-1 && bid-1<MAX_BOARD);
int *pbm = SHM->BMcache[bid-1];
+ boardheader_t *bp = getbcache(bid);
+
// XXX potential issue: (thanks for mtdas@ptt)
// buildBMcache use -1 as "none".
// some function may call is_BM_cache early
@@ -155,6 +170,8 @@ int is_BM_cache(int bid) /* bid starts from 1 */
// reject user who haven't complete registration.
if (!HasUserPerm(PERM_LOGINOK))
return 0;
+ if (is_BM_expired(cuser.firstlogin, bp->BMexpire))
+ return 0;
// XXX hard coded MAX_BMs=4
if( currutmp->uid == pbm[0] ||
currutmp->uid == pbm[1] ||
diff --git a/pttbbs/mbbsd/stuff.c b/pttbbs/mbbsd/stuff.c
index 1381c2e0..364c62ab 100644
--- a/pttbbs/mbbsd/stuff.c
+++ b/pttbbs/mbbsd/stuff.c
@@ -66,31 +66,6 @@ is_uBM(const char *list, const char *id)
return 0;
}
-int
-userid_is_BM(const char *userid, const char *list)
-{
- register int ch, len;
-
- // TODO merge with is_uBM
- ch = list[0];
- if ((ch > ' ') && (ch < 128)) {
- len = strlen(userid);
- do {
- if (!strncasecmp(list, userid, len)) {
- ch = list[len];
- if ((ch == 0) || (ch == '/') || (ch == ']'))
- return 1;
- }
- while ((ch = *list++)) {
- if (ch == '/')
- break;
- }
- } while (ch);
- }
- return 0;
-}
-
-
time4_t
gettime(int line, time4_t dt, const char*head)
{
diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c
index 19b82eba..290c3edb 100644
--- a/pttbbs/mbbsd/user.c
+++ b/pttbbs/mbbsd/user.c
@@ -217,7 +217,8 @@ user_display(const userec_t * u, int adminmode)
outs("\t擔任板主: ");
for (i = 0, bhdr = bcache; i < numboards; i++, bhdr++) {
- if (is_uBM(bhdr->BM, u->userid)) {
+ if ( is_uBM(bhdr->BM, u->userid) &&
+ !is_BM_expired(bhdr->BMexpire, u->firstlogin)) {
outs(bhdr->brdname);
outc(' ');
}
diff --git a/pttbbs/mbbsd/voteboard.c b/pttbbs/mbbsd/voteboard.c
index e278a554..11f7407e 100644
--- a/pttbbs/mbbsd/voteboard.c
+++ b/pttbbs/mbbsd/voteboard.c
@@ -322,7 +322,7 @@ do_voteboard(int type)
do {
if (!getdata(7, 0, "請輸入板主ID:", topic, IDLEN + 1, DOECHO))
return FULLUPDATE;
- }while (!userid_is_BM(topic, bcache[temp - 1].BM));
+ }while (!is_uBM(bcache[temp - 1].BM, topic));
strcat(genbuf, topic);
strcat(genbuf, "\n罷免原因: \n");
break;