diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-30 15:33:13 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-08-30 15:33:13 +0800 |
commit | 7b2cc2e83030882b319bbf87932c7727c174adc7 (patch) | |
tree | 311a608a57199d330df05f9f23d6345971fde564 | |
parent | 2962ffe9d364a629996465a1cf08770791823db3 (diff) | |
download | pttbbs-7b2cc2e83030882b319bbf87932c7727c174adc7.tar pttbbs-7b2cc2e83030882b319bbf87932c7727c174adc7.tar.gz pttbbs-7b2cc2e83030882b319bbf87932c7727c174adc7.tar.bz2 pttbbs-7b2cc2e83030882b319bbf87932c7727c174adc7.tar.lz pttbbs-7b2cc2e83030882b319bbf87932c7727c174adc7.tar.xz pttbbs-7b2cc2e83030882b319bbf87932c7727c174adc7.tar.zst pttbbs-7b2cc2e83030882b319bbf87932c7727c174adc7.zip |
* (pwcu branch) const cuser code complete
git-svn-id: http://opensvn.csie.org/pttbbs/branches/pttbbs.pwcu@4795 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | include/proto.h | 14 | ||||
-rw-r--r-- | include/pttstruct.h | 5 | ||||
-rw-r--r-- | mbbsd/bbs.c | 8 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 1 | ||||
-rw-r--r-- | mbbsd/passwd.c | 66 | ||||
-rw-r--r-- | mbbsd/register.c | 136 |
6 files changed, 98 insertions, 132 deletions
diff --git a/include/proto.h b/include/proto.h index b01e8712..e0f784c0 100644 --- a/include/proto.h +++ b/include/proto.h @@ -458,7 +458,6 @@ int setupnewuser(const userec_t *user); int regform_estimate_queuesize(); void new_register(void); void check_register(void); -void check_birthday(void); int check_regmail(char *email); // check and prompt for invalid reason; will str_lower() mail domain. void delregcodefile(void); @@ -710,6 +709,19 @@ int pwcuSetNickname (const char *nickname); int pwcuChessResult (int sigType, ChessGameResult); int pwcuSetChessEloRating(uint16_t elo_rating); int pwcuSaveUserFlags (); +int pwcuRegCompleteJustify (const char *justify); +int pwcuRegSetTemporaryJustify(const char *justify, const char *email); +int pwcuRegisterSetInfo (const char *rname, + const char *addr, + const char *career, + const char *phone, + const char *email, + int mobile, + uint8_t sex, + uint8_t year, + uint8_t month, + uint8_t day, + uint8_t is_foreign); // non-important based variables (only save on exit) int pwcuSetSignature (unsigned char newsig); diff --git a/include/pttstruct.h b/include/pttstruct.h index cd0c98df..a79e2bb6 100644 --- a/include/pttstruct.h +++ b/include/pttstruct.h @@ -140,11 +140,12 @@ typedef struct userec_t { } PACKSTRUCT userec_t; #ifdef CONST_CUSER -# define cuser ((const userec_t ) pwcuser) +// const userec_t cuser; # define cuser_ref ((const userec_t*)&pwcuser) +# define cuser (*cuser_ref) #else -# define cuser pwcuser # define cuser_ref (&cuser) +# define cuser pwcuser #endif /* flags in userec_t.withme */ diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index aeffdc27..d19c8d91 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -3878,11 +3878,3 @@ Select(void) return do_select(); } -#ifdef HAVEMOBILE -void -mobile_message(const char *mobile, char *message) -{ - // this is for validation. - bsmtp(fpath, title, rcpt, "non-exist"); -} -#endif diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index c77b508e..30117471 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1238,7 +1238,6 @@ user_login(void) } check_bad_login(); check_mailbox_quota(); - check_birthday(); check_register(); pwcuLoginSave(); restore_backup(); diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index e8ed21e2..161239bd 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -241,6 +241,72 @@ pwcuSetLoginView(unsigned int bits) PWCU_END(); } +int +pwcuRegCompleteJustify(const char *justify) +{ + PWCU_START(); + strlcpy( u.justify, justify, sizeof(u.justify)); + strlcpy(cuser.justify, justify, sizeof(cuser.justify)); + _ENABLE_BIT( u.userlevel, (PERM_POST | PERM_LOGINOK)); + _ENABLE_BIT(cuser.userlevel, (PERM_POST | PERM_LOGINOK)); + PWCU_END(); +} + +int +pwcuRegSetTemporaryJustify(const char *justify, const char *email) +{ + PWCU_START(); + strlcpy( u.email, email, sizeof(u.email)); + strlcpy(cuser.email, email, sizeof(cuser.email)); + strlcpy( u.justify, justify, sizeof(u.justify)); + strlcpy(cuser.justify, justify, sizeof(cuser.justify)); + _DISABLE_BIT( u.userlevel, (PERM_POST | PERM_LOGINOK)); + _DISABLE_BIT(cuser.userlevel, (PERM_POST | PERM_LOGINOK)); + PWCU_END(); +} + +int pwcuRegisterSetInfo (const char *rname, + const char *addr, + const char *career, + const char *phone, + const char *email, + int mobile, + uint8_t sex, + uint8_t year, + uint8_t month, + uint8_t day, + uint8_t is_foreign) +{ + PWCU_START(); + strlcpy(u.realname, rname, sizeof(u.realname)); + strlcpy(u.address, addr, sizeof(u.address)); + strlcpy(u.career, career, sizeof(u.career)); + strlcpy(u.phone, phone, sizeof(u.phone)); + strlcpy(u.email, email, sizeof(u.email)); + u.mobile = mobile; + u.sex = sex; + u.year = year; + u.month = month; + u.day = day; + _SETBY_BIT(u.uflag2, FOREIGN, is_foreign); + + // duplicate to cuser + + strlcpy(cuser.realname, rname, sizeof(cuser.realname)); + strlcpy(cuser.address, addr, sizeof(cuser.address)); + strlcpy(cuser.career, career, sizeof(cuser.career)); + strlcpy(cuser.phone, phone, sizeof(cuser.phone)); + strlcpy(cuser.email, email, sizeof(cuser.email)); + cuser.mobile = mobile; + cuser.sex = sex; + cuser.year = year; + cuser.month = month; + cuser.day = day; + _SETBY_BIT(cuser.uflag2, FOREIGN, is_foreign); + + PWCU_END(); +} + #include "chess.h" int pwcuChessResult(int sigType, ChessGameResult r) diff --git a/mbbsd/register.c b/mbbsd/register.c index 224f480a..ac490c76 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -515,12 +515,7 @@ email_justify(const userec_t *muser) snprintf(buf, sizeof(buf), " " BBSENAME " - [ %s ]", makeregcode(genbuf)); -#ifdef HAVEMOBILE - if (strcmp(muser->email, "m") == 0 || strcmp(muser->email, "M") == 0) - mobile_message(mobile, buf); - else -#endif - bsmtp("etc/registermail", buf, muser->email, "non-exist"); + bsmtp("etc/registermail", buf, muser->email, "non-exist"); move(20,0); clrtobot(); outs("�ڭ̧Y�N�H�X�{�ҫH (�z���ӷ|�b 10 ����������)\n" @@ -959,56 +954,6 @@ check_regmail(char *email) return allow; } -void -check_birthday(void) -{ - // check birthday - int changed = 0; - time_t t = (time_t)now; - struct tm tm; - - localtime_r(&t, &tm); - while ( cuser.year < 40 || // magic number 40: see user.c - cuser.year+3 > tm.tm_year) - { - char birthday[sizeof("mmmm/yy/dd ")]; - int y, m, d; - - clear(); - vs_hdr("��J�ͤ�"); - move(2,0); - outs("�������t�X��椺�e���Ũ�סA�бz��J���T���ͤ��T�C"); - - getdata(5, 0, "�ͤ� (�褸�~/��/��, �p " DATE_SAMPLE ")�G", birthday, - sizeof(birthday), DOECHO); - - if (strcmp(birthday, DATE_SAMPLE) == 0) { - vmsg("���n�ƻs�d�ҡI �п�J�A�u��ͤ�"); - continue; - } - if (ParseDate(birthday, &y, &m, &d)) { - vmsg("����榡�����T"); - continue; - } else if (y < 1930) { - vmsg(MSG_ERR_TOO_OLD); - continue; - } else if (y+3 > tm.tm_year+1900) { - vmsg(MSG_ERR_TOO_YOUNG); - continue; - } - - cuser.year = (unsigned char)(y-1900); - cuser.month = (unsigned char)m; - cuser.day = (unsigned char)d; - changed = 1; - } - - if (changed) { - clear(); - resolve_over18(); - } -} - ///////////////////////////////////////////////////////////////////////////// // User Registration (Phase 2: Validation) ///////////////////////////////////////////////////////////////////////////// @@ -1153,8 +1098,7 @@ create_regform_request() file_append_record(FN_REQLIST, cuser.userid); // save justify information - snprintf(cuser.justify, sizeof(cuser.justify), - "<Manual>"); + pwcuRegSetTemporaryJustify("<Manual>", "x"); return 1; } @@ -1183,12 +1127,6 @@ toregister(char *email) "* ��J��o�ͻ{�ҽX���~�Э���@�� E-Mail *\n" "**********************************************************\n"); -#ifdef HAVEMOBILE - outs(" 3.�Y�z����������B�Q�Ĩ����²�T�{�Ҫ��覡 , �п�J m \n" - " �ڭ̱N�|�H�o�t���{�ҽX��²�T���z \n" - " �����Ш�(U)ser => (R)egister ��J�{�ҽX, �Y�i�q�L�{��\n"); -#endif - while (1) { email[0] = 0; getfield(15, "�����{�ҥ�", REGNOTES_ROOT "email", "E-Mail Address", email, 50); @@ -1196,24 +1134,6 @@ toregister(char *email) if (strcmp(email, "X") == 0) email[0] = 'x'; if (strcmp(email, "x") == 0) break; -#ifdef HAVEMOBILE - else if (strcmp(email, "m") == 0 || strcmp(email, "M") == 0) { - if (isvalidmobile(mobile)) { - char yn[3]; - getdata(16, 0, "�ЦA���T�{�z��J��������X���T��? [y/N]", - yn, sizeof(yn), LCECHO); - if (yn[0] == 'y') - break; - } else { - move(15, 0); clrtobot(); - move(17, 0); - outs("���w��������X�����T," - "�Y�z�L��������п�ܨ�L�覡�{��"); - pressanykey(); - } - - } -#endif else if (check_regmail(email)) { char yn[3]; #ifdef USE_EMAILDB @@ -1273,26 +1193,17 @@ toregister(char *email) return; } #endif - strlcpy(cuser.email, email, sizeof(cuser.email)); REGFORM2: if (strcasecmp(email, "x") == 0) { /* ��ʻ{�� */ if (!create_regform_request()) - { vmsg("���U�ӽг�إߥ��ѡC�Ц� " BN_BUGREPORT " ���i�C"); - } } else { // 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), - "<Mobile>"); -#endif - email_justify(cuser_ref); + pwcuRegSetTemporaryJustify("<Email>", email); + email_justify(cuser_ref); } } - int u_register(void) { @@ -1302,9 +1213,7 @@ u_register(void) char inregcode[14], regcode[50]; char ans[3], *errcode; int i = 0; -#ifdef FOREIGN_REG int isForeign = (cuser.uflag2 & FOREIGN) ? 1 : 0; -#endif if (cuser.userlevel & PERM_LOGINOK) { outs("�z�������T�{�w�g�����A���ݶ�g�ӽЪ�"); @@ -1388,7 +1297,8 @@ u_register(void) // make it case insensitive. if (strcasecmp(inregcode, getregcode(regcode)) == 0) { - int unum; + int unum; + char justify[sizeof(cuser.justify)] = ""; delregcodefile(); if ((unum = searchuser(cuser.userid, NULL)) == 0) { vmsg("�t�ο��~�A�d�L���H�I"); @@ -1400,15 +1310,16 @@ u_register(void) if(cuser.uflag2 & FOREIGN) mail_muser(cuser, "[�X�J�Һz��]", "etc/foreign_welcome"); #endif - cuser.userlevel |= (PERM_LOGINOK | PERM_POST); + snprintf(justify, sizeof(justify), "<E-Mail>: %s", Cdate(&now)); + pwcuRegCompleteJustify(justify); outs("\n���U���\\, ���s�W����N���o�����v��\n" "�Ы��U���@������᭫�s�W��~ :)"); - snprintf(cuser.justify, sizeof(cuser.justify), - "<E-Mail>: %s", Cdate(&now)); pressanykey(); u_exit("registed"); exit(0); + // XXX shall never reach here. return QUIT; + } else if (strcasecmp(inregcode, "x") != 0) { if (regcode[0]) { @@ -1557,33 +1468,18 @@ u_register(void) if (ans[0] == 'y') break; } +#ifndef FOREIGN_REG + isForeign = 0; +#endif // 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.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 (isForeign) - cuser.uflag2 |= FOREIGN; - else - cuser.uflag2 &= ~FOREIGN; -#endif + pwcuRegisterSetInfo(rname, addr, career, phone, email, + atoi(mobile), (sex_is[0] - '1') % 8, + year, mon, day, isForeign); // if reach here, email is apparently 'x'. toregister(email); - // update cuser - passwd_sync_update(usernum, cuser_ref); - return FULLUPDATE; } |