作者itoc, 信區: itoc
標題[功能] board.c 看板瀏覽時間
時間05/06/13
作者: itoc (:MM:) 看板: itoc
標題: [功能] 計算看板瀏覽人氣/時間
時間: Sun May 4 21:38:08 2003 Updated: 2005/06/13
計算看板瀏覽人氣/時間
這方法不寫回 .BRD,所以在重開 bbsd 以後會變回零
所以累積的部分只能從重開以後算起
─────────────────────────────────────
: struct.h:BCACHE 加入欄位
int mantime[MAXBOARD]; /* 各板目前正有多少人在閱讀 */
+ time_t lastvisit[MAXBOARD]; /* 各板最後一次瀏覽 */
+ time_t totalvisit[MAXBOARD]; /* 各板從上次重開以來累計瀏覽時間 */
─────────────────────────────────────
關於 lastvisit 的部分
: board.c:XoPost()
if (currbno >= 0)
bshm->mantime[currbno]--; /* 退出上一個板 */
bshm->mantime[bno]++; /* 進入新的板 */
+ bshm->lastvisit[bno] = time(NULL);
─────────────────────────────────────
關於 totalvisit 的部分
: 所有有用到 xover(XZ_POST); xover(XZ_POST); 的都要改
: board.c:brd_force()
if (brd->blast > brd_visit[bno])
#endif
{
+ time_t now;
vmsg("有新公告!請先閱\讀完新公告後再離開");
XoPost(bno);
+ time(&now);
xover(XZ_POST);
+ bshm->totalvisit[bno] += time(0) - now;
: board.c:class_browse()
else /* 進入看板 */
{
+ time_t now;
if (XoPost(chn)) /* 無法閱讀該板 */
return XO_FOOT;
+ time(&now);
xover(XZ_POST);
+ bshm->totalvisit[bno] += time(0) - now;
: board.c:Select()
if (brd = ask_board(bname, BRD_R_BIT, NULL))
{
+ time_t now;
bno = brd - bshm->bcache;
XoPost(bno);
+ time(&now);
xover(XZ_POST);
+ bshm->totalvisit[bno] += time(0) - now;
: favor.c:mf_browse()
MF *mf;
int type;
+ time_t now;
...
...
XoPost(bno);
+ time(&now);
xover(XZ_POST);
+ bshm->totalvisit[bno] += time(0) - now;
: menu.c:menu()
case 'r':
if (bbsmode == M_0MENU)
{
if (currbno >= 0)
{
+ time_t now;
utmp_mode(M_BOARD);
XoPost(currbno);
+ time(&now);
xover(XZ_POST);
+ bshm->totalvisit[bno] += time(0) - now;
: song.c:XoSongSub()
int chn;
+ time_t now;
chn = brd_bno(BN_REQUEST);
XoPost(chn);
+ time(&now);
xover(XZ_POST);
+ bshm->totalvisit[bno] += time(0) - now;
: song.c:XoSongLog()
int chn;
+ time_t now;
chn = brd_bno(BN_KTV);
XoPost(chn);
+ time(&now);
xover(XZ_POST);
+ bshm->totalvisit[bno] += time(0) - now;
─────────────────────────────────────
: 顯示的部分
: 再來就是顯示的部分,隨便要在哪裡顯示
: 例如可以在 post.c:post_head() 或 board.c:class_item() 秀出來
+ int bno;
+ bno = brd_bno(currboard);
用 prints 把以下印出來 (版面自行配置)
"%s", Btime(&(bshm->lastvisit[bno])) // 最後一次瀏覽日期
"%d", bshm->totalvisit[bno] // 累計瀏覽時間 (秒)
─────────────────────────────────────
1. 如果有人用 switch 從看板甲跳去看板乙的話
(1) 看板乙會有記錄最後瀏覽時間,也會計算人次
(2) 但是累積時間會加在看板甲
2. 改完 patch 要清 shm,重開 bbsd
--
╭─ Origin ─╗ ���O���� processor.tfcis.org ~ κλμ ─┤
└─ Modify ─╛ Sun, 04 May 2003 21:51:59 +0800 (CST)