예제 #1
0
파일: boards.c 프로젝트: phoenixgao/fdubbs
/**
 * Create directory when browsing favorites.
 * @param cp browsing status.
 * @return update status.
 */
static int tui_goodbrd_mkdir(choose_t *cp)
{
	choose_board_t *cbrd = cp->data;

	if (!HAS_PERM(PERM_LOGIN) || !cbrd->goodbrd)
		return DONOTHING;

	if (cbrd->parent == 0) {
		if (cbrd->gnum >= GOOD_BRC_NUM) {
			presskeyfor("收藏夹已满", t_lines - 1);
			return MINIUPDATE;
		}

		char name[STRLEN];
		char title[STRLEN];
		name[0] = '\0';
		getdata(t_lines - 1, 0, "创建自定义目录: ", name, 17,
				DOECHO, NA);
		if (name[0] != '\0') {
			strlcpy(title, "自定义目录", sizeof(title));
			getdata(t_lines - 1, 0, "自定义目录描述: ", title, 21,
					DOECHO, NA);
			if (goodbrd_mkdir(cbrd, name, title, 0) == 0) {
				cp->valid = false;
				return PARTUPDATE;
			}
		}
		return MINIUPDATE;
	}
	return DONOTHING;
}
예제 #2
0
파일: boards.c 프로젝트: phoenixgao/fdubbs
static int tui_goodbrd_add(choose_t *cp)
{
	choose_board_t *cbrd = cp->data;

	if (!HAS_PERM(PERM_LOGIN))
		return DONOTHING;

	if (cbrd->goodbrd && (cbrd->parent == -1))
		return DONOTHING;

	if (cbrd->goodbrd) {
		if (cbrd->parent == -1)
			return DONOTHING;

		if (cbrd->gnum >= GOOD_BRC_NUM) {
			presskeyfor("收藏夹已满", t_lines - 1);
			return MINIUPDATE;
		}

		int pos;
		char bname[STRLEN];
		struct boardheader fh;
		if (gettheboardname(1, "输入讨论区名 (按空白键自动搜寻): ",
				&pos, &fh, bname, 1)) {
			if (goodbrd_add(cbrd, pos, cbrd->parent) == 0)
				cp->valid = false;
		}
		return FULLUPDATE;
	} else {
		goodbrd_load(cbrd);
		if (cbrd->gnum >= GOOD_BRC_NUM) {
			presskeyfor("收藏夹已满", t_lines - 1);
			return MINIUPDATE;
		} else {
			char buf[STRLEN];
			snprintf(buf, sizeof(buf), "您确定要添加 %s 到收藏夹吗?",
					cbrd->brds[cp->cur].name);
			if (askyn(buf, false, true)) {
				if (goodbrd_add(cbrd, cbrd->brds[cp->cur].pos + 1, 0) == 0) {
					cp->valid = false;
					return PARTUPDATE;
				}
			}
			return MINIUPDATE;
		}
	}
}
예제 #3
0
파일: boards.c 프로젝트: phoenixgao/fdubbs
/**
 * Copy board when browsing favorites.
 * @param cp browsing status.
 * @return update status.
 */
