diff options
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/admin.c | 1 | ||||
-rw-r--r-- | mbbsd/bbs.c | 2 | ||||
-rw-r--r-- | mbbsd/chat.c | 6 | ||||
-rw-r--r-- | mbbsd/chess.c | 4 | ||||
-rw-r--r-- | mbbsd/kaede.c | 2 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 9 | ||||
-rw-r--r-- | mbbsd/passwd.c | 34 | ||||
-rw-r--r-- | mbbsd/pmore.c | 2 | ||||
-rw-r--r-- | mbbsd/register.c | 2 | ||||
-rw-r--r-- | mbbsd/talk.c | 47 | ||||
-rw-r--r-- | mbbsd/user.c | 12 | ||||
-rw-r--r-- | mbbsd/vote.c | 10 |
12 files changed, 81 insertions, 50 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 0ed06412..9dcc5b8a 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -108,7 +108,6 @@ upgrade_passwd(userec_t *puser) memset(puser->chkpad0, 0, sizeof(puser->chkpad0)); memset(puser->chkpad1, 0, sizeof(puser->chkpad1)); memset(puser->chkpad2, 0, sizeof(puser->chkpad2)); - puser->numlogindays = 0; puser->lastseen = 0; puser->version = PASSWD_VERSION; return ; diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 0d1a1a9a..183bc16f 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -2714,7 +2714,7 @@ recommend(int ent, fileheader_t * fhdr, const char *direct) static int tolog = 0; if( tolog == 0 ) tolog = - (cuser.numlogins < 50 || (now - cuser.firstlogin) < DAY_SECONDS * 7) + (cuser.numlogindays < 50 || (now - cuser.firstlogin) < DAY_SECONDS * 7) ? 1 : 2; if( tolog == 1 ){ FILE *fp; diff --git a/mbbsd/chat.c b/mbbsd/chat.c index f51524ff..9c73c39d 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -204,14 +204,14 @@ chat_query(char *arg) char buf[ANSILINELEN], *ptr; FILE *fp; - snprintf(buf, sizeof(buf), "%s(%s) 共上站 %d 次,發表過 %d 篇文章", + snprintf(buf, sizeof(buf), "%s(%s) 上站資歷 %d 點,發表過 %d 篇文章", xuser.userid, xuser.nickname, - xuser.numlogins, xuser.numposts); + xuser.numlogindays, xuser.numposts); printchatline(buf); snprintf(buf, sizeof(buf), "最近(%s)從[%s]上站", - Cdate(&xuser.lastseen), + Cdate(xuser.lastseen ? &xuser.lastseen : &xuser.lastlogin), (xuser.lasthost[0] ? xuser.lasthost : "(不詳)")); printchatline(buf); diff --git a/mbbsd/chess.c b/mbbsd/chess.c index 7c58b6a8..11cb2a6f 100644 --- a/mbbsd/chess.c +++ b/mbbsd/chess.c @@ -1441,7 +1441,7 @@ ChessPhotoInitial(ChessInfo* info) switch (line) { case 0: sprintf(genbuf, " <代號> %s", xuser.userid); break; case 1: sprintf(genbuf, " <暱稱> %.16s", xuser.nickname); break; - case 2: sprintf(genbuf, " <上站> %d", xuser.numlogins); break; + case 2: sprintf(genbuf, " <上站> %d", xuser.numlogindays); break; case 3: sprintf(genbuf, " <文章> %d", xuser.numposts); break; case 4: sprintf(genbuf, " <職位> %-4s %s", country, level); break; case 5: sprintf(genbuf, " <來源> %.16s", xuser.lasthost); break; @@ -1494,7 +1494,7 @@ ChessPhotoInitial(ChessInfo* info) switch (line - 9) { case 0: sprintf(PHOTO(line), "<代號> %-16.16s ", xuser.userid); break; case 1: sprintf(PHOTO(line), "<暱稱> %-16.16s ", xuser.nickname); break; - case 2: sprintf(PHOTO(line), "<上站> %-16d ", xuser.numlogins); break; + case 2: sprintf(PHOTO(line), "<上站> %-16d ", xuser.numlogindays); break; case 3: sprintf(PHOTO(line), "<文章> %-16d ", xuser.numposts); break; case 4: sprintf(PHOTO(line), "<職位> %-4s %-10s ", country, level); break; case 5: sprintf(PHOTO(line), "<來源> %-16.16s ", xuser.lasthost); break; diff --git a/mbbsd/kaede.c b/mbbsd/kaede.c index 5a5545e5..628f51df 100644 --- a/mbbsd/kaede.c +++ b/mbbsd/kaede.c @@ -30,7 +30,7 @@ expand_esc_star(char *buf, const char *src, int szbuf) strlcpy(buf, cuser.nickname, szbuf); return 2; case 'l': // current user logins - snprintf(buf, szbuf, "%d", cuser.numlogins); + snprintf(buf, szbuf, "%d", cuser.numlogindays); return 2; case 'p': // current user posts snprintf(buf, szbuf, "%d", cuser.numposts); diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 30117471..04e9cbb8 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1049,9 +1049,9 @@ setup_utmp(int mode) strip_nonebig5((unsigned char *)currutmp->nickname, sizeof(currutmp->nickname)); strip_nonebig5((unsigned char *)currutmp->mind, sizeof(currutmp->mind)); - // XXX 不用每 20 才檢查吧 // XXX 這個 check 花不少時間,有點間隔比較好 - if ((cuser.userlevel & PERM_BM) && !(cuser.numlogins % 20)) + // TODO XXX 使用 numlogindays 有點問題,同一天內多次 login 會狂檢查... + if ((cuser.userlevel & PERM_BM) && !(cuser.numlogindays % 20)) check_BM(); /* Ptt 自動取下離職板主權力 */ // resolve fromhost @@ -1090,15 +1090,14 @@ setup_utmp(int mode) inline static void welcome_msg(void) { - prints(ANSI_RESET " 歡迎您第 " - ANSI_COLOR(1;33) "%d" ANSI_COLOR(0;37) " 度拜訪本站,上次您是從 " + prints(ANSI_RESET " 歡迎您再度拜訪本站,上次您是從 " ANSI_COLOR(1;33) "%s" ANSI_COLOR(0;37) " 連往本站," ANSI_CLRTOEND "\n" " 我記得那天是 " ANSI_COLOR(1;33) "%s" ANSI_COLOR(0;37) "。" ANSI_CLRTOEND "\n" ANSI_CLRTOEND "\n" , - cuser.numlogins, cuser.lasthost, Cdate(&(cuser.lastlogin))); + cuser.lasthost, Cdate(&(cuser.lastlogin))); pressanykey(); } diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index 05363661..83fb45a5 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -428,21 +428,41 @@ pwcuToggleUserFlag2 (unsigned int mask) // which we should update/calculate every variables to log. int pwcuLoginSave () { - PWCU_START(); // XXX no need to reload for speed up? + // XXX because LoginSave was called very long after + // login_start_time, so we must reload passwd again + // here to prevent race condition. + // If you want to remove this reload, make sure + // pwcuLoginSave is called AFTER login_start_time + // was decided. + int regdays = 0, prev_regdays = 0; + int reftime = login_start_time; + PWCU_START(); // new host from 'fromhost' + strlcpy( u.lasthost, fromhost, sizeof( u.lasthost)); strlcpy(cuser.lasthost, fromhost, sizeof(cuser.lasthost)); - // calculate numlogins (only increase one per each key) - if (((login_start_time - cuser.firstlogin) % DAY_SECONDS) != - ((cuser.lastlogin - cuser.firstlogin) % DAY_SECONDS) ) - cuser.numlogins++; + // this must be valid. + assert(login_start_time > 0); + + // invalid session? + if (reftime < u.lastlogin) + reftime = u.lastlogin; + + regdays = ( reftime - u.firstlogin) / DAY_SECONDS; + prev_regdays = (u.lastlogin - u.firstlogin) / DAY_SECONDS; + // assert(regdays >= prev_regdays); + + // calculate numlogindays (only increase one per each key) + if (regdays > prev_regdays) + ++u.numlogindays; + cuser.numlogindays = u.numlogindays; // update last login time - cuser.lastlogin = login_start_time; + cuser.lastlogin = u.lastlogin = reftime; if (!PERM_HIDE(currutmp)) - cuser.lastseen = login_start_time; + cuser.lastseen = u.lastseen = reftime; PWCU_END(); } diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c index 1968f557..4304b55e 100644 --- a/mbbsd/pmore.c +++ b/mbbsd/pmore.c @@ -594,7 +594,7 @@ expand_esc_star(char *buf, const char *src, int szbuf) strlcpy(buf, cuser.userid, szbuf); return 2; case 'l': // current user logins - snprintf(buf, szbuf, "%d", cuser.numlogins); + snprintf(buf, szbuf, "%d", cuser.numlogindays); return 2; case 'p': // current user posts snprintf(buf, szbuf, "%d", cuser.numposts); diff --git a/mbbsd/register.c b/mbbsd/register.c index 9f9a2b74..af04508e 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -259,7 +259,7 @@ check_and_expire_account(int uid, const userec_t * urec, int expireRange) if ((val = compute_user_value(urec, now)) < 0) { snprintf(genbuf, sizeof(genbuf), "#%d %-12s %s %d %d %d", uid, urec->userid, Cdatelite(&(urec->lastlogin)), - urec->numlogins, urec->numposts, val); + urec->numlogindays, urec->numposts, val); // 若超過 expireRange 則砍人, // 不然就 return 0 diff --git a/mbbsd/talk.c b/mbbsd/talk.c index da909076..997e7e8e 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -455,37 +455,50 @@ my_query(const char *uident) if ((uentp = (userinfo_t *) search_ulist(tuid))) fri_stat = friend_stat(currutmp, uentp); - prints("《ID暱稱》%s (%s)%*s《經濟狀況》%s", + // ------------------------------------------------------------ + + prints( "《ID暱稱》%s (%s)%*s", muser.userid, muser.nickname, strlen(muser.userid) + strlen(muser.nickname) >= 25 ? 0 : - (int)(25 - strlen(muser.userid) - strlen(muser.nickname)), "", + (int)(25 - strlen(muser.userid) - strlen(muser.nickname)), ""); + + prints( "《經濟狀況》%s", money_level(muser.money)); if (uentp && ((fri_stat & HFM && !uentp->invisible) || strcmp(muser.userid,cuser.userid) == 0)) prints(" ($%d)", muser.money); outc('\n'); - prints("《上站次數》%d次", muser.numlogins); + // ------------------------------------------------------------ + + prints("《上站資歷》%d 點", muser.numlogindays); #ifdef SHOW_LOGINOK if (!(muser.userlevel & PERM_LOGINOK)) outs(" (尚未通過認證)"); #endif - move(2, 40); + + move(vgety(), 40); + prints("《有效文章》%d 篇", muser.numposts); #ifdef ASSESS - prints("《有效文章篇數》%d篇 (劣:%d)\n", muser.numposts, muser.badpost); -#else - prints("《有效文章篇數》%d篇\n", muser.numposts); + prints(" (劣:%d)", muser.badpost); #endif + outc('\n'); + + // ------------------------------------------------------------ prints(ANSI_COLOR(1;33) "《目前動態》%-28.28s" ANSI_RESET, (uentp && isvisible_stat(currutmp, uentp, fri_stat)) ? - modestring(uentp, 0) : "不在站上"); + modestring(uentp, 0) : "不在站上"); + + if ((uentp && ISNEWMAIL(uentp)) || load_mailalert(muser.userid)) + outs("《私人信箱》有新進信件還沒看\n"); + else + outs("《私人信箱》所有信件都看過了\n"); + + // ------------------------------------------------------------ - outs(((uentp && ISNEWMAIL(uentp)) || load_mailalert(muser.userid)) - ? "《私人信箱》有新進信件還沒看\n" : - "《私人信箱》所有信件都看過了\n"); prints("《上次上站》%-28.28s《上次故鄉》", - Cdate(&muser.lastseen)); + Cdate(muser.lastseen ? &muser.lastseen : &muser.lastlogin)); // print out muser.lasthost #ifdef USE_MASKED_FROMHOST if(!HasUserPerm(PERM_SYSOP|PERM_ACCOUNTS)) @@ -494,8 +507,10 @@ my_query(const char *uident) outs(muser.lasthost[0] ? muser.lasthost : "(不詳)"); outs("\n"); - prints("《五子棋戰績》%3d 勝 %3d 敗 %3d 和 " - "《象棋戰績》%3d 勝 %3d 敗 %3d 和\n", + // ------------------------------------------------------------ + + prints("《 五子棋 》%5d 勝 %5d 敗 %5d 和 " + "《象棋戰績》%5d 勝 %5d 敗 %5d 和\n", muser.five_win, muser.five_lose, muser.five_tie, muser.chc_win, muser.chc_lose, muser.chc_tie); @@ -3292,8 +3307,8 @@ talkreply(void) strlcpy(currutmp->msgs[0].last_call_in, "呼叫、呼叫,聽到請回答 (Ctrl-R)", sizeof(currutmp->msgs[0].last_call_in)); currutmp->msgs[0].msgmode = MSGMODE_TALK; - prints("對方來自 [%s],共上站 %d 次,文章 %d 篇\n", - uip->from, xuser.numlogins, xuser.numposts); + prints("對方來自 [%s],上站資歷 %d 點,文章共 %d 篇\n", + uip->from, xuser.numlogindays, xuser.numposts); if (is_chess) ChessShowRequest(); diff --git a/mbbsd/user.c b/mbbsd/user.c index b03ac25b..386e5a23 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -173,8 +173,8 @@ user_display(const userec_t * u, int adminmode) prints("\t\t認證資料: %s\n", u->justify); } - prints("\t\t上站文章: 上站 %d 次 / 文章 %d 篇\n", - u->numlogins, u->numposts); + prints("\t\t上站文章: 上站資歷 %d / 文章 %d 篇\n", + u->numlogindays, u->numposts); sethomedir(genbuf, u->userid); prints("\t\t私人信箱: %d 封 (購買信箱: %d 封)\n", @@ -821,10 +821,10 @@ uinfo_query(const char *orig_uid, int adminmode, int unum) getdata_buf(y++, 0, "最近光臨機器:", x.lasthost, sizeof(x.lasthost), DOECHO); - snprintf(genbuf, sizeof(genbuf), "%d", x.numlogins); - if (getdata_str(y++, 0, "上線次數:", buf, 10, DOECHO, genbuf)) + snprintf(genbuf, sizeof(genbuf), "%d", x.numlogindays); + if (getdata_str(y++, 0, "上線資歷:", buf, 10, DOECHO, genbuf)) if ((tmp = atoi(buf)) >= 0) - x.numlogins = tmp; + x.numlogindays = tmp; snprintf(genbuf, sizeof(genbuf), "%d", x.numposts); if (getdata_str(y++, 0, "文章數目:", buf, 10, DOECHO, genbuf)) if ((tmp = atoi(buf)) >= 0) @@ -1419,7 +1419,7 @@ u_list_CB(void *data, int num, userec_t * uentp) prints("%-14s %-27.27s%5d %5d %s %s\n", uentp->userid, uentp->nickname, - uentp->numlogins, uentp->numposts, + uentp->numlogindays, uentp->numposts, HasUserPerm(PERM_SEEULEVELS) ? permstr : "", ptr); ctx->usercounter++; ctx->y++; diff --git a/mbbsd/vote.c b/mbbsd/vote.c index 8eb2c756..030c6704 100644 --- a/mbbsd/vote.c +++ b/mbbsd/vote.c @@ -646,11 +646,9 @@ vote_maintain(const char *bname) closetime = atoi(inbuf); // borrow variable } while (closetime < 0 || closetime > 120); fprintf(fp, "%d\n", now - (MONTH_SECONDS * closetime)); - do { - getdata(6, 0, "上站次數下限", inbuf, 6, DOECHO); - closetime = atoi(inbuf); // borrow variable - } while (closetime < 0); - fprintf(fp, "%d\n", closetime); + + fprintf(fp, "%d\n", 0); // was: numlogins + do { getdata(6, 0, "文章篇數下限", inbuf, 6, DOECHO); closetime = atoi(inbuf); // borrow variable @@ -791,7 +789,7 @@ user_vote_one(const vote_buffer_t *vbuf, const char *bname) fclose(lfp); // XXX if this is a private vote (limited), I think we don't need to check limits? if (cuser.firstlogin > closetime || cuser.numposts < limits_posts || - cuser.numlogins < limits_logins) { + cuser.numlogindays < limits_logins) { vmsg("你不夠資深喔!"); return FULLUPDATE; } |