<轉錄/Local Save> 板主審核外轉文章 (maple 2 …

作者: Dopin (ats.twbbs.org)   2009-12-11 19:06:45
作者 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 的一致性處理
// 在此再次特別感謝 [email protected] / [email protected]
// 兩位提供寶貴的意見與實作上的手法
// 黃色 新增 / 紅色 變更 / 綠色 刪除 / 天藍 請依實際狀況修改
[基本設定與資料結構的變更]
// 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
/*

Links booklink

Contact Us: admin [ a t ] ucptt.com