summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-02-13 21:26:49 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-02-13 21:26:49 +0800
commitca06b8332c9eb4048bfdcc762608642a4c697c75 (patch)
tree1183242375ab5c7b2cf4d613c16cd180c8fd8fca
parent2c96a71ae4f26917936d48009a9c95ea68dfa96b (diff)
downloadpttbbs-ca06b8332c9eb4048bfdcc762608642a4c697c75.tar
pttbbs-ca06b8332c9eb4048bfdcc762608642a4c697c75.tar.gz
pttbbs-ca06b8332c9eb4048bfdcc762608642a4c697c75.tar.bz2
pttbbs-ca06b8332c9eb4048bfdcc762608642a4c697c75.tar.lz
pttbbs-ca06b8332c9eb4048bfdcc762608642a4c697c75.tar.xz
pttbbs-ca06b8332c9eb4048bfdcc762608642a4c697c75.tar.zst
pttbbs-ca06b8332c9eb4048bfdcc762608642a4c697c75.zip
- the report for changing user permission should use post_msg, to prevent wrong btotal calculation.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3910 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/syspost.c50
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