diff options
-rw-r--r-- | pttbbs/include/config.h | 22 | ||||
-rw-r--r-- | pttbbs/mbbsd/bbs.c | 75 | ||||
-rw-r--r-- | pttbbs/mbbsd/calendar.c | 6 | ||||
-rw-r--r-- | pttbbs/mbbsd/mail.c | 26 | ||||
-rw-r--r-- | pttbbs/mbbsd/menu.c | 3 | ||||
-rw-r--r-- | pttbbs/mbbsd/read.c | 7 | ||||
-rw-r--r-- | pttbbs/mbbsd/record.c | 37 | ||||
-rw-r--r-- | pttbbs/mbbsd/talk.c | 3 | ||||
-rw-r--r-- | pttbbs/mbbsd/xyz.c | 9 |
9 files changed, 88 insertions, 100 deletions
diff --git a/pttbbs/include/config.h b/pttbbs/include/config.h index cec16ae9..c31a5d8a 100644 --- a/pttbbs/include/config.h +++ b/pttbbs/include/config.h @@ -419,6 +419,28 @@ #endif ///////////////////////////////////////////////////////////////////////////// +// Logging 記錄設定 + +#ifndef LOG_CONF_KEYWORD // 記錄搜尋的關鍵字 +#define LOG_CONF_KEYWORD (0) +#endif +#ifndef LOG_CONF_INTERNETMAIL // 記錄 internet outgoing mail +#define LOG_CONF_INTERNETMAIL (0) +#endif +#ifndef LOG_CONF_PUSH // 記錄推文 +#define LOG_CONF_PUSH (0) +#endif +#ifndef LOG_CONF_EDIT_CALENDAR // 記錄編輯行事曆 +#define LOG_CONF_EDIT_CALENDAR (0) +#endif +#ifndef LOG_CONF_POST // 記錄發文 +#define LOG_CONF_POST (0) +#endif +#ifndef LOG_CONF_CRAWLER // 記錄 crawlers +#define LOG_CONF_CRAWLER (0) +#endif + +///////////////////////////////////////////////////////////////////////////// // Default Configurations 預設參數 #define LOGINASNEW /* 採用上站申請帳號制度 */ diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c index ad3b271e..3acea157 100644 --- a/pttbbs/mbbsd/bbs.c +++ b/pttbbs/mbbsd/bbs.c @@ -1411,17 +1411,14 @@ do_general(int garbage GCC_UNUSED) { char addPost = 0; rename(genbuf, fpath); -#ifdef LOGPOST - { - FILE *fp = fopen("log/post", "a"); - fprintf(fp, "%d %s boards/%c/%s/%s\n", - now, cuser.userid, currboard[0], currboard, - postfile.filename); - fclose(fp); - } -#endif setbtotal(currbid); + LOG_IF(LOG_CONF_POST, + log_filef("log/post", LOG_CREAT, + "%d %s boards/%c/%s/%s\n", + now, cuser.userid, currboard[0], currboard, + postfile.filename)); + if( currmode & MODE_SELECT ) append_record(currdirect, &postfile, sizeof(postfile)); if( !islocal && !(bp->brdattr & BRD_NOTRAN) ){ @@ -1517,12 +1514,11 @@ do_general(int garbage GCC_UNUSED) else sendalert(quote_user, ALERT_NEW_MAIL); } else if ((str = strchr(quote_user, '.'))) { -#ifdef USE_LOG_INTERNETMAIL - log_filef("log/internet_mail.log", LOG_CREAT, - "%s [%s (%s)] %s -> %s: %s\n", - Cdatelite(&now), __FUNCTION__, - currboard, cuser.userid, str + 1, save_title); -#endif + LOG_IF(LOG_CONF_INTERNETMAIL, + log_filef("log/internet_mail.log", LOG_CREAT, + "%s [%s (%s)] %s -> %s: %s\n", + Cdatelite(&now), __FUNCTION__, + currboard, cuser.userid, str + 1, save_title)); msg = "回應至作者外部信箱"; if ( bsmtp(fpath, save_title, str + 1, NULL) < 0) msg = "作者無法收信"; @@ -2292,21 +2288,17 @@ read_post(int ent, fileheader_t * fhdr, const char *direct) more_result = more(genbuf, YEA); -#ifdef LOG_CRAWLER - { - // kcwu: log crawler - static int read_count = 0; - extern Fnv32_t client_code; - - ++read_count; - if (read_count % 1000 == 0) { - time4_t t = time4(NULL); - log_filef("log/read_alot", LOG_CREAT, - "%d %s %d %s %08x %d\n", t, Cdate(&t), getpid(), - cuser.userid, client_code, read_count); - } - } -#endif // LOG_CRAWLER + LOG_IF(LOG_CONF_CRAWLER, { + // kcwu: log crawler + static int read_count = 0; + extern Fnv32_t client_code; + ++read_count; + syncnow(); + if (read_count % 1000 == 0) + log_filef("log/read_alot", LOG_CREAT, + "%d %s %d %s %08x %d\n", (int)now, Cdate(&now), getpid(), + cuser.userid, client_code, read_count); + }); { int posttime=atoi(fhdr->filename+2); @@ -3042,27 +3034,10 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) } else return FULLUPDATE; } - - // log if you want -#ifdef LOG_PUSH - { - static int tolog = 0; - if( tolog == 0 ) - tolog = (cuser.numlogindays < 50) ? 1 : 2; - if( tolog == 1 ){ - FILE *fp; - if( (fp = fopen("log/push", "a")) != NULL ){ - fprintf(fp, "%s %d %s %s %s\n", cuser.userid, - (int)now, currboard, fhdr->filename, msg); - fclose(fp); - } - sleep(1); - } - } -#endif // LOG_PUSH - + LOG_IF(LOG_CONF_PUSH, log_filef("log/push", LOG_CREAT, + "%s %d %s %s %s\n", cuser.userid, + (int)now, currboard, fhdr->filename, msg)); STATINC(STAT_RECOMMEND); - { /* build tail first. */ char tail[STRLEN]; diff --git a/pttbbs/mbbsd/calendar.c b/pttbbs/mbbsd/calendar.c index a8c63eb3..3bea36e9 100644 --- a/pttbbs/mbbsd/calendar.c +++ b/pttbbs/mbbsd/calendar.c @@ -295,8 +295,12 @@ u_editcalendar(void) setutmpmode(EDITPLAN); sethomefile(genbuf, cuser.userid, "calendar"); aborted = veditfile(genbuf); - if (aborted != EDIT_ABORTED) + if (aborted != EDIT_ABORTED) { + LOG_IF(LOG_CONF_EDIT_CALENDAR, + log_filef("log/calendar.log", LOG_CREAT, + "%s %s\n", Cdatelite(&now), cuser.userid)); vmsg("行事曆更新完畢"); + } return 0; } else if (genbuf[0] == 'd') { sethomefile(genbuf, cuser.userid, "calendar"); diff --git a/pttbbs/mbbsd/mail.c b/pttbbs/mbbsd/mail.c index d02591be..b54c17b1 100644 --- a/pttbbs/mbbsd/mail.c +++ b/pttbbs/mbbsd/mail.c @@ -787,12 +787,11 @@ do_send(const char *userid, const char *title, const char *log_source) default: outs("Y\n請稍候, 信件傳遞中...\n"); ret = bsmtp(fpath, save_title, userid, NULL); -#ifdef USE_LOG_INTERNETMAIL - log_filef("log/internet_mail.log", LOG_CREAT, - "%s [%s - %s] %s -> %s: %s\n", - Cdatelite(&now), log_source, __FUNCTION__, - cuser.userid, userid, save_title); -#endif + LOG_IF(LOG_CONF_INTERNETMAIL, + log_filef("log/internet_mail.log", LOG_CREAT, + "%s [%s - %s] %s -> %s: %s\n", + Cdatelite(&now), log_source, __FUNCTION__, + cuser.userid, userid, save_title)); hold_mail(fpath, userid, save_title); break; } @@ -1429,13 +1428,14 @@ doforward(const char *direct, const fileheader_t * fh, int mode) } else return -1; -#ifdef USE_LOG_INTERNETMAIL - if (hostaddr) - log_filef("log/internet_mail.log", LOG_CREAT, - "%s [%s] %s -> %s: %s - %s\n", - Cdatelite(&now), __FUNCTION__, - cuser.userid, address, direct, fh->title); -#endif + if (hostaddr) { + LOG_IF(LOG_CONF_INTERNETMAIL, + log_filef("log/internet_mail.log", LOG_CREAT, + "%s [%s] %s -> %s: %s - %s\n", + Cdatelite(&now), __FUNCTION__, + cuser.userid, address, direct, fh->title)); + } + return_no = bsmtp(fname, fh->title, address, NULL); unlink(fname); return (return_no); diff --git a/pttbbs/mbbsd/menu.c b/pttbbs/mbbsd/menu.c index ddf1dc9a..a2cec88f 100644 --- a/pttbbs/mbbsd/menu.c +++ b/pttbbs/mbbsd/menu.c @@ -868,9 +868,6 @@ int _debug_reportstruct() static const commands_t m_xyz_hot[] = { {x_week, 0, "Week 《本週五十大熱門話題》"}, {x_issue, 0, "Issue 《今日十大熱門話題》"}, -#ifdef HAVE_X_BOARDS - {x_boards,0, "Hot Boards 《看板人氣排行榜》"}, -#endif {x_boardman,0, "Man Boards 《看板精華區排行榜》"}, {NULL, 0, NULL} }; diff --git a/pttbbs/mbbsd/read.c b/pttbbs/mbbsd/read.c index 6d16831a..f6da8571 100644 --- a/pttbbs/mbbsd/read.c +++ b/pttbbs/mbbsd/read.c @@ -522,10 +522,9 @@ select_read(const keeploc_t * locmem, int sr_mode) currmode & MODE_SELECT ? "增加條件 標題: ":"搜尋標題: ", keyword, TTLEN, DOECHO) || trim_blank(keyword)) return READ_REDRAW; -#ifdef KEYWORD_LOG - log_filef("keyword_search_log", LOG_CREAT, - "%s:%s\n", currboard, keyword); -#endif + + LOG_IF(LOG_CONF_KEYWORD, log_filef("keyword_search_log", LOG_CREAT, + "%s:%s\n", currboard, keyword)); } else if(sr_mode & RS_KEYWORD_EXCLUDE) { diff --git a/pttbbs/mbbsd/record.c b/pttbbs/mbbsd/record.c index fdd41b13..ce38935b 100644 --- a/pttbbs/mbbsd/record.c +++ b/pttbbs/mbbsd/record.c @@ -537,14 +537,13 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char * if (get_num_records(fpath, sizeof(fileheader_t)) > MAX_KEEPMAIL_HARDLIMIT) { unlink(buf); // TODO add a mail so that origid knows what happened. -#ifdef USE_LOG_INTERNETMAIL - log_filef("log/internet_mail.log", LOG_CREAT, - "%s [%s] (%s -> %s) mailbox overflow (%d > %d)\n", - Cdatelite(&now), __FUNCTION__, - origid, address, - get_num_records(fpath, sizeof(fileheader_t)), - MAX_KEEPMAIL_HARDLIMIT); -#endif + LOG_IF(LOG_CONF_INTERNETMAIL, + log_filef("log/internet_mail.log", LOG_CREAT, + "%s [%s] (%s -> %s) mailbox overflow (%d > %d)\n", + Cdatelite(&now), __FUNCTION__, + origid, address, + get_num_records(fpath, sizeof(fileheader_t)), + MAX_KEEPMAIL_HARDLIMIT)); return 0; } @@ -555,12 +554,11 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char * #ifndef UNTRUSTED_FORWARD_TIMEBOMB // delete the setting if we don't have timebombs. unlink(buf); -#ifdef USE_LOG_INTERNETMAIL - log_filef("log/internet_mail.log", LOG_CREAT, - "%s [%s] Removed bad address: %s (%s)\n", - Cdatelite(&now), __FUNCTION__, - address, origid); -#endif + LOG_IF(LOG_CONF_INTERNETMAIL, + log_filef("log/internet_mail.log", LOG_CREAT, + "%s [%s] Removed bad address: %s (%s)\n", + Cdatelite(&now), __FUNCTION__, + address, origid)); #endif return 0; } @@ -574,12 +572,11 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char * snprintf(fwd_title, sizeof(fwd_title)-1, "[自動轉寄] %s", record->title); bsmtp(buf, fwd_title, address, origid); -#ifdef USE_LOG_INTERNETMAIL - log_filef("log/internet_mail.log", LOG_CREAT, - "%s [%s] %s -> (%s) %s: %s\n", - Cdatelite(&now), __FUNCTION__, - cuser.userid, origid, address, fwd_title); -#endif + LOG_IF(LOG_CONF_INTERNETMAIL, + log_filef("log/internet_mail.log", LOG_CREAT, + "%s [%s] %s -> (%s) %s: %s\n", + Cdatelite(&now), __FUNCTION__, + cuser.userid, origid, address, fwd_title)); // #endif // USE_MAIL_AUTO_FORWARD return 0; } diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c index 04b4afd4..6d37a0c9 100644 --- a/pttbbs/mbbsd/talk.c +++ b/pttbbs/mbbsd/talk.c @@ -2693,6 +2693,9 @@ t_users(void) int mode0 = currutmp->mode; int stat0 = currstat; + if (!HasUserPerm(PERM_LOGINOK)) + return 0; + assert(strncmp(cuser.userid, currutmp->userid, IDLEN)==0); if( strncmp(cuser.userid , currutmp->userid, IDLEN) != 0 ){ abort_bbs(0); diff --git a/pttbbs/mbbsd/xyz.c b/pttbbs/mbbsd/xyz.c index 9c7a8a46..fd234d30 100644 --- a/pttbbs/mbbsd/xyz.c +++ b/pttbbs/mbbsd/xyz.c @@ -22,15 +22,6 @@ x_history(void) return 0; } -#ifdef HAVE_X_BOARDS -static int -x_boards(void) -{ - more("etc/topboard.tmp", YEA); - return 0; -} -#endif - int x_issue(void) { |