From 890dd47e135c29397a6006556e186061f2afcc67 Mon Sep 17 00:00:00 2001 From: piaip Date: Tue, 4 Dec 2007 17:38:19 +0000 Subject: - move hard-coded board names to pttbbs.conf. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3629 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/config.h | 22 ++++++++++++++++++++++ mbbsd/bbs.c | 23 ++++++++++++++++++----- mbbsd/cache.c | 2 +- mbbsd/gamble.c | 2 +- mbbsd/mail.c | 2 +- mbbsd/mbbsd.c | 6 ++---- mbbsd/talk.c | 4 ++-- mbbsd/user.c | 2 +- sample/pttbbs.conf | 29 +++++++++++++++++++++++------ 9 files changed, 71 insertions(+), 21 deletions(-) diff --git a/include/config.h b/include/config.h index 62113515..ff5006a0 100644 --- a/include/config.h +++ b/include/config.h @@ -31,6 +31,28 @@ #define BBSGID (99) #endif +/* Default Board Names */ +#ifndef GLOBAL_BUGREPORT +#define GLOBAL_BUGREPORT "SYSOP" +#endif + +#ifndef GLOBAL_LAW +#define GLOBAL_LAW BBSMNAME "Law" +#endif + +#ifndef GLOBAL_NEWBIE +#define GLOBAL_NEWBIE BBSMNAME "NewHand" +#endif + +#ifndef GLOBAL_NOTE +#define GLOBAL_NOTE "Note" +#endif + +#ifndef GLOBAL_FOREIGN +#define GLOBAL_FOREIGN BBSMNAME "Foreign" +#endif + +/* Environment */ #ifndef RELAY_SERVER_IP /* 寄站外信的 mail server */ #define RELAY_SERVER_IP "127.0.0.1" #endif diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 934cf3e9..2cd2bb91 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -825,7 +825,8 @@ do_general(int isbid) if( !CheckPostPerm() #ifdef FOREIGN_REG // 不是外籍使用者在 PttForeign 板 - && !((cuser.uflag2 & FOREIGN) && strcmp(bp->brdname, "PttForeign") == 0) + && !((cuser.uflag2 & FOREIGN) && + strcmp(bp->brdname, GLOBAL_FOREIGN) == 0) #endif ) { vmsg("對不起,您目前無法在此發表文章!"); @@ -3241,8 +3242,14 @@ good_post(int ent, fileheader_t * fhdr, const char *direct) if (fhdr->filemode & FILE_DIGEST) { fhdr->filemode = (fhdr->filemode & ~FILE_DIGEST); - if (!strcmp(currboard, "Note") || !strcmp(currboard, "PttBug") || - !strcmp(currboard, "Artdsn") || !strcmp(currboard, "PttLaw")) { + if (!strcmp(currboard, GLOBAL_NOTE) || + // 2007/12/05: what is 'Artdsn' here? + // disable it unless someone need it... + // !strcmp(currboard, "Artdsn") || + !strcmp(currboard, GLOBAL_BUGREPORT) || + !strcmp(currboard, GLOBAL_LAW) + ) + { deumoney(searchuser(fhdr->owner, NULL), -1000); // TODO if searchuser() return 0 if (!(currmode & MODE_SELECT)) fhdr->multi.money -= 1000; @@ -3281,8 +3288,14 @@ good_post(int ent, fileheader_t * fhdr, const char *direct) #endif fhdr->filemode = (fhdr->filemode & ~FILE_MARKED) | FILE_DIGEST; - if (!strcmp(currboard, "Note") || !strcmp(currboard, "PttBug") || - !strcmp(currboard, "Artdsn") || !strcmp(currboard, "PttLaw")) { + if (!strcmp(currboard, GLOBAL_NOTE) || + // 2007/12/05: what is 'Artdsn' here? + // disable it unless someone need it... + // !strcmp(currboard, "Artdsn") || + !strcmp(currboard, GLOBAL_BUGREPORT) || + !strcmp(currboard, GLOBAL_LAW) + ) + { deumoney(searchuser(fhdr->owner, NULL), 1000); // TODO if searchuser() return 0 if (!(currmode & MODE_SELECT)) fhdr->multi.money += 1000; diff --git a/mbbsd/cache.c b/mbbsd/cache.c index f38263e8..881748cd 100644 --- a/mbbsd/cache.c +++ b/mbbsd/cache.c @@ -855,7 +855,7 @@ reload_pttcache(void) SHM->Pbusystate = 1; SHM->last_film = 0; bzero(SHM->notes, sizeof(SHM->notes)); - setapath(pbuf, "Note"); + setapath(pbuf, GLOBAL_NOTE); setadir(buf, pbuf); id = 0; if ((fp = fopen(buf, "r"))) { diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index 3229b906..9896333d 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -249,7 +249,7 @@ openticket(int bid) if(rename(buf, outcome) != 0) { unlockutmpmode(); - vmsg("無法準備開獎... 請至 PttBug 報告並附上板名。"); + vmsg("無法準備開獎... 請至 " GLOBAL_BUGREPORT " 報告並附上板名。"); return 0; } diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 74efde1f..0196aa88 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -155,7 +155,7 @@ invalidaddr(const char *addr) "但檢查不出原因,所以我們需要正確的錯誤回報。\n\n" "如果你確實打錯了,請直接略過下面的說明。\n" "如果你認為你輸入的位址確實是對的,請把下面的訊息複製起來\n" - "並貼到 SYSOP 或 PttBug 板。本站為造成不便深感抱歉。\n\n" + "並貼到 " GLOBAL_BUGREPORT " 板。本站為造成不便深感抱歉。\n\n" ANSI_COLOR(1;33)); sprintf(errmsg, "原始輸入位址: [%s]\n" "錯誤位置: 第 %d 字元: 0x%02X [ %c ]\n", diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 3e1fbef0..87b98b0f 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -257,16 +257,14 @@ abort_bbs_debug(int sig) sigaddset(&sigset, SIGXCPU); sigprocmask(SIG_UNBLOCK, &sigset, NULL); - // TODO change the PttBug to some other names for non-PTT sites? - #define CRASH_MSG ANSI_COLOR(0) \ "\r\n程式異常, 立刻斷線. \r\n" \ - "請洽 PttBug 板詳述問題發生經過。\r\n" + "請洽 " GLOBAL_BUGREPORT " 板詳述問題發生經過。\r\n" #define XCPU_MSG ANSI_COLOR(0) \ "\r\n程式耗用過多計算資源, 立刻斷線。\r\n" \ "可能是 (a)執行太多耗用資源的動作 或 (b)程式掉入無窮迴圈. "\ - "請洽 PttBug 板詳述問題發生經過。\r\n" + "請洽 " GLOBAL_BUGREPORT " 板詳述問題發生經過。\r\n" if(sig==SIGXCPU) write(1, XCPU_MSG, sizeof(XCPU_MSG)); diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 31694b34..32d22a96 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -3407,7 +3407,7 @@ GotoNewHand(){ if (currboard[0]) strlcpy(old_board, currboard, IDLEN + 1); - if (enter_board("PttNewHand")==0) { + if (enter_board(GLOBAL_NEWBIE)==0) { Read(); } @@ -3470,7 +3470,7 @@ AngelNotOnline(){ "──────────────┴☉" ANSI_RESET "\n"); move(b_lines - 4, 0); - outs("小主人使用上問題找不到小天使請到新手版(PttNewhand)\n" + outs("小主人使用上問題找不到小天使請到新手版(" GLOBAL_NEWBIE ")\n" " 想留言給小天使請到許\願版(AngelPray)\n" " 想找看板在哪的話可到(AskBoard)\n" "請先在各板上尋找答案或按 Ctrl-P 發問"); diff --git a/mbbsd/user.c b/mbbsd/user.c index c8a7943b..f89d1d82 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -241,7 +241,7 @@ mail_violatelaw(const char *crime, const char *police, const char *reason, const "時間: %s\n" ANSI_COLOR(1;32) "%s" ANSI_RESET "判決:\n " ANSI_COLOR(1;32) "%s" ANSI_RESET "因" ANSI_COLOR(1;35) "%s" ANSI_RESET "行為,\n違反本站站規,處以" ANSI_COLOR(1;35) "%s" ANSI_RESET ",特此通知" - "\n請到 PttLaw 查詢相關法規資訊,並到 Play-Pay-ViolateLaw 繳交罰單", + "\n請到 " GLOBAL_LAW " 查詢相關法規資訊,並到 Play-Pay-ViolateLaw 繳交罰單", ctime4(&now), police, crime, reason, result); fclose(fp); strcpy(fhdr.title, "[報告] 違法判決報告"); diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf index a3ed4c5c..a086184c 100644 --- a/sample/pttbbs.conf +++ b/sample/pttbbs.conf @@ -31,6 +31,29 @@ #define BBSUID 9999 #define BBSGID 99 +/* *** 以下為預設板名 *** */ + +/* 發生錯誤時建議的回報板名為此板 */ +#define GLOBAL_BUGREPORT BBSMNAME "Bug" +/* 法律訴訟的板 */ +#define GLOBAL_LAW BBSMNAME "Law" +/* 新手板 */ +#define GLOBAL_NEWBIE BBSMNAME "NewHand" +/* 動態看板的家 */ +#define GLOBAL_NOTE "Note" +/* 外國板 */ +#define GLOBAL_FOREIGN BBSMNAME "Foreign" + +/* *** 以下為定義時會多出功能的板名 *** */ + +/* 若定義, 則以此為版名提供全站文摘 */ +#define GLOBAL_DIGEST BBSMNAME "Digest" + +/* 若定義, 則全站所有五子棋/象棋棋譜都會紀錄在此板 */ +//#define GLOBAL_FIVECHESS_LOG BBSMNAME "Five" +//#define GLOBAL_CCHESS_LOG BBSMNAME "CChess" + + /* 最大編輯行數, 以防有惡意使用者 post 巨大文章 */ #define MAX_EDIT_LINE 2048 @@ -98,12 +121,6 @@ /* 若定義, 用一個奇怪的數字來檢查我的最愛和看板列表是否錯誤 */ #define MEM_CHECK 0x98761234 -/* 若定義, 則以此為版名提供全站文摘 */ -#define GLOBAL_DIGEST "PttDigest" - -/* 若定義, 則全站所有五子棋/象棋棋譜都會紀錄在此板 */ -//#define GLOBAL_FIVECHESS_LOG "PttFive" -//#define GLOBAL_CCHESS_LOG "PttCChess" /* 若定義, 則可在外部 (shmctl cmsignal) 要求將 mbbsd將 zapbuf 釋放掉. 會使用非正規的記憶體要求函式. (目前只在 FreeBSD上測試過) -- cgit v1.2.3