static int tui_goodbrd_copy(choose_t *cp)
{
	choose_board_t *cbrd = cp->data;

	if (!HAS_PERM(PERM_LOGIN) || !cbrd->goodbrd)
		return DONOTHING;

	if (cbrd->brds[cp->cur].flag & BOARD_CUSTOM_FLAG)
		return DONOTHING;

	cbrd->copy_bnum = cbrd->brds[cp->cur].pos + 1;
	presskeyfor("版面已复制 请按P粘贴", t_lines - 1);
	return MINIUPDATE;
}
예제 #4
0
파일: online.c 프로젝트: fbbs/fbbs
int tui_follow_uname(const char *uname)
{
	if (streq(currentuser.userid, "guest"))
		return DONOTHING;
	char buf[STRLEN];
	//% snprintf(buf, sizeof(buf), "确定关注 %s 吗?", uname);
	snprintf(buf, sizeof(buf), "\xc8\xb7\xb6\xa8\xb9\xd8\xd7\xa2 %s \xc2\xf0?", uname);
	if (!askyn(buf, false, true))
		return MINIUPDATE;
	if (follow(session_get_user_id(), uname, NULL)) {
		//% snprintf(buf, sizeof(buf), "成功关注 %s", uname);
		snprintf(buf, sizeof(buf), "\xb3\xc9\xb9\xa6\xb9\xd8\xd7\xa2 %s", uname);
		presskeyfor(buf, -1);
	}
	return MINIUPDATE;
}
예제 #5
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;
}
예제 #6
0
파일: online.c 프로젝트: fbbs/fbbs
static tui_list_handler_t online_users_handler(tui_list_t *p, int ch)
{
	online_users_t *up = p->data;
	online_user_info_t *ip = up->users + p->cur;
	p->valid = false;

	char buf[STRLEN];
	switch (ch) {
		case 'h': case 'H':
			show_help("help/userlisthelp");
			return FULLUPDATE;
		case 'm': case 'M':
			if (!HAS_PERM(PERM_MAIL))
				return DONOTHING;
			m_send(ip->name);
			return FULLUPDATE;
		case 's': case 'S':
			if (streq(currentuser.userid, "guest") || !HAS_PERM(PERM_TALK)
					|| !session_msgable(ip))
				return DONOTHING;
			tui_send_msg(ip->name);
			return FULLUPDATE;
		case 'o': case 'O':
			return tui_follow_uname(ip->name);
		case 'd': case 'D':
			if (streq(currentuser.userid, "guest"))
				return DONOTHING;
			//% "确定不再关注 %s 吗?"
			snprintf(buf, sizeof(buf), "\xc8\xb7\xb6\xa8\xb2\xbb\xd4\xd9"
					"\xb9\xd8\xd7\xa2 %s \xc2\xf0?", ip->name);
			if (!askyn(buf, false, true))
				return MINIUPDATE;
			{
				user_id_t uid = get_user_id(ip->name);
				if (uid > 0 && unfollow(session_get_user_id(), uid)) {
					//% "已取消关注 %s"
					snprintf(buf, sizeof(buf), "\xd2\xd1\xc8\xa1\xcf\xfb"
							"\xb9\xd8\xd7\xa2 %s", ip->name);
					presskeyfor(buf, -1);
					return PARTUPDATE;
				}
			}		
			return MINIUPDATE;
	}
	if (p->in_query)
		return READ_AGAIN;

	switch (ch) {
		case 'Y':
			if (HAS_PERM(PERM_CLOAK)) {
				x_cloak();
				up->uptime = 0;
				return PARTUPDATE;
			}
			return DONOTHING;
		case 'C': case 'c':
			return alter_nick(up);
		case 'k': case 'K':
			return kick_out(up, ip);
		case 'f': case 'F':
			up->follow = !up->follow;
			if (up->follow)
				set_user_status(ST_FRIEND);
			else
				set_user_status(ST_LUSERS);
			up->uptime = 0;
			return FULLUPDATE;
		case 'W': case 'w':
			if (streq(currentuser.userid, "guest"))
				return DONOTHING;
			up->show_note = !up->show_note;
			return PARTUPDATE;
#if 0
		case KEY_TAB:	
			if (HAS_PERM(PERM_OCHAT)) {
				if (++(up->sort) > USRSORT_STATUS)
					up->sort = USRSORT_USERID;
				up->uptime = 0;
				return FULLUPDATE;
			}
			return DONOTHING;
#endif
		case '\r': case '\n': case KEY_RIGHT:
			online_users_query(p);
			return DONOTHING;
		default:
			return READ_AGAIN;
	}
}
예제 #7
0
파일: tui.c 프로젝트: fbbs/fbbs
/**
 * Prompt and wait user to press any key.
 */
void pressanykey(void)
{
	//% 按任何键继续...
	presskeyfor("\033[m                                \033[5;1;33m"
			"\xb0\xb4\xc8\xce\xba\xce\xbc\xfc\xbc\xcc\xd0\xf8...\033[m", -1);
}
예제 #8
0
파일: stuff.c 프로젝트: phoenixgao/fdubbs
/**
 * Prompt and wait user to press any key.
 */
void pressanykey(void)
{
	presskeyfor("\033[m                                "
			"\033[5;1;33m°´Èκμü¼ÌÐø...", t_lines - 1);
}
예제 #9
0
int pressanykey()
{
	presskeyfor("                                °´Èκμü¼ÌÐø...", t_lines-1);
}