summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-08-30 15:33:13 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-08-30 15:33:13 +0800
commit7b2cc2e83030882b319bbf87932c7727c174adc7 (patch)
tree311a608a57199d330df05f9f23d6345971fde564
parent2962ffe9d364a629996465a1cf08770791823db3 (diff)
downloadpttbbs-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.h14
-rw-r--r--include/pttstruct.h5
-rw-r--r--mbbsd/bbs.c8
-rw-r--r--mbbsd/mbbsd.c1
-rw-r--r--mbbsd/passwd.c66
-rw-r--r--mbbsd/register.c136
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("我們即將寄出認證信 (您應該會在 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("輸入生日");
- move(2,0);
- outs("本站為配合實行內容分級制度,請您輸入正確的生日資訊。");
-
- getdata(5, 0, "生日 (西元年/月/日, 如 " DATE_SAMPLE "):", birthday,
- sizeof(birthday), DOECHO);
-
- if (strcmp(birthday, DATE_SAMPLE) == 0) {
- vmsg("不要複製範例! 請輸入你真實生日");
- continue;
- }
- if (ParseDate(birthday, &y, &m, &d)) {
- vmsg("日期格式不正確");
- 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)
"* 輸入後發生認證碼錯誤請重填一次 E-Mail *\n"
"**********************************************************\n");
-#ifdef HAVEMOBILE
- outs(" 3.若您有手機門號且想採取手機簡訊認證的方式 , 請輸入 m \n"
- " 我們將會寄發含有認證碼的簡訊給您 \n"
- " 收到後請到(U)ser => (R)egister 輸入認證碼, 即可通過認證\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, "請再次確認您輸入的手機號碼正確嘛? [y/N]",
- yn, sizeof(yn), LCECHO);
- if (yn[0] == 'y')
- break;
- } else {
- move(15, 0); clrtobot();
- move(17, 0);
- outs("指定的手機號碼不正確,"
- "若您無手機門號請選擇其他方式認證");
- 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("註冊申請單建立失敗。請至 " BN_BUGREPORT " 報告。");
- }
} 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("您的身份確認已經完成,不需填寫申請表");
@@ -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("系統錯誤,查無此人!");
@@ -1400,15 +1310,16 @@ u_register(void)
if(cuser.uflag2 & FOREIGN)
mail_muser(cuser, "[出入境管理局]", "etc/foreign_welcome");
#endif
- cuser.userlevel |= (PERM_LOGINOK | PERM_POST);
+ snprintf(justify, sizeof(justify), "<E-Mail>: %s", Cdate(&now));
+ pwcuRegCompleteJustify(justify);
outs("\n註冊成功\, 重新上站後將取得完整權限\n"
"請按下任一鍵跳離後重新上站~ :)");
- 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;
}