static int choose_tmpl_key(struct _select_def *conf, int key) { switch (key) { case 's' : { char filepath[STRLEN]; if (conf->pos > template_num) return SHOW_CONTINUE; if (ptemplate[conf->pos-1].tmpl->filename[0]) { clear(); setbfile(filepath,currboard->filename, ptemplate[conf->pos-1].tmpl->filename); ansimore(filepath, 1); return SHOW_REFRESH; } return SHOW_CONTINUE; } break; case 'w': { clear(); if (ptemplate[conf->pos-1].tmpl->content_num <= 0) { move(5,0); prints("斑竹还没有设置问题,本模板暂不可用\n"); } else { int i; for (i=0; i<ptemplate[conf->pos-1].tmpl->content_num; i++) { move(i+2,0); prints("\033[1;32m问题 %d\033[m:%s \033[1;32m最长回答\033[m%d\033[1;32m字节\033[m", i+1, ptemplate[conf->pos-1].cont[i].text, ptemplate[conf->pos-1].cont[i].length); } } pressanykey(); return SHOW_REFRESH; } case 'x' : { clear(); move(2,0); prints("此模版的标题设置为"); move(4,0); prints("%s",ptemplate[conf->pos-1].tmpl->title_tmpl); pressanykey(); return SHOW_REFRESH; } default: break; } return SHOW_CONTINUE; }
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(); }
static int login_query(void) { #ifndef ENABLE_SSH char uname[IDLEN + 2]; char passbuf[PASSLEN]; int attempts; int recover; // For giveupBBS bool auth = false; #endif // ENABLE_SSH // Deny new logins if too many users online. int online = session_count_online(); #ifndef ENABLE_SSH if (online >= MAXACTIVE) { ansimore("etc/loginfull", NA); return -1; } #endif // ENABLE_SSH ansimore2("etc/issue", false, 0, 0); screen_printf("\033[1;35m欢迎光临\033[1;40;33m【 %s 】 \033[m" "[\033[1;33;41m Add '.' after YourID to login for BIG5 \033[m]\n", BBSNAME_UTF8); int peak = session_get_online_record(); if (peak < online) { session_set_online_record(online); peak = online; } screen_printf("\033[1;32m目前已有帐号: [\033[1;36m%d\033[32m/\033[36m%d\033[32m] " "\033[32m目前站上人数: [\033[36m%d\033[32m/\033[36m%d\033[1;32m]\n", get_user_count(), MAXUSERS, online, MAXACTIVE); visitlog(peak); #ifndef ENABLE_SSH attempts = 0; while (!auth) { if (attempts++ >= LOGINATTEMPTS) { ansimore("etc/goodbye", NA); return -1; } //% getdata(0, 0, "\033[1;33m请输入帐号\033[m" getdata(0, 0, "\033[1;33m\xc7\xeb\xca\xe4\xc8\xeb\xd5\xca\xba\xc5\033[m" //% "(试用请输入'\033[1;36mguest\033[m', " "(\xca\xd4\xd3\xc3\xc7\xeb\xca\xe4\xc8\xeb'\033[1;36mguest\033[m', " //% "注册请输入'\033[1;31mnew\033[m'): ", "\xd7\xa2\xb2\xe1\xc7\xeb\xca\xe4\xc8\xeb'\033[1;31mnew\033[m'): ", uname, IDLEN + 1, DOECHO, YEA); if (strcaseeq(uname, "guest") && (online > MAXACTIVE - 10)) { ansimore("etc/loginfull", NA); return -1; } if (strcaseeq(uname, "new")) { memset(¤tuser, 0, sizeof(currentuser)); new_register(); terminal_flush(); exit(1); } else if (*uname == '\0') ; else if (!dosearchuser(uname, ¤tuser, &usernum)) { screen_printf("\033[1;31m经查证,无此 ID。\033[m\n"); } else if (strcaseeq(uname, "guest")) { currentuser.userlevel = 0; break; } else { //% getdata(0, 0, "\033[1;37m请输入密码: \033[m", passbuf, PASSLEN, getdata(0, 0, "\033[1;37m\xc7\xeb\xca\xe4\xc8\xeb\xc3\xdc\xc2\xeb: \033[m", passbuf, PASSLEN, NOECHO, YEA); passbuf[8] = '\0'; switch (bbs_auth(uname, passbuf)) { case BBS_EWPSWD: screen_printf("\033[1;31m密码输入错误...\033[m\n"); break; case BBS_EGIVEUP: recover = chk_giveupbbs(); screen_printf("\033[33m您正在戒网,离戒网结束还有%d天\033[m\n", recover - fb_time() / 3600 / 24); return -1; case BBS_ESUICIDE: screen_printf("\033[32m您已经自杀\033[m\n"); return -1; case BBS_EBANNED: screen_printf("\033[32m本帐号已停机。请到 " "\033[36mNotice\033[32m版 查询原因\033[m\n"); return -1; case BBS_ELFREQ: screen_printf("登录过于频繁,请稍候再来\n"); return -1; case 0: auth = true; break; default: auth = false; break; } memset(passbuf, 0, PASSLEN - 1); } } #else // ENABLE_SSH //% 欢迎使用ssh方式访问本站,请按任意键继续 presskeyfor("\033[1;33m\xbb\xb6\xd3\xad\xca\xb9\xd3\xc3ssh\xb7\xbd\xca\xbd\xb7\xc3\xce\xca\xb1\xbe\xd5\xbe\xa3\xac\xc7\xeb\xb0\xb4\xc8\xce\xd2\xe2\xbc\xfc\xbc\xcc\xd0\xf8", -1); #endif // ENABLE_SSH if (multi_user_check() == -1) return -1; sethomepath(genbuf, currentuser.userid); mkdir(genbuf, 0755); login_start_time = time(NULL); return 0; }
/** * Telnet register interface. */ void new_register(void) { char userid[IDLEN + 1], passwd[PASSLEN], passbuf[PASSLEN], log[STRLEN]; const char *errmsg; if (register_closed()) { ansimore("NOREGISTER", NA); pressreturn(); return; } ansimore("etc/register", NA); #ifndef FDQUAN //% if (!askyn("您是否同意本站Announce版精华区x-3目录所列站规?", false, false)) if (!askyn("\xc4\xfa\xca\xc7\xb7\xf1\xcd\xac\xd2\xe2\xb1\xbe\xd5\xbe""Announce\xb0\xe6\xbe\xab\xbb\xaa\xc7\xf8x-3\xc4\xbf\xc2\xbc\xcb\xf9\xc1\xd0\xd5\xbe\xb9\xe6?", false, false)) return; #endif int tried = 0; prints("\n"); while (1) { if (++tried >= MAX_NEW_TRIES) { //% outs("\n拜拜,按太多下 <Enter> 了...\n"); outs("\n\xb0\xdd\xb0\xdd\xa3\xac\xb0\xb4\xcc\xab\xb6\xe0\xcf\xc2 <Enter> \xc1\xcb...\n"); screen_flush(); return; } //% getdata(0, 0, "请输入帐号名称 (Enter User ID, \"0\" to abort): ", getdata(0, 0, "\xc7\xeb\xca\xe4\xc8\xeb\xd5\xca\xba\xc5\xc3\xfb\xb3\xc6 (Enter User ID, \"0\" to abort): ", userid, sizeof(userid), DOECHO, YEA); if (userid[0] == '0') return; errmsg = register_invalid_user_name(userid); if (errmsg != NULL) { outs(errmsg); continue; } char path[HOMELEN]; sethomepath(path, userid); if (dosearchuser(userid, ¤tuser, &usernum) || dashd(path)) { //% outs("此帐号已经有人使用\n"); outs("\xb4\xcb\xd5\xca\xba\xc5\xd2\xd1\xbe\xad\xd3\xd0\xc8\xcb\xca\xb9\xd3\xc3\n"); continue; } #ifndef REG_CAPTCHA break; #else char link[STRLEN], attempt[CAPTCHA_LEN + 1], answer[CAPTCHA_LEN + 1]; int lnum; int pos = gen_captcha_link(link, sizeof(link), &lnum); if (pos < 0) return; prints("http://"BBSHOST"/captcha/%d.gif\n", lnum); //% getdata(0, 0, "请输入上图所包含的英文字母: ", attempt, sizeof(attempt), getdata(0, 0, "\xc7\xeb\xca\xe4\xc8\xeb\xc9\xcf\xcd\xbc\xcb\xf9\xb0\xfc\xba\xac\xb5\xc4\xd3\xa2\xce\xc4\xd7\xd6\xc4\xb8: ", attempt, sizeof(attempt), DOECHO, YEA); unlink(link); get_captcha_answer(pos, answer, sizeof(answer)); if (strcasecmp(answer, attempt) != 0) { //% outs("验证码输入错误...\n"); outs("\xd1\xe9\xd6\xa4\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3...\n"); continue; } else { break; } #endif // REG_CAPTCHA } for (tried = 0; tried <= MAX_SET_PASSWD_TRIES; ++tried) { passbuf[0] = '\0'; //% getdata(0, 0, "请设定您的密码 (Setup Password): ", passbuf, getdata(0, 0, "\xc7\xeb\xc9\xe8\xb6\xa8\xc4\xfa\xb5\xc4\xc3\xdc\xc2\xeb (Setup Password): ", passbuf, sizeof(passbuf), NOECHO, YEA); errmsg = register_invalid_password(passbuf, userid); if (errmsg) { outs(errmsg); continue; } strlcpy(passwd, passbuf, PASSLEN); //% getdata(0, 0, "请再输入一次您的密码 (Confirm Password): ", passbuf, getdata(0, 0, "\xc7\xeb\xd4\xd9\xca\xe4\xc8\xeb\xd2\xbb\xb4\xce\xc4\xfa\xb5\xc4\xc3\xdc\xc2\xeb (Confirm Password): ", passbuf, PASSLEN, NOECHO, YEA); if (strncmp(passbuf, passwd, PASSLEN) != 0) { //% prints("密码输入错误, 请重新输入密码\n"); prints("\xc3\xdc\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3, \xc7\xeb\xd6\xd8\xd0\xc2\xca\xe4\xc8\xeb\xc3\xdc\xc2\xeb\n"); continue; } passwd[8] = '\0'; break; } if (tried > MAX_SET_PASSWD_TRIES) return; struct userec user; init_userec(&user, userid, passwd, true); strlcpy(user.lasthost, fromhost, sizeof(user.lasthost)); if (create_user(&user) < 0) { outs("Failed to create user.\n"); return; } snprintf(log, sizeof(log), "new account from %s", fromhost); report(log, currentuser.userid); //% prints("请重新登录 %s 并填写注册信息\n", user.userid); prints("\xc7\xeb\xd6\xd8\xd0\xc2\xb5\xc7\xc2\xbc %s \xb2\xa2\xcc\xee\xd0\xb4\xd7\xa2\xb2\xe1\xd0\xc5\xcf\xa2\n", user.userid); pressanykey(); return; }
void new_register() { struct userec newuser; int allocid, do_try, flag; char buf[STRLEN]; /* temp !!!!!*/ #ifdef SECONDSITE prints("不接受新帐号注册!!!\n"); oflush(); sleep(2); exit(-1); #else /* prints("Sorry, we don't accept newusers due to system problem, we'll fixit ASAP\n"); oflush(); sleep(2); exit(-1); */ memset(&newuser, 0, sizeof(newuser)); getdata(0, 0, "使用GB编码阅读?(\xa8\xcf\xa5\xce BIG5\xbd\x58\xbe\x5c\xc5\xaa\xbd\xd0\xbf\xefN)(Y/N)? [Y]: ", buf, 4, DOECHO, NULL, true); if (*buf == 'n' || *buf == 'N') if (!convcode) switch_code(); ansimore("etc/register", false); do_try = 0; while (1) { if (++do_try >= 10) { prints("\n掰掰,按太多下 <Enter> 了...\n"); refresh(); longjmp(byebye, -1); } getdata(0, 0, "请输入代号: ", newuser.userid, IDLEN + 1, DOECHO, NULL, true); flag = 1; if (id_invalid(newuser.userid) == 1) { prints("帐号必须由英文字母或数字组成,并且第一个字符必须是英文字母!\n"); /* prints("帐号必须由英文字母或数字,而且帐号第一个字是英文字母!\n"); */ flag = 0; } if (flag) { if (strlen(newuser.userid) < 2) { prints("代号至少需有两个英文字母!\n"); } else if ((strcasecmp(newuser.userid, "SYSOP") == 0) && (strcmp(newuser.userid, "SYSOP") != 0) && searchuser("SYSOP") == 0) { prints("抱歉,本站只允许注册*全部*大写的SYSOP用户ID。\n"); } else if (!strcasecmp(newuser.userid, "guest") && strcmp(newuser.userid, "guest") && !searchuser("guest")) { prints("抱歉,本站只允许注册*全部*小写的guest用户ID。\n"); } else if ((*newuser.userid == '\0') || bad_user_id(newuser.userid) || (strcasecmp(newuser.userid, "SYSOPS") == 0) || (strcasecmp(newuser.userid, "BMS") == 0)) { prints("抱歉,本站暂不提供此帐号注册。\n"); } else if (searchuser(newuser.userid) != 0) { /*( dosearchuser( newuser.userid ) ) midified by dong , 1998.12.2, change getuser -> searchuser , 1999.10.26 */ prints("此帐号已经有人使用\n"); } else { /*--- ---*/ struct stat lst; time_t lnow; lnow = time(NULL); sethomepath(genbuf, newuser.userid); if (!stat(genbuf, &lst) && S_ISDIR(lst.st_mode) && (lnow - lst.st_ctime < SEC_DELETED_OLDHOME /* 3600*24*30 */)) { prints("目前无法注册帐号%s,请与系统管理人员联系。\n", newuser.userid); sprintf(genbuf, "IP %s new id %s failed[home changed in past 30 days]", getSession()->fromhost, newuser.userid); bbslog("user","%s",genbuf); } else { /* etnlegend, 2006.10.14, 新用户可能继承原有同名用户信件... */ sethomepath(genbuf,newuser.userid); my_f_rm(genbuf); setmailpath(genbuf,newuser.userid); my_f_rm(genbuf); break; } } } } newuser.firstlogin = newuser.lastlogin = time(NULL) - 13 * 60 * 24; do_try = 0; while (1) { char passbuf[STRLEN], passbuf2[STRLEN]; if (++do_try >= 10) { prints("\n掰掰,按太多下 <Enter> 了...\n"); refresh(); longjmp(byebye, -1); } getdata(0, 0, "请设定您的密码: ", passbuf, 39, NOECHO, NULL, true); if (strlen(passbuf) < 4 || !strcmp(passbuf, newuser.userid)) { prints("密码太短或与使用者代号相同, 请重新输入\n"); continue; } getdata(0, 0, "请再输入一次你的密码: ", passbuf2, 39, NOECHO, NULL, true); if (strcmp(passbuf, passbuf2) != 0) { prints("密码输入错误, 请重新输入密码.\n"); continue; } setpasswd(passbuf, &newuser); #ifdef NEWSMTH strcpy(getSession()->passwd, passbuf); #endif break; } if (searchuser(newuser.userid) != 0) { prints("此帐号已经有人使用\n"); refresh(); longjmp(byebye, -1); } newuser.userlevel = PERM_BASIC; newuser.userdefine[0] = -1; newuser.userdefine[1] = -1; /* newuser.userdefine&=~DEF_MAILMSG; newuser.userdefine&=~DEF_EDITMSG; */ SET_UNDEFINE(&newuser, DEF_NOTMSGFRIEND); if (convcode) SET_UNDEFINE(&newuser, DEF_USEGB); SET_UNDEFINE(&newuser, DEF_SHOWREALUSERDATA); newuser.exittime = time(NULL) - 100; /*newuser.unuse2 = -1;*/ newuser.flags |= PAGER_FLAG; newuser.title = 0; newuser.firstlogin = newuser.lastlogin = time(NULL); allocid = getnewuserid2(newuser.userid); if (allocid > MAXUSERS || allocid <= 0) { prints("抱歉, 由于某些系统原因, 无法注册新的帐号.\n\r"); oflush(); sleep(2); exit(1); } newbbslog(BBSLOG_USIES, "APPLY: %s uid %d from %s", newuser.userid, allocid, getSession()->fromhost); update_user(&newuser, allocid, 1); if (!dosearchuser(newuser.userid)) { /* change by KCN 1999.09.08 fprintf(stderr,"User failed to create\n") ; */ prints("User failed to create %d-%s\n", allocid, newuser.userid); oflush(); exit(1); } bbslog("user","%s","new account"); #endif /* SECONDSITE */ }
int showout() { int i, i2 = 0; char foo[1024]; char tmpfile[STRLEN]; char buf[20]; int notreload = 0; GOPHER newitem; while (1) { if (gopher_position < 0) { return; } print_gophertitle(); printgopher_title(); update_endline(); if (!notreload) { i = 0; if (get_con(g_main[gopher_position]->server, g_main[gopher_position]->port) == -1) { show_message(NULL); free(g_main[gopher_position]); gopher_position--; notreload = 0; continue; } enterdir(g_main[gopher_position]->file); show_message("¶Áȡ׼±¸ÖÐ"); for (i = 0; i < MAXGOPHERITEMS; i++) { if (readfield(a, foo, 1024) <= 0) { break; } if (foo[0] == '.' && foo[1] == '\r' && foo[2] == '\n') { break; } strncpy(newitem.title, foo, 70); if (readfield(a, foo, 1024) == 0) { break; } strncpy(newitem.file, foo, 80); if (readfield(a, foo, 1024) == 0) { break; } strncpy(newitem.server, foo, 40); if (readline(a, foo, 1024) == 0) { break; } newitem.port = atoi(foo); if (newitem.title[0] != newitem.file[0]) { break; } if (newitem.title[0] != '0' && newitem.title[0] != '1') { i--; continue; } refresh(); append_record(gophertmpfile, &newitem, sizeof(GOPHER)); sprintf(buf, "[1;3%dmת[3%dm»»[3%dm×Ê[3%dmÁÏ[3%dmÖÐ[m", (i % 7) + 1 ,((i + 1) % 7) + 1, ((i + 2) % 7) + 1, ((i + 3) % 7) + 1, ((i + 4) % 7) + 1); show_message(buf); } show_message(NULL); } else notreload = 0; if (i <= 0) { move(3, 0); clrtobot(); move(10, 0); clrtoeol(); prints(" [1;31mûÓÐÈκεÄ×ÊÁÏ...[m"); pressanykey(); free(g_main[gopher_position]); gopher_position--; continue; } close(a); move(0, 0); clrtobot(); setlistrange(i); i2 = choose(NA, g_main[gopher_position]->position, print_gophertitle, deal_gopherkey, show_gopher, do_gopher); if (i2 == -1) { free(g_main[gopher_position]); clear_gophertmpfile(); gopher_position--; continue; } g_main[gopher_position]->position = i2; get_record(gophertmpfile, &newitem, sizeof(GOPHER), i2 + 1); tmpitem = &newitem; if (newitem.title[0] == '0') { if (get_con(newitem.server, newitem.port) == -1) continue; enterdir(newitem.file); setuserfile(tmpfile, "gopher.tmp"); savetmpfile(tmpfile); ansimore(tmpfile, YEA); notreload = 1; unlink(tmpfile); continue; } else { GOPHER *newgi; clear_gophertmpfile(); gopher_position++; newgi = (GOPHER *) malloc(sizeof(GOPHER)); strncpy(newgi->server, tmpitem->server, 40); strncpy(newgi->file, tmpitem->file, 80); strncpy(newgi->title, tmpitem->title, 70); newgi->port = tmpitem->port; newgi->position = 0; g_main[gopher_position] = newgi; continue; } } }
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 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 int tmpl_key(struct _select_def *conf, int key) { int oldmode; switch (key) { case 'a' : tmpl_check_limit(template_num); tmpl_add(); return SHOW_DIRCHANGE; break; case 'd' : { char ans[3]; getdata(t_lines - 1, 0, "确实要删除吗(Y/N)? [N]: ", ans, sizeof(ans), DOECHO, NULL, true); if (ans[0] == 'Y' || ans[0] == 'y') { int i; deepfree(ptemplate + conf->pos - 1, currboard->filename); template_num--; for (i=conf->pos-1; i<template_num; i++) memcpy(ptemplate+i, ptemplate+i+1, sizeof(struct a_template)); ptemplate[template_num].tmpl = NULL; ptemplate[template_num].cont = NULL; tmpl_save(); } if (template_num > 0) return SHOW_DIRCHANGE; else return SHOW_QUIT; } break; case 'c': do { extern bool in_do_sendmsg; extern int super_select_board(char *bname); int ret; char bname[STRLEN] = ""; move(0,0); clrtoeol(); prints("%s","复制到讨论区 [ \033[1;32mSPACE/TAB\033[m - 自动补全, \033[1;32mESC\033[m - 退出 ]"); move(1,0); clrtoeol(); prints("请输入讨论区名称 [\033[1;32m%s\033[m]: ",currboard->filename); make_blist(0, 3); in_do_sendmsg=1; ret = namecomplete(NULL, bname); in_do_sendmsg=0; CreateNameList(); /* free list memory. */ if (ret == KEY_ESC) { /* noop */ } else if (!*bname || !strcmp(bname, currboard->filename)) { /* copy to current board */ tmpl_check_BM(currboard->filename); /* sanity check, how about stick here when deposing? */ tmpl_check_limit(template_num); if (tmpl_copy(conf->pos)) tmplcp_sorry(); else tmplcp_success(); } else { /* copy to another board */ struct a_template *ptemp; int temp_num = tmpl_init_ex(0, bname, &ptemp); if (temp_num >= 0) { tmpl_check_BM(bname); /* sanity check */ tmpl_check_limit(temp_num); if (tmpl_copy_to_board(bname, &ptemp, &temp_num, conf->pos)) tmplcp_sorry(); else tmplcp_success(); tmpl_free_ex(&ptemp, temp_num); } } } while (0); return SHOW_DIRCHANGE; /* etnlegend, 2006.05.19, move templates... */ case 'm': do { struct a_template temp; char ans[4]; int i,pos; getdata(t_lines-1,0,"请输入希望移动到的位置序号: ",ans,4,DOECHO,NULL,true); trimstr(ans); if (!isdigit(ans[0])) break; pos=atoi(ans); pos=((pos<1)?1:((pos>template_num)?template_num:pos)); if (pos==conf->pos) break; memcpy(&temp,&ptemplate[conf->pos-1],sizeof(struct a_template)); if (pos>conf->pos) { for (i=(conf->pos-1); i<(pos-1); i++) memcpy(&ptemplate[i],&ptemplate[i+1],sizeof(struct a_template)); } else { for (i=(conf->pos-1); i>(pos-1); i--) memcpy(&ptemplate[i],&ptemplate[i-1],sizeof(struct a_template)); } memcpy(&ptemplate[pos-1],&temp,sizeof(struct a_template)); tmpl_save(); } while (0); return SHOW_DIRCHANGE; /* END - etnlegend, 2006.05.19, move templates ... */ case 't' : { char newtitle[60]; strcpy(newtitle, ptemplate[conf->pos-1].tmpl->title); getdata(t_lines - 1, 0, "新名称: ", newtitle, 50, DOECHO, NULL, false); if (newtitle[0] == '\0' || newtitle[0]=='\n' || ! strcmp(newtitle,ptemplate[conf->pos-1].tmpl->title)) return SHOW_REFRESH; strncpy(ptemplate[conf->pos-1].tmpl->title, newtitle, 50); ptemplate[conf->pos-1].tmpl->title[49]='\0'; tmpl_save(); return SHOW_REFRESH; } break;/* case 'z' : { char newtitle[30]; strcpy(newtitle, ptemplate[conf->pos-1].tmpl->title_prefix); getdata(t_lines - 1, 0, "请输入此模板的文章标题前缀: ", newtitle, 20, DOECHO, NULL, false); if( newtitle[0] == '\0' || newtitle[0]=='\n' || ! strcmp(newtitle,ptemplate[conf->pos-1].tmpl->title_prefix) ) return SHOW_REFRESH; strncpy(ptemplate[conf->pos-1].tmpl->title_prefix, newtitle, 20); ptemplate[conf->pos-1].tmpl->title_prefix[19]='\0'; tmpl_save(); return SHOW_REFRESH; }*/ case 'f' : { char filepath[STRLEN]; int oldmode; oldmode = uinfo.mode; modify_user_mode(EDITUFILE); if (ptemplate[conf->pos-1].tmpl->filename[0] == '\0') { setbfile(filepath, currboard->filename, ""); if (GET_POSTFILENAME(ptemplate[conf->pos-1].tmpl->filename, filepath) != 0) { clear(); move(3,0); prints("创建模板文件失败!"); pressanykey(); return SHOW_REFRESH; } tmpl_save(); } setbfile(filepath, currboard->filename, ptemplate[conf->pos-1].tmpl->filename); vedit(filepath,0,NULL,NULL,0); modify_user_mode(oldmode); return SHOW_REFRESH; } case 's' : { char filepath[STRLEN]; setbfile(filepath, currboard->filename, ptemplate[conf->pos-1].tmpl->filename); clear(); ansimore(filepath,1); return SHOW_REFRESH; } case 'b' : { if (ptemplate[conf->pos-1].tmpl->flag & TMPL_BM_FLAG) ptemplate[conf->pos-1].tmpl->flag &= ~TMPL_BM_FLAG ; else ptemplate[conf->pos-1].tmpl->flag |= TMPL_BM_FLAG; tmpl_save(); return SHOW_REFRESH; } case 'i' : { char newtitle[STRLEN]; strcpy(newtitle, ptemplate[conf->pos-1].tmpl->title_tmpl); getdata(t_lines - 1, 0, "新文章标题: ", newtitle, STRLEN, DOECHO, NULL, false); if (newtitle[0] == '\0' || newtitle[0]=='\n' || ! strcmp(newtitle,ptemplate[conf->pos-1].tmpl->title_tmpl)) return SHOW_REFRESH; strncpy(ptemplate[conf->pos-1].tmpl->title_tmpl, newtitle, STRLEN); ptemplate[conf->pos-1].tmpl->title_tmpl[STRLEN-1]='\0'; tmpl_save(); return SHOW_REFRESH; } case 'x' : { clear(); move(2,0); prints("此模版的标题设置为"); move(4,0); prints("%s",ptemplate[conf->pos-1].tmpl->title_tmpl); pressanykey(); return SHOW_REFRESH; } /* case 'h': { clear(); move(1,0); prints(" x : 查看标题格式\n"); prints(" i : 修改标题格式"); pressanykey(); return SHOW_REFRESH; } */ case 'l': /* by pig2532 on 2005.12.01 */ oldmode = uinfo.mode; show_allmsgs(); modify_user_mode(oldmode); return SHOW_REFRESH; case 'w': /* by pig2532 on 2005-12-1 */ oldmode = uinfo.mode; if (!HAS_PERM(getCurrentUser(), PERM_PAGE)) break; s_msg(); modify_user_mode(oldmode); return SHOW_REFRESH; case 'u': /* by pig2532 on 2005-12-1 */ clear(); oldmode = uinfo.mode; modify_user_mode(QUERY); t_query(NULL); modify_user_mode(oldmode); return SHOW_REFRESH; case 'U': /* pig2532 2005.12.10 */ board_query(); return SHOW_REFRESH; default : break; } return SHOW_CONTINUE; }