diff options
-rw-r--r-- | pttbbs/include/proto.h | 7 | ||||
-rw-r--r-- | pttbbs/mbbsd/syspost.c | 35 |
2 files changed, 33 insertions, 9 deletions
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h index f60e6fb4..37c240c8 100644 --- a/pttbbs/include/proto.h +++ b/pttbbs/include/proto.h @@ -642,12 +642,17 @@ int getdata_buf(int line, int col, const char *prompt, char *buf, int len, int /* syspost */ int post_msg(const char* bname, const char* title, const char *msg, const char* author); +int post_msg2(const char* bname, const char* title, const char *msg, + const char* author, char *output_path); int post_file(const char *bname, const char *title, const char *filename, const char *author); void post_newboard(const char *bgroup, const char *bname, const char *bms); void post_violatelaw(const char *crime, const char *police, const char *reason, const char *result); void post_violatelaw2(const char *crime, const char *police, const char *reason, const char *result, const char *memo); void post_change_perm(int oldperm, int newperm, const char *sysopid, const char *userid); -void post_policelog(const char *bname, const char *atitle, const char *action, const char *reason, const int toggle); +void post_policelog(const char *bname, const char *atitle, const char *action, + const char *reason, const int toggle); +void post_policelog2(const char *bname, const char *atitle, const char *action, + const char *reason, const int toggle, const char *attach_file); /* talk */ #define iswritable(uentp) \ diff --git a/pttbbs/mbbsd/syspost.c b/pttbbs/mbbsd/syspost.c index fc979559..824fb625 100644 --- a/pttbbs/mbbsd/syspost.c +++ b/pttbbs/mbbsd/syspost.c @@ -1,8 +1,8 @@ /* $Id$ */ #include "bbs.h" -int -post_msg(const char* bname, const char* title, const char *msg, const char* author) +int post_msg2(const char* bname, const char* title, const char *msg, + const char* author, char *output_path) { char fname[PATHLEN]; FILE *fp; @@ -15,13 +15,15 @@ post_msg(const char* bname, const char* title, const char *msg, const char* auth stampfile(fname, &fhdr); fp = fopen(fname, "w"); + if (output_path) + strlcpy(output_path, fname, PATHLEN); + if (!fp) return -1; fprintf(fp, "作者: %s 看板: %s\n標題: %s \n", author, bname, title); fprintf(fp, "時間: %s\n", ctime4(&now)); - /* 文章的內容 */ fputs(msg, fp); fclose(fp); @@ -35,6 +37,11 @@ post_msg(const char* bname, const char* title, const char *msg, const char* auth return 0; } +int post_msg(const char* bname, const char* title, const char *msg, + const char* author) { + return post_msg2(bname, title, msg, author, NULL); +} + int post_file(const char *bname, const char *title, const char *filename, const char *author) { @@ -144,15 +151,27 @@ post_newboard(const char *bgroup, const char *bname, const char *bms) } void -post_policelog(const char *bname, const char *atitle, const char *action, const char *reason, const int toggle) +post_policelog2(const char *bname, const char *atitle, const char *action, + const char *reason, const int toggle, const char *attach_file) { - char genbuf[ANSILINELEN], title[TTLEN+1]; + char msg_file[PATHLEN]; + char genbuf[ANSILINELEN], title[TTLEN+1]; - snprintf(title, sizeof(title), "[%s][%s] %s by %s", action, toggle ? "開啟" : "關閉", bname, cuser.userid); + snprintf(title, sizeof(title), "[%s][%s] %s by %s", action, + toggle ? "開啟" : "關閉", bname, cuser.userid); snprintf(genbuf, sizeof(genbuf), - "%s (%s) %s %s 看板 %s 功\能\n原因 : %s\n%s%s\n", + "%s (%s) %s %s 看板 %s 功\能\n原因 : %s\n%s%s\n\n", cuser.userid, fromhost, toggle ? "開啟" : "關閉", bname, action, reason, atitle ? "文章標題 : " : "", atitle ? atitle : ""); - post_msg("PoliceLog", title, genbuf, "[系統]"); + if (post_msg2("PoliceLog", title, genbuf, "[系統]", msg_file) == 0) { + if (attach_file) + AppendTail(attach_file, msg_file, 0); + } +} + +void +post_policelog(const char *bname, const char *atitle, const char *action, + const char *reason, const int toggle) { + return post_policelog2(bname, atitle, action, reason, toggle, NULL); } |