コード例 #1
0
ファイル: mbbsd.c プロジェクト: YanlongLai/Program
static void login_query() {
    char uid[IDLEN + 1], passbuf[PASSLEN];
    int attempts;
    char genbuf[200];
    extern struct utmpfile_t *utmpshm;
    resolve_utmp();
    attach_uhash();
    attempts = utmpshm->number;
    show_file("etc/Welcome", 1, -1, NO_RELOAD);
    output("1",1);
    if(attempts >= MAX_ACTIVE) {
	outs("由於人數太多,請您稍後再來。\n");
	refresh();
	exit(1);
    }

    /* hint */
    
    attempts = 0;
    while(1) {

	if(attempts++ >= LOGINATTEMPTS) {
	    more("etc/goodbye", NA);
	    pressanykey();
	    exit(1);
	}

	getdata(20, 0, "請輸入代號,或以[guest]參觀,以[new]註冊:",
		uid, IDLEN + 1, DOECHO);
	if(strcasecmp(uid, str_new) == 0) {
#ifdef LOGINASNEW
	    new_register();
	    break;
#else
	    outs("本系統目前無法以 new 註冊, 請用 guest 進入\n");
	    continue;
#endif
	} else if(uid[0] == '\0' || !dosearchuser(uid)) {
	    outs(err_uid);
	} else if(strcmp(uid, STR_GUEST)) {
	    getdata(21, 0, MSG_PASSWD, passbuf, PASSLEN, NOECHO);
	    passbuf[8] = '\0';
	    
	    if(!checkpasswd(cuser.passwd, passbuf) /* ||
	       (HAS_PERM(PERM_SYSOP) && !use_shell_login_mode)*/) {
		logattempt(cuser.userid, '-');
		outs(ERR_PASSWD);
	    } else {
		logattempt(cuser.userid, ' ');
		if(strcasecmp("SYSOP", cuser.userid) == 0)
		    cuser.userlevel = PERM_BASIC | PERM_CHAT | PERM_PAGE |
			PERM_POST | PERM_LOGINOK | PERM_MAILLIMIT |
			PERM_CLOAK | PERM_SEECLOAK | PERM_XEMPT |
			PERM_DENYPOST | PERM_BM | PERM_ACCOUNTS |
			PERM_CHATROOM | PERM_BOARD | PERM_SYSOP |
			PERM_BBSADM;
		break;
	    }
	} else {	/* guest */
	    cuser.userlevel = 0;
	    cuser.uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
	    break;
	}
    }
    multi_user_check();
    sethomepath(genbuf, cuser.userid);
    mkdir(genbuf, 0755);
}
コード例 #2
0
ファイル: main.c プロジェクト: erichuang1994/fbbs
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(&currentuser, 0, sizeof(currentuser));
			new_register();
			terminal_flush();
			exit(1);
		} else if (*uname == '\0')
			;
		else if (!dosearchuser(uname, &currentuser, &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;
}
コード例 #3
0
ファイル: mbbsd.c プロジェクト: yrchen/Athena
static void
login_query()
{
	char		uid       [IDLEN + 1], passbuf[PASSLEN];
	int		attempts;
	char		genbuf    [200];

	resolve_utmp();
	attempts = utmpshm->number;
	clear();

#ifdef CAMERA
	film_out(time(0) % 5, 0);
#else
	show_file("etc/Welcome0", 0, 20, ONLY_COLOR);
#endif

	if (attempts >= MAXACTIVE) {
		pressanykey("目前站上人數已達上限,請您稍後再來。");
		oflush();
		sleep(1);
		exit(1);
	}
	attempts = 0;
	while (1) {
		if (attempts++ >= LOGINATTEMPTS) {
			more("etc/goodbye", NA);
			pressanykey_old("錯誤太多次,掰掰~~~~~");
			exit(1);
		}
		uid[0] = '\0';
		getdata(22, 2, "您的代號:", uid, IDLEN + 1, DOECHO, 0);
		if (strcasecmp(uid, str_new) == 0) {

#ifdef LOGINASNEW
			DL_func("SO/register.so:va_new_register", 0);
			break;
#else
			pressanykey("本系統目前無法以 new 註冊, 請用 guest 進入");
			continue;
#endif
		} else if (uid[0] == '\0' /* || !dosearchuser(uid) */ )
			pressanykey(err_uid);
		else if (belong(FN_DISABLED, uid)) {
			pressanykey("該 ID 為本站禁止上站之 ID");
			logattempt(uid, '*');
		} else if (strcmp(uid, STR_GUEST)) {
			getdata(22, 30, "您的密碼:", passbuf, PASSLEN, PASS, 0);
			passbuf[8] = '\0';

			if (!dosearchuser(uid)) {
				logattempt(uid, '!');
				pressanykey(ERR_PASSWD);
			} else if (!chkpasswd(cuser.passwd, passbuf)) {
				logattempt(cuser.userid, '-');
				pressanykey(ERR_PASSWD);
			} else {
				/* SYSOP gets all permission bits */

				if (!strcasecmp(cuser.userid, str_sysop))
					cuser.userlevel = ~0;

				logattempt(cuser.userid, ' ');
				break;
			}
		} else {
			/* guest 的話 */
#ifdef LOGINASGUEST
			cuser.userlevel = 0;
			cuser.uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
			break;
#else
			pressanykey("本站不提供 guest 上站");
			continue;
#endif
		}
	}

	multi_user_check();
	sethomepath(genbuf, cuser.userid);
	mkdir(genbuf, 0755);
	srand(time(0) ^ getpid() ^ (getpid() << 10));
	srandom(time(0) ^ getpid() ^ (getpid() << 10));
}