diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-19 04:30:14 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-04-19 04:30:14 +0800 |
commit | da6a317fcaa76d01a43f80925f8d3137e193984c (patch) | |
tree | 59722cebfe6f33c8d002bc526f36191edfd477f6 /mbbsd | |
parent | a1f92612eb4f8e33612b498314c9c5ebd167a9b5 (diff) | |
download | pttbbs-da6a317fcaa76d01a43f80925f8d3137e193984c.tar pttbbs-da6a317fcaa76d01a43f80925f8d3137e193984c.tar.gz pttbbs-da6a317fcaa76d01a43f80925f8d3137e193984c.tar.bz2 pttbbs-da6a317fcaa76d01a43f80925f8d3137e193984c.tar.lz pttbbs-da6a317fcaa76d01a43f80925f8d3137e193984c.tar.xz pttbbs-da6a317fcaa76d01a43f80925f8d3137e193984c.tar.zst pttbbs-da6a317fcaa76d01a43f80925f8d3137e193984c.zip |
*** PASSWD CHANGE *** PLEASE READ UPDATING FOR DEFAILT INFORMATION.
YOU NEED TO SHUTDOWN BBS TO PREPARE THIS CHANGE.
- split justify to career and phone
- prevent padding in structers that wil be written to disk
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4194 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/admin.c | 51 | ||||
-rw-r--r-- | mbbsd/board.c | 5 | ||||
-rw-r--r-- | mbbsd/register.c | 127 | ||||
-rw-r--r-- | mbbsd/testsz.c | 21 | ||||
-rw-r--r-- | mbbsd/user.c | 68 |
5 files changed, 127 insertions, 145 deletions
diff --git a/mbbsd/admin.c b/mbbsd/admin.c index 0a105e0d..e22ad368 100644 --- a/mbbsd/admin.c +++ b/mbbsd/admin.c @@ -89,6 +89,25 @@ static int retrieve_backup(userec_t *user) return -1; } +void +upgrade_passwd(userec_t *puser) +{ + if (puser->version == PASSWD_VERSION) + return; + if (!puser->userid[0]) + return; + if (puser->version == 2275) // chicken change + { + memset(puser->career, 0, sizeof(puser->career)); + memset(puser->phone, 0, sizeof(puser->phone)); + memset(puser->chkpad0, 0, sizeof(puser->chkpad0)); + memset(puser->chkpad1, 0, sizeof(puser->chkpad1)); + memset(puser->chkpad2, 0, sizeof(puser->chkpad2)); + puser->version = PASSWD_VERSION; + return; + } +} + static int search_key_user(const char *passwdfile, int mode) { @@ -109,32 +128,38 @@ search_key_user(const char *passwdfile, int 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); + vs_hdr("關鍵字搜尋"); + outs("搜尋欄位: [0]全部 1.ID 2.姓名 3.暱稱 4.地址 5.Mail 6.IP 7.職業 8.電話 9.認證\n"); + getdata(2, 0, "要搜尋哪種資料?", key, 2, NUMECHO); + if (isascii(key[0]) && isdigit(key[0])) keytype = key[0] - '0'; - if (keytype < 0 || keytype > 7) + if (keytype < 0 || keytype > 9) keytype = 0; - getdata(0, 0, "請輸入關鍵字: ", key, sizeof(key), DOECHO); + getdata(3, 0, "請輸入關鍵字: ", key, sizeof(key), DOECHO); } if(!key[0]) { fclose(fp1); return 0; } - while ((fread(&user, sizeof(user), 1, fp1)) > 0 && unum++ < MAX_USERS) { + vs_hdr(key); + + while ((fread(&user, sizeof(user), 1, fp1)) > 0 && unum++ <= MAX_USERS) { // skip empty records if (!user.userid[0]) continue; if (!(unum & 0xFF)) { - move(1, 0); + vs_hdr(key); prints("第 [%d] 筆資料\n", unum); refresh(); } + // XXX 這裡會取舊資料,要小心 PWD 的 upgrade + upgrade_passwd(&user); + keymatch = NULL; if (!mode) @@ -157,18 +182,24 @@ search_key_user(const char *passwdfile, int mode) DBCS_strcasestr(user.address, key)) keymatch = user.address; else if ((!keytype || keytype == 5) && - DBCS_strcasestr(user.email, key)) + strcasestr(user.email, key)) // not DBCS. keymatch = user.email; else if ((!keytype || keytype == 6) && - DBCS_strcasestr(user.lasthost, key)) + 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.phone, key)) + keymatch = user.phone; + else if ((!keytype || keytype == 9) && DBCS_strcasestr(user.justify, key)) keymatch = user.justify; } if(keymatch) { - move(1, 0); + vs_hdr(key); prints("第 [%d] 筆資料\n", unum); refresh(); diff --git a/mbbsd/board.c b/mbbsd/board.c index e999dc21..801d29c6 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -382,13 +382,10 @@ b_config(void) (bp->brdattr & BRD_IPLOGRECMD) ? ANSI_COLOR(1)"自動":"不會"); -// enable if we have it. -#ifdef EXP_ALIGNEDCMT prints( " " ANSI_COLOR(1;36) "a" ANSI_RESET " - 推文時 %s" ANSI_RESET " 開頭\n", (bp->brdattr & BRD_ALIGNEDCMT) ? - ANSI_COLOR(1)"對齊":"不對齊"); -#endif + ANSI_COLOR(1)"對齊":"不用對齊"); #ifdef USE_AUTOCPLOG prints( " " ANSI_COLOR(1;36) "x" ANSI_RESET diff --git a/mbbsd/register.c b/mbbsd/register.c index 899e78c8..7c21cd49 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -2,8 +2,6 @@ #include "bbs.h" #define FN_REGISTER_LOG "register.log" // global registration history -#define FN_JUSTIFY "justify" -#define FN_JUSTIFY_WAIT "justify.wait" #define FN_REJECT_NOTIFY "justify.reject" // Regform1 file name (deprecated) @@ -370,21 +368,6 @@ delregcodefile(void) // Justify Utilities //////////////////////////////////////////////////////////////////////////// -static void -justify_wait(char *userid, char *phone, char *career, - char *rname, char *addr, char *mobile) -{ - char buf[PATHLEN]; - sethomefile(buf, userid, FN_JUSTIFY_WAIT); - if (phone[0] != 0) { - FILE* fn = fopen(buf, "w"); - assert(fn); - fprintf(fn, "%s\n%s\ndummy\n%s\n%s\n%s\n", - phone, career, rname, addr, mobile); - fclose(fn); - } -} - static void email_justify(const userec_t *muser) { @@ -785,8 +768,7 @@ check_register(void) } int -create_regform_request( - const char *career, const char *phone) +create_regform_request() { FILE *fn; @@ -798,13 +780,11 @@ create_regform_request( return 0; // create request data - // fprintf(fn, "num: %d, %s", usernum, ctime4(&now)); fprintf(fn, "uid: %s\n", cuser.userid); fprintf(fn, "name: %s\n", cuser.realname); - fprintf(fn, "career: %s\n", career); + fprintf(fn, "career: %s\n", cuser.career); fprintf(fn, "addr: %s\n", cuser.address); - fprintf(fn, "phone: %s\n", phone); - // fprintf(fn, "mobile: %s\n", mobile); + fprintf(fn, "phone: %s\n", cuser.phone); fprintf(fn, "email: %s\n", "x"); // email is apparently 'x' here. fprintf(fn, "----\n"); fclose(fn); @@ -814,15 +794,13 @@ create_regform_request( // save justify information snprintf(cuser.justify, sizeof(cuser.justify), - "%s:%s:<Manual>", phone, career); + "<Manual>"); return 1; } static void -toregister(char *email, char *phone, char *career, char *mobile) +toregister(char *email) { - justify_wait(cuser.userid, phone, career, cuser.realname, cuser.address, mobile); - clear(); vs_hdr("認證設定"); if (cuser.userlevel & PERM_NOREGCODE){ @@ -920,18 +898,17 @@ toregister(char *email, char *phone, char *career, char *mobile) strlcpy(cuser.email, email, sizeof(cuser.email)); REGFORM2: if (strcasecmp(email, "x") == 0) { /* 手動認證 */ - if (!create_regform_request(career, phone)) + if (!create_regform_request()) { vmsg("註冊申請單建立失敗。請至 " BN_BUGREPORT " 報告。"); } } else { - // register by mail of phone - snprintf(cuser.justify, sizeof(cuser.justify), - "%s:%s:<Email>", phone, career); + // register by mail or mobile + snprintf(cuser.justify, sizeof(cuser.justify), "<Email>"); #ifdef HAVEMOBILE if (phone != NULL && email[1] == 0 && tolower(email[0]) == 'm') snprintf(cuser.justify, sizeof(cuser.justify), - "%s:%s:<Mobile>", phone, career); + "<Mobile>"); #endif email_justify(&cuser); } @@ -949,8 +926,6 @@ u_register(void) unsigned char year, mon, day; char inregcode[14], regcode[50]; char ans[3], *errcode; - char genbuf[200]; - FILE *fn; int i = 0; if (cuser.userlevel & PERM_LOGINOK) { @@ -963,7 +938,7 @@ u_register(void) if (i > 0) { - clear(); + vs_hdr("註冊單尚在處理中"); move(3, 0); prints(" 您的註冊申請單尚在處理中(處理順位: %d),請耐心等候\n\n", i); outs(" 如果您已收到註冊碼卻看到這個畫面,那代表您在使用 Email 註冊後\n"); @@ -971,57 +946,29 @@ u_register(void) ANSI_RESET "\n\n"); outs(" 進入人工審核程序後 Email 註冊自動失效,有註冊碼也沒用,\n"); outs(" 要等到審核完成 (會多花很多時間,通常起碼數天) ,所以請耐心等候。\n\n"); - /* 下面是國王的 code 所需要的 message */ -#if 0 - outs(" 另外請注意,若站長審註冊單時您正在站上則會無法審核、自動跳過。\n"); - outs(" 所以等候審核時請勿掛站。若超過兩三天仍未被審到,通常就是這個原因。\n"); -#endif vmsg("您的註冊申請單尚在處理中"); return FULLUPDATE; } strlcpy(rname, cuser.realname, sizeof(rname)); - strlcpy(addr, cuser.address, sizeof(addr)); - strlcpy(email, cuser.email, sizeof(email)); + strlcpy(addr, cuser.address, sizeof(addr)); + strlcpy(email, cuser.email, sizeof(email)); + strlcpy(career,cuser.career, sizeof(career)); + strlcpy(phone, cuser.phone, sizeof(phone)); if (cuser.mobile) snprintf(mobile, sizeof(mobile), "0%09d", cuser.mobile); else mobile[0] = 0; + if (cuser.month == 0 && cuser.day == 0 && cuser.year == 0) birthday[0] = 0; else snprintf(birthday, sizeof(birthday), "%04i/%02i/%02i", 1900 + cuser.year, cuser.month, cuser.day); + sex_is[0] = (cuser.sex % 8) + '1'; sex_is[1] = 0; - career[0] = phone[0] = '\0'; - sethomefile(genbuf, cuser.userid, FN_JUSTIFY_WAIT); - if ((fn = fopen(genbuf, "r"))) { - fgets(genbuf, sizeof(genbuf), fn); - chomp(genbuf); - strlcpy(phone, genbuf, sizeof(phone)); - - fgets(genbuf, sizeof(genbuf), fn); - chomp(genbuf); - strlcpy(career, genbuf, sizeof(career)); - - fgets(genbuf, sizeof(genbuf), fn); // old version compatible - - fgets(genbuf, sizeof(genbuf), fn); - chomp(genbuf); - strlcpy(rname, genbuf, sizeof(rname)); - - fgets(genbuf, sizeof(genbuf), fn); - chomp(genbuf); - strlcpy(addr, genbuf, sizeof(addr)); - - fgets(genbuf, sizeof(genbuf), fn); - chomp(genbuf); - strlcpy(mobile, genbuf, sizeof(mobile)); - - fclose(fn); - } if (cuser.userlevel & PERM_NOREGCODE) { vmsg("您不被允許\使用認證碼認證。請填寫註冊申請單"); @@ -1036,7 +983,6 @@ u_register(void) strcmp(cuser.email, "x") != 0 && /* 上次手動認證失敗 */ strcmp(cuser.email, "X") != 0) { - clear(); vs_hdr("EMail認證"); move(2, 0); @@ -1077,12 +1023,8 @@ u_register(void) cuser.userlevel |= (PERM_LOGINOK | PERM_POST); outs("\n註冊成功\, 重新上站後將取得完整權限\n" "請按下任一鍵跳離後重新上站~ :)"); - sethomefile(genbuf, cuser.userid, FN_JUSTIFY_WAIT); - unlink(genbuf); snprintf(cuser.justify, sizeof(cuser.justify), - "%s:%s:email", phone, career); - sethomefile(genbuf, cuser.userid, FN_JUSTIFY); - log_file(genbuf, LOG_CREAT, cuser.justify); + "<E-Mail>: %s", Cdate(&now)); pressanykey(); u_exit("registed"); exit(0); @@ -1096,11 +1038,11 @@ u_register(void) else { vmsg("認證碼已過期,請重新註冊。"); - toregister(email, phone, career, mobile); + toregister(email); return FULLUPDATE; } } else { - toregister(email, phone, career, mobile); + toregister(email); return FULLUPDATE; } } @@ -1210,26 +1152,27 @@ u_register(void) } // copy values to cuser - strlcpy(cuser.realname, rname, sizeof(cuser.realname)); - strlcpy(cuser.address, addr, sizeof(cuser.address)); - strlcpy(cuser.email, email, sizeof(cuser.email)); + strlcpy(cuser.realname, rname, sizeof(cuser.realname)); + strlcpy(cuser.address, addr, sizeof(cuser.address)); + strlcpy(cuser.email, email, sizeof(cuser.email)); + strlcpy(cuser.career, career, sizeof(cuser.career)); + strlcpy(cuser.phone, phone, sizeof(cuser.phone)); + cuser.mobile = atoi(mobile); cuser.sex = (sex_is[0] - '1') % 8; cuser.month = mon; cuser.day = day; cuser.year = year; + #ifdef FOREIGN_REG if (fore[0]) cuser.uflag2 |= FOREIGN; else cuser.uflag2 &= ~FOREIGN; #endif - trim(career); - trim(addr); - trim(phone); // if reach here, email is apparently 'x'. - toregister(email, phone, career, mobile); + toregister(email); // update cuser passwd_update(usernum, &cuser); @@ -1430,12 +1373,8 @@ regform_accept(const char *userid, const char *justify) strlcpy(muser.email, "x", sizeof(muser.email)); // handle files - sethomefile(buf, muser.userid, FN_JUSTIFY_WAIT); - unlink(buf); sethomefile(buf, muser.userid, FN_REJECT_NOTIFY); unlink(buf); - sethomefile(buf, muser.userid, FN_JUSTIFY); - log_filef(buf, LOG_CREAT, "%s\n", muser.justify); // update password file passwd_update(unum, &muser); @@ -1475,8 +1414,6 @@ regform_reject(const char *userid, const char *reason, const RegformEntry *pre) muser.userlevel &= ~(PERM_LOGINOK | PERM_POST); // handle files - sethomefile(buf, muser.userid, FN_JUSTIFY_WAIT); - unlink(buf); // update password file passwd_update(unum, &muser); @@ -1699,17 +1636,15 @@ regfrm_accept(RegformEntry *pre, int priority) sethomefile(fn, pre->userid, FN_REGFORM); // build justify string - removespace(pre->phone); - removespace(pre->career); snprintf(justify, sizeof(justify), - "%s:%s:%s", pre->phone, pre->career, cuser.userid); + "[%s] %s", cuser.userid, Cdate(&now)); // call handler regform_accept(pre->userid, justify); // append current form to history. sethomefile(fnlog, pre->userid, FN_REGFORM_LOG); - snprintf(buf, sizeof(buf), "Date: %s", Cdate(&now)); + snprintf(buf, sizeof(buf), "Date: %s\n", Cdate(&now)); file_append_line(fnlog, buf); AppendTail(fn, fnlog, 0); // global history @@ -2311,10 +2246,10 @@ regform2_validate_page(int dryrun) for (i = 0; i < cforms; i++) { - char justify[REGLEN]; + char justify[REGLEN+1]; if (ans[i] == 'y') snprintf(justify, sizeof(justify), // build justify string - "%s:%s:%s", forms[i].phone, forms[i].career, cuser.userid); + "%s %s", cuser.userid, Cdate(&now)); prints("%2d. %-12s - %c %s\n", i+1, forms[i].userid, ans[i], ans[i] == 'n' ? rejects[i] : diff --git a/mbbsd/testsz.c b/mbbsd/testsz.c new file mode 100644 index 00000000..99d4ad22 --- /dev/null +++ b/mbbsd/testsz.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <sys/types.h> +#include "bbs.h" + +int main() +{ + printf("sizeof(size_t) = %lu\n", sizeof(size_t)); + printf("sizeof(off_t) = %lu\n", sizeof(off_t)); + printf("sizeof(int) = %lu\n", sizeof(int)); + printf("sizeof(long) = %lu\n", sizeof(long)); + printf("sizeof(time_t) = %lu\n", sizeof(time_t)); + printf("sizeof(time4_t) = %lu %s\n", sizeof(time4_t), sizeof(time4_t) == 4 ? "" : "ERROR!!!!!"); + printf("sizeof(userec_t) = %lu\n", sizeof(userec_t)); + printf("sizeof(fileheader_t) = %lu\n", sizeof(fileheader_t)); + printf("sizeof(boardheader_t) = %lu\n", sizeof(boardheader_t)); + printf("sizeof(chicken_t) = %lu\n", sizeof(chicken_t)); + printf("sizeof(userinfo_t) = %lu\n", sizeof(userinfo_t)); + printf("sizeof(msgque_t) = %lu\n", sizeof(msgque_t)); + printf("sizeof(SHM_t) = %lu\n", sizeof(SHM_t)); + return 0; +} diff --git a/mbbsd/user.c b/mbbsd/user.c index 44985776..18f5576d 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -124,60 +124,58 @@ user_display(const userec_t * u, int adminmode) " " ANSI_COLOR(30;41) "┴┬┴┬┴┬" ANSI_RESET " " ANSI_COLOR(1;30;45) " 使 用 者" " 資 料 " " " ANSI_RESET " " ANSI_COLOR(30;41) "┴┬┴┬┴┬" ANSI_RESET "\n"); - prints(" 代號暱稱: %s(%s)\n" - " 真實姓名: %s" -#if FOREIGN_REG_DAY > 0 - " %s%s" -#elif defined(FOREIGN_REG) - " %s" -#endif - "\n" - " 居住住址: %s\n" - " 電子信箱: %s\n" - " 性 別: %s\n" - " 銀行帳戶: %d 銀兩\n", - u->userid, u->nickname, u->realname, + prints("\t\t代號暱稱: %s(%s)\n", u->userid, u->nickname); + prints("\t\t真實姓名: %s", u->realname); #if FOREIGN_REG_DAY > 0 + prints(" %s%s", u->uflag2 & FOREIGN ? "(外籍: " : "", u->uflag2 & FOREIGN ? (u->uflag2 & LIVERIGHT) ? "永久居留)" : "未取得居留權)" - : "", + : ""); #elif defined(FOREIGN_REG) - u->uflag2 & FOREIGN ? "(外籍)" : "", + prints(" %s" u->uflag2 & FOREIGN ? "(外籍)" : ""); #endif - u->address, u->email, - sex[u->sex % 8], u->money); - - sethomedir(genbuf, u->userid); - prints(" 私人信箱: %d 封 (購買信箱: %d 封)\n" - " 手機號碼: %010d\n" - " 生 日: %04i/%02i/%02i (%s滿18歲)\n", - get_num_records(genbuf, sizeof(fileheader_t)), - u->exmailbox, u->mobile, + outs("\n"); // end of realname + prints("\t\t職業學歷: %s\n", u->career); + prints("\t\t居住地址: %s\n", u->address); + prints("\t\t電話手機: %s", u->phone); + if (u->mobile) + prints(" / %010d", u->mobile); + outs("\n"); + + prints("\t\t電子信箱: %s\n", u->email); + prints("\t\t銀行帳戶: %d 銀兩\n", u->money); + prints("\t\t性 別: %s\n", sex[u->sex%8]); + prints("\t\t生 日: %04i/%02i/%02i (%s滿18歲)\n", u->year + 1900, u->month, u->day, - resolve_over18_user(u) ? "已" : "未" - ); + resolve_over18_user(u) ? "已" : "未"); - prints(" 註冊日期: (已滿%d天) %s", + prints("\t\t註冊日期: (已滿%d天) %s", (int)((now - u->firstlogin)/86400), ctime4(&u->firstlogin)); - prints(" 上次上站: %s (%s)\n", u->lasthost, Cdate(&u->lastlogin)); + prints("\t\t上次上站: %s (%s)\n", + u->lasthost, Cdate(&u->lastlogin)); if (adminmode) { strcpy(genbuf, "bTCPRp#@XWBA#VSM0123456789ABCDEF"); for (diff = 0; diff < 32; diff++) if (!(u->userlevel & (1 << diff))) genbuf[diff] = '-'; - prints(" 帳號權限: %s\n", genbuf); - prints(" 認證資料: %s\n", u->justify); + prints("\t\t帳號權限: %s\n", genbuf); + prints("\t\t認證資料: %s\n", u->justify); } - prints(" 上站文章: %d 次 / %d 篇\n", + prints("\t\t上站文章: %d 次 / %d 篇\n", u->numlogins, u->numposts); + sethomedir(genbuf, u->userid); + prints("\t\t私人信箱: %d 封 (購買信箱: %d 封)\n", + get_num_records(genbuf, sizeof(fileheader_t)), + u->exmailbox); + if (!adminmode) { diff = (now - login_start_time) / 60; - prints(" 停留期間: %d 小時 %2d 分\n", + prints("\t\t停留期間: %d 小時 %2d 分\n", diff / 60, diff % 60); } @@ -186,7 +184,7 @@ user_display(const userec_t * u, int adminmode) int i; boardheader_t *bhdr; - outs(" 擔任板主: "); + outs("\t\t擔任板主: "); for (i = 0, bhdr = bcache; i < numboards; i++, bhdr++) { if (is_uBM(bhdr->BM, u->userid)) { @@ -199,7 +197,7 @@ user_display(const userec_t * u, int adminmode) // conditional fields #ifdef ASSESS - prints(" 優 劣 文: 優:%d / 劣:%d\n", + prints("\t\t優 劣 文: 優:%d / 劣:%d\n", u->goodpost, u->badpost); #endif // ASSESS @@ -223,7 +221,7 @@ user_display(const userec_t * u, int adminmode) #ifdef PLAY_ANGEL if (adminmode) - prints(" 小 天 使: %s\n", + prints("\t\t小 天 使: %s\n", u->myangel[0] ? u->myangel : "無"); #endif |