static void show_prop(prop_list_t *p, int i) { GBK_BUFFER(name, PROP_ITEM_CCHARS); GBK_BUFFER(categ, PROP_CATEG_CCHARS); convert_u2g(prop_list_get_name(p, i), gbk_name); convert_u2g(prop_list_get_categ_name(p, i), gbk_categ); printf("<item id='%d' name='%s' categ='%s' price='%d'/>", prop_list_get_id(p, i), gbk_name, gbk_categ, TO_YUAN_INT(prop_list_get_price(p, i))); }
static void show_my_prop(my_props_t *p, int i) { GBK_BUFFER(name, PROP_ITEM_CCHARS); GBK_BUFFER(categ, PROP_CATEG_CCHARS); convert_u2g(my_prop_get_item_name(p, i), gbk_name); convert_u2g(my_prop_get_categ_name(p, i), gbk_categ); printf("<prop record='%d' item='%d' name='%s' categ='%s' price='%d'" " order='%s'", my_prop_get_record_id(p, i), my_prop_get_item_id(p, i), gbk_name, gbk_categ, TO_YUAN_INT(my_prop_get_price(p, i)), format_time(my_prop_get_order_time(p, i), TIME_FORMAT_XML)); printf(" expire='%s'/>", format_time(my_prop_get_expire(p, i), TIME_FORMAT_XML)); }
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; }
static tui_list_display_t following_list_display(tui_list_t *p, int i) { following_list_t *list = p->data; char gbk_note[FOLLOW_NOTE_CCHARS * 2 + 1]; convert_u2g(following_list_get_notes(list, i), gbk_note); prints(" %4d %-12s %s\n", i + 1, following_list_get_name(list, i), gbk_note); return 0; }
static int show_sector(int sid, db_res_t *res, int last) { for (int i = last + 1; i < db_res_rows(res); ++i) { int sector = db_get_integer(res, i, 2); if (sector == sid) { last = i; const char *utf8_descr = db_get_value(res, i, 1); GBK_BUFFER(descr, BOARD_DESCR_CCHARS); if (!web_request_type(UTF8)) { convert_u2g(utf8_descr, gbk_descr); } printf("<brd name='%s' desc='%s'/>", db_get_value(res, i, 0), web_request_type(UTF8) ? utf8_descr : gbk_descr); } } return last; }
static int show_title_detail(int record) { db_res_t *res = db_query("SELECT title, approved FROM titles" " WHERE record_id = %d AND user_id = %"DBIdUID, record, session_uid()); if (!res || db_res_rows(res) <= 0) { db_clear(res); return BBS_EINVAL; } GBK_BUFFER(title, TITLE_CCHARS); convert_u2g(db_get_value(res, 0, 0), gbk_title); xml_header(NULL); printf("<bbspropdetail>"); print_session(); //% printf("<prop>自定义身份%s: %s</prop></bbspropdetail>", printf("<prop>\xd7\xd4\xb6\xa8\xd2\xe5\xc9\xed\xb7\xdd%s: %s</prop></bbspropdetail>", //% db_get_bool(res, 0, 1) ? "" : "[尚在审核]", gbk_title); db_get_bool(res, 0, 1) ? "" : "[\xc9\xd0\xd4\xda\xc9\xf3\xba\xcb]", gbk_title); db_clear(res); return 0; }
int web_sector(void) { int sid = 0; board_t parent = { .id = 0 }; db_res_t *res = NULL; const char *sname = web_get_param("s"); if (*sname) { res = db_query("SELECT id, descr" " FROM board_sectors WHERE name = %s", sname); if (!res || db_res_rows(res) < 1) { db_clear(res); return BBS_EINVAL; } } else { const char *pname = web_get_param("board"); if (*pname) get_board(pname, &parent); else get_board_by_bid(strtol(web_get_param("bid"), NULL, 10), &parent); if (!parent.id || !(parent.flag & BOARD_FLAG_DIR) || !has_read_perm(&parent)) return BBS_ENOBRD; } xml_header(NULL); printf("<bbsboa link='%sdoc' ", get_post_list_type_string()); if (*sname) { char path[HOMELEN]; sprintf(path, "%s/info/egroup%d/icon.jpg", BBSHOME, (int) strtol(sname, NULL, 16)); if (dashf(path)) printf(" icon='%s'", path); const char *utf8_sector = db_get_value(res, 0, 1); if (web_request_type(UTF8)) { printf(" title='%s'>", utf8_sector); } else { GBK_BUFFER(sector, BOARD_SECTOR_NAME_CCHARS); convert_u2g(utf8_sector, gbk_sector); printf(" title='%s'>", gbk_sector); } sid = db_get_integer(res, 0, 0); db_clear(res); } else { if (web_request_type(UTF8)) { printf(" dir= '1' title='%s'>", parent.descr); } else { GBK_BUFFER(descr, BOARD_DESCR_CCHARS); convert_u2g(parent.descr, gbk_descr); printf(" dir= '1' title='%s'>", gbk_descr); } } if (sid) res = db_query(BOARD_SELECT_QUERY_BASE "WHERE b.sector = %d", sid); else res = db_query(BOARD_SELECT_QUERY_BASE "WHERE b.parent = %d", parent.id); if (res && db_res_rows(res) > 0) show_board(res); db_clear(res); print_session(); printf("</bbsboa>"); return 0; } int bbsclear_main(void) { if (!session_id()) return BBS_ELGNREQ; board_t board; if (!get_board(web_get_param("board"), &board) || !has_read_perm(&board)) return BBS_ENOBRD; session_set_board(board.id); const char *start = web_get_param("start"); brc_init(currentuser.userid, board.name); brc_clear_all(); brc_sync(currentuser.userid); char buf[STRLEN]; snprintf(buf, sizeof(buf), "doc?board=%s&start=%s", board.name, start); http_header(); refreshto(0, buf); printf("</head></html>"); return 0; } int bbsnot_main(void) { board_t board; if (!get_board(web_get_param("board"), &board) || !has_read_perm(&board)) return BBS_ENOBRD; if (board.flag & BOARD_FLAG_DIR) return BBS_EINVAL; session_set_board(board.id); char fname[HOMELEN]; snprintf(fname, sizeof(fname), "vote/%s/notes", board.name); mmap_t m; m.oflag = O_RDONLY; if (mmap_open(fname, &m) < 0) return BBS_ENOFILE; xml_header(NULL); printf("<bbsnot brd='%s'>", board.name); xml_fputs2((char *) m.ptr, m.size); mmap_close(&m); print_session(); printf("</bbsnot>"); return 0; }