diff options
-rw-r--r-- | mbbsd/syspost.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index da62db13..9ced9918 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -57,45 +57,37 @@ post_file(const char *bname, const char *title, const char *filename, const char void post_change_perm(int oldperm, int newperm, const char *sysopid, const char *userid) { - FILE *fp; - fileheader_t fhdr; - char genbuf[200], reason[30]; - int i, flag = 0; - - setbpath(genbuf, GLOBAL_SECURITY); - stampfile(genbuf, &fhdr); - if (!(fp = fopen(genbuf, "w"))) - return; + char genbuf[(NUMPERMS+1) * STRLEN*2] = "", reason[30] = ""; + char title[TTLEN+1]; + char *s = genbuf; + int i, flag = 0; - fprintf(fp, "作者: [系統安全局] 看板: " GLOBAL_SECURITY "\n" - "標題: [公安報告] 站長修改權限報告\n" - "時間: %s\n", ctime4(&now)); + // generate log (warning: each line should <= STRLEN*2) for (i = 0; i < NUMPERMS; i++) { if (((oldperm >> i) & 1) != ((newperm >> i) & 1)) { - fprintf(fp, " 站長" ANSI_COLOR(1;32) "%s%s%s%s" ANSI_RESET "的權限\n", + sprintf(s, " 站長" ANSI_COLOR(1;32) "%s%s%s%s" ANSI_RESET "的權限\n", sysopid, (((oldperm >> i) & 1) ? ANSI_COLOR(1;33) "關閉" : ANSI_COLOR(1;33) "開啟"), userid, str_permid[i]); + s += strlen(s); flag++; } } - if (flag) { - clrtobot(); - clear(); - while (!getdata(5, 0, "請輸入理由以示負責:", - reason, sizeof(reason), DOECHO)); - fprintf(fp, "\n " ANSI_COLOR(1;37) "站長%s修改權限理由是:%s" ANSI_RESET, - cuser.userid, reason); - fclose(fp); - - snprintf(fhdr.title, sizeof(fhdr.title), - "[公安報告] 站長%s修改%s權限報告", - cuser.userid, userid); - strlcpy(fhdr.owner, "[系統安全局]", sizeof(fhdr.owner)); - append_record("boards/S/Security/" FN_DIR, &fhdr, sizeof(fhdr)); - } else - fclose(fp); + if (!flag) // nothing changed + return; + + clrtobot(); + clear(); + while (!getdata(5, 0, "請輸入理由以示負責:", + reason, sizeof(reason), DOECHO)); + sprintf(s, "\n " ANSI_COLOR(1;37) "站長%s修改權限理由是:%s" ANSI_RESET, + cuser.userid, reason); + + snprintf(title, sizeof(title), "[公安報告] 站長%s修改%s權限報告", + cuser.userid, userid); + + post_msg(GLOBAL_SECURITY, title, genbuf, "[系統安全局]"); } void |