diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-06 21:07:50 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-06 21:07:50 +0800 |
commit | 12fe18273839304131da83bbb54a639896fd69f0 (patch) | |
tree | 3926b1aee6b56d7f55747b0fe774b598cde5c5d8 | |
parent | 2933c380c0ffa5422cc5bc74e23e6a92440cca92 (diff) | |
download | pttbbs-12fe18273839304131da83bbb54a639896fd69f0.tar pttbbs-12fe18273839304131da83bbb54a639896fd69f0.tar.gz pttbbs-12fe18273839304131da83bbb54a639896fd69f0.tar.bz2 pttbbs-12fe18273839304131da83bbb54a639896fd69f0.tar.lz pttbbs-12fe18273839304131da83bbb54a639896fd69f0.tar.xz pttbbs-12fe18273839304131da83bbb54a639896fd69f0.tar.zst pttbbs-12fe18273839304131da83bbb54a639896fd69f0.zip |
* experimental: add user recent login history view
git-svn-id: http://opensvn.csie.org/pttbbs/branches/pttbbs.pwcu@4810 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/common.h | 4 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 22 | ||||
-rw-r--r-- | mbbsd/menu.c | 21 |
3 files changed, 46 insertions, 1 deletions
diff --git a/include/common.h b/include/common.h index bf7a1cef..da8a20be 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 (32000) +#endif // 自訂刪除文章時出現的標題與檔案 diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 04e9cbb8..a99a5145 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1115,6 +1115,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) { @@ -1235,6 +1255,8 @@ user_login(void) if( vans("是否要顯示「壽星」於使用者名單上?(y/N)") == 'y' ) currutmp->birth = 1; } + + append_log_recent_login(); check_bad_login(); check_mailbox_quota(); check_register(); diff --git a/mbbsd/menu.c b/mbbsd/menu.c index fdba2381..fbffa4da 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,13 @@ u_myfiles() return 0; } +static int +u_mylogs() +{ + domenu(M_UMENU, "個人記錄", 'L', myuserlog); + return 0; +} + void Customize(); // user.c @@ -600,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 |