int bbsinfo_main(void) { if (!loginok) return BBS_ELGNREQ; parse_post_data(); char *type = getparm("type"); xml_header("bbs"); if (*type != '\0') { printf("<bbsinfo "); print_session(); printf(">%s</bbsinfo>", check_info()); } else { printf("<bbsinfo post='%d' login='******' stay='%d' " "since='%s' host='%s' year='%d' month='%d' " "day='%d' gender='%c' ", currentuser.numposts, currentuser.numlogins, currentuser.stay / 60, getdatestring(currentuser.firstlogin, DATE_XML), currentuser.lasthost, currentuser.birthyear, currentuser.birthmonth, currentuser.birthday, currentuser.gender); print_session(); printf(" last='%s'><nick>", getdatestring(currentuser.lastlogin, DATE_XML)); xml_fputs(currentuser.username, stdout); printf("</nick></bbsinfo>"); } return 0; }
int web_fav(void) { if (!session_id()) return BBS_ELGNREQ; xml_header(NULL); printf("<bbsfav>"); print_session(); db_res_t *res = db_query("SELECT b.id, b.name, b.descr FROM boards b" " JOIN fav_boards f ON b.id = f.board WHERE f.user_id = %d", session_uid()); if (res) { for (int i = 0; i < db_res_rows(res); ++i) { int bid = db_get_integer(res, i, 0); const char *name = db_get_value(res, i, 1); GBK_BUFFER(descr, BOARD_DESCR_CCHARS); convert_u2g(db_get_value(res, i, 2), gbk_descr); printf("<brd bid='%d' brd='%s'>", bid, name); xml_fputs(gbk_descr); printf("</brd>"); } } db_clear(res); printf("</bbsfav>"); return 0; }
/** * Print override information. * @param buf the starting address of override struct. * @param count not used. * @param args not used. * @return 0. */ static int print_override(void *buf, int count, void *args) { override_t *ov = buf; printf("<ov id='%s'>", ov->id); xml_fputs(ov->exp, stdout); printf("</ov>"); return 0; }
static void override_info(void) { char file[HOMELEN]; sethomefile(file, currentuser.userid, "friends"); mmap_t m; m.oflag = O_RDONLY; if (mmap_open(file, &m) < 0) return; hash_t ht; if (hash_create(&ht, 0, NULL) < 0) { mmap_close(&m); return; } int count = m.size / sizeof(override_t); if (count > 0) { override_t *ov = m.ptr; for (int i = 0; i < count; i++) { hash_set(&ht, ov->id, HASH_KEY_STRING, ov->id); ov++; } time_t now = time(NULL); struct user_info *uinfo = utmpshm->uinfo; struct userec *user; const char *ip; int idle; for (int i = 0; i < MAXACTIVE; ++i) { if (uinfo->active && !(uinfo->invisible && !HAS_PERM(PERM_SEECLOAK)) && hash_get(&ht, uinfo->userid, HASH_KEY_STRING)) { user = uidshm->passwd + (uinfo->uid - 1); if (HAS_DEFINE(user->userdefine, DEF_NOTHIDEIP)) ip = mask_host(uinfo->from); else ip = "......"; if (uinfo->mode == BBSNET) idle = 0; else idle = (now - uinfo->idle_time) / 60; printf("<ov id='%s' action='%s' idle='%d' ip='%s'>", uinfo->userid, mode_type(uinfo->mode), idle, ip); xml_fputs(uinfo->username, stdout); printf("</ov>"); } uinfo++; } } hash_destroy(&ht); mmap_close(&m); }
int bbsfall_main(void) { if (!session_get_id()) return BBS_ELGNREQ; xml_header(NULL); printf("<bbsfall>"); print_session(); following_list_t *fl = following_list_load(session_get_user_id()); if (fl) { for (int i = following_list_rows(fl) - 1; i >= 0; --i) { printf("<ov id='%s'>", following_list_get_name(fl, i)); xml_fputs(following_list_get_notes(fl, i)); printf("</ov>"); } } printf("</bbsfall>"); 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); }