static bool hasannperm(const char *title, const struct userec *user, const board_t *board) { if ((strstr(title, "BM: SYSOPS") && !HAS_PERM2(PERM_SYSOPS, user)) || (strstr(title, "BM: OBOARDS") && !HAS_PERM2(PERM_OBOARDS, user)) || (strstr(title, "BM: BMS") && !is_bm(user, board))) return false; return true; }
int bbslogin_main(void) { char fname[STRLEN]; char buf[256], id[IDLEN + 1], pw[PASSLEN]; struct userec user; if (parse_post_data() < 0) return BBS_EINVAL; strlcpy(id, getparm("id"), sizeof(id)); if (*id == '\0') return login_screen(); strlcpy(pw, getparm("pw"), sizeof(pw)); if (loginok && !strcasecmp(id, currentuser.userid)) { const char *ref = get_login_referer(); printf("Location: %s\n\n", ref); return 0; } if (getuserec(id, &user) == 0) return BBS_ENOUSR; user.numlogins++; if (strcasecmp(id, "guest")) { int total; time_t stay, recent, now, t; if (!checkpasswd(user.passwd, pw)) { sprintf(buf, "%-12.12s %s @%s\n", user.userid, getdatestring(time(NULL), DATE_ZH), fromhost); sethomefile(fname, user.userid, "logins.bad"); file_append(fname, buf); file_append("logins.bad", buf); return BBS_EWPSWD; } total = check_multi(&user); if (!HAS_PERM2(PERM_SYSOPS, &user) && total >= 2) return BBS_ELGNQE; if (!HAS_PERM2(PERM_LOGIN, &user)) return BBS_EACCES; now = time(NULL); // Do not count frequent logins. if (now - user.lastlogin < 20 * 60 && user.numlogins >= 100) user.numlogins--; if (total > 1) { recent = user.lastlogout; if (user.lastlogin > recent) recent = user.lastlogin; stay = now - recent; if (stay < 0) stay = 0; } else { stay = 0; } t = user.lastlogin; user.lastlogin = now; user.stay += stay; #ifdef CHECK_FREQUENTLOGIN if (!HAS_PERM(PERM_SYSOPS) && abs(t - time(NULL)) < 10) { report("Too Frequent", user.userid); return BBS_ELFREQ; } #endif strlcpy(user.lasthost, fromhost, sizeof(user.lasthost)); save_user_data(&user); currentuser = user; } log_usies("ENTER", fromhost, &user); if (!loginok && strcasecmp(id, "guest")) wwwlogin(&user, getparm("ref")); return 0; }
int tui_query_result(const char *userid) { struct userec user; int unum = getuserec(userid, &user); if (!unum) return -1; screen_move(0, 0); screen_clrtobot(); int color = 2; if (HAS_DEFINE(user.userdefine, DEF_COLOREDSEX)) color = (user.gender == 'F') ? 5 : 6; char horo[32] = ""; if (HAS_DEFINE(user.userdefine, DEF_S_HOROSCOPE) && strcasecmp(user.userid, "guest") != 0) { snprintf(horo, sizeof(horo), "[\033[1;3%dm%s\033[m] ", color, horoscope(user.birthmonth, user.birthday)); } //% prints("\033[0;1;37m%s \033[m(\033[1;33m%s\033[m) 共上站 \033[1;32m%d\033[m " prints("\033[0;1;37m%s \033[m(\033[1;33m%s\033[m) \xb9\xb2\xc9\xcf\xd5\xbe \033[1;32m%d\033[m " //% "次 %s\n", user.userid, user.username, user.numlogins, horo); "\xb4\xce %s\n", user.userid, user.username, user.numlogins, horo); bool self = !strcmp(currentuser.userid, user.userid); const char *host; if (user.lasthost[0] == '\0') { //% host = "(不详)"; host = "(\xb2\xbb\xcf\xea)"; } else { if (self || HAS_PERM2(PERM_OCHAT, ¤tuser)) host = user.lasthost; else host = mask_host(user.lasthost); } //% prints("进站 [\033[1;32m%s\033[m] %s[\033[1;32m%s\033[m]\n", prints("\xbd\xf8\xd5\xbe [\033[1;32m%s\033[m] %s[\033[1;32m%s\033[m]\n", format_time(user.lastlogin, TIME_FORMAT_ZH), //% strlen(host) > IPADDR_OMIT_THRES ? "" : "来自 ", host); strlen(host) > IPADDR_OMIT_THRES ? "" : "\xc0\xb4\xd7\xd4 ", host); user_id_t uid = get_user_id(userid); session_basic_info_t *res = get_sessions(uid); bool any_session_visible = false; for (int i = 0; i < (res ? session_basic_info_count(res) : 0); ++i) { if (HAS_PERM(PERM_SEECLOAK) || session_basic_info_visible(res, i)) { any_session_visible = true; break; } } if (any_session_visible) { //% prints("在线 [\033[1;32m讯息器:(\033[36m%s\033[32m)\033[m] ", prints("\xd4\xda\xcf\xdf [\033[1;32m\xd1\xb6\xcf\xa2\xc6\xf7:(\033[36m%s\033[32m)\033[m] ", //% "打开"); "\xb4\xf2\xbf\xaa"); } else { fb_time_t t = user.lastlogout; if (user.lastlogout < user.lastlogin) t = ((fb_time() - user.lastlogin) / 120) % 47 + 1 + user.lastlogin; //% prints("离站 [\033[1;32m%s\033[m] ", format_time(t, TIME_FORMAT_ZH)); prints("\xc0\xeb\xd5\xbe [\033[1;32m%s\033[m] ", format_time(t, TIME_FORMAT_ZH)); } char path[HOMELEN]; snprintf(path, sizeof(path), "mail/%c/%s/%s", toupper(user.userid[0]), user.userid, DOT_DIR); int perf = countperf(&user); //% prints("表现值 " prints("\xb1\xed\xcf\xd6\xd6\xb5 " #ifdef SHOW_PERF "%d(\033[1;33m%s\033[m)" #else "[\033[1;33m%s\033[m]" #endif //% " 信箱 [\033[1;5;32m%2s\033[m]\n" " \xd0\xc5\xcf\xe4 [\033[1;5;32m%2s\033[m]\n" #ifdef SHOW_PERF , perf #endif //% , cperf(perf), (check_query_mail(path) == 1) ? "信" : " "); , cperf(perf), (check_query_mail(path) == 1) ? "\xd0\xc5" : " "); int exp = countexp(&user); uinfo_t u; uinfo_load(user.userid, &u); #ifdef ENABLE_BANK //% prints("贡献 [\033[1;32m%d\033[m", TO_YUAN_INT(u.contrib)); prints("\xb9\xb1\xcf\xd7 [\033[1;32m%d\033[m", TO_YUAN_INT(u.contrib)); if (self || HAS_PERM2(PERM_OCHAT, ¤tuser)) { prints("/\033[1;33m%d\033[m", TO_YUAN_INT(u.money)); } { char rank_buf[8]; snprintf(rank_buf, sizeof(rank_buf), "%.1f%%", PERCENT_RANK(u.rank)); prints("](%s) ", rank_buf); } #endif #ifdef ALLOWGAME //% prints("存贷款 [\033[1;32m%d\033[m/\033[1;32m%d\033[m]" prints("\xb4\xe6\xb4\xfb\xbf\xee [\033[1;32m%d\033[m/\033[1;32m%d\033[m]" //% "(\033[1;33m%s\033[m) 经验值 [\033[1;32m%d\033[m]\n", "(\033[1;33m%s\033[m) \xbe\xad\xd1\xe9\xd6\xb5 [\033[1;32m%d\033[m]\n", user.money, user.bet, cmoney(user.money - user.bet), exp); //% prints("发文 [\033[1;32m%d\033[m] 奖章 [\033[1;32m%d\033[m]" prints("\xb7\xa2\xce\xc4 [\033[1;32m%d\033[m] \xbd\xb1\xd5\xc2 [\033[1;32m%d\033[m]" //% "(\033[1;33m%s\033[m) 生命力 [\033[1;32m%d\033[m]\n", "(\033[1;33m%s\033[m) \xc9\xfa\xc3\xfc\xc1\xa6 [\033[1;32m%d\033[m]\n", user.numposts, user.nummedals, cnummedals(user.nummedals), compute_user_value(&user)); #else //% prints("发文 [\033[1;32m%d\033[m] ", user.numposts); prints("\xb7\xa2\xce\xc4 [\033[1;32m%d\033[m] ", user.numposts); //% prints("经验值 [\033[1;33m%-10s\033[m]", cexpstr(exp)); prints("\xbe\xad\xd1\xe9\xd6\xb5 [\033[1;33m%-10s\033[m]", cexpstr(exp)); #ifdef SHOWEXP prints("(%d)", exp); #endif //% prints(" 生命力 [\033[1;32m%d\033[m]\n", compute_user_value(&user)); prints(" \xc9\xfa\xc3\xfc\xc1\xa6 [\033[1;32m%d\033[m]\n", compute_user_value(&user)); #endif char buf[160]; show_position(&user, buf, sizeof(buf), u.title); //% prints("身份 %s\n", buf); prints("\xc9\xed\xb7\xdd %s\n", buf); uinfo_free(&u); if (any_session_visible) show_statuses(res); session_basic_info_clear(res); show_user_plan(userid); return 0; }