summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/proto.h1
-rw-r--r--include/pttstruct.h13
-rw-r--r--mbbsd/board.c4
-rw-r--r--mbbsd/cal.c2
-rw-r--r--mbbsd/ch_go.c10
-rw-r--r--mbbsd/ch_gomo.c10
-rw-r--r--mbbsd/chat.c3
-rw-r--r--mbbsd/chc.c10
-rw-r--r--mbbsd/mbbsd.c2
-rw-r--r--mbbsd/passwd.c16
-rw-r--r--mbbsd/register.c5
-rw-r--r--mbbsd/talk.c4
-rw-r--r--mbbsd/user.c11
-rw-r--r--mbbsd/var.c2
14 files changed, 58 insertions, 35 deletions
diff --git a/include/proto.h b/include/proto.h
index 4263dd01..bd547eea 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -718,6 +718,7 @@ int pwcuLoginSave ();
int pwcuExitSave ();
// initialization
+void pwcuInitZero ();
void pwcuInitGuestPerm ();
void pwcuInitGuestInfo ();
int pwcuInitAdminPerm ();
diff --git a/include/pttstruct.h b/include/pttstruct.h
index c0ea9f64..cd0c98df 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -66,7 +66,7 @@ typedef struct userec_t {
uint32_t numlogins; /* 上站次數 */
uint32_t numposts; /* 文章篇數 */
time4_t firstlogin; /* 註冊時間 */
- time4_t lastlogin; /* 最近上站時間 */
+ time4_t lastlogin; /* 最近上站時間(包含隱身) */
char lasthost[IPV4LEN+1];/* 上次上站來源 */
int32_t money; /* Ptt幣 */
@@ -97,7 +97,8 @@ typedef struct userec_t {
uint32_t numlogindays; /* 登入天次 */
char chkpad1[48];
- time4_t chkpad2[3]; /* in case 有人忘了把 time4_t 調好... */
+ time4_t lastseen; /* 最近上站時間(隱身不計) */
+ time4_t chkpad2[2]; /* in case 有人忘了把 time4_t 調好... */
// 以上應為 sizeof(chicken_t) 同等大小
time4_t lastsong; /* 上次點歌時間 */
@@ -138,6 +139,14 @@ typedef struct userec_t {
char pad_tail[28];
} PACKSTRUCT userec_t;
+#ifdef CONST_CUSER
+# define cuser ((const userec_t ) pwcuser)
+# define cuser_ref ((const userec_t*)&pwcuser)
+#else
+# define cuser pwcuser
+# define cuser_ref (&cuser)
+#endif
+
/* flags in userec_t.withme */
#define WITHME_ALLFLAG 0x55555555
#define WITHME_TALK 0x00000001
diff --git a/mbbsd/board.c b/mbbsd/board.c
index a3101175..e2bad4a8 100644
--- a/mbbsd/board.c
+++ b/mbbsd/board.c
@@ -1343,7 +1343,7 @@ set_menu_BM(char *BM)
{
if (!HasUserPerm(PERM_NOCITIZEN) && (HasUserPerm(PERM_ALLBOARD) || is_uBM(BM, cuser.userid))) {
currmode |= MODE_GROUPOP;
- cuser.userlevel |= PERM_SYSSUBOP | PERM_BM;
+ // cuser.userlevel |= PERM_SYSSUBOP | PERM_BM;
}
}
@@ -1599,7 +1599,7 @@ choose_board(int newflag)
fav_sort_by_class();
}
else
- cuser.uflag ^= BRDSORT_FLAG;
+ pwcuToggleSortBoard();
brdnum = -1;
break;
diff --git a/mbbsd/cal.c b/mbbsd/cal.c
index 342049b8..c920aeb1 100644
--- a/mbbsd/cal.c
+++ b/mbbsd/cal.c
@@ -402,7 +402,7 @@ resolve_over18_user(const userec_t *u)
void
resolve_over18(void)
{
- over18 = resolve_over18_user(&cuser);
+ over18 = resolve_over18_user(cuser_ref);
}
int
diff --git a/mbbsd/ch_go.c b/mbbsd/ch_go.c
index 9c7256cd..a9e68005 100644
--- a/mbbsd/ch_go.c
+++ b/mbbsd/ch_go.c
@@ -819,9 +819,9 @@ go_gameend(ChessInfo* info, ChessGameResult result)
currutmp->go_tie++;
}
- go_usr_put(&cuser, user1);
+ go_usr_put(cuser_ref, user1);
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_update(usernum, cuser_ref);
} else if (info->mode == CHESS_MODE_REPLAY) {
free(info->board);
free(info->tag);
@@ -936,9 +936,9 @@ gochess(int s, ChessGameMode mode)
if (info->mode == CHESS_MODE_VERSUS) {
/* Assume that info->user1 is me. */
info->user1.lose++;
- passwd_sync_query(usernum, &cuser);
- go_usr_put(&cuser, &info->user1);
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_query(usernum, cuser_ref);
+ go_usr_put(cuser_ref, &info->user1);
+ passwd_sync_update(usernum, cuser_ref);
}
if (mode == CHESS_MODE_WATCH)
diff --git a/mbbsd/ch_gomo.c b/mbbsd/ch_gomo.c
index b8a74cb6..0bffe04a 100644
--- a/mbbsd/ch_gomo.c
+++ b/mbbsd/ch_gomo.c
@@ -410,9 +410,9 @@ gomo_gameend(ChessInfo* info, ChessGameResult result)
currutmp->five_tie++;
}
- gomoku_usr_put(&cuser, user1);
+ gomoku_usr_put(cuser_ref, user1);
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_update(usernum, cuser_ref);
} else if (info->mode == CHESS_MODE_REPLAY) {
free(info->board);
free(info->tag);
@@ -535,9 +535,9 @@ gomoku(int s, ChessGameMode mode)
if (info->mode == CHESS_MODE_VERSUS) {
/* Assume that info->user1 is me. */
info->user1.lose++;
- passwd_sync_query(usernum, &cuser);
- gomoku_usr_put(&cuser, &info->user1);
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_query(usernum, cuser_ref);
+ gomoku_usr_put(cuser_ref, &info->user1);
+ passwd_sync_update(usernum, cuser_ref);
}
if (mode == CHESS_MODE_WATCH)
diff --git a/mbbsd/chat.c b/mbbsd/chat.c
index e6a78842..f51524ff 100644
--- a/mbbsd/chat.c
+++ b/mbbsd/chat.c
@@ -210,7 +210,8 @@ chat_query(char *arg)
printchatline(buf);
snprintf(buf, sizeof(buf),
- "最近(%s)從[%s]上站", Cdate(&xuser.lastlogin),
+ "最近(%s)從[%s]上站",
+ Cdate(&xuser.lastseen),
(xuser.lasthost[0] ? xuser.lasthost : "(不詳)"));
printchatline(buf);
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index b250a01e..2a52f43b 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -848,9 +848,9 @@ chc(int s, ChessGameMode mode)
/* Assume that info->user1 is me. */
info->user1.lose++;
count_chess_elo_rating(&info->user1, &info->user2, 0.0);
- passwd_sync_query(usernum, &cuser);
- chcusr_put(&cuser, &info->user1);
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_query(usernum, cuser_ref);
+ chcusr_put(cuser_ref, &info->user1);
+ passwd_sync_update(usernum, cuser_ref);
}
if (mode == CHESS_MODE_WATCH)
@@ -904,8 +904,8 @@ chc_gameend(ChessInfo* info, ChessGameResult result)
currutmp->chc_tie++;
}
currutmp->chess_elo_rating = user1->rating;
- chcusr_put(&cuser, user1);
- passwd_sync_update(usernum, &cuser);
+ chcusr_put(cuser_ref, user1);
+ passwd_sync_update(usernum, cuser_ref);
} else if (info->mode == CHESS_MODE_REPLAY) {
free(info->board);
free(info->tag);
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 99394c0b..8c27da5e 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -775,7 +775,7 @@ login_query(char *ruid)
sleep(3);
exit(1);
}
- bzero(&cuser, sizeof(cuser));
+ pwcuInitZero();
#ifdef DEBUG
move(19, 0);
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c
index e529a874..5803b5b8 100644
--- a/mbbsd/passwd.c
+++ b/mbbsd/passwd.c
@@ -1,10 +1,16 @@
/* $Id$ */
+#define PWCU_IMPL
#include "bbs.h"
#ifdef _BBS_UTIL_C_
#error sorry, mbbsd/passwd.c does not support utility mode anymore. please use libcmbbs instead.
#endif
+#ifdef CONST_CUSER
+ #undef cuser
+ #define cuser pwcuser
+#endif
+
void
passwd_force_update(int flag)
{
@@ -274,11 +280,10 @@ int pwcuLoginSave ()
// new host from 'fromhost'
strlcpy(cuser.lasthost, fromhost, sizeof(cuser.lasthost));
+ cuser.lastlogin = login_start_time;
- // XXX keep 'lastlogin' and 'disp_lastlogin'...
- // new 'lastlogin'
if (!PERM_HIDE(currutmp))
- cuser.lastlogin = login_start_time;
+ cuser.lastseen = login_start_time;
// calculate numlogins
@@ -313,6 +318,11 @@ int pwcuExitSave ()
// Initialization
+void pwcuInitZero ()
+{
+ bzero(&cuser, sizeof(cuser));
+}
+
int pwcuInitAdminPerm ()
{
PWCU_START();
diff --git a/mbbsd/register.c b/mbbsd/register.c
index 495fdfcd..224f480a 100644
--- a/mbbsd/register.c
+++ b/mbbsd/register.c
@@ -1,4 +1,5 @@
/* $Id$ */
+#define PWCU_IMPL
#include "bbs.h"
#define FN_REGISTER_LOG "register.log" // global registration history
@@ -1287,7 +1288,7 @@ toregister(char *email)
snprintf(cuser.justify, sizeof(cuser.justify),
"<Mobile>");
#endif
- email_justify(&cuser);
+ email_justify(cuser_ref);
}
}
@@ -1581,7 +1582,7 @@ u_register(void)
toregister(email);
// update cuser
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_update(usernum, cuser_ref);
return FULLUPDATE;
}
diff --git a/mbbsd/talk.c b/mbbsd/talk.c
index f04c4ddb..068cd567 100644
--- a/mbbsd/talk.c
+++ b/mbbsd/talk.c
@@ -458,7 +458,7 @@ my_query(const char *uident)
{
// XXX there're still users asking why money is not updated...
reload_money();
- memcpy(&muser, &cuser, sizeof(muser));
+ memcpy(&muser, cuser_ref, sizeof(muser));
}
if ((uentp = (userinfo_t *) search_ulist(tuid)))
@@ -494,7 +494,7 @@ my_query(const char *uident)
? "《私人信箱》有新進信件還沒看\n" :
"《私人信箱》所有信件都看過了\n");
prints("《上次上站》%-28.28s《上次故鄉》",
- Cdate(&muser.lastlogin));
+ Cdate(&muser.lastseen));
// print out muser.lasthost
#ifdef USE_MASKED_FROMHOST
if(!HasUserPerm(PERM_SYSOP|PERM_ACCOUNTS))
diff --git a/mbbsd/user.c b/mbbsd/user.c
index 05071eea..c14d5bf1 100644
--- a/mbbsd/user.c
+++ b/mbbsd/user.c
@@ -1,4 +1,5 @@
/* $Id$ */
+#define PWCU_IMPL
#include "bbs.h"
static char * const sex[8] = {
@@ -79,7 +80,7 @@ int u_cancelbadpost(void)
if(search_ulistn(usernum,2))
{vmsg("請登出其他視窗, 否則不受理."); return 0;}
- passwd_sync_query(usernum, &cuser);
+ passwd_sync_query(usernum, cuser_ref);
if (currutmp && (currutmp->alerts & ALERT_PWD))
currutmp->alerts &= ~ALERT_PWD;
@@ -104,7 +105,7 @@ int u_cancelbadpost(void)
{
int prev = cuser.badpost--;
cuser.timeremovebadpost = now;
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_update(usernum, cuser_ref);
log_filef("log/cancelbadpost.log", LOG_CREAT,
"%s %s 刪除一篇劣文 (%d -> %d 篇)\n",
Cdate(&now), cuser.userid, prev, cuser.badpost);
@@ -526,7 +527,7 @@ void Customize(void)
if(dirty)
{
- passwd_sync_update(usernum, &cuser);
+ passwd_sync_update(usernum, cuser_ref);
outs("設定已儲存。\n");
} else {
outs("結束設定。\n");
@@ -1123,8 +1124,8 @@ u_info(void)
{
move(2, 0);
reload_money();
- user_display(&cuser, 0);
- uinfo_query(&cuser, 0, usernum);
+ user_display(cuser_ref, 0);
+ uinfo_query (cuser_ref, 0, usernum);
strlcpy(currutmp->nickname, cuser.nickname, sizeof(currutmp->nickname));
return 0;
}
diff --git a/mbbsd/var.c b/mbbsd/var.c
index a9f52c73..727e9163 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -98,7 +98,7 @@ char margs[64] = "\0"; /* main argv list */
pid_t currpid; /* current process ID */
time4_t login_start_time;
time4_t start_time;
-userec_t cuser; /* current user structure */
+userec_t pwcuser; /* current user structure */
crosspost_t postrecord; /* anti cross post */
unsigned int currbrdattr;
unsigned int currstat;