From ebbe5ec42b49f275c7dbcf09e762b4c0ab4e58e8 Mon Sep 17 00:00:00 2001 From: piaip Date: Fri, 25 Apr 2008 08:16:42 +0000 Subject: - improve 'C' in namelist editing: removing users haven't login for a specific time. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4246 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/friend.c | 32 ++++++++++++++++++++++++++++---- mbbsd/pfterm.c | 6 ++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/mbbsd/friend.c b/mbbsd/friend.c index bfce3f56..9644aa1b 100644 --- a/mbbsd/friend.c +++ b/mbbsd/friend.c @@ -230,13 +230,24 @@ delete_friend_from_file(const char *file, const char *string, int case_sensitiv return ret; } +// (2^31)/86400/30 = 828 +#define MAX_EXPIRE_MONTH (800) + int -friend_validate(int type) +friend_validate(int type, int expire) { FILE *fp = NULL, *nfp = NULL; char fpath[PATHLEN]; char genbuf[STRLEN+1], buf[STRLEN+1]; int ret = 0; + userec_t u; + + // expire is measured in month + if (expire > 0 && expire < MAX_EXPIRE_MONTH) + expire *= 86400 *30; + else + expire = 0; + syncnow(); setfriendfile(fpath, type); nfp = tmpfile(); @@ -259,7 +270,16 @@ friend_validate(int type) chomp(buf); if (searchuser(buf, NULL)) + { + if (expire > 0) { + // drop user if (now-lastlogin) longer than expire*month + getuser(buf, &u); + + if (now - u.lastlogin > expire) + continue; + } fputs(genbuf, nfp); + } } fclose(fp); @@ -463,8 +483,9 @@ friend_edit(int type) fclose(fp); } getdata(1, 0, (count ? - "(A)增加(D)刪除(E)修改(P)引入(L)列出" - "(K)清空(C)整理有效名單(W)水球(Q)結束?[Q] " : + "(A)增加(D)刪除(E)修改(P)引入(L)列出(K)清空" + ANSI_COLOR(33) "(C)整理有效名單" ANSI_RESET + "(W)水球(Q)結束?[Q] " : "(A)增加 (P)引入其他名單 (Q)結束?[Q] "), uident, 3, LCECHO); if (uident[0] == 'a') { @@ -475,8 +496,11 @@ friend_edit(int type) dirty = 1; } } else if (uident[0] == 'c') { + getdata(2, 0, + "要從名單中清除幾個月沒上站(包含帳號已消失)的使用者?", + uident, 4, NUMECHO); // delete all users that not in list. - friend_validate(type); + friend_validate(type, atoi(uident)); dirty = 1; } else if (uident[0] == 'p') { friend_append(type, count); diff --git a/mbbsd/pfterm.c b/mbbsd/pfterm.c index 3eb4a16e..27c27bff 100644 --- a/mbbsd/pfterm.c +++ b/mbbsd/pfterm.c @@ -151,6 +151,12 @@ // http://en.wikipedia.org/wiki/ANSI_escape_code // http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf ////////////////////////////////////////////////////////////////////////// +// The supported escapes are based on 'cons25' termcap and +// Windows 2000/XP/Vista built-in telnet. +// +// Underline is only supported by vt100 (and monochrome) so we drop it. +// Blink is supported by vt100/cons25 and we keep it. +////////////////////////////////////////////////////////////////////////// // Experimental now #if defined(EXP_PFTERM) || defined(USE_PFTERM) -- cgit v1.2.3