summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/common.h1
-rw-r--r--include/proto.h1
-rw-r--r--include/pttstruct.h5
-rw-r--r--mbbsd/bbs.c159
-rw-r--r--mbbsd/board.c11
-rw-r--r--mbbsd/stuff.c6
6 files changed, 100 insertions, 83 deletions
diff --git a/include/common.h b/include/common.h
index 786f13df..a1a0ee29 100644
--- a/include/common.h
+++ b/include/common.h
@@ -9,7 +9,6 @@
#define FN_USSONG "ussong" /* 點歌統計 */
#define FN_POST_NOTE "post.note" /* po文章備忘錄 */
#define FN_POST_BID "post.bid"
-#define FN_APPLICATION "application"
#define FN_MONEY "etc/money"
#define FN_OVERRIDES "overrides"
#define FN_REJECT "reject"
diff --git a/include/proto.h b/include/proto.h
index e2acaa98..68146f79 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -433,6 +433,7 @@ int dashd(char *fname);
int invalid_pname(char *str);
void setbdir(char *buf, char *boardname);
void setbfile(char *buf, char *boardname, char *fname);
+void setbnfile(char *buf, char *boardname, char *fname, int n);
int dashl(char *fname);
char *subject(char *title);
int not_alnum(char ch);
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 2bcb7ed1..293ec677 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -141,7 +141,9 @@ typedef struct boardheader_t {
int nuser; /* 多少人在這板 */
int postexpire; /* postexpire */
time_t endgamble;
- char pad3[84];
+ char posttype[33];
+ char posttype_f;
+ char pad3[50];
} boardheader_t;
#define BRD_NOZAP 000000001 /* 不可zap */
@@ -372,6 +374,7 @@ typedef struct {
char today_is[20];
int n_notes[MAX_MOVIE_SECTION]; /* 一節中有幾個 看板 */
int next_refresh[MAX_MOVIE_SECTION]; /* 下一次要refresh的 看板 */
+ msgque_t loginmsg; /* 進站水球 */
int max_film;
int max_history;
time_t Puptime;
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 1fe876ea..44a507bd 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -515,8 +515,8 @@ do_general(int isbid)
bid_t bidinfo;
fileheader_t postfile;
char fpath[80], buf[80];
- int aborted, defanony, ifuseanony;
- char genbuf[200], *owner, *ctype[] = {"問題", "建議", "討論", "心得", "閒聊", "公告", "情報"};
+ int aborted, defanony, ifuseanony, i;
+ char genbuf[200], *owner, *ctype[] = {"問題", "建議", "討論", "心得", "閒聊", "請益", "公告", "情報"};
boardheader_t *bp;
int islocal;
@@ -581,10 +581,17 @@ do_general(int isbid)
else {
if(!isbid)
{
- getdata(21, 0,
- "種類:1.問題 2.建議 3.討論 4.心得 5.閒聊 6.公告 7.情報 (1-7或不選)",
- save_title, 3, LCECHO);
-
+ sprintf(buf,"種類:");
+ for(i=0; i<8 && bp->posttype[i*2]; i++)
+ sprintf(buf+6+7*i,"%d.%2.2s ", i+1, bp->posttype+2*i);
+ if(i==0)
+ {
+ strcat(buf, "1.問題 2.建議 3.討論 4.心得 5.閒聊 6.請益 "
+ "7.公告 8.情報 ");
+ i=8;
+ }
+ sprintf(buf+6+7*i,"(1-%d或不選)",i);
+ getdata(21, 0, buf, save_title, 3, LCECHO);
local_article = save_title[0] - '1';
if (local_article >= 0 && local_article <= 6)
snprintf(save_title, sizeof(save_title),
@@ -831,6 +838,54 @@ b_call_in(int ent, fileheader_t * fhdr, char *direct)
return DONOTHING;
}
+
+static int
+b_posttype(int ent, fileheader_t * fhdr, char *direct)
+{
+ boardheader_t *bp;
+ int i, aborted;
+ char filepath[256], genbuf[6], title[3], posttype_f, posttype[33];
+
+ if(!currmode & MODE_BOARD) return DONOTHING;
+
+ bp = getbcache(currbid);
+
+ move(2,0);
+ clrtobot();
+ move(2,0);
+ outs("文章種類:");
+ posttype_f = bp->posttype_f;
+ for(i=0; i<8; i++)
+ {
+ strncpy(genbuf, bp->posttype+i*4, 4);
+ genbuf[4]=0;
+ sprintf(title,"%d.",i+1);
+ if(!getdata_buf(2,10, title, genbuf, 5, DOECHO)) break;
+ sprintf(posttype+i*4,"%4.4s", genbuf);
+ if( posttype_f & (1<<i) )
+ {
+ if(getdata(2, 20, "設定範本格式?(Y/n)", genbuf, 3, LCECHO) &&
+ genbuf[0]=='n') continue;
+ }
+ else if (!getdata(2, 20, "設定範本格式?(y/N)", genbuf, 3, LCECHO) ||
+ genbuf[0]!='y') continue;
+
+ setbnfile(filepath, bp->brdname, "postsample", i);
+ aborted = vedit(filepath, NA, NULL);
+ if (aborted == -1) {
+ clear();
+ posttype_f &= ~(1<<i);
+ continue;
+ }
+ posttype_f |= (1<<i);
+ }
+ bp->posttype_f = posttype_f;
+ strncpy(bp->posttype, posttype, 32); /* 這邊應該要防race condition */
+
+ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
+ return FULLUPDATE;
+}
+
static void
do_reply(fileheader_t * fhdr)
{
@@ -1789,7 +1844,7 @@ del_post(int ent, fileheader_t * fhdr, char *direct)
if (cuser.numposts)
cuser.numposts--;
/* XXX: is_BM(cuser.userid) is always true @_@ */
- if (!(currmode & MODE_DIGEST && is_BM(cuser.userid))){
+ if (!(currmode & MODE_DIGEST && currmode & MODE_BOARD)){
move(b_lines - 1, 0);
clrtoeol();
demoney(-fhdr->money);
@@ -2049,18 +2104,6 @@ b_post_note()
return 0;
}
-static int
-b_application()
-{
- char buf[200];
-
- if (currmode & MODE_BOARD) {
- setbfile(buf, currboard, FN_APPLICATION);
- vedit(buf, NA, NULL);
- return FULLUPDATE;
- }
- return 0;
-}
static int
can_vote_edit()
@@ -2276,22 +2319,13 @@ b_help()
static int
b_changerecommend(int ent, fileheader_t * fhdr, char *direct)
{
- boardheader_t bh;
- int bid;
- if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)) ||
- currboard[0] == 0 ||
- (bid = getbnum(currboard)) < 0 ||
- get_record(fn_board, &bh, sizeof(bh), bid) == -1)
- return DONOTHING;
- if( bh.brdattr & BRD_NORECOMMEND )
- bh.brdattr -= BRD_NORECOMMEND;
- else
- bh.brdattr += BRD_NORECOMMEND;
- setup_man(&bh);
- substitute_record(fn_board, &bh, sizeof(bh), bid);
- reset_board(bid);
+ boardheader_t *bp;
+ if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)))
+ bp = getbcache(currbid);
+ bp->brdattr ^= BRD_NORECOMMEND;
+ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
vmsg("本板現在 %s 推薦",
- (bh.brdattr & BRD_NORECOMMEND) ? "禁止" : "開放");
+ (bp->brdattr & BRD_NORECOMMEND) ? "禁止" : "開放");
return FULLUPDATE;
}
@@ -2303,41 +2337,31 @@ char board_hidden_status;
static int
change_hidden(int ent, fileheader_t * fhdr, char *direct)
{
- boardheader_t bh;
- int bid;
-
- if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)) ||
- currboard[0] == 0 ||
- (bid = getbnum(currboard)) < 0 ||
- get_record(fn_board, &bh, sizeof(bh), bid) == -1)
+ boardheader_t *bp;
+ if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)))
return DONOTHING;
- if (((bh.brdattr & BRD_HIDE) && (bh.brdattr & BRD_POSTMASK))) {
+ bp = getbcache(currbid);
+ if (((bp->brdattr & BRD_HIDE) && (bp->brdattr & BRD_POSTMASK))) {
if (getans("目前板在隱形狀態, 要解隱形嘛(Y/N)?[N]") != 'y')
return FULLUPDATE;
- if (getans("再確認一次, 真的要把板板公開嘛 @____@(Y/N)?[N]") != 'y')
- return FULLUPDATE;
- if (bh.brdattr & BRD_HIDE)
- bh.brdattr &= ~BRD_HIDE;
- if (bh.brdattr & BRD_POSTMASK)
- bh.brdattr &= ~BRD_POSTMASK;
+ bp->brdattr &= ~BRD_HIDE;
+ bp->brdattr &= ~BRD_POSTMASK;
log_usies("OpenBoard", bh.brdname);
outs("君心今傳眾人,無處不聞弦歌。\n");
board_hidden_status = 0;
- hbflreload(bid);
+ hbflreload(currbid);
} else {
if (getans("目前板在現形狀態, 要隱形嘛(Y/N)?[N]") != 'y')
return FULLUPDATE;
- bh.brdattr |= BRD_HIDE;
- bh.brdattr |= BRD_POSTMASK;
+ bp->brdattr |= BRD_HIDE;
+ bp->brdattr |= BRD_POSTMASK;
log_usies("CloseBoard", bh.brdname);
outs("君心今已掩抑,惟盼善自珍重。\n");
board_hidden_status = 1;
}
- setup_man(&bh);
- substitute_record(fn_board, &bh, sizeof(bh), bid);
- reset_board(bid);
- log_usies("SetBoard", bh.brdname);
+ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
+ log_usies("SetBoard", bp->brdname);
pressanykey();
return FULLUPDATE;
}
@@ -2345,33 +2369,26 @@ change_hidden(int ent, fileheader_t * fhdr, char *direct)
static int
change_counting(int ent, fileheader_t * fhdr, char *direct)
{
- boardheader_t bh;
- int bid;
- if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)) ||
- currboard[0] == 0 ||
- (bid = getbnum(currboard)) < 0 ||
- get_record(fn_board, &bh, sizeof(bh), bid) == -1)
+ boardheader_t *bp;
+ if (!((currmode & MODE_BOARD) || HAS_PERM(PERM_SYSOP)))
return DONOTHING;
-
- if (!(bh.brdattr & BRD_HIDE && bh.brdattr & BRD_POSTMASK))
+ bp = getbcache(currbid);
+ if (!(bp->brdattr & BRD_HIDE && bp->brdattr & BRD_POSTMASK))
return FULLUPDATE;
- if (bh.brdattr & BRD_BMCOUNT) {
+ if (bp->brdattr & BRD_BMCOUNT) {
if (getans("目前板列入十大排行, 要取消列入十大排行嘛(Y/N)?[N]") != 'y')
return FULLUPDATE;
- bh.brdattr &= ~BRD_BMCOUNT;
- log_usies("NoCountBoard", bh.brdname);
+ bp->brdattr &= ~BRD_BMCOUNT;
outs("你再灌水也不會有十大的呀。\n");
} else {
if (getans("目前看板不列入十大排行, 要列入十大嘛(Y/N)?[N]") != 'y')
return FULLUPDATE;
- bh.brdattr |= BRD_BMCOUNT;
- log_usies("CountBoard", bh.brdname);
+ bp->brdattr |= BRD_BMCOUNT;
outs("快灌水衝十大第一吧。\n");
}
- substitute_record(fn_board, &bh, sizeof(bh), bid);
- log_usies("SetBoard", bh.brdname);
+ substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
pressanykey();
return FULLUPDATE;
}
@@ -2401,7 +2418,7 @@ struct onekey_t read_comms[] = {
#endif
{'h', b_help},
{'I', b_changerecommend},
- {'i', b_application},
+ {'i', b_posttype},
{'K', b_water_edit},
{'L', solve_post},
{'M', b_vote_maintain},
diff --git a/mbbsd/board.c b/mbbsd/board.c
index a08bfd73..23aec763 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1509,16 +1509,7 @@ choose_board(int newflag)
check_newpost(ptr);
head = -1;
setutmpmode(newflag ? READNEW : READBRD);
- } else {
- setbfile(buf, B_BH(ptr)->brdname, FN_APPLICATION);
- if (more(buf, YEA) == -1) {
- move(1, 0);
- clrtobot();
- outs(privateboard);
- pressanykey();
- }
- head = -1;
- }
+ }
} else { /* sub class */
move(12, 1);
bidtmp = class_bid;
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index a6aaec46..0970e58c 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -6,6 +6,7 @@
/* ----------------------------------------------------- */
static char *str_home_file = "home/%c/%s/%s";
static char *str_board_file = "boards/%c/%s/%s";
+static char *str_board_n_file = "boards/%c/%s/%s.%d";
#define STR_DOTDIR ".DIR"
static char *str_dotdir = STR_DOTDIR;
@@ -78,6 +79,11 @@ setbfile(char *buf, char *boardname, char *fname)
sprintf(buf, str_board_file, boardname[0], boardname, fname);
}
+void
+setbnfile(char *buf, char *boardname, char *fname, int n)
+{
+ sprintf(buf, str_board_n_file, boardname[0], boardname, fname, n);
+}
/*
* input direct
* output buf: copy direct