diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-10-19 19:31:04 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2010-10-19 19:31:04 +0800 |
commit | 43b2494d6d44525f0e0fc0f0ede1aa69754deb92 (patch) | |
tree | 161c936ba0c5cadb2537d5c66bb39d88529b050d | |
parent | 38a5a1df585345d5c3fd204214be54aaa7c85be8 (diff) | |
download | pttbbs-43b2494d6d44525f0e0fc0f0ede1aa69754deb92.tar pttbbs-43b2494d6d44525f0e0fc0f0ede1aa69754deb92.tar.gz pttbbs-43b2494d6d44525f0e0fc0f0ede1aa69754deb92.tar.bz2 pttbbs-43b2494d6d44525f0e0fc0f0ede1aa69754deb92.tar.lz pttbbs-43b2494d6d44525f0e0fc0f0ede1aa69754deb92.tar.xz pttbbs-43b2494d6d44525f0e0fc0f0ede1aa69754deb92.tar.zst pttbbs-43b2494d6d44525f0e0fc0f0ede1aa69754deb92.zip |
complete recentpay support
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5128 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/common/bbs/log.c | 21 | ||||
-rw-r--r-- | pttbbs/include/cmbbs.h | 4 | ||||
-rw-r--r-- | pttbbs/include/common.h | 4 | ||||
-rw-r--r-- | pttbbs/mbbsd/cal.c | 25 | ||||
-rw-r--r-- | pttbbs/mbbsd/menu.c | 16 |
5 files changed, 55 insertions, 15 deletions
diff --git a/pttbbs/common/bbs/log.c b/pttbbs/common/bbs/log.c index eef9d807..bcf1c7d3 100644 --- a/pttbbs/common/bbs/log.c +++ b/pttbbs/common/bbs/log.c @@ -1,3 +1,24 @@ #include "bbs.h" #include "cmbbs.h" +// common log with formats for BBS (utils and clients) + +int +log_payment(const char *filename, int money, int oldm, int newm, + const char *reason) +{ +#if defined(USE_RECENTPAY) || defined(LOG_RECENTPAY) + return log_filef(filename, + LOG_CREAT, + "%s %s $%d ($%d => $%d) %s\n", + Cdatelite(&now), + money >= 0 ? "支出" : "收入", + money >= 0 ? money : -money, + oldm, + newm, + reason); +#else + return 0; +#endif +} + diff --git a/pttbbs/include/cmbbs.h b/pttbbs/include/cmbbs.h index 393d849c..697b8be7 100644 --- a/pttbbs/include/cmbbs.h +++ b/pttbbs/include/cmbbs.h @@ -38,6 +38,10 @@ extern int stampdir(char *fpath, fileheader_t * fh); extern int stamplink(char *fpath, fileheader_t * fh); extern int stampfile_u(char *fpath, fileheader_t *fh); // does not zero existing data in fh +/* log.c */ +extern int log_payment(const char *filename, int money, int oldm, int newm, + const char *reason); + /* cache.c */ #define search_ulist(uid) search_ulistn(uid, 1) #define getbcache(bid) (bcache + bid - 1) diff --git a/pttbbs/include/common.h b/pttbbs/include/common.h index e3ba731d..d8d8d374 100644 --- a/pttbbs/include/common.h +++ b/pttbbs/include/common.h @@ -46,6 +46,10 @@ #ifndef SZ_RECENTLOGIN #define SZ_RECENTLOGIN (16000) // size of max recent log before rotation #endif +#define FN_RECENTPAY "money.recent" +#ifndef SZ_RECENTPAY +#define SZ_RECENTPAY (16000) +#endif // 自訂刪除文章時出現的標題與檔案 diff --git a/pttbbs/mbbsd/cal.c b/pttbbs/mbbsd/cal.c index 8882bd5a..6c65da3a 100644 --- a/pttbbs/mbbsd/cal.c +++ b/pttbbs/mbbsd/cal.c @@ -77,18 +77,13 @@ do_pay(int uid, int money, const char *item, const char *reason) if (uid == usernum) reload_money(); -#ifdef FN_RECENTPAY - - char buf[PATHLEN]; - sethomefile(buf, userid, FN_RECENTPAY); - rotate_text_logfile(buf, SZ_RECENTPAY, 0.2); - syncnow(); - log_filef(buf, LOG_CREAT, "%s %s $%d ($%d => $%d) %s\n", - Cdatelite(&now), - money >= 0 ? "支出" : "收入", - money >= 0 ? money : -money, - oldm, newm, reason); -#endif + { + char buf[PATHLEN]; + sethomefile(buf, userid, FN_RECENTPAY); + rotate_text_logfile(buf, SZ_RECENTPAY, 0.2); + syncnow(); + log_payment(buf, money, oldm, newm, reason); + } return newm; } @@ -491,10 +486,10 @@ give_money_ui(const char *userid) char fpath[PATHLEN]; if (mail_redenvelop( myid, id, m - mtax, fpath) < 0) { -#ifdef FN_RECENTPAY - outs("您可以於下列位置找到最近的交易記錄:\n" +#ifdef USE_RECENTPAY + outs("您可於下列位置找到最近的交易記錄:\n" "主選單 => (U)ser個人設定 => (L)MyLogs 個人記錄 => " - "(V)RecentVice 最近交易記錄\n"); + "(P)Recent Pay 最近交易記錄\n"); #endif vmsg("交易完成。"); return 0; diff --git a/pttbbs/mbbsd/menu.c b/pttbbs/mbbsd/menu.c index 0c81d155..2f39ebc7 100644 --- a/pttbbs/mbbsd/menu.c +++ b/pttbbs/mbbsd/menu.c @@ -649,6 +649,19 @@ static int u_view_recentlogin() return more(fn, YEA); } +#ifdef USE_RECENTPAY +static int u_view_recentpay() +{ + char fn[PATHLEN]; + clear(); + mvouts(10, 5, "注意: 本記錄尚於測試中,可能會有未記錄到的交易記錄。"); + mvouts(11, 5, " 此處內容僅供參考,實際金錢異動以站方內部資料為準"); + pressanykey(); + setuserfile(fn, FN_RECENTPAY); + return more(fn, YEA); +} +#endif + static const commands_t myfilelist[] = { {u_editplan, PERM_LOGINOK, "QQueryEdit 編輯名片檔"}, {u_editsig, PERM_LOGINOK, "SSignature 編輯簽名檔"}, @@ -657,6 +670,9 @@ static const commands_t myfilelist[] = { static const commands_t myuserlog[] = { {u_view_recentlogin, 0, "LLRecent Login 最近上站記錄"}, +#ifdef USE_RECENTPAY + {u_view_recentpay, 0, "PPRecent Pay 最近交易記錄"}, +#endif {NULL, 0, NULL} }; |