From 4ef59339ce51c6378e04a7b716241bdbdd2b4e6a Mon Sep 17 00:00:00 2001 From: wens Date: Wed, 2 Jan 2008 15:16:23 +0000 Subject: use emaildb interface in user register git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3774 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/proto.h | 6 ++++++ mbbsd/Makefile | 7 ++++--- mbbsd/user.c | 31 ++++++++++++++++++++++++++++++- sample/pttbbs.conf | 3 +++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/include/proto.h b/include/proto.h index 2332e7b4..c39c94c9 100644 --- a/include/proto.h +++ b/include/proto.h @@ -231,6 +231,12 @@ char *ask_tmpbuf(int y); void edit_outs(const char *text); void edit_outs_n(const char *text, int n); +/* emaildb */ +#ifdef USE_EMAILDB +int emaildb_check_email(char * email, int email_len); +int emaildb_update_email(char * userid, int userid_len, char * email, int email_len); +#endif + /* fav */ void fav_set_old_folder(fav_t *fp); int get_data_number(fav_t *fp); diff --git a/mbbsd/Makefile b/mbbsd/Makefile index 1917f87b..9eb6bbc2 100644 --- a/mbbsd/Makefile +++ b/mbbsd/Makefile @@ -10,9 +10,10 @@ CFLAGS+= -DBLOG LDFLAGS+= -L/usr/local/lib/mysql -lmysqlclient .endif -.if !defined(WITHOUT_EMAIL_DB) && defined(WITH_EMAIL_DB) -CFLAGS+= -DUSE_EMAIL_DB -LDFLAGS+= -L/usr/local/lib/sqlite3 -lsqlite3 +.if !defined(WITHOUT_EMAILDB) && defined(WITH_EMAILDB) +OBJS+= emaildb.o +CFLAGS+= -DUSE_EMAILDB +LDFLAGS+= -lsqlite3 .endif .if !defined(WITHOUT_PFTERM) && defined(WITH_PFTERM) diff --git a/mbbsd/user.c b/mbbsd/user.c index 8645ab62..ce2dedbe 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -698,6 +698,7 @@ uinfo_query(userec_t *u, int adminmode, int unum) if (strcmp(buf, x.email) && strchr(buf, '@')) { strlcpy(x.email, buf, sizeof(x.email)); mail_changed = 1 - adminmode; + delregcodefile(); } break; case '7': @@ -1077,7 +1078,6 @@ uinfo_query(userec_t *u, int adminmode, int unum) snprintf(buf, sizeof(buf), "%d", x.mobile); justify_wait(x.userid, phone, career, x.realname, x.address, buf); - email_justify(&x); } memcpy(u, &x, sizeof(x)); if (i == QUIT) { @@ -1441,10 +1441,29 @@ toregister(char *email, char *genbuf, char *phone, char *career, #endif else if (isvalidemail(email)) { char yn[3]; +#ifdef USE_EMAILDB + int email_count = emaildb_check_email(email, strlen(email)); + + if (email_count < 0) { + move(15, 0); clrtobot(); + move(17, 0); + outs("暫時不允許 email 認證註冊, 請稍後再試\n"); + pressanykey(); + return; + } else if (email_count >= EMAILDB_LIMIT) { + move(15, 0); clrtobot(); + move(17, 0); + outs("指定的 E-Mail 已註冊過多帳號, 請使用其他 E-Mail, 或輸入 x 採手動認證\n"); + outs("但注意手動認證通常會花上數週以上的時間。\n"); + } else { +#endif getdata(16, 0, "請再次確認您輸入的 E-Mail 位置正確嘛? [y/N]", yn, sizeof(yn), LCECHO); if (yn[0] == 'Y' || yn[0] == 'y') break; +#ifdef USE_EMAILDB + } +#endif } else { move(15, 0); clrtobot(); move(17, 0); @@ -1452,6 +1471,16 @@ toregister(char *email, char *genbuf, char *phone, char *career, outs("但注意手動認證通常會花上數週以上的時間。\n"); } } +#ifdef USE_EMAILDB + if (emaildb_update_email(cuser.userid, strlen(cuser.userid), + email, strlen(email)) < 0) { + move(15, 0); clrtobot(); + move(17, 0); + outs("暫時不允許 email 認證註冊, 請稍後再試\n"); + pressanykey(); + return; + } +#endif strlcpy(cuser.email, email, sizeof(cuser.email)); REGFORM2: if (strcasecmp(email, "x") == 0) { /* 手動認證 */ diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf index a8415603..97554aa0 100644 --- a/sample/pttbbs.conf +++ b/sample/pttbbs.conf @@ -279,6 +279,9 @@ /* 若定義, 則每篇發文會寫到 log/post , 可以給分析或張爸魔一類的程式用 */ //#define LOGPOST +/* 限制一個email能註冊的帳號數量 (要使用請在make的時候加 WITH_EMAILDB) */ +#define EMAILDB_LIMIT 5 + /* 前進站畫面 */ #define INSCREEN \ "前進站畫面 (請至 pttbbs.conf 修改您的前進站畫面)" -- cgit v1.2.3