作者Dopin (ats.twbbs.org)
站内SetupBBS
标题<转录/Local Save> 板主审核外转文章 (maple 2.3x 家族)
时间Fri Dec 11 19:06:45 2009
作者 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
/* ----------------------------------------------------- */
/* 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