From c7ec45b470726d9b50e7d549a09569e22e2a9a69 Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 30 Aug 2009 12:56:13 +0000 Subject: * add more checking to numlogindays git-svn-id: http://opensvn.csie.org/pttbbs/branches/pttbbs.pwcu@4802 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/proto.h | 2 ++ mbbsd/user.c | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/proto.h b/include/proto.h index e0f784c0..bc32e07d 100644 --- a/include/proto.h +++ b/include/proto.h @@ -745,5 +745,7 @@ int pwcuInitAdminPerm (); /* calendar */ int calendar(void); int ParseDate(const char *date, int *year, int *month, int *day); +int ParseDateTime(const char *date, int *year, int *month, int *day, + int *hour, int *min, int *sec); #endif diff --git a/mbbsd/user.c b/mbbsd/user.c index ef73930f..0e8fdb53 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -847,10 +847,22 @@ uinfo_query(const char *orig_uid, int adminmode, int unum) break; } - snprintf(genbuf, sizeof(genbuf), "%d", x.numlogindays); - if (getdata_str(y++, 0, "上線資歷:", buf, 10, DOECHO, genbuf)) - if ((tmp = atoi(buf)) >= 0) - x.numlogindays = tmp; + do { + int max_days = (x.lastlogin - x.firstlogin) / DAY_SECONDS; + snprintf(genbuf, sizeof(genbuf), "%d", x.numlogindays); + if (getdata_str(y++, 0, "上線資歷:", buf, 10, DOECHO, genbuf)) + if ((tmp = atoi(buf)) >= 0) + x.numlogindays = tmp; + if (x.numlogindays > max_days) + { + x.numlogindays = max_days; + vmsgf("根據此使用者最後上線時間,資歷最大值為 %d.", max_days); + move(--y, 0); clrtobot(); + continue; + } + break; + } while (1); + snprintf(genbuf, sizeof(genbuf), "%d", x.numposts); if (getdata_str(y++, 0, "文章數目:", buf, 10, DOECHO, genbuf)) if ((tmp = atoi(buf)) >= 0) -- cgit v1.2.3