diff options
-rw-r--r-- | include/common.h | 4 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 22 | ||||
-rw-r--r-- | mbbsd/menu.c | 20 |
3 files changed, 45 insertions, 1 deletions
diff --git a/include/common.h b/include/common.h index d3fee9b5..f9377875 100644 --- a/include/common.h +++ b/include/common.h @@ -43,6 +43,10 @@ #define FN_BOARDHELP "etc/board.help" #define FN_USERMEMO "memo.txt" // 使用者個人記事本 #define FN_BADLOGIN "logins.bad" // in BBSHOME & user directory +#define FN_RECENTLOGIN "logins.recent" // in user directory +#ifndef SZ_RECENTLOGIN +#define SZ_RECENTLOGIN (16000) // size of max recent log before rotation +#endif // 自訂刪除文章時出現的標題與檔案 diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 7782c5ed..45ebce20 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1151,6 +1151,26 @@ inline static void check_bad_login(void) } } +inline static void append_log_recent_login() +{ + char buf[STRLEN], logfn[PATHLEN]; + int szlogfn = 0, szlogentry = 0; + + // prepare log format + snprintf(buf, sizeof(buf), "%s %-15s\n", + Cdatelite(&login_start_time), fromhost); + szlogentry = strlen(buf); // should be the same for all entries + + setuserfile(logfn, FN_RECENTLOGIN); + szlogfn = dashs(logfn); + if (szlogfn > SZ_RECENTLOGIN) { + // rotate to 1/4 of SZ_RECENTLOGIN + delete_records(logfn, szlogentry, 1, + (szlogfn-(SZ_RECENTLOGIN/4)) / szlogentry); + } + log_file(logfn, LOG_CREAT, buf); +} + inline static void birthday_make_a_wish(const struct tm *ptime, const struct tm *tmp) { if (tmp->tm_mday != ptime->tm_mday) { @@ -1302,6 +1322,8 @@ user_login(void) if( vans("是否要顯示「壽星」於使用者名單上?(y/N)") == 'y' ) currutmp->birth = 1; } + + append_log_recent_login(); check_bad_login(); check_mailbox_quota(); check_birthday(); diff --git a/mbbsd/menu.c b/mbbsd/menu.c index bd598cea..c9212224 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -570,6 +570,12 @@ static const commands_t namelist[] = { {NULL, 0, NULL} }; +static int u_view_recentlogin() +{ + char fn[PATHLEN]; + setuserfile(fn, FN_RECENTLOGIN); + return more(fn, YEA); +} static const commands_t myfilelist[] = { {u_editplan, PERM_LOGINOK, "QQueryEdit 編輯名片檔"}, @@ -577,6 +583,11 @@ static const commands_t myfilelist[] = { {NULL, 0, NULL} }; +static const commands_t myuserlog[] = { + {u_view_recentlogin, 0, "LLRecent Login 最近上站記錄"}, + {NULL, 0, NULL} +}; + static int u_myfiles() { @@ -584,6 +595,12 @@ u_myfiles() return 0; } +static int +u_mylogs() +{ + domenu(M_UMENU, "個人記錄", 'L', myuserlog); + return 0; +} int u_fixgoodpost(void); // assess.c void Customize(); // user.c @@ -601,8 +618,9 @@ static const commands_t userlist[] = { {u_customize, PERM_BASIC, "UUCustomize 個人化設定"}, {u_info, PERM_LOGINOK, "IInfo 設定個人資料與密碼"}, {calendar, PERM_LOGINOK, "CCalendar 行事曆"}, - {u_loginview, PERM_BASIC, "LLogin View 選擇進站畫面"}, + {u_loginview, PERM_BASIC, "VVLogin View 選擇進站畫面"}, {u_myfiles, PERM_LOGINOK, "MMy Files 【個人檔案】 (名片,簽名檔...)"}, + {u_mylogs, PERM_LOGINOK, "LLMy Logs 【個人記錄】 (最近上線...)"}, #if HAVE_FREECLOAK {u_cloak, PERM_LOGINOK, "KKCloak 隱身術"}, #else |