※ [本文轉錄自 Dopin 信箱]
作者: Dopin.bbs@ym66189.ym.edu.tw
標題: patch -- 查詢上線記錄
時間: Wed Nov 27 12:14:45 2002
作者: Dopin (Update 1.32 Beta) 看板: ATSVersion
標題: patch -- 查詢上線記錄
時間: Wed Nov 27 11:45:14 2002
// 這幾天在 ptt 看到 sunev 君發了篇想要查詢使用自己 ID 的來源 我覺得挺有意思
// 的 便下去插個花 其實我原本的想法是再另外寫個檔 加上時間 但後來 Lwms 兄提到
// 使用 remoteuser 來做處理 嗯 也對啦 既然只要查詢來源 用這個就好了
// 不過 remotuser 這個檔實在很...因為他並不是純文字 還加了些辨識碼在裡面 所以
// 不方便直接叫用 ... 雖然我稍微看了 add_distinct / del_distinct 這兩個函式
// 但一個是增加此特殊欄位的 另一個則為刪除 少了個轉換的 (也許是我無知 QQ)
// 反正遇到問題就是給他硬上 這就是我的處理方法 -.-;;;
// util/trans_distinct.c 新增此程式 並加到 Makefile 中 make update
/*-------------------------------------------------------*/
/* util/trans_distinct.c ( Atlantis BBS Ver 1.32 ) */
/*-------------------------------------------------------*/
/* target : 切割非文字 distinct 格式並輸出至檔案 */
/* create : 02/11/27 (Dopin) */
/* update : */
/*-------------------------------------------------------*/
/* syntex : trans_distinct <Source File> <Target File> */
/*-------------------------------------------------------*/
#include "bbs.h"
int trans_distinct(char *fsource, char *ftarget) {
char buf[512];
int ch, i;
FILE *fs, *ft;
if((fs = fopen(fsource, "rb")) == NULL) return -1;
if((ft = fopen(ftarget, "w+")) == NULL) {
fclose(fs);
return -1;
}
i = 0;
while(!feof(fs) && !ferror(fs)) {
fscanf(fs, "%c", &ch);
if(feof(fs) || ferror(fs)) break;
if(ch == 10) {
fprintf(ft, "%s\n", buf);
i = 0;
}
else buf[i++] = (char)ch;
}
fclose(fs);
fclose(ft);
return 0;
}
int main(int argc, char *argv[]) {
if(argc != 3) return 1;
return trans_distinct(argv[1], argv[2]);
}
// maple/config.h
/* 列出註冊名單 */
#define USE_ULIST // 原 SOB 內建程式
#define QUERY_REMOTEUSER // 查詢最近上站記錄 Dopin (ats.twbbs.org)
// maple/dopin.c
/* 於程式的最後新增此段 */
void settmpfile(char *fpath, char *fname) {
sprintf(fpath, "tmp/%s.%s", fname, cuser.userid);
}
#ifdef QUERY_REMOTEUSER
/* Dopin 02/11/27 */
int query_rmuser(void) {
char bufs[40], buft[40], command[100];
setuserfile(bufs, "remoteuser");
settmpfile(buft, "remoteuser");
sprintf(command, "bin/trans_distinct %s %s", bufs, buft);
system(command);
settmpfile(bufs, "remoteuser_20");
/* 有點忘了 tail 的參數了 有錯請指教 */
sprintf(command, "tail -n 20 %s > %s", buft, bufs);
system(command);
more(bufs, YEA);
remove(buft);
remove(bufs);
}
#endif
/* 到這裡 */
// menu.c
/* ----------------------------------------------------- */
/* User menu */
/* ----------------------------------------------------- */
int u_register(), b_favor(), u_editfiles(), u_cloak(), u_ansi(), u_movie();
int u_lock(), u_list(), setreco();
#ifdef HAVE_SUICIDE
int u_kill();
#endif
#ifdef QUERY_REMOTEUSER
int query_rmuser();
#endif
static struct commands userlist[] = {
...
u_register, PERM_BASIC, "RRegister 填寫*[1;37;43m註冊申請單*[m ",
#ifdef QUERY_REMOTEUSER
query_rmuser, PERM_LOGINOK,"QQueryRmtUser 查詢*[1;37;44m上線記錄*[m ",
#endif
#ifdef USE_ULIST
u_list, PERM_SYSOP, "UUsers *[1;37;41m列出註冊名單*[m ",
#endif
NULL, 0, NULL };
// 改完後 make clean update 如跑 mbbsd 請重新啟動程序
// 缺點 --> 只能顯示來源 QQ;;;
--
※ Origin: ATLANTIS DN: ats.twbbs.org IP: 140.129.66.189 ST: atlantis
--
修正部份敘述
--
※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw)
◆ From: 210.68.39.15
※ 編輯: Dopin 來自: 210.68.39.15 (11/27 13:56)