summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-02 09:54:57 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-04-02 09:54:57 +0800
commit83db4da4e36b3c5438f4759c835aa8440f650915 (patch)
treeac75ca5876c004a7ec37fa94a08859bfd8e54e04 /mbbsd
parent20532cc19e163e5e1d1dd3400ab5cf542e4f0937 (diff)
downloadpttbbs-83db4da4e36b3c5438f4759c835aa8440f650915.tar
pttbbs-83db4da4e36b3c5438f4759c835aa8440f650915.tar.gz
pttbbs-83db4da4e36b3c5438f4759c835aa8440f650915.tar.bz2
pttbbs-83db4da4e36b3c5438f4759c835aa8440f650915.tar.lz
pttbbs-83db4da4e36b3c5438f4759c835aa8440f650915.tar.xz
pttbbs-83db4da4e36b3c5438f4759c835aa8440f650915.tar.zst
pttbbs-83db4da4e36b3c5438f4759c835aa8440f650915.zip
check post perm on demand
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1667 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/bbs.c41
-rw-r--r--mbbsd/board.c16
-rw-r--r--mbbsd/mbbsd.c5
-rw-r--r--mbbsd/voteboard.c4
4 files changed, 37 insertions, 29 deletions
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();