diff options
-rw-r--r-- | include/pttstruct.h | 3 | ||||
-rw-r--r-- | mbbsd/bbs.c | 19 | ||||
-rw-r--r-- | mbbsd/gamble.c | 4 | ||||
-rw-r--r-- | mbbsd/voteboard.c | 180 |
4 files changed, 75 insertions, 131 deletions
diff --git a/include/pttstruct.h b/include/pttstruct.h index 10c32588..2bcb7ed1 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -139,7 +139,7 @@ typedef struct boardheader_t { void *parent; int childcount; /* 有多少個child */ int nuser; /* 多少人在這板 */ - char pad5[4]; /* original void *u */ + int postexpire; /* postexpire */ time_t endgamble; char pad3[84]; } boardheader_t; @@ -186,6 +186,7 @@ typedef struct fileheader_t { #define FILE_BOTH 0x80 /* both replay for mail and board */ #define FILE_MULTI 0x100 /* multi send for mail */ #define FILE_BID 0x20 /* for bid */ +#define FILE_VOTE 0x40 /* for vote */ #define STRLEN 80 /* Length of most string data */ diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index e63a4120..57bdde9d 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -735,21 +735,25 @@ do_post() boardheader_t *bp; bp = getbcache(currbid); if (bp->brdattr & BRD_VOTEBOARD) - return do_voteboard(); + return do_voteboard(0); else if (!(bp->brdattr & BRD_GROUPBOARD)) return do_general(0); - touchdircache(currbid); return 0; } int +do_post_vote() +{ + return do_voteboard(1); +} + +int do_post_openbid() { boardheader_t *bp; bp = getbcache(currbid); if (!(bp->brdattr & BRD_VOTEBOARD)) return do_general(1); - touchdircache(currbid); return 0; } @@ -830,7 +834,7 @@ do_reply(fileheader_t * fhdr) { boardheader_t *bp; bp = getbcache(currbid); - if (bp->brdattr & BRD_VOTEBOARD) + if (bp->brdattr & BRD_VOTEBOARD || (fhdr->filemode & FILE_VOTE)) do_voteboardreply(fhdr); else do_generalboardreply(fhdr); @@ -860,7 +864,7 @@ edit_post(int ent, fileheader_t * fhdr, char *direct) if (strcmp(bp->brdname, "Security") == 0) return DONOTHING; - if (!HAS_PERM(PERM_SYSOP) && (bp->brdattr & BRD_VOTEBOARD)) + if (!HAS_PERM(PERM_SYSOP) && ((bp->brdattr & BRD_VOTEBOARD) || fhdr->filemode & FILE_VOTE)) return DONOTHING; if ((!HAS_PERM(PERM_SYSOP)) && @@ -942,7 +946,7 @@ cross_post(int ent, fileheader_t * fhdr, char *direct) clrtoeol(); move(1, 0); bp = getbcache(currbid); - if (bp && (bp->brdattr & BRD_VOTEBOARD)) + if (bp && (bp->brdattr & BRD_VOTEBOARD) ) return FULLUPDATE; generalnamecomplete("轉錄本文章於看板:", xboard, sizeof(xboard), SHM->Bnumber, @@ -1547,7 +1551,7 @@ recommend(int ent, fileheader_t * fhdr, char *direct) vmsg("抱歉, 本板禁止推薦或競標"); return FULLUPDATE; } - if (!(currmode & MODE_POST) || bp->brdattr & BRD_VOTEBOARD) { + if (!(currmode & MODE_POST) || bp->brdattr & BRD_VOTEBOARD || fhdr->filemode & FILE_VOTE) { vmsg("您因權限不足!"); return FULLUPDATE; } @@ -2416,6 +2420,7 @@ struct onekey_t read_comms[] = { {'z', b_man}, {Ctrl('P'), do_post}, {Ctrl('O'), do_post_openbid}, + {Ctrl('V'), do_post_vote}, {Ctrl('W'), whereami}, {'\0', NULL} }; diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index ead8c124..9b9939df 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -311,7 +311,11 @@ openticket(int bid) fclose(fp1); } if (fp) + { + fprintf(fp, "\n--\n※ 開獎站 :" BBSNAME "(" MYHOSTNAME + ") \n◆ From: %s\n", fromhost); fclose(fp); + } if (bet != 98) snprintf(buf, sizeof(buf), "[公告] %s 賭盤開獎", bh->brdname); diff --git a/mbbsd/voteboard.c b/mbbsd/voteboard.c index a0db074e..2af3537d 100644 --- a/mbbsd/voteboard.c +++ b/mbbsd/voteboard.c @@ -175,7 +175,7 @@ do_voteboardreply(fileheader_t * fhdr) } int -do_voteboard() +do_voteboard(int type) { fileheader_t votefile; char topic[100]; @@ -196,24 +196,38 @@ do_voteboard() clrtobot(); prints("您正在使用 PTT 的連署系統\n"); prints("本連署系統將詢問您一些問題,請小心回答才能開始連署\n"); - prints("任意提出連署案者,將被列入本系統不受歡迎使用者喔\n"); + prints("任意提出連署案者,將被列入不受歡迎使用者喔\n"); pressanykey(); move(0, 0); clrtobot(); - prints("(1)申請新板 (2)廢除舊板 (3)連署板主 (4)罷免板主\n"); - if (!strcmp(currboard, VOTEBOARD)) - prints("(5)連署小組長 (6)罷免小組長 "); - if (!strcmp(currboard, VOTEBOARD) && HAS_PERM(PERM_SYSOP)) - prints("(7)站民公投"); - prints("(8)申請新群組"); + prints("(1)活動連署 (2)記名公投 \n"); + if(type==0) + prints("(3)申請新板 (4)廢除舊板 (5)連署板主 (6)罷免板主 (7)連署小組長 (8)罷免小組長 (9)申請新群組\n"); do { - getdata(3, 0, "請輸入連署類別:", topic, 3, DOECHO); + getdata(3, 0, "請輸入連署類別 [0:取消]:", topic, 3, DOECHO); temp = atoi(topic); - } while (temp <= 0 && temp >= 9); - + } while (temp < 0 || temp > 9 || (type && temp>2)); switch (temp) { + case 0: + return FULLUPDATE; case 1: + if (!getdata(4, 0, "請輸入活動主題:", topic, 30, DOECHO)) + return FULLUPDATE; + snprintf(title, sizeof(title), "%s %s", "[活動連署]", topic); + snprintf(genbuf, sizeof(genbuf), + "%s\n\n%s%s\n", "活動連署", "活動主題: ", topic); + strcat(genbuf, "\n活動內容: \n"); + break; + case 2: + if (!getdata(4, 0, "請輸入公投主題:", topic, 30, DOECHO)) + return FULLUPDATE; + snprintf(title, sizeof(title), "%s %s", "[記名公投]", topic); + snprintf(genbuf, sizeof(genbuf), + "%s\n\n%s%s\n", "記名公投", "公投主題: ", topic); + strcat(genbuf, "\n公投原因: \n"); + break; + case 3: do { if (!getdata(4, 0, "請輸入看板英文名稱:", topic, IDLEN + 1, DOECHO)) return FULLUPDATE; @@ -239,71 +253,37 @@ do_voteboard() getdata(7, 0, "請輸入板主名單:", topic, IDLEN * 3 + 3, DOECHO); strcat(genbuf, topic); strcat(genbuf, "\n申請原因: \n"); - outs("請輸入申請原因(至多五行),要清楚填寫不然不會核准喔"); - for (i = 9; i < 13; i++) { - if (!getdata(i, 0, ":", topic, 60, DOECHO)) - break; - strcat(genbuf, topic); - strcat(genbuf, "\n"); - } - if (i == 9) - return FULLUPDATE; break; - case 2: - do { - if (!getdata(4, 0, "請輸入看板英文名稱:", topic, IDLEN + 1, DOECHO)) - return FULLUPDATE; - else if (getbnum(topic) <= 0) - outs("本名稱並不存在"); - else - break; - } while (temp > 0); + case 4: + generalnamecomplete("請輸入看板英文名稱:", + topic, IDLEN+1, + SHM->Bnumber, + completeboard_compar, + completeboard_permission, + completeboard_getname); snprintf(title, sizeof(title), "[廢除舊板] %s", topic); snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n", "廢除舊板", "英文名稱: ", topic); strcat(genbuf, "\n廢除原因: \n"); - outs("請輸入廢除原因(至多五行),要清楚填寫不然不會核准喔"); - for (i = 8; i < 13; i++) { - if (!getdata(i, 0, ":", topic, 60, DOECHO)) - break; - strcat(genbuf, topic); - strcat(genbuf, "\n"); - } - if (i == 8) - return FULLUPDATE; - break; - case 3: - do { - if (!getdata(4, 0, "請輸入看板英文名稱:", topic, IDLEN + 1, DOECHO)) - return FULLUPDATE; - else if (getbnum(topic) <= 0) - outs("本名稱並不存在"); - else - break; - } while (temp > 0); + case 5: + generalnamecomplete("請輸入看板英文名稱:", + topic, IDLEN+1, + SHM->Bnumber, + completeboard_compar, + completeboard_permission, + completeboard_getname); snprintf(title, sizeof(title), "[連署板主] %s", topic); snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", "連署板主", "英文名稱: ", topic, "申請 ID : ", cuser.userid); strcat(genbuf, "\n申請政見: \n"); - outs("請輸入申請政見(至多五行),要清楚填寫不然不會核准喔"); - for (i = 8; i < 13; i++) { - if (!getdata(i, 0, ":", topic, 60, DOECHO)) - break; - strcat(genbuf, topic); - strcat(genbuf, "\n"); - } - if (i == 8) - return FULLUPDATE; break; - case 4: - do { - if (!getdata(4, 0, "請輸入看板英文名稱:", topic, IDLEN + 1, DOECHO)) - return FULLUPDATE; - else if ((i = getbnum(topic)) <= 0) - outs("本名稱並不存在"); - else - break; - } while (temp > 0); + case 6: + generalnamecomplete("請輸入看板英文名稱:", + topic, IDLEN+1, + SHM->Bnumber, + completeboard_compar, + completeboard_permission, + completeboard_getname); snprintf(title, sizeof(title), "[罷免板主] %s", topic); snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s", "罷免板主", "英文名稱: ", @@ -318,17 +298,8 @@ do_voteboard() } while (temp > 0); strcat(genbuf, topic); strcat(genbuf, "\n罷免原因: \n"); - outs("請輸入罷免原因(至多五行),要清楚填寫不然不會核准喔"); - for (i = 8; i < 13; i++) { - if (!getdata(i, 0, ":", topic, 60, DOECHO)) - break; - strcat(genbuf, topic); - strcat(genbuf, "\n"); - } - if (i == 8) - return FULLUPDATE; break; - case 5: + case 7: if (!getdata(4, 0, "請輸入小組中英文名稱:", topic, 30, DOECHO)) return FULLUPDATE; snprintf(title, sizeof(title), "[連署小組長] %s", topic); @@ -336,18 +307,8 @@ do_voteboard() "%s\n\n%s%s\n%s%s", "連署小組長", "小組名稱: ", topic, "申請 ID : ", cuser.userid); strcat(genbuf, "\n申請政見: \n"); - outs("請輸入申請政見(至多五行),要清楚填寫不然不會核准喔"); - for (i = 8; i < 13; i++) { - if (!getdata(i, 0, ":", topic, 60, DOECHO)) - break; - strcat(genbuf, topic); - strcat(genbuf, "\n"); - } - if (i == 8) - return FULLUPDATE; break; - case 6: - + case 8: if (!getdata(4, 0, "請輸入小組中英文名稱:", topic, 30, DOECHO)) return FULLUPDATE; snprintf(title, sizeof(title), "[罷免小組長] %s", topic); @@ -357,55 +318,27 @@ do_voteboard() return FULLUPDATE; strcat(genbuf, topic); strcat(genbuf, "\n罷免原因: \n"); - outs("請輸入罷免原因(至多五行),要清楚填寫不然不會核准喔"); - for (i = 8; i < 13; i++) { - if (!getdata(i, 0, ":", topic, 60, DOECHO)) - break; - strcat(genbuf, topic); - strcat(genbuf, "\n"); - } - if (i == 8) - return FULLUPDATE; - break; - case 7: - if (!HAS_PERM(PERM_SYSOP)) - return FULLUPDATE; - if (!getdata(4, 0, "請輸入公投主題:", topic, 30, DOECHO)) - return FULLUPDATE; - snprintf(title, sizeof(title), "%s %s", "[站民公投]", topic); - snprintf(genbuf, sizeof(genbuf), - "%s\n\n%s%s\n", "站民公投", "公投主題: ", topic); - strcat(genbuf, "\n公投原因: \n"); - outs("請輸入公投原因(至多五行),要清楚填寫不然不會核准喔"); - for (i = 8; i < 13; i++) { - if (!getdata(i, 0, ":", topic, 60, DOECHO)) - break; - strcat(genbuf, topic); - strcat(genbuf, "\n"); - } - if (i == 8) - return FULLUPDATE; break; - case 8: + case 9: if (!getdata(4, 0, "請輸入群組中英文名稱:", topic, 30, DOECHO)) return FULLUPDATE; snprintf(title, sizeof(title), "[申請新群組] %s", topic); snprintf(genbuf, sizeof(genbuf), "%s\n\n%s%s\n%s%s", "申請群組", "群組名稱: ", topic, "申請 ID : ", cuser.userid); strcat(genbuf, "\n申請政見: \n"); - outs("請輸入申請政見(至多五行),要清楚填寫不然不會核准喔"); - for (i = 8; i < 13; i++) { + break; + default: + return FULLUPDATE; + } + outs("請輸入簡介或政見(至多五行),要清楚填寫不然不會核准喔"); + for (i = 8; i < 13; i++) { if (!getdata(i, 0, ":", topic, 60, DOECHO)) break; strcat(genbuf, topic); strcat(genbuf, "\n"); } - if (i == 8) + if (i == 8) return FULLUPDATE; - break; - default: - return FULLUPDATE; - } strcat(genbuf, "連署結束時間: "); now += 14 * 24 * 60 * 60; snprintf(topic, sizeof(topic), "(%ld)", now); @@ -430,6 +363,7 @@ do_voteboard() fclose(fp); strlcpy(votefile.owner, cuser.userid, sizeof(votefile.owner)); strlcpy(votefile.title, title, sizeof(votefile.title)); + votefile.filemode |= FILE_VOTE; setbdir(genbuf, currboard); if (append_record(genbuf, &votefile, sizeof(votefile)) != -1) setbtotal(currbid); |