diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-02-14 00:39:32 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-02-14 00:39:32 +0800 |
commit | 3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb (patch) | |
tree | f34bdadd7afc68cbb7c6645dc732c89e18df895d /mbbsd | |
parent | 5514fc1b12811a5dd903699cac2e6575dd855155 (diff) | |
download | pttbbs-3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb.tar pttbbs-3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb.tar.gz pttbbs-3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb.tar.bz2 pttbbs-3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb.tar.lz pttbbs-3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb.tar.xz pttbbs-3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb.tar.zst pttbbs-3e2ae6ca365f880a3a35bd9e69c6607fb69c15fb.zip |
- improved user searching
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3914 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/admin.c | 72 |
1 files changed, 51 insertions, 21 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 1e5b515c..a49bed21 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -97,12 +97,25 @@ search_key_user(const char *passwdfile, int mode) int coun = 0; FILE *fp1 = fopen(passwdfile, "r"); char friendfile[128]="", key[22], *keymatch; - + int keytype = 0; assert(fp1); clear(); - getdata(0, 0, mode ? "請輸入使用者關鍵字[電話|地址|姓名|上站地點|" - "email|小雞id] :" : "請輸入id :", key, sizeof(key), DOECHO); + if (!mode) + { + getdata(0, 0, "請輸入id :", key, sizeof(key), DOECHO); + } else { + // improved search + getdata(0, 0, "搜尋哪種欄位?" + "([0]全部 1.ID 2.姓名 3.暱稱 4.地址 5.email 6.IP 7.認證/電話) ", + key, 2, DOECHO); + if (isascii(key[0]) && isdigit(key[0])) + keytype = key[0] - '0'; + if (keytype < 0 || keytype > 7) + keytype = 0; + getdata(0, 0, "請輸入關鍵字: ", key, sizeof(key), DOECHO); + } + if(!key[0]) { fclose(fp1); return 0; @@ -113,30 +126,47 @@ search_key_user(const char *passwdfile, int mode) if (!user.userid[0]) continue; - if (!(++coun & 15)) { + if (!(++coun & 0xFF)) { move(1, 0); prints("第 [%d] 筆資料\n", coun); refresh(); } + keymatch = NULL; - if (!strcasecmp(user.userid, key)) - keymatch = user.userid; - else if(mode) { - if(strstr(user.realname, key)) - keymatch = user.realname; - else if(strstr(user.nickname, key)) - keymatch = user.nickname; - else if(strstr(user.lasthost, key)) - keymatch = user.lasthost; - else if(strcasestr(user.email, key)) - keymatch = user.email; - else if(strstr(user.address, key)) - keymatch = user.address; - else if(strstr(user.justify, key)) - keymatch = user.justify; - else if(strstr(user.mychicken.name, key)) - keymatch = user.mychicken.name; + + if (!mode) + { + // only verify id + if (!strcasecmp(user.userid, key)) + keymatch = user.userid; + } else { + // search by keytype + if ((!keytype || keytype == 1) && + strcasestr(user.userid, key)) + keymatch = user.userid; + else if ((!keytype || keytype == 2) && + strcasestr(user.realname, key)) + keymatch = user.realname; + else if ((!keytype || keytype == 3) && + strcasestr(user.nickname, key)) + keymatch = user.nickname; + else if ((!keytype || keytype == 4) && + strcasestr(user.address, key)) + keymatch = user.address; + else if ((!keytype || keytype == 5) && + strcasestr(user.email, key)) + keymatch = user.email; + else if ((!keytype || keytype == 6) && + strcasestr(user.lasthost, key)) + keymatch = user.lasthost; + else if ((!keytype || keytype == 7) && + strcasestr(user.justify, key)) + keymatch = user.justify; + else if ((!keytype) && + strcasestr(user.mychicken.name, key)) + keymatch = user.mychicken.name; } + if(keymatch) { move(1, 0); prints("第 [%d] 筆資料\n", coun); |