static void logattempt(char *uid, char type) { /* '-' login failure ' ' success '!' not * exist '*' spamd */ char fname [PATHLEN]; char genbuf [200], datemsg[20]; sprintf(genbuf, "%c%-12s[%s] %s@%s", type, uid, Etime(&login_start_time), remoteusername, fromhost); f_cat(str_badlogin, genbuf); if (type == '-') { sprintf(genbuf, "[%s] %s", Etime(&login_start_time), fromhost); sethomefile(fname, uid, str_badlogin); f_cat(fname, genbuf); } /* 個人上站記錄 from myth */ if (type != '!') { strftime(datemsg, 20, "%Y/%m/%d %T", localtime(&login_start_time)); sprintf(genbuf, "%s %c%-8s %s@%s", datemsg, type, "BBS", remoteusername, fromhost); sethomefile(fname, uid, FN_LOGLOGIN); f_cat(fname, genbuf); } }
void u_exit(char *mode) { extern void auto_backup(); /* 編輯器自動備份 */ userec xuser; int diff = (time(0) - login_start_time) / 60; rec_get(fn_passwd, &xuser, sizeof(xuser), usernum); auto_backup(); setflags(PAGER_FLAG, currutmp->pager != 1); setflags(CLOAK_FLAG, currutmp->invisible); xuser.pager = currutmp->pager; /* 記錄pager狀態, add by wisely */ xuser.invisible = currutmp->invisible; /* 紀錄隱形狀態 by wildcat */ xuser.totaltime += time(0) - update_time; xuser.numposts = cuser.numposts; xuser.feeling[4] = '\0'; if (!HAS_PERM(PERM_DENYPOST) && !currutmp->invisible) { char buf [256]; time_t now; time(&now); sprintf(buf, "<<下站通知>> -- 我走囉! - %s", Etime(&now)); do_aloha(buf); } purge_utmp(currutmp); if (!diff && cuser.numlogins > 1 && strcmp(cuser.userid, STR_GUEST)) xuser.numlogins = --cuser.numlogins; /* Leeym 上站停留時間限制式 */ substitute_record(fn_passwd, &xuser, sizeof(userec), usernum); log_usies(mode, NULL); }
void log_usies(char *mode, char *msg) { char buf [256], data[256]; time_t now; time(&now); if (!msg) { sprintf(data, "Stay: %d (%s)", (now - login_start_time) / 60, cuser.username); msg = data; } sprintf(buf, "%s %s %-13s%s", Etime(&now), mode, cuser.userid, msg); f_cat(FN_USIES, buf); }
char * Ptt_prints(char *str, int mode) { char *po, *px, *ptr, strbuf[40] = ""; while ((po = strstr(str, "\033[12")) != '\0') po[0] = 0; while ((po = strstr(str, "\033[10")) != '\0') po[0] = 0; while ((po = strstr(str, "\033n")) != '\0') po[0] = 0; while ((po = strstr(str, "\033]")) != '\0') po[0] = 0; while ((po = strstr(str, "\033[=")) != '\0') po[0] = 0; while ((po = strstr(str, "\033*")) != '\0') { switch (*(po + 2)) { case 'S': *po = 0; px = po + 3; sprintf(strbuf, "%s", BOARDNAME); break; case 's': *po = 0; px = po + 3; sprintf(strbuf, "%s", cuser.userid); break; case 't': { time_t now = time(0); *po = 0; px = po + 3; sprintf(strbuf, "%s", Etime(&now)); break; } case 'u': { int attempts; extern struct UTMPFILE *utmpshm; attempts = utmpshm->number; *po = 0; px = po + 3; sprintf(strbuf, "%d", attempts); break; } case 'z': /* ·|¦©°£©Ò¦³Áô¨ªº¤H */ *po = 0; px = po + 3; sprintf(strbuf, "%d", guest_count_ulist()); break; case 'b': *po = 0; px = po + 3; sprintf(strbuf, "%d/%d", cuser.month, cuser.day, px); break; case 'l': *po = 0; px = po + 3; sprintf(strbuf, "%d", cuser.numlogins); break; case 'p': *po = 0; px = po + 3; sprintf(strbuf, "%d", cuser.numposts); break; case 'n': *po = 0; px = po + 3; sprintf(strbuf, "%s", cuser.username); break; case 'm': *po = 0; px = po + 3; sprintf(strbuf, "%d", cuser.silvermoney); break; default: *po = 0; px = NULL; break; } if (px) { /* ©È·¸¦ì */ ptr = strbuf + strlen(strbuf); *(ptr + 1) = '\0'; while (*po++ = strbuf[0]) { *ptr = *px++; strcpy(strbuf, strbuf + 1); } } } strip_ansi(str, str, mode); return str; }
void CMoveSenseSet::ShowVideoTime(int iIndex) { g_PubData.g_iVideoTime1 = m_moveAlarm.week.days[iIndex].seg[0].enable; g_PubData.g_iVideoTime2 = m_moveAlarm.week.days[iIndex].seg[1].enable; g_PubData.g_iVideoTime3 = m_moveAlarm.week.days[iIndex].seg[2].enable; g_PubData.g_iVideoTime4 = m_moveAlarm.week.days[iIndex].seg[3].enable; if(m_moveAlarm.week.days[iIndex].seg[0].enable == 1) { int iY = m_moveAlarm.week.days[iIndex].seg[0].time_start.hour; int iM = m_moveAlarm.week.days[iIndex].seg[0].time_start.minute; int iD = m_moveAlarm.week.days[iIndex].seg[0].time_start.second; COleDateTime cTime; cTime = COleDateTime::GetCurrentTime(); COleDateTime Stime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_STime1 = Stime; iY = m_moveAlarm.week.days[iIndex].seg[0].time_end.hour; iM = m_moveAlarm.week.days[iIndex].seg[0].time_end.minute; iD = m_moveAlarm.week.days[iIndex].seg[0].time_end.second; COleDateTime Etime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_ETime1 = Etime; } if(m_moveAlarm.week.days[iIndex].seg[1].enable == 1) { int iY = m_moveAlarm.week.days[iIndex].seg[1].time_start.hour; int iM = m_moveAlarm.week.days[iIndex].seg[1].time_start.minute; int iD = m_moveAlarm.week.days[iIndex].seg[1].time_start.second; COleDateTime cTime; cTime = COleDateTime::GetCurrentTime(); COleDateTime Stime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_STime2 = Stime; iY = m_moveAlarm.week.days[iIndex].seg[1].time_end.hour; iM = m_moveAlarm.week.days[iIndex].seg[1].time_end.minute; iD = m_moveAlarm.week.days[iIndex].seg[1].time_end.second; COleDateTime Etime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_ETime2 = Etime; } if(m_moveAlarm.week.days[iIndex].seg[2].enable == 1) { int iY = m_moveAlarm.week.days[iIndex].seg[2].time_start.hour; int iM = m_moveAlarm.week.days[iIndex].seg[2].time_start.minute; int iD = m_moveAlarm.week.days[iIndex].seg[2].time_start.second; COleDateTime cTime; cTime = COleDateTime::GetCurrentTime(); COleDateTime Stime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_STime3 = Stime; iY = m_moveAlarm.week.days[iIndex].seg[2].time_end.hour; iM = m_moveAlarm.week.days[iIndex].seg[2].time_end.minute; iD = m_moveAlarm.week.days[iIndex].seg[2].time_end.second; COleDateTime Etime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_ETime3 = Etime; } if(m_moveAlarm.week.days[iIndex].seg[3].enable == 1) { int iY = m_moveAlarm.week.days[iIndex].seg[3].time_start.hour; int iM = m_moveAlarm.week.days[iIndex].seg[3].time_start.minute; int iD = m_moveAlarm.week.days[iIndex].seg[3].time_start.second; COleDateTime cTime; cTime = COleDateTime::GetCurrentTime(); COleDateTime Stime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_STime4 = Stime; iY = m_moveAlarm.week.days[iIndex].seg[3].time_end.hour; iM = m_moveAlarm.week.days[iIndex].seg[3].time_end.minute; iD = m_moveAlarm.week.days[iIndex].seg[3].time_end.second; COleDateTime Etime(cTime.GetYear(),cTime.GetMonth(), cTime.GetDay(),iY, iM, iD); g_PubData.g_ETime4 = Etime; } }
static void hit_alarm_clock() { static int stay_time = 0; static int idle_time = 0; time_t now = time(0); char buf[100]="\0"; if(currutmp->pid != currpid) setup_utmp(XMODE); /* 重新配置 shm */ #ifdef DOTIMEOUT if((idle_time = now - currutmp->lastact) > IDLE_TIMEOUT && !HAS_PERM(PERM_RESEARCH)) #else if((idle_time = now - currutmp->lastact) > !HAS_PERM(PERM_RESEARCH)) #endif { outmsg("超過閒置時間!踢出去囉……"); abort_bbs(); } if (HAS_HABIT(HABIT_MOVIE) && (currstat && (currstat < CLASS || currstat == MAILALL))) movie(0); alarm(MOVIE_INT); stay_time += MOVIE_INT; #ifdef DOTIMEOUT if(idle_time > IDLE_TIMEOUT - 60 && !HAS_PERM(PERM_RESEARCH)) #else if(idle_time > 60 && !HAS_PERM(PERM_RESEARCH)) #endif sprintf(buf, "[1;5;37;41m警告:您已閒置過久,若無回應,系統即將切離!![m"); else if(stay_time > 10 * 60 && chkmail(0)) { sprintf(buf, "\033[1;33;41m[%s] 信箱�媮晹釣S看過的信唷\033[m", Etime(&now)); stay_time = 0 ; } else if(stay_time > STAY_TIMEOUT && HAS_HABIT(HABIT_ALARM)) { /* 在這裡提示 user 休息一下 */ char *msg[10] = { "伸伸腰, 揉揉眼, 喝口茶....喘口氣...再繼續...!", "一邊是友情 一邊是愛情 左右的故事為難著自己...", "是否有人瞭解您內心的孤寂? 大家來talk talk吧.. ", "左三圈,右三圈,脖子扭扭屁股扭扭 大家來作運動唷~", "我灌..我灌..我灌灌灌! 灌到硬碟爆掉...", "用•功\•唸•書", "書念完了沒啊....^.^", "明天有沒有考試啊...念書重要唷...!", "看∼流星!", "•書在心中氣自皇•讀書去•"}; int i = rand() % 10; sprintf(buf, "[1;33;41m[%s] %s[m", Etime(&now), msg[i]); stay_time = 0 ; } if(buf[0]) { outmsg(buf); bell(); } }
static void user_login() { char genbuf [200]; struct tm *ptime, *tmp; time_t now = time(0); int a; extern struct FROMCACHE *fcache; extern int fcache_semid; log_usies("ENTER", fromhost); setproctitle("%s: %s", cuser.userid, fromhost); /* ------------------------ */ /* 初始化 uinfo、flag、mode */ /* ------------------------ */ setup_utmp(LOGIN); currmode = MODE_STARTED; enter_uflag = cuser.uflag; /* get local time */ tmp = localtime(&cuser.lastlogin); update_data(); /* wildcat: update user data */ /* Ptt check 同時上線人數 */ resolve_fcache(); resolve_utmp(); if ((a = utmpshm->number) > fcache->max_user) { sem_init(FROMSEM_KEY, &fcache_semid); sem_lock(SEM_ENTER, fcache_semid); fcache->max_user = a; fcache->max_time = now; sem_lock(SEM_LEAVE, fcache_semid); } #ifdef INITIAL_SETUP if (getbnum(DEFAULT_BOARD) == 0) { strcpy(currboard, "尚未選定"); } else #endif { brc_initial(DEFAULT_BOARD); set_board(); } /* ------------ */ /* 畫面處理開始 */ /* ------------ */ if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST))) { char buf [256]; time_t now; time(&now); sprintf(buf, "<<上站通知>> -- 我來囉! - %s", Etime(&now)); do_aloha(buf); } time(&now); ptime = localtime(&now); #ifdef CAMERA film_out(FILM_LOGIN, 0); #else more("etc/Welcome_login", NA); #endif #if 0 /* wildcat : 搬家通知用 */ if (belong(BBSHOME "/etc/oldip", fromhost)) { more(BBSHOME "/etc/removal"); abort_bbs(); } #endif if ((cuser.day == ptime->tm_mday) && (cuser.month == (ptime->tm_mon + 1))) currutmp->birth = 1; else currutmp->birth = 0; if (cuser.userlevel) { /* not guest */ move(t_lines - 3, 0); prints(" 歡迎您第 [1;33m%d[0;37m 度拜訪本站,\ 上次您是從 [1;33m%s[0;37m 連往本站,\n\ 我記得那天是 [1;33m%s[0;37m。\n", ++cuser.numlogins, cuser.lasthost, Etime(&cuser.lastlogin)); pressanykey(NULL); /* Ptt */ if (currutmp->birth == 1) { #ifdef CAMERA film_out(FILM_WEL_BIRTH, 0); #else more("etc/Welcome_birth", YEA); #endif brc_initial("Greeting"); set_board(); do_post(); } sethomefile(genbuf, cuser.userid, str_badlogin); if (more(genbuf, NA) != -1) { if (getans2(b_lines, 0, "您要刪除以上錯誤嘗試的記錄嗎?", 0, 2, 'y') != 'n') unlink(genbuf); } check_register(); strncpy(cuser.lasthost, fromhost, 24); substitute_record(fn_passwd, &cuser, sizeof(cuser), usernum); cuser.lasthost[23] = '\0'; restore_backup(); }