From edf79950859b8f87c6e4b34eb790366cb4a0d4c2 Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 6 Sep 2009 15:19:11 +0000 Subject: * add view recent login in trunk git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4815 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/mbbsd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'mbbsd/mbbsd.c') 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(); -- cgit v1.2.3