// pager与msg设定 // int x_userdefine() { int id; unsigned int newlevel; set_user_status(ST_USERDEF); if (!(id = getuser(currentuser.userid))) { screen_move_clear(3); //% prints("错误的使用者 ID..."); prints("\xb4\xed\xce\xf3\xb5\xc4\xca\xb9\xd3\xc3\xd5\xdf ID..."); pressreturn(); screen_clear(); return 0; } screen_move(1, 0); screen_clrtobot(); screen_move(2, 0); use_define = 1; //% newlevel = setperms(lookupuser.userdefine, "参数", NUMDEFINES, newlevel = setperms(lookupuser.userdefine, "\xb2\xce\xca\xfd", NUMDEFINES, showperminfo); screen_move(2, 0); if (newlevel == lookupuser.userdefine) //% prints("参数没有修改...\n"); prints("\xb2\xce\xca\xfd\xc3\xbb\xd3\xd0\xd0\xde\xb8\xc4...\n"); else { lookupuser.userdefine = newlevel; currentuser.userdefine = newlevel; substitut_record(PASSFILE, &lookupuser, sizeof(struct userec), id); //% prints("新的参数设定完成...\n\n"); prints("\xd0\xc2\xb5\xc4\xb2\xce\xca\xfd\xc9\xe8\xb6\xa8\xcd\xea\xb3\xc9...\n\n"); } pressreturn(); screen_clear(); use_define = 0; return 0; }
static void write_defnotepad(void) { currentuser.notedate = time(NULL); set_safe_record(); substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); return; }
// pager与msg设定 // int x_userdefine() { int id; unsigned int newlevel; set_user_status(ST_USERDEF); if (!(id = getuser(currentuser.userid))) { screen_move_clear(3); screen_printf("错误的使用者 ID..."); pressreturn(); screen_clear(); return 0; } screen_move(1, 0); screen_clrtobot(); screen_move(2, 0); use_define = 1; newlevel = setperms(lookupuser.userdefine, "参数", NUMDEFINES, showperminfo); screen_move(2, 0); if (newlevel == lookupuser.userdefine) screen_printf("参数没有修改...\n"); else { lookupuser.userdefine = newlevel; currentuser.userdefine = newlevel; substitut_record(PASSFILE, &lookupuser, sizeof(struct userec), id); screen_printf("新的参数设定完成...\n\n"); } pressreturn(); screen_clear(); use_define = 0; return 0; }
static int alter_nick(online_users_t *up) { char buf[STRLEN]; if (streq(currentuser.userid, "guest")) return DONOTHING; buf[0] = '\0'; //% getdata(-1, 0, "变换昵称(不是临时变换)为: ", buf, NAMELEN, getdata(-1, 0, "\xb1\xe4\xbb\xbb\xea\xc7\xb3\xc6(\xb2\xbb\xca\xc7\xc1\xd9\xca\xb1\xb1\xe4\xbb\xbb)\xce\xaa: ", buf, NAMELEN, DOECHO, NA); if (buf[0] != '\0') { set_safe_record(); strlcpy(currentuser.username, buf, sizeof(currentuser.username)); substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); up->uptime = 0; return PARTUPDATE; } return MINIUPDATE; }
int getnewuserid(void) { struct userec user; memset(&user, 0, sizeof(user)); strlcpy(user.userid, "new", sizeof(user.userid)); int i = searchnewuser(); char buf[STRLEN]; snprintf(buf, sizeof(buf), "uid %d from %s", i, fromhost); log_usies("APPLY", genbuf, ¤tuser); if (i <= 0 || i > MAXUSERS) return i; substitut_record(PASSFILE, &user, sizeof(user), i); return i; }
// Save user info on exit. void u_exit(void) { // 这些信号的处理要关掉, 否则在离线时等候回车时出现 // 信号会导致重写名单, 这个导致的名单混乱比kick user更多 (ylsdd) fb_signal(SIGALRM, SIG_DFL); fb_signal(SIGPIPE, SIG_DFL); fb_signal(SIGTERM, SIG_DFL); fb_signal(SIGUSR1, SIG_IGN); fb_signal(SIGUSR2, SIG_IGN); if (HAS_PERM(PERM_LOGINCLOAK)) setflags(CLOAK_FLAG, !session_visible()); set_safe_record(); update_user_stay(¤tuser, false, false); substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); uidshm->status[usernum - 1]--; session_destroy(session_id()); session_set_pid(0); }
static void user_login(void) { char fname[STRLEN]; // SYSOP gets all permission bits when login. if (strcmp(currentuser.userid, "SYSOP") == 0) { currentuser.userlevel = ~0; substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); } fromhost[sizeof(fromhost) - 1] = 0; //added by iamfat 2004.01.05 to avoid overflow log_usies("ENTER", fromhost, ¤tuser); SpecialID(currentuser.userid, fromhost, sizeof(fromhost)); u_enter(); report("Enter", currentuser.userid); #ifdef USE_NOTEPAD notepad_init(); if (strcmp(currentuser.userid, "guest") != 0) { if (DEFINE(DEF_NOTEPAD)) { int noteln; if (lastnote> currentuser.notedate) currentuser.noteline = 0; noteln = countln("etc/notepad"); if (currentuser.noteline == 0) { shownotepad(); } else if ((noteln - currentuser.noteline)> 0) { screen_move(0, 0); ansimore2("etc/notepad", NA, 0, noteln - currentuser.noteline + 1); terminal_getchar(); screen_clear(); } currentuser.noteline = noteln; write_defnotepad(); } } #endif if (show_statshm("etc/hotspot", 0)) { screen_flush(); pressanykey(); } if ((vote_flag(NULL, '\0', 2 /* 检查读过新的Welcome 没 */) == 0)) { if (dashf("Welcome")) { ansimore("Welcome", YEA); vote_flag(NULL, 'R', 2 /* 写入读过新的Welcome */); } } else { ansimore("Welcome2", YEA); } show_statshm("0Announce/bbslist/day", 1); screen_flush(); screen_move_clear(-2); if (currentuser.numlogins < 1) { currentuser.numlogins = 0; //% prints("\033[1;36m☆ 这是您第 \033[33m1\033[36m 次拜访本站,请记住今天吧。\n"); prints("\033[1;36m\xa1\xee \xd5\xe2\xca\xc7\xc4\xfa\xb5\xda \033[33m1\033[36m \xb4\xce\xb0\xdd\xb7\xc3\xb1\xbe\xd5\xbe\xa3\xac\xc7\xeb\xbc\xc7\xd7\xa1\xbd\xf1\xcc\xec\xb0\xc9\xa1\xa3\n"); //% prints("☆ 您第一次连入本站的时间为 \033[33m%s\033[m ", format_time(time(NULL), TIME_FORMAT_ZH)); prints("\xa1\xee \xc4\xfa\xb5\xda\xd2\xbb\xb4\xce\xc1\xac\xc8\xeb\xb1\xbe\xd5\xbe\xb5\xc4\xca\xb1\xbc\xe4\xce\xaa \033[33m%s\033[m ", format_time(fb_time(), TIME_FORMAT_ZH)); } else { prints( //% "\033[1;36m☆ 这是您第 \033[33m%d\033[36m 次拜访本站,上次您是从 \033[33m%s\033[36m 连往本站。\n", "\033[1;36m\xa1\xee \xd5\xe2\xca\xc7\xc4\xfa\xb5\xda \033[33m%d\033[36m \xb4\xce\xb0\xdd\xb7\xc3\xb1\xbe\xd5\xbe\xa3\xac\xc9\xcf\xb4\xce\xc4\xfa\xca\xc7\xb4\xd3 \033[33m%s\033[36m \xc1\xac\xcd\xf9\xb1\xbe\xd5\xbe\xa1\xa3\n", currentuser.numlogins + 1, currentuser.lasthost); //% prints("☆ 上次连线时间为 \033[33m%s\033[m ", format_time(currentuser.lastlogin, TIME_FORMAT_ZH)); prints("\xa1\xee \xc9\xcf\xb4\xce\xc1\xac\xcf\xdf\xca\xb1\xbc\xe4\xce\xaa \033[33m%s\033[m ", format_time(currentuser.lastlogin, TIME_FORMAT_ZH)); } terminal_getchar(); setuserfile(fname, BADLOGINFILE); if (ansimore(fname, NA) != -1) { //% if (askyn("您要删除以上密码输入错误的记录吗", NA, NA) == YEA) if (askyn("\xc4\xfa\xd2\xaa\xc9\xbe\xb3\xfd\xd2\xd4\xc9\xcf\xc3\xdc\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3\xb5\xc4\xbc\xc7\xc2\xbc\xc2\xf0", NA, NA) == YEA) unlink(fname); } set_safe_record(); tui_check_uinfo(¤tuser); strlcpy(currentuser.lasthost, fromhost, sizeof(currentuser.lasthost)); if (login_start_time - currentuser.lastlogin >= 20 * 60 || !strcmp(currentuser.userid, "guest") || currentuser.numlogins < 100) { currentuser.numlogins++; } session_basic_info_t *res = get_my_sessions(); update_user_stay(¤tuser, true, session_basic_info_count(res) > 1); session_basic_info_clear(res); #ifdef ALLOWGAME if (currentuser.money> 1000000) { currentuser.nummedals += currentuser.money / 10000; currentuser.money %= 1000000; } if ((signed int) (currentuser.money - currentuser.bet) < -4990 && currentuser.numlogins < 10 && currentuser.numposts < 10 && currentuser.nummedals == 0) currentuser.money += 1000; #endif if (currentuser.firstlogin == 0) { currentuser.firstlogin = time(NULL) - 7 * 86400; } substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); extern char currmaildir[]; setmdir(currmaildir, currentuser.userid); check_register_info(); }
// Handle giveupBBS(戒网) transactions. // Return expiration date (in days from epoch). // TODO: Better rewrite it.. int chk_giveupbbs(void) { int i, j, tmpcount, tmpid, sflag[10][2]; FILE *fn; int lcount = 0; char buf[NAME_MAX]; int recover = 0; sethomefile(buf, currentuser.userid, "giveupBBS"); fn = fopen(buf, "r"); if (fn) { struct userec tmpuserec; memcpy(tmpuserec.userid, currentuser.userid, sizeof(tmpuserec.userid)); tmpid = getuserec(tmpuserec.userid, &tmpuserec); while (!feof(fn)) { if (fscanf(fn, "%d %d", &i, &j) <= 0) break; sflag[lcount][0] = i; sflag[lcount][1] = j; lcount++; } tmpcount = lcount; fclose(fn); for (i = 0; i < lcount; i++) { if(sflag[i][0] == 1) recover = sflag[i][1]; if (sflag[i][1] <= time(NULL) / 3600 / 24) { tmpcount--; switch (sflag[i][0]) { case 1: tmpuserec.userlevel |= PERM_LOGIN; recover = 0; break; case 2: tmpuserec.userlevel |= PERM_POST; break; case 3: tmpuserec.userlevel |= PERM_TALK; break; case 4: tmpuserec.userlevel |= PERM_MAIL; break; } sflag[i][1] = 0; } } if (tmpuserec.flags[0] & GIVEUPBBS_FLAG && tmpcount == 0) tmpuserec.flags[0] &= ~GIVEUPBBS_FLAG; substitut_record(PASSFILE, &tmpuserec, sizeof(struct userec), tmpid); if (tmpcount == 0) unlink(buf); else { fn = fopen(buf, "w"); if (fn) { for (i = 0; i < lcount; i++) if (sflag[i][1] > 0) fprintf(fn, "%d %d\n", sflag[i][0], sflag[i][1]); fclose(fn); } } } return recover; }
int main(int argc, char **argv) { bool pretend = (argc != 2) || (strcasecmp(argv[1], "-f") != 0); int fd; FILE *log, *data, *post; if (!pretend) { int fd = open(BBSHOME"/tmp/killuser", O_RDWR | O_CREAT | O_EXCL, 0600); if (fd < 0) return EXIT_FAILURE; unlink(BBSHOME"/tmp/killuser"); log = fopen(BBSHOME"/tomb/log", "w+"); if (!log) return EXIT_FAILURE; data = fopen(BBSHOME"/tomb/PASSWDS", "w+"); if (!data) return EXIT_FAILURE; post = fopen(BBSHOME"/tomb/post", "w+"); if (!post) return EXIT_FAILURE; log_usies("CLEAN", "dated users.", NULL); } fb_time_t now = time(NULL); struct userec user, zero; memset(&zero, 0, sizeof(zero)); char file[HOMELEN], buf[HOMELEN]; for (int i = 0; i < MAXUSERS; ++i) { getuserbyuid(&user, i + 1); int val = compute_user_value(&user); if (user.userid[0] != '\0' && val < 0) { user.userid[sizeof(user.userid) - 1] = '\0'; if (pretend) { puts(user.userid); continue; } post_add(post, &user, now); fwrite(&user, sizeof(user), 1, data); fprintf(log, "%s\n", user.userid); snprintf(file, sizeof(file), "mail/%c/%s", toupper(user.userid[0]), user.userid); snprintf(buf, sizeof(buf), "%s~", file); rename(file, buf); snprintf(file, sizeof(file), "home/%c/%s", toupper(user.userid[0]), user.userid); snprintf(buf, sizeof(buf), "%s~", file); rename(file, buf); substitut_record(PASSFILE, &zero, sizeof(zero), i + 1); del_uidshm(i + 1, user.userid); } } if (!pretend) { fclose(post); fclose(data); fclose(log); close(fd); } return EXIT_SUCCESS; }
void check_register_info(void) { struct userec *urec = ¤tuser; FILE *fout; char buf[192], buf2[STRLEN]; if (!(urec->userlevel & PERM_LOGIN)) { urec->userlevel = 0; return; } #ifdef NEWCOMERREPORT if (urec->numlogins == 1) { screen_clear(); file_temp_name(buf, sizeof(buf)); if ((fout = fopen(buf, "w")) != NULL) { //% fprintf(fout, "大家好,\n\n"); fprintf(fout, "\xb4\xf3\xbc\xd2\xba\xc3,\n\n"); //% fprintf(fout, "我是 %s (%s), 来自 %s\n", fprintf(fout, "\xce\xd2\xca\xc7 %s (%s), \xc0\xb4\xd7\xd4 %s\n", currentuser.userid, urec->username, fromhost); //% fprintf(fout, "今天%s初来此站报到, 请大家多多指教。\n", fprintf(fout, "\xbd\xf1\xcc\xec%s\xb3\xf5\xc0\xb4\xb4\xcb\xd5\xbe\xb1\xa8\xb5\xbd, \xc7\xeb\xb4\xf3\xbc\xd2\xb6\xe0\xb6\xe0\xd6\xb8\xbd\xcc\xa1\xa3\n", //% (urec->gender == 'M') ? "小弟" : "小女子"); (urec->gender == 'M') ? "\xd0\xa1\xb5\xdc" : "\xd0\xa1\xc5\xae\xd7\xd3"); screen_move(2, 0); //% prints("非常欢迎 %s 光临本站,希望您能在本站找到属于自己的一片天空!\n\n", currentuser.userid); prints("\xb7\xc7\xb3\xa3\xbb\xb6\xd3\xad %s \xb9\xe2\xc1\xd9\xb1\xbe\xd5\xbe\xa3\xac\xcf\xa3\xcd\xfb\xc4\xfa\xc4\xdc\xd4\xda\xb1\xbe\xd5\xbe\xd5\xd2\xb5\xbd\xca\xf4\xd3\xda\xd7\xd4\xbc\xba\xb5\xc4\xd2\xbb\xc6\xac\xcc\xec\xbf\xd5\xa3\xa1\n\n", currentuser.userid); //% prints("请您作个简短的个人简介, 向本站其他使用者打个招呼\n"); prints("\xc7\xeb\xc4\xfa\xd7\xf7\xb8\xf6\xbc\xf2\xb6\xcc\xb5\xc4\xb8\xf6\xc8\xcb\xbc\xf2\xbd\xe9, \xcf\xf2\xb1\xbe\xd5\xbe\xc6\xe4\xcb\xfb\xca\xb9\xd3\xc3\xd5\xdf\xb4\xf2\xb8\xf6\xd5\xd0\xba\xf4\n"); //% prints("(简介最多三行, 写完可直接按 <Enter> 跳离)...."); prints("(\xbc\xf2\xbd\xe9\xd7\xee\xb6\xe0\xc8\xfd\xd0\xd0, \xd0\xb4\xcd\xea\xbf\xc9\xd6\xb1\xbd\xd3\xb0\xb4 <Enter> \xcc\xf8\xc0\xeb)...."); getdata(6, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { //% fprintf(fout, "\n\n自我介绍:\n\n"); fprintf(fout, "\n\n\xd7\xd4\xce\xd2\xbd\xe9\xc9\xdc:\n\n"); fprintf(fout, "%s\n", buf2); getdata(7, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "%s\n", buf2); getdata(8, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "%s\n", buf2); } } } fclose(fout); //% sprintf(buf2, "新手上路: %s", urec->username); sprintf(buf2, "\xd0\xc2\xca\xd6\xc9\xcf\xc2\xb7: %s", urec->username); Postfile(buf, "newcomers", buf2, 2); unlink(buf); } pressanykey(); } #endif #ifndef FDQUAN //检查邮箱 while (!HAS_PERM(PERM_BINDMAIL)) { screen_clear(); if (HAS_PERM(PERM_REGISTER)) { //% while (askyn("是否绑定复旦邮箱", NA, NA)== NA) while (askyn("\xca\xc7\xb7\xf1\xb0\xf3\xb6\xa8\xb8\xb4\xb5\xa9\xd3\xca\xcf\xe4", NA, NA)== NA) //add by eefree.06.7.20 { //% if (askyn("是否填写校友信息", NA, NA) == NA) { if (askyn("\xca\xc7\xb7\xf1\xcc\xee\xd0\xb4\xd0\xa3\xd3\xd1\xd0\xc5\xcf\xa2", NA, NA) == NA) { screen_clear(); continue; } check_reg_extra(); return; } //add end. } tui_check_reg_mail(); } #endif screen_clear(); if (HAS_PERM(PERM_REGISTER)) return; #ifndef AUTOGETPERM if (check_register_ok()) { #endif set_safe_record(); urec->userlevel |= PERM_DEFAULT; substitut_record(PASSFILE, urec, sizeof(struct userec), usernum); return; #ifndef AUTOGETPERM } #endif if (!chkmail()) fill_reg_form(); }
void check_register_info() { struct userec *urec = ¤tuser; FILE *fout; char buf[192], buf2[STRLEN]; #ifdef MAILCHECK char ans[4]; #ifdef CODE_VALID int i; #endif #endif if (!(urec->userlevel & PERM_LOGIN)) { urec->userlevel = 0; return; } #ifdef NEWCOMERREPORT if (urec->numlogins == 1) { clear(); sprintf(buf, "tmp/newcomer.%s", currentuser.userid); if ((fout = fopen(buf, "w")) != NULL) { fprintf(fout, "��Һ�,\n\n"); fprintf(fout, "���� %s (%s), ���� %s\n", currentuser.userid, urec->username, fromhost); fprintf(fout, "����%s������վ����, ���Ҷ��ָ�̡�\n", (urec->gender == 'M') ? "С��" : "СŮ��"); move(2, 0); prints("�dz���ӭ %s ���ٱ�վ��ϣ�������ڱ�վ�ҵ������Լ���һƬ��գ�\n\n", currentuser.userid); prints("����������̵ĸ��˼��, ��վ����ʹ���ߴ���к�\n"); prints("(����������, д���ֱ�Ӱ� <Enter> ����)...."); getdata(6, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "\n\n���ҽ���:\n\n"); fprintf(fout, "%s\n", buf2); getdata(7, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "%s\n", buf2); getdata(8, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "%s\n", buf2); } } } fclose(fout); sprintf(buf2, "������·: %s", urec->username); Postfile(buf, "newcomers", buf2, 2); unlink(buf); } pressanykey(); } #endif #ifdef PASSAFTERTHREEDAYS if (urec->lastlogin - urec->firstlogin < 3 * 86400) { if (!HAS_PERM(PERM_SYSOP)) { set_safe_record(); urec->userlevel &= ~(PERM_DEFAULT); urec->userlevel |= PERM_LOGIN; substitut_record(PASSFILE, urec, sizeof(struct userec), usernum); ansimore("etc/newregister", YEA); return; } } #endif #ifndef FDQUAN //������� while (!HAS_PERM(PERM_BINDMAIL)) { clear(); if (HAS_PERM(PERM_REGISTER)) { while (askyn("�Ƿ��������", NA, NA)== NA) //add by eefree.06.7.20 { if (askyn("�Ƿ���дУ����Ϣ", NA, NA) == NA) { clear(); continue; } check_reg_extra(); return; } //add end. } check_reg_mail(); } #endif clear(); if (HAS_PERM(PERM_REGISTER)) return; #ifndef AUTOGETPERM if (check_register_ok()) { #endif set_safe_record(); urec->userlevel |= PERM_DEFAULT; substitut_record(PASSFILE, urec, sizeof(struct userec), usernum); return; #ifndef AUTOGETPERM } #endif #ifdef MAILCHECK #ifdef CODE_VALID sethomefile(buf, currentuser.userid, ".regpass"); if (dashf(buf)) { move(13, 0); prints("����δͨ�����ȷ��... \n"); prints("�����ڱ�������ע��ȷ������, \"��֤����\"����Ϊ���ȷ��\n"); prints("һ���� %d ���ַ�, ��Сд���в���, ��ע��.\n", RNDPASSLEN); prints("����ȡ�������������� [Enter] ��.\n"); prints("[1;33m��ע��, ����������һ����֤�������������������룡[m\n"); if ((fout = fopen(buf, "r")) != NULL) { fscanf(fout, "%s", buf2); fclose(fout); for (i = 0; i < 3; i++) { move(18, 0); prints("������ %d �λ���\n", 3 - i); getdata(19,0,"��������֤����: ",genbuf,(RNDPASSLEN+1),DOECHO,YEA); if (strcmp(genbuf, "") != 0) { if (strcmp(genbuf, buf2) != 0) continue; else break; } } } else i = 3; if (i == 3) { prints("������֤ʧ��! ����Ҫ��дע�ᵥ�����ȷ������ȷ���������\n"); getdata(22,0,"��ѡ��1.��ע�ᵥ 2.����ȷ���� [1]:",ans,2,DOECHO,YEA); if(ans[0] == '2') { send_regmail(¤tuser); pressanykey(); } else x_fillform(); } else { set_safe_record(); urec->userlevel |= PERM_DEFAULT; substitut_record(PASSFILE, urec,sizeof(struct userec), usernum); prints("������!! ����˳����ɱ�վ��ʹ����ע������,\n"); prints("������������ӵ��һ��ʹ���ߵ�Ȩ��������...\n"); unlink(buf); mail_file("etc/smail", "SYSOP", "��ӭ���뱾վ����"); pressanykey(); } return; } #endif if ( (!strstr(urec->email, BBSHOST)) && (!invalidaddr(urec->email)) && (!invalid_email(urec->email))) { move(13, 0); prints("���ĵ������� ����ͨ��������֤... \n"); prints(" ��վ�����ϼ�һ����֤�Ÿ���,\n"); prints(" ��ֻҪ�� %s ����, �Ϳ��Գ�Ϊ��վ�ϸ���.\n\n", urec->email); prints(" ��Ϊ��վ�ϸ���, �������и����Ȩ���!\n"); prints(" ��Ҳ����ֱ����дע�ᵥ��Ȼ��ȴ�վ�����ֹ���֤��\n"); getdata(21,0,"��ѡ��1.��ע�ᵥ 2.��ȷ���� [1]: ",ans,2,DOECHO,YEA); if(ans[0] == '2') { send_regmail(¤tuser); getdata(21,0,"ȷ�����Ѽij�, ��������Ŷ!! ",ans, 2, DOECHO, YEA); return; } } #endif /* Following line modified by Amigo 2002.04.23. Fill form only when no new letter. */ /* x_fillform();*/ if (!chkmail()) x_fillform(); }
void check_reg_mail() { struct userec *urec = ¤tuser; char buf[192], code[STRLEN], email[STRLEN]="��������"; FILE *fout; int i; sethomefile(buf, urec->userid, ".regpass"); if (!dashf(buf)) { move(1, 0); prints(" ���������ĸ�������([email protected])\n"); prints(" [1;32m��վ���ø����������֤����������֤�������ĸ�������[m"); do { getdata(3, 0, " E-Mail:> ", email, STRLEN-12, DOECHO, YEA); if (invalidaddr(email) ||(strstr(email, "@fudan.edu.cn") == NULL) || invalid_email(email) == 1) { prints(" �Բ���, ��email��ַ��Ч, ���������� \n"); continue; } else break; } while (1); regmail_send(urec, email); } move(4, 0); clrtoeol(); move(5, 0); prints(" [1;33m ��֤���ѷ��͵� %s �������[m\n", email); getdata(7, 0, " ����������֤��ô��[Y/n] ", buf, 2, DOECHO, YEA); if (buf[0] != 'n' && buf[0] != 'N') { move(9, 0); prints("������ע��ȷ������, \"��֤��\"����Ϊ���ȷ��\n"); prints("һ���� %d ���ַ�, ��Сд���в���, ��ע��.\n", RNDPASSLEN); prints("��ע��, ����������һ����֤�������������������룡\n"); prints("\n[1;31m��ʾ��ע������� 3�κ�ϵͳ��Ҫ��������������䡣[m\n"); sethomefile(buf, currentuser.userid, ".regpass"); if ((fout = fopen(buf, "r")) != NULL) { //����֤�� fscanf(fout, "%s", code); fscanf(fout, "%s", email); fclose(fout); //3�λ��� for (i = 0; i < 3; i++) { move(15, 0); prints("������ %d �λ���\n", 3 - i); getdata(16, 0, "��������֤��: ", genbuf, (RNDPASSLEN+1), DOECHO, YEA); if (strcmp(genbuf, "") != 0) { if (strcmp(genbuf, code) != 0) continue; else break; } } } else i = 3; unlink(buf); if (i == 3) { prints("��֤����֤ʧ��!���������䡣\n"); //add by eefree 06.8.16 sethomefile(buf, currentuser.userid, ".regextra"); if (dashf(buf)) unlink(buf); //add end pressanykey(); } else { set_safe_record(); urec->userlevel |= PERM_BINDMAIL; strcpy(urec->email, email); substitut_record(PASSFILE, urec, sizeof(struct userec), usernum); prints("��֤����֤�ɹ�!\n"); //add by eefree 06.8.10 sethomefile(buf, currentuser.userid, ".regextra"); if (dashf(buf)) { prints("���ǽ���ʱ������������ʹ��Ȩ��,����˶�������ĸ�����Ϣ����ֹͣ���ķ���Ȩ��,\n"); prints("�����ȷ����������Ǹ�����ʵ��Ϣ.\n"); } //add end if (!HAS_PERM(PERM_REGISTER)) { prints("�������дע�ᵥ��\n"); } pressanykey(); } } else { } }
void new_register(void) { char userid[IDLEN + 1], passwd[PASSLEN], passbuf[PASSLEN], log[STRLEN]; #ifndef FDQUAN char code[IDLEN+1]; const char *verify_num; int sec; #endif if (dashf("NOREGISTER")) { ansimore("NOREGISTER", NA); pressreturn(); return; } ansimore("etc/register", NA); #ifndef FDQUAN if (!askyn("���Ƿ�ͬ�ⱾվAnnounce�澫����x-3Ŀ¼����վ��?", false, false)) return 0; #endif int tried = 0; prints("\n"); while (1) { if (++tried >= 9) { prints("\n�ݰݣ���̫���� <Enter> ��...\n"); refresh(); return; } #ifndef FDQUAN verify_num = generate_verify_num(); getdata(0, 0, "������������ʾ������: ", code, IDLEN + 1, DOECHO, YEA); #endif getdata(0, 0, "�������ʺ����� (Enter User ID, \"0\" to abort): ", userid, sizeof(userid), DOECHO, YEA); if (userid[0] == '0') return; const char *errmsg = invalid_userid(userid); if (errmsg != NULL) { outs(errmsg); continue; } #ifndef FDQUAN sec = random() % 5; prints("Ϊ����������ע���߳�ͻ...�����ĵȺ� %d ��...\n", sec); oflush(); sleep(sec); if (strcmp(verify_num, code)) { snprintf(log, sizeof(log), "verify '%s' error with code %s!=%s from %s", userid, verify_num, code, fromhost); report(log, currentuser.userid); prints("��Ǹ, ���������֤�벻��ȷ.\n"); continue; } snprintf(log, sizeof(log), "verify '%s' with code %s from %s ", userid, code, fromhost); report(log, currentuser.userid); #endif char path[HOMELEN]; sethomepath(path, userid); if (dosearchuser(userid, ¤tuser, &usernum) || dashd(path)) prints("���ʺ��Ѿ�����ʹ��\n"); else break; } for (tried = 0; tried <= MAX_SET_PASSWD_TRIES; ++tried) { passbuf[0] = '\0'; getdata(0, 0, "���趨�������� (Setup Password): ", passbuf, sizeof(passbuf), NOECHO, YEA); if (strlen(passbuf) < 4 || !strcmp(passbuf, userid)) { prints("����̫�̻���ʹ���ߴ�����ͬ, ����������\n"); continue; } strlcpy(passwd, passbuf, PASSLEN); getdata(0, 0, "��������һ���������� (Reconfirm Password): ", passbuf, PASSLEN, NOECHO, YEA); if (strncmp(passbuf, passwd, PASSLEN) != 0) { prints("�����������, ��������������.\n"); continue; } passwd[8] = '\0'; break; } if (tried > MAX_SET_PASSWD_TRIES) return; struct userec newuser; #ifdef ALLOWSWITCHCODE fill_new_userec(&newuser, userid, passwd, !convcode); #else fill_new_userec(&newuser, userid, passwd, true); #endif /* added by roly */ sprintf(genbuf, "/bin/rm -fr %s/mail/%c/%s", BBSHOME, toupper(newuser.userid[0]), newuser.userid) ; system(genbuf); sprintf(genbuf, "/bin/rm -fr %s/home/%c/%s", BBSHOME, toupper(newuser.userid[0]), newuser.userid) ; system(genbuf); /* add end */ int allocid = getnewuserid(); if (allocid > MAXUSERS || allocid <= 0) { prints("No space for new users on the system!\n\r"); return; } setuserid(allocid, newuser.userid); if (substitut_record(PASSFILE, &newuser, sizeof(newuser), allocid) == -1) { prints("too much, good bye!\n"); return; } if (!dosearchuser(newuser.userid, ¤tuser, &usernum)) { prints("User failed to create\n"); return; } snprintf(log, sizeof(log), "new account from %s", fromhost); report(log, currentuser.userid); prints("�����µ�¼ %s ����дע����Ϣ\n", newuser.userid); pressanykey(); return; }
static choose_handler_t choose_board_handler(choose_t *cp, int ch) { choose_board_t *cbrd = cp->data; board_data_t *ptr; char ans[2]; bool modify_mode = false; switch (ch) { case '*': if (cbrd->brds[cp->cur].flag & BOARD_CUSTOM_FLAG) return DONOTHING; ptr = cbrd->brds + cp->cur; show_board_info(ptr->name); return FULLUPDATE; case 'C': return tui_goodbrd_copy(cp); case 'c': cbrd->newflag = !cbrd->newflag; return PARTUPDATE; case 'L': m_read(); cp->valid = false; modify_mode = true; break; case 'M': m_new(); cp->valid = false; modify_mode = true; break; case 'u': modify_user_mode(QUERY); t_query(); modify_mode = true; break; case 'H': getdata(t_lines - 1, 0, "您选择? (1) 本日十大 (2) 系统热点 [1]", ans, 2, DOECHO, YEA); if (ans[0] == '2') show_help("etc/hotspot"); else show_help("0Announce/bbslist/day"); break; case 'l': msg_more(); modify_mode = true; break; case 'P': return tui_goodbrd_paste(cp); case '!': save_zapbuf(cbrd); free(cbrd->brds); free(cbrd->gbrds); Goodbye(); return -1; case 'h': show_help("help/boardreadhelp"); break; case '/': // TODO: search. break; case 's': if (currentuser.flags[0] & BRDSORT_FLAG) { currentuser.flags[0] ^= BRDSORT_FLAG; currentuser.flags[0] |= BRDSORT_ONLINE; cbrd->cmp = board_cmp_online; } else if (currentuser.flags[0] & BRDSORT_ONLINE) { currentuser.flags[0] ^= BRDSORT_ONLINE; cbrd->cmp = board_cmp_default; } else { currentuser.flags[0] |= BRDSORT_FLAG; cbrd->cmp = board_cmp_flag; } qsort(cbrd->brds, cbrd->num, sizeof(*cbrd->brds), cbrd->cmp); substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); return PARTUPDATE; case 'y': if (cbrd->gnum) return DONOTHING; cbrd->yank = !cbrd->yank; cp->valid = false; return PARTUPDATE; case 'z': if (cbrd->gnum) return DONOTHING; if (HAS_PERM(PERM_LOGIN) && !(cbrd->brds[cp->cur].flag & BOARD_NOZAP_FLAG)) { ptr = cbrd->brds + cp->cur; ptr->zap = !ptr->zap; ptr->total = -1; cbrd->zapbuf[ptr->pos] = (ptr->zap ? 0 : login_start_time); } cp->valid = false; return PARTUPDATE; case 'a': return tui_goodbrd_add(cp); case 'A': return tui_goodbrd_mkdir(cp); case 'T': return tui_goodbrd_rename(cp); case 'd': return tui_goodbrd_rm(cp); case '\r': case '\n': case KEY_RIGHT: if (cbrd->num > 0) choose_board_read(cp); cp->valid = false; modify_mode = true; break; case 'S': if (!HAS_PERM(PERM_TALK)) return DONOTHING; s_msg(); modify_mode = true; break; case 'o': if (!HAS_PERM(PERM_LOGIN)) return DONOTHING; online_users_show_override(); modify_mode = true; break; default: return DONOTHING; } if (modify_mode) modify_user_mode(cbrd->newflag ? READNEW : READBRD); return FULLUPDATE; }