int web_sel(void) { xml_header("bbssel"); printf("<bbssel>"); print_session(); const char *brd = web_get_param("brd"); if (*brd != '\0') { char name[BOARD_NAME_LEN + 3]; snprintf(name, sizeof(name), "%%%s%%", brd); db_res_t *res = db_query(BOARD_SELECT_QUERY_BASE "WHERE lower(b.name) LIKE %s", name); if (res && db_res_rows(res) > 0) { board_t board; for (int i = 0; i < db_res_rows(res); ++i) { res_to_board(res, i, &board); if (has_read_perm(&board)) { board_to_gbk(&board); printf("<brd dir='%d' title='%s' desc='%s' />", is_board_dir(&board), board.name, board.descr); } } } else { printf("<notfound/>"); } db_clear(res); } printf("</bbssel>"); return 0; }
int bbssel_main(void) { xml_header("bbssel"); printf("<bbssel "); print_session(); printf(">"); char *brd = getparm("brd"); if (*brd != '\0') { struct boardheader *bp; int found = 0; for (int i = 0; i < MAXBOARD; i++) { bp = bcache + i; if (!hasreadperm(¤tuser, bp)) continue; if (strcasestr(bp->filename, brd) || strcasestr(bp->title, brd)) { printf("<brd dir='%d' title='%s' desc='%s' />", is_board_dir(bp), bp->filename, get_board_desc(bp)); found++; } } if (!found) printf("<notfound />"); } printf("</bbssel>"); return 0; }
int bbsmybrd_main(void) { if (!loginok) return BBS_ELGNREQ; int type = strtol(getparm("type"), NULL, 10); if (type != 0) return read_submit(); // Read '.goodbrd'. char file[HOMELEN]; sethomefile(file, currentuser.userid, ".goodbrd"); mmap_t m; m.oflag = O_RDONLY; if (mmap_open(file, &m) < 0) return BBS_ENOFILE; struct goodbrdheader *iter, *end; int num = m.size / sizeof(struct goodbrdheader); if (num > GOOD_BRC_NUM) num = GOOD_BRC_NUM; end = (struct goodbrdheader *)m.ptr + num; // Print 'bid's of favorite boards. xml_header("bbs"); printf("<bbsmybrd "); print_session(); printf(" limit='%d'>", GOOD_BRC_NUM); for (iter = m.ptr; iter != end; iter++) { if (!gbrd_is_custom_dir(iter)) printf("<my bid='%d'/>", iter->pos + 1); } mmap_close(&m); // Print all boards available. struct boardheader *b; for (int i = 0; i < MAXBOARD; i++) { b = bcache + i; if (b->filename[0] <= 0x20 || b->filename[0] > 'z') continue; if (!hasreadperm(¤tuser, b)) continue; printf("<mbrd bid='%d' desc='%s' %s/>", i + 1, b->title + 11, is_board_dir(b) ? "dir='1'" : ""); } printf("</bbsmybrd>"); return 0; }