diff options
author | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-07 17:50:45 +0800 |
---|---|---|
committer | wens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-01-07 17:50:45 +0800 |
commit | 2409b9e7fc94c497502e83ff07de7142888a3009 (patch) | |
tree | 2119bdbd1dc059866aedc4eb1bd49a50068263e7 | |
parent | 60b225b0159f59b97ec191474618e9b09e6cfe9a (diff) | |
download | pttbbs-2409b9e7fc94c497502e83ff07de7142888a3009.tar pttbbs-2409b9e7fc94c497502e83ff07de7142888a3009.tar.gz pttbbs-2409b9e7fc94c497502e83ff07de7142888a3009.tar.bz2 pttbbs-2409b9e7fc94c497502e83ff07de7142888a3009.tar.lz pttbbs-2409b9e7fc94c497502e83ff07de7142888a3009.tar.xz pttbbs-2409b9e7fc94c497502e83ff07de7142888a3009.tar.zst pttbbs-2409b9e7fc94c497502e83ff07de7142888a3009.zip |
add post limits for BM.
rename "do_votelimitedit" to "do_limitedit".
rename "zerovotelimit.c" to "zero_limits.c".
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2388 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 2 | ||||
-rw-r--r-- | include/pttstruct.h | 8 | ||||
-rw-r--r-- | mbbsd/bbs.c | 134 | ||||
-rw-r--r-- | mbbsd/mail.c | 8 | ||||
-rw-r--r-- | mbbsd/voteboard.c | 67 | ||||
-rw-r--r-- | util/zero_limits.c (renamed from util/zerovotelimit.c) | 6 |
6 files changed, 145 insertions, 80 deletions
diff --git a/include/proto.h b/include/proto.h index 667b9950..005dcb17 100644 --- a/include/proto.h +++ b/include/proto.h @@ -68,6 +68,7 @@ void ReadSelect(void); int save_violatelaw(void); int board_select(void); int board_digest(void); +int do_limitedit(int ent, fileheader_t * fhdr, char *direct); /* board */ #define setutmpbid(bid) currutmp->brc_id=bid; @@ -668,7 +669,6 @@ int vice_main(void); /* voteboard */ int do_voteboard(int); void do_voteboardreply(fileheader_t *fhdr); -int do_votelimitedit(int ent, fileheader_t * fhdr, char *direct); /* xyz */ int m_sysop(void); diff --git a/include/pttstruct.h b/include/pttstruct.h index fd1acece..a7df3568 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -165,11 +165,13 @@ typedef struct boardheader_t { char BM[IDLEN * 3 + 3]; /* BMs' userid, token '/' */ unsigned int brdattr; /* board的屬性 */ char chesscountry; - unsigned char limit_posts; /* 連署 : 文章篇數下限 */ - unsigned char limit_logins; /* 連署 : 登入次數下限 */ + unsigned char vote_limit_posts; /* 連署 : 文章篇數下限 */ + unsigned char vote_limit_logins; /* 連署 : 登入次數下限 */ char pad[1]; /* 沒用到的 */ time_t bupdate; /* note update time */ - char pad2[3]; /* 沒用到的 */ + unsigned char post_limit_posts; /* 發表文章 : 文章篇數下限 */ + unsigned char post_limit_logins; /* 發表文章 : 登入次數下限 */ + char pad2[1]; /* 沒用到的 */ unsigned char bvote; /* 正舉辦 Vote 數 */ time_t vtime; /* Vote close time */ unsigned int level; /* 可以看此板的權限 */ diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index adbcdde8..5892505c 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -539,6 +539,12 @@ do_general(int isbid) vmsg("對不起,您目前無法在此發表文章!"); return READ_REDRAW; } + if ( cuser.numlogins < ((unsigned int)(bcache[currbid - 1].post_limit_logins) * 10) || + cuser.numposts < ((unsigned int)(bcache[currbid - 1].post_limit_posts) * 10) ) { + move(5, 10); + vmsg("你的上站數/文章數不足喔!"); + return FULLUPDATE; + } #ifdef NO_WATER_POST #ifndef DEBUG /* why we need this in DEBUG mode? */ /* 三分鐘內最多發表五篇文章 */ @@ -783,21 +789,35 @@ static void do_generalboardreply(fileheader_t * fhdr) { char genbuf[3]; - getdata(b_lines - 1, 0, - "▲ 回應至 (F)看板 (M)作者信箱 (B)二者皆是 (Q)取消?[F] ", - genbuf, sizeof(genbuf), LCECHO); - switch (genbuf[0]) { - case 'm': - mail_reply(0, fhdr, 0); - case 'q': - break; + + if ( cuser.numlogins < ((unsigned int)(bcache[currbid - 1].post_limit_logins) * 10) || + cuser.numposts < ((unsigned int)(bcache[currbid - 1].post_limit_posts) * 10) ) { + getdata(b_lines - 1, 0, "▲ 回應至 (M)作者信箱 (Q)取消?[M] ", + genbuf, sizeof(genbuf), LCECHO); + switch (genbuf[0]) { + case 'q': + break; + default: + mail_reply(0, fhdr, 0); + } + } + else { + getdata(b_lines - 1, 0, + "▲ 回應至 (F)看板 (M)作者信箱 (B)二者皆是 (Q)取消?[F] ", + genbuf, sizeof(genbuf), LCECHO); + switch (genbuf[0]) { + case 'm': + mail_reply(0, fhdr, 0); + case 'q': + break; - case 'b': - curredit = EDIT_BOTH; - default: - strlcpy(currtitle, fhdr->title, sizeof(currtitle)); - strlcpy(quote_user, fhdr->owner, sizeof(quote_user)); - do_post(); + case 'b': + curredit = EDIT_BOTH; + default: + strlcpy(currtitle, fhdr->title, sizeof(currtitle)); + strlcpy(quote_user, fhdr->owner, sizeof(quote_user)); + do_post(); + } } *quote_file = 0; } @@ -1000,6 +1020,13 @@ cross_post(int ent, fileheader_t * fhdr, char *direct) postrecord.checksum[0] = ent; } + if ( cuser.numlogins < ((unsigned int)(bcache[author - 1].post_limit_logins) * 10) || + cuser.numposts < ((unsigned int)(bcache[author - 1].post_limit_posts) * 10) ) { + move(5, 10); + vmsg("你的上站數/文章數不足喔!"); + return FULLUPDATE; + } + ent = 1; author = 0; if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser.userid)) { @@ -1108,6 +1135,83 @@ read_post(int ent, fileheader_t * fhdr, char *direct) return FULLUPDATE; } +int +do_limitedit(int ent, fileheader_t * fhdr, char *direct) +{ + char genbuf[256]; + int temp; + boardheader_t *bp = NULL; + + if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP))) + return DONOTHING; + bp = getbcache(currbid); + if (fhdr->filemode & FILE_VOTE) + getdata(23, 0, "更改 (A)本板發表限制 (B)本板預設 (C)本篇連署限制 (Q)取消?[Q]", genbuf, 3, LCECHO); + else + getdata(23, 0, "更改 (A)本板發表限制 (B)本板預設連署限制 (Q)取消?[Q]", genbuf, 3, LCECHO); + + if (genbuf[0] == 'a' || genbuf[0] == 'A') { + sprintf(genbuf, "%u", bp->post_limit_logins * 10); + do { + getdata_buf(23, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO); + temp = atoi(genbuf); + } while (temp < 0 || temp > 2550); + bp->post_limit_logins = (unsigned char)(temp / 10); + + sprintf(genbuf, "%u", bp->post_limit_posts * 10); + do { + getdata_buf(23, 0, "文章篇數下限 (0~2550):", genbuf, 5, LCECHO); + temp = atoi(genbuf); + } while (temp < 0 || temp > 2550); + bp->post_limit_posts = (unsigned char)(temp / 10); + substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); + log_usies("SetBoard", bp->brdname); + vmsg("修改完成!"); + return FULLUPDATE; + } + else if (genbuf[0] == 'b' || genbuf[0] == 'B') { + sprintf(genbuf, "%u", bp->vote_limit_logins * 10); + do { + getdata_buf(23, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO); + temp = atoi(genbuf); + } while (temp < 0 || temp > 2550); + bp->vote_limit_logins = (unsigned char)(temp / 10); + + sprintf(genbuf, "%u", bp->vote_limit_posts * 10); + do { + getdata_buf(23, 0, "文章篇數下限 (0~2550):", genbuf, 5, LCECHO); + temp = atoi(genbuf); + } while (temp < 0 || temp > 2550); + bp->vote_limit_posts = (unsigned char)(temp / 10); + substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); + log_usies("SetBoard", bp->brdname); + vmsg("修改完成!"); + return FULLUPDATE; + } + else if ((fhdr->filemode & FILE_VOTE) && (genbuf[0] == 'c' || genbuf[0] == 'C') ) { + sprintf(genbuf, "%u", (unsigned int)(fhdr->multi.vote_limits.logins) * 10); + do { + getdata_buf(23, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO); + temp = atoi(genbuf); + } while (temp < 0 || temp > 2550); + temp /= 10; + fhdr->multi.vote_limits.logins = (unsigned char)temp; + + sprintf(genbuf, "%u", (unsigned int)(fhdr->multi.vote_limits.posts) * 10); + do { + getdata_buf(23, 0, "文章篇數下限 (0~2550):", genbuf, 5, LCECHO); + temp = atoi(genbuf); + } while (temp < 0 || temp > 2550); + temp /= 10; + fhdr->multi.vote_limits.posts = (unsigned char)temp; + substitute_ref_record(direct, fhdr, ent); + vmsg("修改完成!"); + return FULLUPDATE; + } + vmsg("取消修改"); + return FULLUPDATE; +} + /* ----------------------------------------------------- */ /* 採集精華區 */ /* ----------------------------------------------------- */ @@ -2421,7 +2525,7 @@ const onekey_t read_comms[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 'A' 65 bh_title_edit, // 'B' - do_votelimitedit, // 'C' + do_limitedit, // 'C' del_range, // 'D' edit_post, // 'E' NULL, // 'F' diff --git a/mbbsd/mail.c b/mbbsd/mail.c index b9d19440..cb29f976 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -1043,6 +1043,14 @@ mail_cross_post(int ent, fileheader_t * fhdr, char *direct) if (*xboard == '\0' || !haspostperm(xboard)) return TITLE_REDRAW; + ent = getbnum(xboard); + if ( cuser.numlogins < ((unsigned int)(bcache[ent - 1].post_limit_logins) * 10) || + cuser.numposts < ((unsigned int)(bcache[ent - 1].post_limit_posts) * 10) ) { + move(5, 10); + vmsg("你的上站數/文章數不足喔!"); + return FULLUPDATE; + } + ent = 1; if (HAS_PERM(PERM_SYSOP) || !strcmp(fhdr->owner, cuser.userid)) { getdata(2, 0, "(1)原文轉載 (2)舊轉錄格式?[1] ", diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index 5cfa3983..8fba9b9e 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -2,62 +2,6 @@ #include "bbs.h" #define VOTEBOARD "NewBoard" -int -do_votelimitedit(int ent, fileheader_t * fhdr, char *direct) -{ - char genbuf[256]; - int temp; - boardheader_t *bp = NULL; - - if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP))) - return DONOTHING; - bp = getbcache(currbid); - if (!(bp->brdattr & BRD_VOTEBOARD || (fhdr->filemode & FILE_VOTE))) - return DONOTHING; - getdata(23, 0, "更改 (A)本篇 (B)本版預設連署限制 (C)取消?[C]", genbuf, 3, LCECHO); - if (genbuf[0] == 'a' || genbuf[0] == 'A') { - sprintf(genbuf, "%u", (unsigned int)(fhdr->multi.vote_limits.logins) * 10); - do { - getdata_buf(23, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO); - temp = atoi(genbuf); - } while (temp < 0 || temp > 2550); - temp /= 10; - fhdr->multi.vote_limits.logins = (unsigned char)temp; - - sprintf(genbuf, "%u", (unsigned int)(fhdr->multi.vote_limits.posts) * 10); - do { - getdata_buf(23, 0, "文章篇數下限 (0~2550):", genbuf, 5, LCECHO); - temp = atoi(genbuf); - } while (temp < 0 || temp > 2550); - temp /= 10; - fhdr->multi.vote_limits.posts = (unsigned char)temp; - substitute_ref_record(direct, fhdr, ent); - vmsg("修改完成!"); - return FULLUPDATE; - } - else if (genbuf[0] == 'b' || genbuf[0] == 'B') { - sprintf(genbuf, "%u", bp->limit_logins * 10); - do { - getdata_buf(23, 0, "上站次數下限 (0~2550):", genbuf, 5, LCECHO); - temp = atoi(genbuf); - } while (temp < 0 || temp > 2550); - bp->limit_logins = (unsigned char)(temp / 10); - - sprintf(genbuf, "%u", bp->limit_posts * 10); - do { - getdata_buf(23, 0, "文章篇數下限 (0~2550):", genbuf, 5, LCECHO); - temp = atoi(genbuf); - } while (temp < 0 || temp > 2550); - bp->limit_posts = (unsigned char)(temp / 10); - substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); - log_usies("SetBoard", bp->brdname); - vmsg("修改完成!"); - return FULLUPDATE; - } - vmsg("取消修改"); - return FULLUPDATE; -} - void do_voteboardreply(fileheader_t * fhdr) { @@ -221,6 +165,12 @@ do_voteboard(int type) vmsg("對不起,您目前無法在此發表文章!"); return FULLUPDATE; } + if ( 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); + vmsg("你的上站數/文章數不足喔!"); + return FULLUPDATE; + } move(0, 0); clrtobot(); outs("您正在使用 PTT 的連署系統\n"); @@ -392,11 +342,10 @@ do_voteboard(int type) strlcpy(votefile.owner, cuser.userid, sizeof(votefile.owner)); strlcpy(votefile.title, title, sizeof(votefile.title)); votefile.filemode |= FILE_VOTE; - temp = getbnum(currboard); /* use lower 16 bits of 'money' to store limits */ /* lower 8 bits are posts, higher 8 bits are logins */ - votefile.multi.vote_limits.logins = (unsigned int)bcache[temp - 1].limit_logins; - votefile.multi.vote_limits.posts = (unsigned int)bcache[temp - 1].limit_posts; + votefile.multi.vote_limits.logins = (unsigned int)bcache[currbid - 1].vote_limit_logins; + votefile.multi.vote_limits.posts = (unsigned int)bcache[currbid - 1].vote_limit_posts; setbdir(genbuf, currboard); if (append_record(genbuf, &votefile, sizeof(votefile)) != -1) setbtotal(currbid); diff --git a/util/zerovotelimit.c b/util/zero_limits.c index 0405d180..e9824ff5 100644 --- a/util/zerovotelimit.c +++ b/util/zero_limits.c @@ -6,8 +6,10 @@ void transform(boardheader_t *new, boardheader_t *old) { memcpy(new, old, sizeof(boardheader_t)); - new->limit_posts = (unsigned char) 0; - new->limit_logins = (unsigned char) 0; + new->post_limit_posts = (unsigned char) 0; + new->post_limit_logins = (unsigned char) 0; + new->vote_limit_posts = (unsigned char) 0; + new->vote_limit_logins = (unsigned char) 0; memset(new->pad, 0, sizeof(new->pad)); memset(new->pad2, 0, sizeof(new->pad2)); memset(new->pad3, 0, sizeof(new->pad3)); |