From 551fed3d083395ad9c826c82192be5df94e36160 Mon Sep 17 00:00:00 2001 From: in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> Date: Sun, 17 Mar 2002 06:06:26 +0000 Subject: register by EMail code git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@36 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/menu.c | 7 +-- mbbsd/register.c | 6 +- mbbsd/user.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 161 insertions(+), 33 deletions(-) diff --git a/mbbsd/menu.c b/mbbsd/menu.c index d48670b3..d10b754f 100644 --- a/mbbsd/menu.c +++ b/mbbsd/menu.c @@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: menu.c,v 1.2 2002/03/17 06:06:26 in2 Exp $ */ #include <stdio.h> #include <stdlib.h> #include <time.h> @@ -58,9 +58,8 @@ void showtitle(char *title, char *mid) { else if(currutmp->mailalert) { mid = "\033[41;5m �l�t�ӫ��a�o " TITLE_COLOR; spc = 22; - } else if(HAS_PERM(PERM_SYSOP) && (nreg = dashs(fn_register)/163) > 10) { - /* �W�L�Q�ӤH���f�� */ - sprintf(numreg, "\033[41;5m ��%03d/%03d���f�� " TITLE_COLOR, + } else if(HAS_PERM(PERM_SYSOP) && (nreg = dashs(fn_register)/163)) { + sprintf(numreg, "\033[41;5m ��%03d/%03d���f�� " TITLE_COLOR, nreg, (int)dashs("register.new.tmp") / 163); mid = numreg; diff --git a/mbbsd/register.c b/mbbsd/register.c index e9c25be5..1ef56e9e 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -1,4 +1,4 @@ -/* $Id: register.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */ +/* $Id: register.c,v 1.2 2002/03/17 06:04:18 in2 Exp $ */ #define _XOPEN_SOURCE #include <stdio.h> @@ -303,7 +303,8 @@ void check_register() { while(strlen(cuser.address) < 8) getdata(6, 0, "�p���a�}�G", cuser.address, 50, DOECHO); - + + /* if(!strchr(cuser.email, '@')) { bell(); move(t_lines - 4, 0); @@ -320,6 +321,7 @@ void check_register() { } while(!strchr(cuser.email, '@')); } + */ if(!HAS_PERM(PERM_SYSOP) && !HAS_PERM(PERM_LOGINOK)) { /* �^�йL�����{�ҫH��A�δ��g E-mail post �L */ clear(); diff --git a/mbbsd/user.c b/mbbsd/user.c index 72850ad7..46aaf7ed 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -1,4 +1,4 @@ -/* $Id: user.c,v 1.2 2002/03/09 17:27:57 in2 Exp $ */ +/* $Id: user.c,v 1.3 2002/03/17 06:04:18 in2 Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -740,13 +740,121 @@ static int removespace(char* s){ return index; } -int u_register() { +static int ispersonalid(char *inid) +{ + char *lst="ABCDEFGHJKLMNPQRSTUVWXYZIO", id[20]; + int i, j, cksum; + + strcpy(id, inid); + i = cksum = 0; + if( !isalpha(id[0]) && (strlen(id)!=10) ) + return 0; + id[0] = toupper(id[0]); + /* A->10, B->11, ..H->17,I->34, J->18... */ + while( lst[i] != id[0] ) + i++; + i += 10; + id[0] = i % 10 + '0'; + if( !isdigit(id[9]) ) + return 0; + cksum += (id[9] - '0') + (i / 10); + + for( j = 0 ; j < 9 ; ++j ){ + if( !isdigit(id[j]) ) + return 0; + cksum += (id[j] - '0') * (9 - j); + } + return (cksum % 10) == 0; +} + +static char *getregcode(char *buf) +{ + sprintf(buf, "%s%s%s", + crypt(cuser.email, "PT"), + crypt(cuser.address, "2x"), + crypt(cuser.realname, "02")); + return buf; +} + +static int isvaildemail(char *email) +{ + if( strstr(email, ".bbs@") || + strstr(email, "url.com.tw") || + strstr(email, "yahoo.com") || + strstr(email, "hotmail.com")|| + !strstr(email, "@") ) + return 0; + return 1; +} + +static void toregister(char *email, char *genbuf, char *phone, char *career, + char *ident, char *rname, char *addr, char *mobile) +{ + FILE *fn; + time_t now; + char buf[80]; + clear(); + stand_title("�{�ҳ]�w"); + move(2, 0); + outs("�z�n, �����Ĩ�ؤ覡�{��:\n" + " 1.�z�Y�� E-Mail , �i�H�z�L E-Mail �i��{��\n" + " �п�J�z�� E-Mail , �z�|����ڭ̱H�X�t���{�ҽX���H��\n" + " ����Ш� (U)ser => (R)egister ��J, �Y�i�q�L�{��\n" + "\n" + " 2.�z�Y�S�� E-Mail , �п�J 0 ,\n" + " �ڭ̷|�ѯ����˦ۼf�ֱz�����U���\n"); + while( 1 ){ + email[0] = 0; + getfield(10, "�����{�ҥ�", "E-Mail Address", email, 50); + if( email[0] == 0 || email[0] == '0' || isvaildemail(email) ) + break; + else{ + move(17, 0); + prints("���w�� E-Mail ���X�k, �Y�z�L E-Mail �п�J 0"); + } + } + if( email[0] == 0 ) /* �U���A�� */ + return; + else if( email[0] == '0' ){ /* ��ʻ{�� */ + if ((fn = fopen(fn_register, "a"))) { + now = time(NULL); + fprintf(fn, "num: %d, %s", usernum, ctime(&now)); + fprintf(fn, "uid: %s\n", cuser.userid); + fprintf(fn, "ident: %s\n", ident); + fprintf(fn, "name: %s\n", rname); + fprintf(fn, "career: %s\n", career); + fprintf(fn, "addr: %s\n", addr); + fprintf(fn, "phone: %s\n", phone); + fprintf(fn, "mobile: %s\n", mobile); + fprintf(fn, "email: %s\n", email); + fprintf(fn, "----\n"); + fclose(fn); + } + } + else{ + if( phone != NULL ){ + sprintf(genbuf, "%s:%s:<Email>", phone, career); + strncpy(cuser.justify, genbuf, REGLEN); + sethomefile(buf, cuser.userid, "justify"); + } + sprintf(buf, "�z�b "BBSNAME" ���{�ҽX: %s", getregcode(genbuf)); + bsmtp("etc/registermail", buf, email, 0); + outs("�ڭ̧Y�N�H�X�{�ҫH (�i��n�·бz����T����)\n" + "�����z�i�H��ڻ{�ҫH���D���{�ҽX\n" + "��J�� (U)ser -> (R)egister ��N�i�H�������U"); + pressanykey(); + return; + } +} + +int u_register(void) +{ char rname[20], addr[50], ident[11], mobile[20]; char phone[20], career[40], email[50],birthday[9],sex_is[2],year,mon,day; + char inregcode[50], regcode[50]; char ans[3], *ptr; - FILE *fn; - time_t now; char genbuf[200]; + FILE *fn; if(cuser.userlevel & PERM_LOGINOK) { outs("�z�������T�{�w�g�����A���ݶ�g�ӽЪ�"); @@ -765,7 +873,37 @@ int u_register() { } fclose(fn); } - + + memset(phone, 0, sizeof(phone)); + if( cuser.year != 0 ){ /* �w�g�Ĥ@����L�F~ ^^" */ + clear(); + move(1, 0); + prints("%s(%s) �z�n�A�п�J�z���{�ҽX�ο�J 0���� E-Mail ", + cuser.userid, cuser.username); + inregcode[0] = 0; + getdata(10, 0, "�z���{�ҽX: ", inregcode, 45, DOECHO); + if( strcmp(inregcode, getregcode(regcode)) == 0 ){ + int unum; + if( (unum = getuser(cuser.userid)) == 0 ){ + outs("�t�ο��~�A�d�L���H\n\n"); + u_exit("getuser error"); + } + mail_muser(cuser, "[���U���\\�o]", "etc/registeredmail"); + cuser.userlevel |= (PERM_LOGINOK | PERM_POST); + prints("\n���U���\\, ���s�W����N���o�����v��\n" + "�Ы��U���@������᭫�s�W��~ :)"); + pressanykey(); + u_exit("registed"); + exit(0); + return QUIT; + } else if( strcmp(inregcode, "0") != 0 ){ + outs("�{�ҽX���~\n"); + pressanykey(); + } + toregister(email, genbuf, NULL, NULL, NULL, NULL, NULL, NULL); + return FULLUPDATE; + } + getdata(b_lines - 1, 0, "�z�T�w�n��g���U���(Y/N)�H[N] ", ans, 3, LCECHO); if(ans[0] != 'y') return FULLUPDATE; @@ -788,7 +926,9 @@ int u_register() { cuser.userid, cuser.username); do{ getfield(3, "D120908396", "�����Ҹ�", ident, 11); - }while(removespace(ident)<10 || !isalpha(ident[0])); + if( 'a' <= ident[0] && ident[0] <= 'z' ) + ident[0] -= 32; + }while( !ispersonalid(ident) ); do{ getfield(5, "�ХΤ���", "�u��m�W", rname, 20); }while(!removespace(rname) || isalpha(rname[0])); @@ -800,7 +940,7 @@ int u_register() { }while(!(addr[0])); do{ getfield(11, "�]�A���~�����ϰ�X", "�s���q��", phone, 20); - }while(!removespace(phone)); + }while( !removespace(phone) || phone[0] != '0' || strlen(phone) < 8 ); getfield(13, "�u��J�Ʀr �p:0912345678", "������X", mobile, 20); while(1) { int len; @@ -825,9 +965,7 @@ int u_register() { break; } getfield(17, "1.���� 2.�j�� ", "�ʧO", sex_is, 2); - getfield(19, "�����{�ҥ�", "E-Mail Address", email, 50); - - getdata(b_lines - 1, 0, "�H�W��ƬO�_���T(Y/N)�H(Q)�������U [N] ", + getdata(18, 0, "�H�W��ƬO�_���T(Y/N)�H(Q)�������U [N] ", ans, 3, LCECHO); if(ans[0] == 'q') return 0; @@ -843,23 +981,12 @@ int u_register() { cuser.month = mon; cuser.day = day; cuser.year = year; - if((fn = fopen(fn_register, "a"))) { - now = time(NULL); - trim(career); - trim(addr); - trim(phone); - fprintf(fn, "num: %d, %s", usernum, ctime(&now)); - fprintf(fn, "uid: %s\n", cuser.userid); - fprintf(fn, "ident: %s\n", ident); - fprintf(fn, "name: %s\n", rname); - fprintf(fn, "career: %s\n", career); - fprintf(fn, "addr: %s\n", addr); - fprintf(fn, "phone: %s\n", phone); - fprintf(fn, "mobile: %s\n", mobile); - fprintf(fn, "email: %s\n", email); - fprintf(fn, "----\n"); - fclose(fn); - } + trim(career); + trim(addr); + trim(phone); + + toregister(email, genbuf, phone, career, ident, rname, addr, mobile); + clear(); move(9,3); prints("�̫�Post�@�g\033[32m�ۧڤ��Ф峹\033[m���j�a�a�A" -- cgit v1.2.3