diff options
-rw-r--r-- | include/modes.h | 17 | ||||
-rw-r--r-- | include/proto.h | 1 | ||||
-rw-r--r-- | mbbsd/bbs.c | 41 | ||||
-rw-r--r-- | mbbsd/board.c | 16 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 5 | ||||
-rw-r--r-- | mbbsd/voteboard.c | 4 |
6 files changed, 47 insertions, 37 deletions
diff --git a/include/modes.h b/include/modes.h index dc97a06b..16d23754 100644 --- a/include/modes.h +++ b/include/modes.h @@ -104,14 +104,15 @@ #define XEASY 0x333 /* Return value to un-redraw screen */ /* for currmode */ -#define MODE_STARTED 1 /* 是否已經進入系統 */ -#define MODE_POST 2 /* 是否可以在 currboard 發表文章 */ -#define MODE_BOARD 4 /* 是否可以在 currboard 刪除、mark文章 */ -#define MODE_GROUPOP 8 /* 是否為小組長 (可以在 MENU 開板) */ -#define MODE_DIGEST 0x10 /* 是否為 digest mode */ -#define MODE_ETC 0x20 /* 是否為 etc mode */ -#define MODE_SELECT 0x40 /* 搜尋使用者標題 */ -#define MODE_DIRTY 0x80 /* 是否更動過 userflag */ +#define MODE_STARTED 0x0001 /* 是否已經進入系統 */ +#define MODE_POST 0x0002 /* 是否可以在 currboard 發表文章 */ +#define MODE_POSTCHECKED 0x0004 /* 是否已檢查在 currboard 發表文章的權限 */ +#define MODE_BOARD 0x0008 /* 是否可以在 currboard 刪除、mark文章 */ +#define MODE_GROUPOP 0x0010 /* 是否為小組長 (可以在 MENU 開板) */ +#define MODE_DIGEST 0x0020 /* 是否為 digest mode */ +#define MODE_ETC 0x0040 /* 是否為 etc mode */ +#define MODE_SELECT 0x0080 /* 搜尋使用者標題 */ +#define MODE_DIRTY 0x0100 /* 是否更動過 userflag */ /* for curredit */ #define EDIT_MAIL 1 /* 目前是 mail/board ? */ diff --git a/include/proto.h b/include/proto.h index 69e6ea74..2828a196 100644 --- a/include/proto.h +++ b/include/proto.h @@ -54,6 +54,7 @@ int del_range(int ent, fileheader_t *fhdr, char *direct); int cmpfowner(fileheader_t *fhdr); int b_note_edit_bname(int bid); int Read(); +int CheckPostPerm(void); void anticrosspost(); int Select(); void do_reply_title(int row, char *title); diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index b783eb6b..7f1369ca 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -121,12 +121,28 @@ set_board() strcpy(currBM, "徵求中"); else snprintf(currBM, sizeof(currBM), "板主:%s", bp->BM); + + /* init basic perm, but post perm is checked on demand */ currmode = (currmode & (MODE_DIRTY | MODE_GROUPOP)) | MODE_STARTED; +} - if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid)) - currmode = currmode | MODE_BOARD | MODE_POST; - else if (haspostperm(currboard)) - currmode |= MODE_POST; +/* check post perm on demand, no double checks in current board */ +int CheckPostPerm(void) +{ + if (!(currmode & MODE_POSTCHECKED)) { + currmode |= MODE_POSTCHECKED; + if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid)) { + currmode = currmode | MODE_BOARD | MODE_POST; + return 1; + } + else if (haspostperm(currboard)) { + currmode |= MODE_POST; + return 1; + } + currmode &= ~MODE_POST; + return 0; + } + return (currmode & MODE_POST); } static void @@ -524,7 +540,7 @@ do_general(int isbid) bp = getbcache(currbid); clear(); - if (!(currmode & MODE_POST) + if (!CheckPostPerm() #ifdef FOREIGN_REG // 不是外籍使用者在 PttForeign 板 && !((cuser->uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0) @@ -912,7 +928,7 @@ do_reply(fileheader_t * fhdr) static int reply_post(int ent, fileheader_t * fhdr, char *direct) { - if (!(currmode & MODE_POST)) + if (!CheckPostPerm()) return DONOTHING; setdirpath(quote_file, direct, fhdr->filename); @@ -937,7 +953,7 @@ edit_post(int ent, fileheader_t * fhdr, char *direct) return DONOTHING; if( !HAS_PERM(PERM_SYSOP) && - (!(currmode & MODE_POST) || strcmp(fhdr->owner, cuser->userid) != 0) ) + (!CheckPostPerm() || strcmp(fhdr->owner, cuser->userid) != 0) ) return DONOTHING; if( currmode & MODE_SELECT ) @@ -1014,7 +1030,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct) char genbuf[200]; char genbuf2[4]; boardheader_t *bp; - if (!(currmode & MODE_POST)) { + if (!CheckPostPerm()) { move(5, 10); outs("對不起,您目前無法轉錄文章!"); pressanykey(); @@ -1145,7 +1161,7 @@ read_post(int ent, fileheader_t * fhdr, char *direct) return FULLUPDATE; case 7: case 8: - if ((currmode & MODE_POST)) { + if (CheckPostPerm()) { strlcpy(quote_file, genbuf, sizeof(quote_file)); do_reply(fhdr); *quote_file = 0; @@ -1216,7 +1232,7 @@ read_post(int ent, fileheader_t * fhdr, char *direct) case 'r': case 'R': case 'Y': - if ((currmode & MODE_POST)) { + if (CheckPostPerm()) { strlcpy(quote_file, genbuf, sizeof(quote_file)); do_reply(fhdr); *quote_file = 0; @@ -1652,7 +1668,7 @@ recommend(int ent, fileheader_t * fhdr, char *direct) vmsg("抱歉, 本板禁止推薦或競標"); return FULLUPDATE; } - if (!(currmode & MODE_POST) || bp->brdattr & BRD_VOTEBOARD || fhdr->filemode & FILE_VOTE) { + if (!CheckPostPerm() || bp->brdattr & BRD_VOTEBOARD || fhdr->filemode & FILE_VOTE) { vmsg("您權限不足, 無法推薦!"); return FULLUPDATE; } @@ -2082,7 +2098,7 @@ sequent_messages(fileheader_t * fptr) case 'r': case 'Y': case 'R': - if (currmode & MODE_POST) { + if (CheckPostPerm()) { strlcpy(quote_file, genbuf, sizeof(quote_file)); do_reply(fptr); *quote_file = 0; @@ -2642,6 +2658,7 @@ Read() curredit &= ~EDIT_MAIL; i_read(READING, buf, readtitle, readdoent, read_comms, currbid); + currmode &= ~MODE_POSTCHECKED; #ifdef LOG_BOARD log_board(currboard, now - usetime); #endif diff --git a/mbbsd/board.c b/mbbsd/board.c index dff9d9b0..200376eb 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -340,20 +340,6 @@ void imovefav(int old) move_in_current_folder(old, new); } -void load_brdbuf(void) -{ - char buf[128]; - setuserfile(buf, FAV4); - if( !dashf(buf) ) { - fav_v3_to_v4(); - } - fav_load(); - - /* subscribe new fav (deprecated) */ - if (get_fav_root() != NULL) - updatenewfav(1); -} - void init_brdbuf() { @@ -921,7 +907,7 @@ choose_board(int newflag) setutmpmode(newflag ? READNEW : READBRD); if( get_current_fav() == NULL ) - load_brdbuf(); + fav_load(); ++choose_board_depth; brdnum = 0; if (!cuser->userlevel) /* guest yank all boards */ diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index de97ecde..64795836 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -987,6 +987,11 @@ user_login() #endif passwd_update(usernum, cuser); + fav_load(); + /* subscribe new fav (deprecated) */ + if (get_fav_root() != NULL) + updatenewfav(1); + for (i = 0; i < NUMVIEWFILE; i++) if ((cuser->loginview >> i) & 1) more(loginview_file[(int)i][0], YEA); diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 5f42571a..7714b14e 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -20,7 +20,7 @@ do_voteboardreply(fileheader_t * fhdr) clear(); - if (!(currmode & MODE_POST)) { + if (!CheckPostPerm()) { move(5, 10); prints("對不起,您目前無法在此發表文章!"); pressanykey(); @@ -157,7 +157,7 @@ do_voteboard(int type) int temp; clear(); - if (!(currmode & MODE_POST)) { + if (!CheckPostPerm()) { move(5, 10); prints("對不起,您目前無法在此發表文章!"); pressanykey(); |