static char *generate_content(const post_request_t *pr, const char *uname, const char *nick, const char *ip, bool anony, size_t length) { UTF8_BUFFER(nick, NAMELEN); convert_g2u(nick, utf8_nick); char header[512]; snprintf(header, sizeof(header), "发信人: %s (%s), 信区: %s\n标 题: %s\n发信站: %s (%s)\n\n", uname, utf8_nick, pr->board->name, pr->title, BBSNAME_UTF8, format_time(fb_time(), TIME_FORMAT_UTF8_ZH)); int header_len = strlen(header); int content_len = length ? length : strlen(pr->content); if (pr->convert_type != CONVERT_NONE) content_len *= 2; char signature[MAXSIGLINES * SIGNATURE_LINE_LEN + 5]; char utf8_signature[sizeof(signature) * 2 + 1]; if (!anony && pr->sig > 0) { read_signature_legacy(uname, pr->sig, signature, sizeof(signature)); convert_g2u(signature, utf8_signature); } else { strlcpy(utf8_signature, "\n--", sizeof(utf8_signature)); } int signature_len = strlen(utf8_signature); char source[256] = { '\0' }; if (ip) { char utf8_ip[80]; convert_g2u(ip, utf8_ip); snprintf(source, sizeof(source), "\033[m\033[1;%2dm※ %s:·"BBSNAME_UTF8 " "BBSHOST"·%s[FROM: %s]\033[m\n", 31 + rand() % 7, pr->crosspost ? "转载" : "来源", pr->web ? "HTTP " : "", utf8_ip); } int source_len = strlen(source); int total_len = header_len + content_len + signature_len + source_len + 2; char *content = malloc(total_len); memcpy(content, header, header_len); if (pr->convert_type != CONVERT_NONE) convert(pr->convert_type, pr->content, CONVERT_ALL, content + header_len, total_len - header_len, NULL, NULL); else strlcpy(content + header_len, pr->content, total_len - header_len); int len = strlen(content); if (len < total_len) memcpy(content + len, utf8_signature, total_len - len); len += signature_len; if (content[len - 1] != '\n' && len < total_len) { content[len++] = '\n'; } if (len < total_len) memcpy(content + len, source, total_len - len); content[len + source_len] = '\0'; return content; }
int x_lockscreen(void) { set_user_status(ST_LOCKSCREEN); screen_move(9, 0); screen_clrtobot(); screen_move(9, 0); prints("\033[1;37m" "\n _ _____ ___ _ _ ___ ___ __" "\n ( ) ( _ ) ( _`\\ ( ) ( ) ( _`\\ ( _`\\ | |" "\n | | | ( ) | | ( (_) | |/'/' | (_(_) | | ) | | |" "\n | | _ | | | | | | _ | , < | _)_ | | | ) | |" "\n | |_( ) | (_) | | (_( ) | |\\`\\ | (_( ) | |_) | |==|" "\n (____/' (_____) (____/' (_) (_) (____/' (____/' |__|\n" //% "\n\033[1;36m屏幕已在\033[33m %s\033[36m 时被%s暂时锁住了...\033[m", "\n\033[1;36m\xc6\xc1\xc4\xbb\xd2\xd1\xd4\xda\033[33m %s\033[36m \xca\xb1\xb1\xbb%s\xd4\xdd\xca\xb1\xcb\xf8\xd7\xa1\xc1\xcb...\033[m", format_time(fb_time(), TIME_FORMAT_ZH), currentuser.userid); char buf[PASSLEN + 1]; buf[0] = '\0'; while (*buf == '\0' || !passwd_check(currentuser.userid, buf)) { screen_move(18, 0); screen_clrtobot(); //% getdata(19, 0, "请输入您的密码以解锁: ", buf, PASSLEN, NOECHO, YEA); getdata(19, 0, "\xc7\xeb\xca\xe4\xc8\xeb\xc4\xfa\xb5\xc4\xc3\xdc\xc2\xeb\xd2\xd4\xbd\xe2\xcb\xf8: ", buf, PASSLEN, NOECHO, YEA); } return FULLUPDATE; }
void log_attempt(const char *name, const char *addr, const char *type) { char file[STRLEN], buf[256]; snprintf(buf, sizeof(buf), "%-12.12s %-30s %s %s\n", name, format_time(fb_time(), TIME_FORMAT_ZH), addr, type); file_append(BADLOGINFILE, buf); sethomefile(file, name, BADLOGINFILE); file_append(file, buf); }
void tui_update_status_line(void) { extern time_t login_start_time; //main.c char date[STRLEN]; screen_move_clear(-1); if (!DEFINE(DEF_ENDLINE)) return; fb_time_t now = fb_time(); int cur_sec = now % 10; if (cur_sec < 5) { strlcpy(date, format_time(now, TIME_FORMAT_UTF8_ZH), sizeof(date)); } else { if (resolve_boards() >= 0) convert_g2u(brdshm->date, date); else date[0] = '\0'; } if (cur_sec >= 5 && is_birth(¤tuser)) { screen_printf("\033[0;1;33;44m[\033[36m " "啦啦~~生日快乐!记得要请客哟 :P" " \033[33m]\033[m"); } else { int stay = (now - login_start_time) / 60; char stay_str[20]; describe_stay(stay, stay_str, sizeof(stay_str)); char notice[128]; notice_string(notice, sizeof(notice)); int notice_width = screen_display_width(notice, true); screen_printf("\033[1;44;33m[\033[36m%29s\033[33m]" "[\033[36m%5d\033[33m人\033[36m%3d\033[33m友]", date, session_count_online(), session_count_online_followed(!HAS_PERM(PERM_SEECLOAK))); // 剩下35列 if (notice_width) { int space = 33 - notice_width; if (space > 0) tui_repeat_char(' ', space); screen_printf("[\033[%d;36m%s\033[m\033[1;33;44m]\033[m", _suppress_notice ? 1 : 5, notice); } else { int space = 27 - strlen(currentuser.userid); tui_repeat_char(' ', space); prints("[\033[36m%s\033[33m]%s\033[m", currentuser.userid, stay_str); } } }
static bool activate_session(session_id_t sid, const char *uname) { db_res_t *res = db_cmd("UPDATE sessions SET active = TRUE, stamp = %t" " WHERE id = %"DBIdSID, fb_time(), sid); db_clear(res); if (res) return !do_web_login(uname, NULL, false); return false; }
static void notice_count(int *replies, int *mentions) { static fb_time_t last; fb_time_t now = fb_time(); if (now - last > 10) { user_id_t user_id = session_get_user_id(); *replies = post_reply_get_count(user_id); *mentions = post_mention_get_count(user_id); last = now; } else { *replies = post_reply_get_count_cached(); *mentions = post_mention_get_count_cached(); } }
static void get_idle_str(char *buf, size_t size, fb_time_t refresh, int status) { int idle = 0; if (refresh > 0 && status != ST_BBSNET) idle = (fb_time() - refresh) / 60; if (!idle) { *buf = '\0'; } else { if (idle > 999) strlcpy(buf, "999+", size); else snprintf(buf, size, "%d", idle); } }
static void show_status_line(const editor_t *editor) { screen_move_clear(-1); if (editor->hide_status_line) return; bool mail = chkmail(); vector_size_t x; text_line_size_t y; real_pos(editor, &x, &y); screen_printf("\033[1;33;44m[%s] [\033[32m%s\033[33m]" " [\033[32m按\033[31mCtrl-Q\033[32m求救\033[33m]" " [\033[32m%d\033[33m,\033[32m%d\033[33m]\033[K\033[m", mail ? "\033[5;32m信\033[m\033[1;33;44m" : " ", format_time(fb_time(), TIME_FORMAT_UTF8_ZH) + 7, x, y); }
static tui_list_loader_t online_users_load(tui_list_t *p) { online_users_t *up = p->data; fb_time_t now = fb_time(); if (now < up->uptime + REFRESH_TIME) return up->num; up->uptime = now; online_users_free(up); if (up->follow) { return online_users_load_followings(p); } else { if (up->bid) return online_users_load_board(p); else return online_users_load_all(p); } }
/** * The main entrance of bbswebd. * @return 0 on success, 1 on initialization error. */ int main(void) { fb_signal(SIGTERM, exit_handler); fb_signal(SIGUSR1, exit_handler); if (initialize() < 0) return EXIT_FAILURE; initialize_environment(INIT_CONV | INIT_DB | INIT_MDB); while (FCGI_Accept() >= 0) { if (!web_ctx_init()) return EXIT_FAILURE; const web_handler_t *h = _get_handler(); int code = BBS_ENOURL; if (h) { get_client_ip(); session_validate(); brc_reset(); if (session_get_id()) { if (h->status != ST_IDLE) set_user_status(h->status); session_set_idle(session_get_id(), fb_time()); if (h->status != ST_READING) session_set_board(0); } code = execute(h); } if (code > 0) web_respond(code); else check_bbserr(code); web_ctx_destroy(); } return 0; }
static void show_sessions_of_friends(void) { db_res_t *res = session_get_followed(); if (!res) return; fb_time_t now = fb_time(); for (int i = 0; i < db_res_rows(res); ++i) { bool visible = db_get_bool(res, i, 3); if (!visible && !HAS_PERM(PERM_SEECLOAK)) continue; session_id_t sid = db_get_session_id(res, i, 0); const char *uname = db_get_value(res, i, 2); const char *ip = db_get_value(res, i, 4); fb_time_t refresh = session_get_idle(sid); int status = get_user_status(sid); struct userec user; getuserec(uname, &user); int idle; if (refresh < 1 || status == ST_BBSNET) idle = 0; else idle = (now - refresh) / 60; if (HAS_DEFINE(user.userdefine, DEF_NOTHIDEIP)) ip = mask_host(ip); else ip = "......"; printf("<ov id='%s' action='%s' idle='%d' ip='%s'>", uname, session_status_descr(status), idle, ip); xml_fputs(user.username); printf("</ov>"); } db_clear(res); }
void active_board_init(bool force) { fb_time_t now = fb_time(); if (!force) { fb_time_t last = mdb_integer(0, "GET", ACTIVE_BOARD_UPTIME_KEY); if (now - last < ACTIVE_BOARD_INIT_INTERVAL) return; } mdb_cmd("SET", ACTIVE_BOARD_UPTIME_KEY" %"PRIdFBT, now); board_t board; if (get_board(ACTIVE_BOARD_NAME, &board) <= 0) return; record_t record; if (post_record_open(board.id, &record) < 0) return; active_board_clear(); record_foreach(&record, NULL, 0, active_board_init_callback, NULL); record_close(&record); }
static void user_login(void) { char fname[STRLEN]; // SYSOP gets all permission bits when login. if (strcmp(currentuser.userid, "SYSOP") == 0) { currentuser.userlevel = ~0; substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); } fromhost[sizeof(fromhost) - 1] = 0; //added by iamfat 2004.01.05 to avoid overflow log_usies("ENTER", fromhost, ¤tuser); SpecialID(currentuser.userid, fromhost, sizeof(fromhost)); u_enter(); report("Enter", currentuser.userid); #ifdef USE_NOTEPAD notepad_init(); if (strcmp(currentuser.userid, "guest") != 0) { if (DEFINE(DEF_NOTEPAD)) { int noteln; if (lastnote> currentuser.notedate) currentuser.noteline = 0; noteln = countln("etc/notepad"); if (currentuser.noteline == 0) { shownotepad(); } else if ((noteln - currentuser.noteline)> 0) { screen_move(0, 0); ansimore2("etc/notepad", NA, 0, noteln - currentuser.noteline + 1); terminal_getchar(); screen_clear(); } currentuser.noteline = noteln; write_defnotepad(); } } #endif if (show_statshm("etc/hotspot", 0)) { screen_flush(); pressanykey(); } if ((vote_flag(NULL, '\0', 2 /* 检查读过新的Welcome 没 */) == 0)) { if (dashf("Welcome")) { ansimore("Welcome", YEA); vote_flag(NULL, 'R', 2 /* 写入读过新的Welcome */); } } else { ansimore("Welcome2", YEA); } show_statshm("0Announce/bbslist/day", 1); screen_flush(); screen_move_clear(-2); if (currentuser.numlogins < 1) { currentuser.numlogins = 0; //% prints("\033[1;36m☆ 这是您第 \033[33m1\033[36m 次拜访本站,请记住今天吧。\n"); prints("\033[1;36m\xa1\xee \xd5\xe2\xca\xc7\xc4\xfa\xb5\xda \033[33m1\033[36m \xb4\xce\xb0\xdd\xb7\xc3\xb1\xbe\xd5\xbe\xa3\xac\xc7\xeb\xbc\xc7\xd7\xa1\xbd\xf1\xcc\xec\xb0\xc9\xa1\xa3\n"); //% prints("☆ 您第一次连入本站的时间为 \033[33m%s\033[m ", format_time(time(NULL), TIME_FORMAT_ZH)); prints("\xa1\xee \xc4\xfa\xb5\xda\xd2\xbb\xb4\xce\xc1\xac\xc8\xeb\xb1\xbe\xd5\xbe\xb5\xc4\xca\xb1\xbc\xe4\xce\xaa \033[33m%s\033[m ", format_time(fb_time(), TIME_FORMAT_ZH)); } else { prints( //% "\033[1;36m☆ 这是您第 \033[33m%d\033[36m 次拜访本站,上次您是从 \033[33m%s\033[36m 连往本站。\n", "\033[1;36m\xa1\xee \xd5\xe2\xca\xc7\xc4\xfa\xb5\xda \033[33m%d\033[36m \xb4\xce\xb0\xdd\xb7\xc3\xb1\xbe\xd5\xbe\xa3\xac\xc9\xcf\xb4\xce\xc4\xfa\xca\xc7\xb4\xd3 \033[33m%s\033[36m \xc1\xac\xcd\xf9\xb1\xbe\xd5\xbe\xa1\xa3\n", currentuser.numlogins + 1, currentuser.lasthost); //% prints("☆ 上次连线时间为 \033[33m%s\033[m ", format_time(currentuser.lastlogin, TIME_FORMAT_ZH)); prints("\xa1\xee \xc9\xcf\xb4\xce\xc1\xac\xcf\xdf\xca\xb1\xbc\xe4\xce\xaa \033[33m%s\033[m ", format_time(currentuser.lastlogin, TIME_FORMAT_ZH)); } terminal_getchar(); setuserfile(fname, BADLOGINFILE); if (ansimore(fname, NA) != -1) { //% if (askyn("您要删除以上密码输入错误的记录吗", NA, NA) == YEA) if (askyn("\xc4\xfa\xd2\xaa\xc9\xbe\xb3\xfd\xd2\xd4\xc9\xcf\xc3\xdc\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3\xb5\xc4\xbc\xc7\xc2\xbc\xc2\xf0", NA, NA) == YEA) unlink(fname); } set_safe_record(); tui_check_uinfo(¤tuser); strlcpy(currentuser.lasthost, fromhost, sizeof(currentuser.lasthost)); if (login_start_time - currentuser.lastlogin >= 20 * 60 || !strcmp(currentuser.userid, "guest") || currentuser.numlogins < 100) { currentuser.numlogins++; } session_basic_info_t *res = get_my_sessions(); update_user_stay(¤tuser, true, session_basic_info_count(res) > 1); session_basic_info_clear(res); #ifdef ALLOWGAME if (currentuser.money> 1000000) { currentuser.nummedals += currentuser.money / 10000; currentuser.money %= 1000000; } if ((signed int) (currentuser.money - currentuser.bet) < -4990 && currentuser.numlogins < 10 && currentuser.numposts < 10 && currentuser.nummedals == 0) currentuser.money += 1000; #endif if (currentuser.firstlogin == 0) { currentuser.firstlogin = time(NULL) - 7 * 86400; } substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); extern char currmaildir[]; setmdir(currmaildir, currentuser.userid); check_register_info(); }
// Do autoposting according to "etc/autopost", // if no such action has been taken since last 00:00 UTC. static void notepad_init(void) { FILE *check; char notetitle[STRLEN]; char tmp[STRLEN * 2]; char *fname, *bname, *ntitle; long int maxsec; maxsec = 86400; lastnote = 0; if ((check = fopen("etc/checknotepad", "r")) != NULL) { fgets(tmp, sizeof(tmp), check); lastnote = atol(tmp); fclose(check); } fb_time_t now = fb_time(); if ((now - lastnote) >= maxsec) { screen_move(-1, 0); //% prints("对不起,系统自动发信,请稍候....."); prints("\xb6\xd4\xb2\xbb\xc6\xf0\xa3\xac\xcf\xb5\xcd\xb3\xd7\xd4\xb6\xaf\xb7\xa2\xd0\xc5\xa3\xac\xc7\xeb\xc9\xd4\xba\xf2....."); screen_flush(); check = fopen("etc/checknotepad", "w"); lastnote = now - (now % maxsec); if (check) { fprintf(check, "%ld", lastnote); fclose(check); } if ((check = fopen("etc/autopost", "r")) != NULL) { while (fgets(tmp, STRLEN, check) != NULL) { fname = strtok(tmp, " \n\t:@"); bname = strtok(NULL, " \n\t:@"); ntitle = strtok(NULL, " \n\t:@"); if (fname == NULL || bname == NULL || ntitle == NULL) continue; else { char *str = format_time(now, TIME_FORMAT_ZH); snprintf(notetitle, sizeof(notetitle), "[%14.14s %6.6s] %s", str, str + 23, ntitle); if (dashf(fname)) { Postfile(fname, bname, notetitle, 1); //% sprintf(tmp, "%s 自动张贴", ntitle); sprintf(tmp, "%s \xd7\xd4\xb6\xaf\xd5\xc5\xcc\xf9", ntitle); report(tmp, currentuser.userid); } } } fclose(check); } char *str = format_time(now, TIME_FORMAT_ZH); //% snprintf(notetitle, sizeof(notetitle), "[%14.14s %6.6s] 留言板记录", snprintf(notetitle, sizeof(notetitle), "[%14.14s %6.6s] \xc1\xf4\xd1\xd4\xb0\xe5\xbc\xc7\xc2\xbc", str, str + 23); if (dashf("etc/notepad")) { Postfile("etc/notepad", "Notepad", notetitle, 1); unlink("etc/notepad"); } //% report("自动发信时间更改", currentuser.userid); report("\xd7\xd4\xb6\xaf\xb7\xa2\xd0\xc5\xca\xb1\xbc\xe4\xb8\xfc\xb8\xc4", currentuser.userid); } return; }
static int login_query(void) { #ifndef ENABLE_SSH char uname[IDLEN + 2]; char passbuf[PASSLEN]; int attempts; int recover; // For giveupBBS bool auth = false; #endif // ENABLE_SSH // Deny new logins if too many users online. int online = session_count_online(); #ifndef ENABLE_SSH if (online >= MAXACTIVE) { ansimore("etc/loginfull", NA); return -1; } #endif // ENABLE_SSH ansimore2("etc/issue", false, 0, 0); screen_printf("\033[1;35m欢迎光临\033[1;40;33m【 %s 】 \033[m" "[\033[1;33;41m Add '.' after YourID to login for BIG5 \033[m]\n", BBSNAME_UTF8); int peak = session_get_online_record(); if (peak < online) { session_set_online_record(online); peak = online; } screen_printf("\033[1;32m目前已有帐号: [\033[1;36m%d\033[32m/\033[36m%d\033[32m] " "\033[32m目前站上人数: [\033[36m%d\033[32m/\033[36m%d\033[1;32m]\n", get_user_count(), MAXUSERS, online, MAXACTIVE); visitlog(peak); #ifndef ENABLE_SSH attempts = 0; while (!auth) { if (attempts++ >= LOGINATTEMPTS) { ansimore("etc/goodbye", NA); return -1; } //% getdata(0, 0, "\033[1;33m请输入帐号\033[m" getdata(0, 0, "\033[1;33m\xc7\xeb\xca\xe4\xc8\xeb\xd5\xca\xba\xc5\033[m" //% "(试用请输入'\033[1;36mguest\033[m', " "(\xca\xd4\xd3\xc3\xc7\xeb\xca\xe4\xc8\xeb'\033[1;36mguest\033[m', " //% "注册请输入'\033[1;31mnew\033[m'): ", "\xd7\xa2\xb2\xe1\xc7\xeb\xca\xe4\xc8\xeb'\033[1;31mnew\033[m'): ", uname, IDLEN + 1, DOECHO, YEA); if (strcaseeq(uname, "guest") && (online > MAXACTIVE - 10)) { ansimore("etc/loginfull", NA); return -1; } if (strcaseeq(uname, "new")) { memset(¤tuser, 0, sizeof(currentuser)); new_register(); terminal_flush(); exit(1); } else if (*uname == '\0') ; else if (!dosearchuser(uname, ¤tuser, &usernum)) { screen_printf("\033[1;31m经查证,无此 ID。\033[m\n"); } else if (strcaseeq(uname, "guest")) { currentuser.userlevel = 0; break; } else { //% getdata(0, 0, "\033[1;37m请输入密码: \033[m", passbuf, PASSLEN, getdata(0, 0, "\033[1;37m\xc7\xeb\xca\xe4\xc8\xeb\xc3\xdc\xc2\xeb: \033[m", passbuf, PASSLEN, NOECHO, YEA); passbuf[8] = '\0'; switch (bbs_auth(uname, passbuf)) { case BBS_EWPSWD: screen_printf("\033[1;31m密码输入错误...\033[m\n"); break; case BBS_EGIVEUP: recover = chk_giveupbbs(); screen_printf("\033[33m您正在戒网,离戒网结束还有%d天\033[m\n", recover - fb_time() / 3600 / 24); return -1; case BBS_ESUICIDE: screen_printf("\033[32m您已经自杀\033[m\n"); return -1; case BBS_EBANNED: screen_printf("\033[32m本帐号已停机。请到 " "\033[36mNotice\033[32m版 查询原因\033[m\n"); return -1; case BBS_ELFREQ: screen_printf("登录过于频繁,请稍候再来\n"); return -1; case 0: auth = true; break; default: auth = false; break; } memset(passbuf, 0, PASSLEN - 1); } } #else // ENABLE_SSH //% 欢迎使用ssh方式访问本站,请按任意键继续 presskeyfor("\033[1;33m\xbb\xb6\xd3\xad\xca\xb9\xd3\xc3ssh\xb7\xbd\xca\xbd\xb7\xc3\xce\xca\xb1\xbe\xd5\xbe\xa3\xac\xc7\xeb\xb0\xb4\xc8\xce\xd2\xe2\xbc\xfc\xbc\xcc\xd0\xf8", -1); #endif // ENABLE_SSH if (multi_user_check() == -1) return -1; sethomepath(genbuf, currentuser.userid); mkdir(genbuf, 0755); login_start_time = time(NULL); 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; }
void tui_update_status_line(void) { extern time_t login_start_time; //main.c char date[STRLEN]; screen_move_clear(-1); if (!DEFINE(DEF_ENDLINE)) return; fb_time_t now = fb_time(); int cur_sec = now % 10; if (cur_sec < 5) { strlcpy(date, format_time(now, TIME_FORMAT_ZH), sizeof(date)); } else { if (resolve_boards() >= 0) strlcpy(date, brdshm->date, 30); else date[0] = '\0'; } if (cur_sec >= 5 && is_birth(¤tuser)) { //% "啦啦~~,生日快乐! 记得要请客哟 :P" prints("\033[0;1;44;33m[\033[36m " "\xc0\xb2\xc0\xb2\xa1\xab\xa1\xab\xa3\xac\xc9\xfa\xc8\xd5" "\xbf\xec\xc0\xd6! \xbc\xc7\xb5\xc3\xd2\xaa\xc7\xeb" "\xbf\xcd\xd3\xb4 :P \033[33m]\033[m"); } else { int stay = (now - login_start_time) / 60; char stay_str[20]; describe_stay(stay, stay_str, sizeof(stay_str)); char notice[128]; notice_string(notice, sizeof(notice)); int notice_len = strlen(notice); prints( "\033[1;44;33m[\033[36m%29s\033[33m]" //% "人 友" "[\033[36m%5d\033[33m\xc8\xcb\033[36m%3d\033[33m\xd3\xd1]", date, session_count_online(), session_count_online_followed(!HAS_PERM(PERM_SEECLOAK))); if (notice_len) { int space = 25 - notice_len; if (space > 0) { tui_repeat_char(' ', space); prints("[\033[%d;36m%s\033[m\033[1;33;44m]%s\033[m", _suppress_notice ? 1 : 5, notice, stay_str); } else { space += 6; if (space > 0) tui_repeat_char(' ', space); prints("[\033[%d;36m%s\033[m\033[1;33;44m]\033[m", _suppress_notice ? 1 : 5, notice); } } else { int space = 25 - strlen(currentuser.userid); tui_repeat_char(' ', space); prints("[\033[36m%s\033[33m]%s\033[m", currentuser.userid, stay_str); } } }