作者 Dopin (SOB/ATS gcc4ok ?) 看板 InstallBBS
標題 建議更新 板主審理外轉文章 (maple 2.3X 家族)
時間 Mon Dec 7 21:54:40 2009
───────────────────────────────────────
// 許多站有很多全國轉信板 但不是板主闕如 或是連線砍信不同步 或根本不收砍信
// 訊息 幾個大站也有些 被遺忘的看板 不時有怪信件轉出 這個 patch 建議是給所
// 有架構系統於 maple 2.36 家族 含 Maple 2.36/Maple 2.39/SOB(2003年版以前)
// /PTT(非 Current)/WD 等 沒做過類似 patch 的站台使用的
// 原理很簡單 就是發文不直接 call outgo_post 而是等板主去使用熱鍵審核確定要
// 不要 轉出去/不轉出去 雖然 maple 2.3X 本身就有 (S)ave/(L)ocal 等兩種存檔
// 模式 但絕大多數人不會使用 L 甚至廣告商他恨不得東西快快轉出去
// 本文原文 2003/07/12 發布於 ATSVersion @ bbs.bsd.com.tw 經修改後適用於所
// 有 maple 2.3X 家族 不過仍可能有些小地方不適用 有勞自行比較變更 尤其是有
// 做過置底更動的版本 請注意 .DIR 的一致性處理
// 在此再次特別感謝 Joehorn.bbs@Star.leobbs.net / dinos.bbs@bbs.bsd.com.tw
// 兩位提供寶貴的意見與實作上的手法
// 黃色 新增 / 紅色 變更 / 綠色 刪除 / 天藍 請依實際狀況修改
[基本設定與資料結構的變更]
// src/maple/config.h (或是 src/include/config.h) 找任何你想定義的地方新增
#undef HAVE_SUICIDE /* 提供使用者自殺功能 */
#undef OUTGO_SET_DEFAULT /* 定義發文後預設做轉出處理 反定義則需 */
/* 經板主審核後方轉出 預設反定義 */
// src/maple/struct.h (或 src/include/strutc.h 或 pttstruct.h)
struct fileheader {
char filename[FNLEN-2]; /* M.9876543210.A */ // 挪壹字元放下面變數
char outgo; /* 外轉設定 */
char goodpost; /* Dopin: 切格用於提報功能 */
char savemode; /* file save mode */
char owner[IDLEN + 2]; /* uid[.] */
char date[6]; /* [02/02] or space(5) */
char title[TTLEN + 1];
uschar filemode; /* must be last field @ boards.c */
};
typedef struct fileheader fileheader;
struct boardheader {
char brdname[IDLEN + 1]; /* bid */
char title[BTLEN + 1];
char BM[IDLEN * 3 + 3]; /* BMs' uid, token '/' */
char yankflags[11]; /* Dopin: for extra_mode */
time_t bupdate; /* note update time */
char pad2[2]; // 同理 挪壹字元給下面的 outgo_mode 使用 結構長度不變
char outgo_mode; /* tag_outgo */
uschar bvote; /* Vote flags */
time_t vtime; /* Vote close time */
usint level;
};
typedef struct boardheader boardheader;
// src/include/modes.h (或 src/include/modes.h)
#define RS_CURRENT 0x10 /* match current read article */
#define RS_THREAD 0x20 /* search the first article */
#define RS_AUTHOR 0x40 /* search author's article */
#define RS_OUTGO 0x400 /* search select outgo article */
// 數值設大一點 以免跟上面或下面的一堆數值衝到
[新的外轉文章處理]
// src/maple/bbs.c
#include "bbs.h"
#include "put_good.h"
extern int mail_reply();
extern int cmpfname(char *, fileheader *);
extern char currdirect[MAXPATHLEN];
...
int local_article;
void outgo_post(fileheader *, char *, int);
#define UPDATE_USEREC (currmode |= MODE_DIRTY)
static int g_board_names(fhdr)
void set_board() {
...
}
/* 新增此函式 */
#ifndef OUTGO_SET_DEFAULT
static int tag_outgo(int ent, fileheader *fptr, char *direct) {
char ans[2];
fileheader fh;
if(!(currmode & MODE_BOARD)) return DONOTHING;
/* 未開啟功能前的 / 已確定轉出的 不可設定 */
if(fptr->outgo && fptr->outgo != 'Y') {
char buf[96];
sprintf(buf, "將 <%-.40s> 設為 (Y)轉出 (N)不轉出 [Q] : ", fptr->title);
getdata(b_lines, 0, buf, ans, 2, LCECHO, 0);
if(*ans == 'y' || *ans == 'n') {
int fno;
if(currmode & MODE_SELECT) {
setbfile(buf, currboard, ".DIR");
if((fno = search_record(buf, &fh, sizeof(fh), cmpfname,
fptr->filename)) <= 0) {
pressanykey("檔案讀取錯誤 變更中止");
goto TAG_OUTGO_END;
}
}
else {
strcpy(buf, direct);
fno = ent;
}
fptr->outgo = toupper(*ans);
if(get_record(buf, &fh, sizeof(fh), fno) != -1) {
if(!strcmp(fh.filename, fptr->filename)) {
substitute_record(buf, fptr, sizeof(*fptr), fno);
if(*ans == 'y') outgo_post(&fh, currboard, 'Y');
}
else pressanykey("檔案資料驗證有誤 請重新操作");
}
}
}
else pressanykey("此檔案不允許\變更設定");
TAG_OUTGO_END:
return NEWDIRECT;
}
#endif
/* 到這裡 */
static void readtitle() {
...
}
/* 以下函式請照著變更處修改 */
void outgo_post(fileheader *fh, char *board, int mode) {
char userid[IDLEN+1], username[24];
FILE *fp;
boardheader *bp = getbcache(board);
if(!bp
#ifndef OUTGO_SET_DEFAULT
|| bp->outgo_mode == 'N'
#endif
) return;
#ifndef OUTGO_SET_DEFAULT
if(mode == 'S') {
if(bp->outgo_mode == 'S') {
fh->outgo = 'S';
return;
}
}
#endif
fh->outgo = 'Y';
#ifndef OUTGO_SET_DEFAULT
if(getuser(fh->owner) > 0) {
strcpy(userid, xuser.userid);
strcpy(username, xuser.username);
}
else return;
#else
strcpy(userid, cuser.userid);
strcpy(username, cuser.username);
#endif
if(fp = fopen("innd/out.bntp", "a+")) {
fprintf(fp, "%s\t%s\t%s\t%s\t%s\n", board,
fh->filename, userid, username, fh->title);
fclose(fp);
}
}
/* 到這裡 */
int do_post() {
...
setbdir(buf, currboard);
if(aborted != 1) outgo_post(&postfile, currboard, 'S');
if(append_record(buf, &postfile, sizeof(postfile)) != -1) {
if(currmode & MODE_SELECT)
append_record(currdirect,&postfile,sizeof(postfile));
if(aborted != 1)
outgo_post(&postfile, currboard);
brc_addlist(postfile.filename);
outs("順利貼出佈告,");
...
}
static int cross_post(int ent, fileheader *fhdr, char *direct) {
...
setbdir(fname, xboard);
if(!xfile.filemode) outgo_post(&xfile, xboard, 'S');
append_record(fname, (char *) &xfile, sizeof(xfile));
if(!xfile.filemode) outgo_post(&xfile, xboard);
cuser.numposts++;
...
}
// src/maple/mail.c
extern void outgo_post(fileheader *, char *, int);
extern int del_range();
extern int cmpfmode();
static int mail_cross_post(int ent, fileheader *fhdr, char *direct) {
...
setbdir(fname, xboard);
if(!xfile.filemode && !author) outgo_post(&xfile, xboard, 'S');
append_record(fname, (char *) &xfile, sizeof(xfile));
if(!xfile.filemode && !author)
outgo_post(&xfile, xboard);
if(getbh(&bh, currboard)) if(!(bh.yankflags[1])) cuser.numposts++;
...
}
// src/maple/bbs.c
/* 如果有類似在板上秀檔名的設定 也可照以下修改 (函式名各家不同) */
static int b_showfname(int ent, fileheader *fhdr, char *direct) {
...
sprintf(buf, "boards/%s/%s", currboard, fhdr->filename);
pressanykey("%s <%s outgo>", buf, fhdr->outgo == 'S' ? "Select" :
fhdr->outgo == 'N' ? "Do not" : "Can/Already");
return FULLUPDATE;
}
/* 到這裡 */
struct one_key read_comms[] = {
...
#ifndef OUTGO_SET_DEFAULT
'#', tag_outgo, // 使用那一個熱鍵 請依實際需要修改
#endif
'\0', NULL
};
[選取所有需要審核的信件]
// src/maple/read.c
/* ----------------------------------------------------- */
/* cursor & reading record position control */
/* ----------------------------------------------------- */
int cmpfname(char *filename, fileheader *fhdr) {
return (!strcmp(filename, fhdr->filename));
}
static int select_read(keeploc *locmem, int sr_mode) {
register char *tag, *query;
fileheader fh;
char fpath[80], genbuf[MAXPATHLEN], *outgo = "S";
...
else if (sr_mode == RS_CURRENT)
query = ".";
else if (sr_mode == RS_THREAD)
query = "m";
#ifndef OUTGO_SET_DEFAULT
else if(sr_mode == RS_OUTGO) query = outgo;
#endif
else {
...
case RS_CURRENT:
while(read(fd,&fh,size) == size){
tag = fh.owner;
if(!strchr(tag, '.'))
write(fr,&fh,size);
}
break;
#ifndef OUTGO_SET_DEFAULT
case RS_OUTGO:
while(read(fd, &fh, size) == size)
if(fh.outgo == 'S') write(fr, &fh, size);
break;
#endif
case RS_THREAD:
...
}
static int i_read_key(rcmdlist, locmem, ch)
...
case 'a':
case 'A':
if(select_read(locmem,RS_AUTHOR)) return NEWDIRECT;
else return READ_REDRAW;
#ifndef OUTGO_SET_DEFAULT
case '^': // 請依實際狀況修改適當熱鍵
if(!(currmode & MODE_BOARD)) return DONOTHING;
if(select_read(locmem, RS_OUTGO)) return NEWDIRECT;
else {
pressanykey("未找到任何需要審核是否 外轉 之文章");
return READ_REDRAW;
}
#endif
[顯示看板外轉方式與系統維護]
// src/maple/board.c
static void show_brdlist(head, clsflag, newflag, num) {
,,,
else if(!newflag) { // 各版本顯示格式不同 本段請依實際狀況修改
boardheader *bp = getbcache(ptr->name);
if(!bp) continue;
if(ptr->total == -1) check_newpost(ptr);
prints("%5d%c%s", head,
#ifndef OUTGO_SET_DEFAULT
bp->outgo_mode ? bp->outgo_mode :
#endif
ptr->zap ? '-' : ' ', ptr->unread ? "‧" :
"。");
}
else if (ptr->zap)
...
}
// src/maple/admin.c
/* 於新增看板的函式 的適當位置中 新增 */
int m_newbrd() {
...
#ifdef OUTGO_SET_DEFAULT
newboard.outgo_mode = 'A';
#else
getdata(7, 0, "轉信原則 (A)全部轉出 (N)不轉出 (S)板主審核 [S] ", ans,
2, LCECHO, 0);
if(*ans == 'a' || *ans == 'n' || *ans == 's')
newboard.outgo_mode = toupper(*ans);
else newboard.outgo_mode = 'S'; // 都沒設全部預設板主設定 以免轉出
#endif
newboard.level = 0;
getdata(8, 0, "設定讀寫權限(Y/N)?[N] ", ans, 4, LCECHO, 0);
if (*ans == 'y')
...
}
/* 於新增看板的函式 的適當位置中 新增 */
int m_board() {
...
#ifdef OUTGO_SET_DEFAULT
newbh.outgo_mode = 'A';
#else
getdata(13, 0, "轉信原則 (A)全部轉出 (N)不轉出 (S)板主審核 [Q] ", genbuf,
2, LCECHO, 0);
if(*genbuf == 'a' || *genbuf == 'n' || *genbuf == 's')
newbh.outgo_mode = toupper(*genbuf);
if(bh.outgo_mode == 'A' || bh.outgo_mode == 'N' || bh.outgo_mode == 'S') ;
else newbh.outgo_mode = 'S';
#endif
getdata(14, 0, "是否更改存取權限(Y/N)?[N] ", genbuf, 2, LCECHO, 0);
if(*genbuf == 'y') {
...
}
--
Origin: Atlantis DN: bbs.bsd.com.tw IP : 203.70.65.27 ST: atlantis
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.70.65.27