/* 使用者管理 */ int m_user(void) { userec_t xuser; int id; char genbuf[200]; vs_hdr("使用者設定"); usercomplete(msg_uid, genbuf); if (*genbuf) { move(2, 0); if ((id = getuser(genbuf, &xuser))) { user_display(&xuser, 1); if( HasUserPerm(PERM_ACCOUNTS) ) uinfo_query(xuser.userid, 1, id); else pressanykey(); } else { outs(err_uid); clrtoeol(); pressanykey(); } } return 0; }
BLAPI_PROTO bl_title(lua_State* L) { int n = lua_gettop(L); const char *s = NULL; if (n > 0) s = lua_tostring(L, 1); if (s == NULL) return 0; vs_hdr(s); return 0; }
void card_end_game() { clear(); vs_hdr("遊樂場"); if (card_get_money()) { int m = card_get_money(); prints("\n 遊戲結束,您此次的戰果為 %d - %d = " ANSI_COLOR(1;3%d) "%d" ANSI_RESET " 枚籌碼。\n\n", m, CARD_MONEY_DEFAULT, m >= CARD_MONEY_DEFAULT ? 3 : 1, m - CARD_MONEY_DEFAULT); } else {
static int search_key_user(const char *passwdfile, int mode) { userec_t user; int ch; int unum = 0; FILE *fp1 = fopen(passwdfile, "r"); char friendfile[PATHLEN]="", key[22], *keymatch; int keytype = 0; int isCurrentPwd; assert(fp1); isCurrentPwd = (strcmp(passwdfile, FN_PASSWD) == 0); clear(); if (!mode) { getdata(0, 0, "請輸入id :", key, sizeof(key), DOECHO); } else { // improved search vs_hdr("關鍵字搜尋"); outs("搜尋欄位: [0]全部 1.ID 2.姓名 3.暱稱 4.地址 5.Mail 6.IP 7.職業 8.認證\n"); getdata(2, 0, "要搜尋哪種資料?", key, 2, NUMECHO); if (isascii(key[0]) && isdigit(key[0])) keytype = key[0] - '0'; if (keytype < 0 || keytype > 8) keytype = 0; getdata(3, 0, "請輸入關鍵字: ", key, sizeof(key), DOECHO); } if(!key[0]) { fclose(fp1); return 0; } vs_hdr(key); // <= or < ? I'm not sure... while ((fread(&user, sizeof(user), 1, fp1)) > 0 && unum++ < MAX_USERS) { // skip empty records if (!user.userid[0]) continue; if (!(unum & 0xFF)) { vs_hdr(key); prints("第 [%d] 筆資料\n", unum); refresh(); } // XXX 這裡會取舊資料,要小心 PWD 的 upgrade if (!upgrade_passwd(&user)) continue; keymatch = NULL; if (!mode) { // only verify id if (!strcasecmp(user.userid, key)) keymatch = user.userid; } else { // search by keytype if ((!keytype || keytype == 1) && DBCS_strcasestr(user.userid, key)) keymatch = user.userid; else if ((!keytype || keytype == 2) && DBCS_strcasestr(user.realname, key)) keymatch = user.realname; else if ((!keytype || keytype == 3) && DBCS_strcasestr(user.nickname, key)) keymatch = user.nickname; else if ((!keytype || keytype == 4) && DBCS_strcasestr(user.address, key)) keymatch = user.address; else if ((!keytype || keytype == 5) && strcasestr(user.email, key)) // not DBCS. keymatch = user.email; else if ((!keytype || keytype == 6) && strcasestr(user.lasthost, key)) // not DBCS. keymatch = user.lasthost; else if ((!keytype || keytype == 7) && DBCS_strcasestr(user.career, key)) keymatch = user.career; else if ((!keytype || keytype == 8) && DBCS_strcasestr(user.justify, key)) keymatch = user.justify; } if(keymatch) { vs_hdr(key); prints("第 [%d] 筆資料\n", unum); refresh(); user_display(&user, 1); // user_display does not have linefeed in tail. if (isCurrentPwd && HasUserPerm(PERM_ACCOUNTS)) uinfo_query(user.userid, 1, unum); else outs("\n"); // XXX don't trust 'user' variable after here // because uinfo_query may have changed it. outs(ANSI_COLOR(44) " 空白鍵" \ ANSI_COLOR(37) ":搜尋下一個 " \ ANSI_COLOR(33)" Q" ANSI_COLOR(37)": 離開"); outs(mode ? " A: add to namelist " ANSI_RESET " " : " S: 取用備份資料 " ANSI_RESET " "); while (1) { while ((ch = vkey()) == 0) ; if (ch == 'a' || ch=='A' ) { if(!friendfile[0]) { friend_special(); setfriendfile(friendfile, FRIEND_SPECIAL); } friend_add(user.userid, FRIEND_SPECIAL, keymatch); break; } if (ch == ' ') break; if (ch == 'q' || ch == 'Q') { fclose(fp1); return 0; } if (ch == 's' && !mode) { if (retrieve_backup(&user) >= 0) { fclose(fp1); vmsg("已成功\取用備份資料。"); return 0; } else { vmsg("錯誤: 取用備份資料失敗。"); } } } }