Example #1
0
static void post_add(FILE *fp, const struct userec *user, fb_time_t now)
{
    fprintf(fp, "\033[1;37m%s \033[m(\033[1;33m%s\033[m) 共上站 "
            "\033[1;32m%d\033[m 次 [\033[1;3%dm%s\033[m]\n",
            user->userid, user->username, user->numlogins,
            (user->gender == 'F') ? 5 : 6,
            horoscope(user->birthmonth, user->birthday));
    fprintf(fp, "上 次 在:[\033[1;32m%s\033[m] 从 [\033[1;32m%s\033[m] "
            "到本站一游。\n", getdatestring(user->lastlogin, DATE_ZH),
            (user->lasthost[0] == '\0' ? "(不详)" : user->lasthost));
    fprintf(fp, "离站时间:[\033[1;32m%s\033[m] ",
            getdatestring(user->lastlogout, DATE_ZH));

    int exp = countexp(user);
    int perf = countperf(user);
#ifdef SHOW_PERF
    fprintf(fp, "表现值:%d(\033[1;33m%s\033[m)\n", perf, cperf(perf));
#else
    fprintf(fp, "表现值:[\033[1;33m%s\033[m]\n", cperf(perf));
#endif

#ifdef ALLOWGAME
    fprintf(fp, "银行存款: [\033[1;32m%d元\033[m] "
            "目前贷款: [\033[1;32m%d元\033[m](\033[1;33m%s\033[m) "
            "经验值:[\033[1;32m%d\033[m](\033[1;33m%s\033[m)。\n",
            user->money, user->bet, cmoney(user->money - user->bet),
            exp, cexpstr(exp));
    fprintf(fp, "文 章 数: [\033[1;32m%d\033[m] "
            "奖章数: [\033[1;32m%d\033[m](\033[1;33m%s\033[m) 生命力:"
            "[\033[1;32m%d\033[m] 网龄[\033[1;32m%"PRIdFBT"天\033[m]\n\n",
            user->numposts, user->nummedals, cnummedals(user->nummedals),
            compute_user_value(user), (now - user->firstlogin) / 86400);
#else
    fprintf(fp, "文 章 数:[\033[1;32m%d\033[m] 经 验 值:"
#ifdef SHOWEXP
            "%d(\033[1;33m%-10s\033[m)"
#else
            "[\033[1;33m%-10s\033[m]"
#endif
            " 生命力:[\033[1;32m%d\033[m] 网龄[\033[1;32m%d天\033[m]\n\n",
            user->numposts,
#ifdef SHOWEXP
            exp,
#endif
            cexpstr(exp), compute_user_value(user),
            (now - user->firstlogin) / 86400);
#endif
}
Example #2
0
int
bbsqry_main()
{
	FILE *fp;
	char userid[14], filename[80], buf[512];
	struct userec *x;
	int tmp2;
	struct in_addr in;
	html_header(1);
	check_msg();
	changemode(QUERY);
	strsncpy(userid, getparm("U"), 13);
	if (!userid[0])
		strsncpy(userid, getparm("userid"), 13);
	printf("<body><center>");
	printf("%s -- 查询网友<hr>\n", BBSNAME);
	if (userid[0] == 0) {
		printf("<form name=qry action=bbsqry>\n");
		printf
		    ("请输入用户名: <input name=userid maxlength=12 size=12>\n");
		printf("<input type=submit value=查询用户>\n");
		printf("</form><hr>\n");
		printf("<script>document.qry.userid.focus();</script>");
		http_quit();
	}
	if (getuser(userid, &x) <= 0) {
		printf("不可能,肯定是你敲错了,根本没这人啊");
		printf("<p><a href=javascript:history.go(-1)>快速返回</a>");
		http_quit();
	}
	printf("</center><pre>\n");
	if (x->mypic) {
		printf("<table align=left><tr><td><center>");
		printmypic(x->userid);
		printf("</center></td></tr></table>");
	}
	printf("<b><font size=+1>%s</font></b> (<font class=gre>%s</font>) "
	       "共上站 <font class=gre>%d</font> 次,"
	       "发表文章 <font class=gre>%d</font> 篇\n",
	       x->userid, x->username, x->numlogins, x->numposts);
//      show_special(x->userid);

	in.s_addr = x->lasthost & 0x0000ffff;
	printf
	    ("上次在 <font color=green>%s</font> 从 <font color=green>%s</font> 到本站一游。<br>",
	     Ctime(x->lastlogin), inet_ntoa(in));
	mails(userid, &tmp2);
	printf("信箱:[<font color=green>%s</font>],", tmp2 ? "⊙" : "  ");
	if (!strcasecmp(x->userid, currentuser->userid)) {
		printf
		    ("经验值:[<font color=green>%d</font>](<font color=olive>%s</font>) ",
		     countexp(x), cuserexp(countexp(x)));
		printf
		    ("表现值:[<font color=green>%d</font>](<font color=olive>%s</font>) ",
		     countperf(x), cperf(countperf(x)));
	}
	if (x->dieday) {
		printf
		    ("<br>已经离开了人世,呜呜...<br>还有 [<b>%d</b>] 天就要转世投胎了<br>",
		     countlife(x));
	} else {
		printf("生命力:[<font color=red>%d</font>]。<br>",
		       countlife(x));
		if (x->userlevel & PERM_BOARDS) {
			int i;
			printf("担任版务:");
			for (i = 0; i < MAXBOARD && i < shm_bcache->number; i++)
				bm_printboard(&shm_bcache->bcache[i],
					      x->userid);
			printf("<br>");
		}
		if (!show_onlinestate(userid)) {
			printf
			    ("目前不在站上, 上次离站时间 [<font color=blue>%s</font>]\n\n",
			     (x->lastlogout >=
			      x->lastlogin) ? Ctime(x->
						    lastlogout) :
			     "因在线上或不正常断线不详");
		}
	}
	printf("\n");
	printf("</pre><table width=100%%><tr><td>");
	sethomefile(filename, x->userid, "plans");
	fp = fopen(filename, "r");
	sprintf(filename, "00%s-plan", x->userid);
	fdisplay_attach(NULL, NULL, NULL, NULL);
	if (fp) {
		while (1) {
			if (fgets(buf, 256, fp) == 0)
				break;
			if (!strncmp(buf, "begin 644 ", 10)) {
				errlog("old attach %s", filename);
				fdisplay_attach(stdout, fp, buf, filename);
				continue;
			}
			fhhprintf(stdout, "%s", buf);
		}
		fclose(fp);
	} else {
		printf("<font color=teal>没有个人说明档</font><br>");
	}

	printf("</td></tr></table>");
	printf
	    ("<br><br><a href=bbspstmail?userid=%s&title=没主题>[书灯絮语]</a> ",
	     x->userid);
	printf("<a href=bbssendmsg?destid=%s>[发送讯息]</a> ", x->userid);
	printf("<a href=bbsfadd?userid=%s>[加入好友]</a> ", x->userid);
	printf("<a href=bbsfdel?userid=%s>[删除好友]</a> ", x->userid);
	if (x->userlevel & PERM_SPECIAL8) {
		printf
		    ("<a href=bbs0an?path=/groups/GROUP_0/Personal_Corpus/%c/%s>[个人文集]</a> ",
		     mytoupper(x->userid[0]), x->userid);
	}
	sethomefile(filename, x->userid, "B/config");
	if (file_isfile(filename)) {
		printf
		    ("<a href=blog?U=%s>[Blog]</a>", x->userid);
	}
	printf("<hr>");
	printf("<center><form name=qry action=bbsqry>\n");
	printf("请输入用户名: <input name=userid maxlength=12 size=12>\n");
	printf("<input type=submit value=查询用户>\n");
	printf("</form><hr>\n");
	printf("</body>\n");
	http_quit();
	return 0;
}
Example #3
0
int
apiqry_main()
{
	FILE *fp;
	char userid[14], filename[80], buf[512], output[4096],output_utf8[4096];
	struct userec *x;
	struct user_info *u;
	int i, tmp2, num;
	json_header();
//	changemode(QUERY);
	strsncpy(userid, getparm("U"), 13);
	if (!userid[0])
		strsncpy(userid,getparm("userid"), 13);
	if (userid[0] == '\0')
	{
		printf("{\"User\":null}");
		return 0;
	}
	x = getuser(userid);
	if (x == 0)
	{
		printf("{\"User\":null}");
		return 0;
	}
	// ��ʼ����û�����
	sstrcat(output, "{\"User\":{");
	// ��ʾ��������
	sstrcat(output, "\"UserID\":\"%s\",\"UserNickName\":\"%s\",\"LoginCounts\":%d,\"PostCounts\":%d,\"LastLogin\":\"%s\",\"LastHost\":\"%s\",", x->userid, x->username, x->numlogins, x->numposts,Ctime(x->lastlogin), x->lasthost);
	// ��ʾ��������
	if(!strcasecmp(x->userid, currentuser.userid)){
		sstrcat(output, "\"Exp\":%d,\"ExpLevel\":\"%s\",\"Perf\":%d,\"PerfLevel\":\"%s\"",countexp(x), cexp(countexp(x)), countperf(x), cperf(countperf(x)));
	}
	// ��ʾ����վ�����Ϣ
	if(x->userlevel & PERM_BOARDS)
	{
		sstrcat(output, "\"BOARDBM\":[");
		sethomefile(filename, x->userid, "mboard");
		new_apply_record(filename, sizeof(struct boardmanager), (void *)bm_printboardapi, output);
		sstrcat(output, "],");
	}
	if((x->userlevel & PERM_SYSOP) && (x->userlevel&PERM_ARBITRATE))
		sstrcat(output, "\"Job\":\"��վ������\",");
	else if(x->userlevel & PERM_SYSOP)
		sstrcat(output, "\"Job\":\"����վ��\",");
	else if(x->userlevel & PERM_OBOARDS)
		sstrcat(output, "\"Job\":\"ʵϰվ��\",");
	else if(x->userlevel & PERM_ARBITRATE)
		sstrcat(output, "\"Job\":\"���μ�ί\",");
	else if(x->userlevel & PERM_SPECIAL4)
		sstrcat(output, "\"Job\":\"����\",");
	else if(x->userlevel & PERM_WELCOME)
		sstrcat(output, "\"Job\":\"ϵͳ����\",");
	else if(x->userlevel & PERM_SPECIAL7)
	{
		if((x->userlevel & PERM_SPECIAL1) && !(x->userlevel & PERM_CLOAK))
			sstrcat(output, "\"Job\":\"���γ���Ա\",");
		else
			sstrcat(output, "\"Job\":\"�������Ա\",");
	}
	else if(x->userlevel & PERM_ACCOUNTS)
		sstrcat(output, "\"Job\":\"�ʺŹ���Ա\",");
		
	// ��ʾ��ǰ״̬��null ���� array
	num = 0;
	sstrcat(output, "\"States\":");
	for (i=0; i<MAXACTIVE; ++i)
	{
		u = &(shm_utmp->uinfo[i]);
		if(!strcmp(u->userid, x->userid))
		{
			if(u->active == 0 || u->pid ==0 || (u->invisible && !HAS_PERM(PERM_SEECLOAK)))
				continue;
			++num;
			if(num == 1)
				sstrcat(output, "[");
			if(u->mode != USERDF4){
				if(u->invisible)
					sstrcat(output, "\"C%s\"", ModeType(u->mode));
				else
					sstrcat(output, "\"%s\"", ModeType(u->mode));
			}
			else
				// �Զ���״̬
				sstrcat(output, "%s", u->user_state_temp);
		}
		if( (num>0) && (i == MAXACTIVE - 1))
			sstrcat(output, "],");
	}
	if (num == 0 )
	{
		sstrcat(output, "\"null\",");
		if( x->lastlogout != NULL )
			sstrcat(output, "\"LastLogout\":\"%s\",",Ctime(x->lastlogout));
		else
			sstrcat(output, "\"LastLogout\":null,");
	}
		
	
	// ��ʾ˵����
	sethomefile(filename,x->userid,"plans");
	fp = fopen(filename, "r");
	sprintf(filename, "00%s-plan", x->userid);
	if (fp) {
		sstrcat(output, "\"PersonalIntro\":\""); // ��ʼ����˵����
		while(1){
			if(fgets(buf,256,fp) == 0)
				break;
			if (buf[strlen(buf) - 1] == '\n'){
				int currentlength;
				currentlength = strlen(buf);
				buf[currentlength - 1] = '\\';
				buf[currentlength] = 'n';
				buf[currentlength + 1] = 0;
			}
			if(!strncmp(buf,"bigin 644",10)){
				// errlog()
				// fdisplay_attach()
			}
			sstrcat(output, "%s", buf);
		}
		sstrcat(output, "\","); // ��������˵����
		fclose(fp);
	}
	else //û�и���˵����
		sstrcat(output, "\"PersonalIntro\":null,");
		
	// ��ʾ�����ǩ
	show_special_api(x->userid, output);
	// �������
	sstrcat(output, "}}"); 
	g2u(output,sizeof(output), output_utf8,sizeof(output_utf8));
	printf("%s", output_utf8);
	//http_quit();
	return 0;
}
Example #4
0
int
bbsqry_main()
{
	FILE *fp;
	char userid[14], filename[80], buf[512];
	struct userec *x;
	struct user_info *u;
	int i, tmp2, num;
	html_header(1);
	check_msg();
	changemode(QUERY);
	strsncpy(userid, getparm("U"), 13);
	if (!userid[0])
		strsncpy(userid, getparm("userid"), 13);
	printf("<body><center>");
	printf("<div class=rhead>%s -- ��ѯ����</div><hr>\n", BBSNAME);
	if (userid[0] == 0) {
		printf("<form action=bbsqry>\n");
		printf
		    ("�������û���: <input name=userid maxlength=12 size=12>\n");
		printf("<input type=submit value=��ѯ�û�>\n");
		printf("</form><hr>\n");
		http_quit();
	}
	x = getuser(userid);
	if (x == 0) {
		int i, j = 0;
		printf("û������û������ѵ�����Щ:<p>");
		printf("<table width=600>");
		for (i = 0; i < shm_ucache->number; i++)
			if (strcasestr(shm_ucache->userid[i], userid) ==
			    shm_ucache->userid[i]) {
				j++;
				if (j % 6 == 1)
					printf("<tr>");
				printf("<td>");
				printf("<a href=bbsqry?userid=%s>%s</a>",
				       shm_ucache->userid[i],
				       shm_ucache->userid[i]);
				printf("</td>");
				sprintf(buf, "bbsqry?userid=%s",
					shm_ucache->userid[i]);
				if (j % 6 == 0)
					printf("</tr>");
				if (j >= 12 * 6)
					break;
			}
		printf("</table>");
		if (!j)
			printf("�����ܣ��϶������ô��ˣ�����û���˰�");
		if (j == 1)
			redirect(buf);
		printf("<p><a href=javascript:history.go(-1)>���ٷ���</a>");
		http_quit();
	}
	printf("</center><pre style='font-size:14px'>\n");
	sprintf(buf,
		"%s (%s) ����վ %d �Σ��������� %d ƪ",
		x->userid, x->username, x->numlogins, x->numposts);
	hprintf("%s", buf);
	show_special_web(x->userid);//add by wjbta@bmy  ����id��ʶ
	printf("\n");
	hprintf("�ϴ��� [%s] �� [%s] ����վһ�Ρ�\n",
		Ctime(x->lastlogin), x->lasthost);
	mails(userid, &tmp2);
	hprintf("���䣺[%s]��", tmp2 ? "��" : "  ");
	if (!strcasecmp(x->userid, currentuser.userid)) {
		hprintf("����ֵ��[%d](%s) ", countexp(x),
			cexp(countexp(x)));
		hprintf("����ֵ��[%d](%s) ", countperf(x),
			cperf(countperf(x)));
	}
	hprintf("��������[%d]��\n", count_life_value(x));
	if (x->userlevel & PERM_BOARDS) {
		hprintf("�����");
		sethomefile(filename, x->userid, "mboard");
		new_apply_record(filename, sizeof (struct boardmanager),
				 (void *) bm_printboard, NULL);
		if (x->userlevel & !strcmp(x->userid, "SYSOP")) hprintf("[ϵͳ����Ա]");
		else if (x->userlevel & !strcmp(x->userid, "lanboy")) hprintf("[ϵͳ����Ա]");
		else if ((x->userlevel&PERM_SYSOP) && (x->userlevel&PERM_ARBITRATE) )	hprintf("[��վ������]");
		else if (x->userlevel & PERM_SYSOP)	hprintf("[����վ��]");
		else if (x->userlevel & PERM_OBOARDS)   hprintf("[ʵϰվ��]");
		else if (x->userlevel & PERM_ARBITRATE)	hprintf("[���μ�ί]");
		else if (x->userlevel & PERM_SPECIAL4)	hprintf("[����]");
		else if (x->userlevel & PERM_WELCOME) hprintf("[ϵͳ����]");
		else if (x->userlevel & PERM_SPECIAL7)
		{
		if ( (x->userlevel & PERM_SPECIAL1) && !(x->userlevel & PERM_CLOAK) ) 
		hprintf("[���γ���Ա]");		
		else		
		hprintf("[�������Ա]");
		}
		else if (x->userlevel & PERM_ACCOUNTS) hprintf ("[�ʺŹ���Ա]"); 
		hprintf("\n");
	}
	num = 0;
	for (i = 0; i < MAXACTIVE; i++) {
		u = &(shm_utmp->uinfo[i]);
		if (!strcmp(u->userid, x->userid)) {
			if (u->active == 0 || u->pid == 0
			    || (u->invisible && !HAS_PERM(PERM_SEECLOAK)))
				continue;
			num++;
			if (num == 1)
				hprintf("Ŀǰ��վ��, ״̬����:\n");
			if (u->invisible)
				hprintf("C");
			if (u->mode != USERDF4)
			  hprintf("\033[%dm%s ", u->pid == 1 ? 35 : 32,
				ModeType(u->mode));
			else							/* �Զ���״̬ */
			  hprintf("\033[%dm%s ", u->pid == 1 ? 35 : 32,
				u->user_state_temp);
			if (num % 5 == 0)
				printf("\n");
		}
	}
	if (num == 0) {
		hprintf("Ŀǰ����վ��, �ϴ���վʱ�� [%s]\n\n",
			x->lastlogout ? Ctime(x->lastlogout) :
			"�������ϻ��������߲���");
	}
	printf("\n");
	printf("</pre><table width=100%%><tr><td class=f2>");
	sethomefile(filename, x->userid, "plans");
	fp = fopen(filename, "r");
	sprintf(filename, "00%s-plan", x->userid);
	fdisplay_attach(NULL, NULL, NULL, NULL);
	if (fp) {
		while (1) {
			if (fgets(buf, 256, fp) == 0)
				break;
			if (!strncmp(buf, "begin 644 ", 10)) {
				errlog("old attach %s", filename);
				fdisplay_attach(stdout, fp, buf, filename);
				continue;
			}
			fhhprintf(stdout, "%s", buf);
		}
		fclose(fp);
	} else {
		hprintf("û�и���˵����\n");
	}
	printf("</td></tr></table>");
	printf
	    ("<br><br><a href=bbspstmail?userid=%s&title=û����>[�������]</a> ",
	     x->userid);
	printf("<a href=bbssendmsg?destid=%s>[����ѶϢ]</a> ", x->userid);
	printf("<a href=bbsfadd?userid=%s>[�������]</a> ", x->userid);
	printf("<a href=bbsfdel?userid=%s>[ɾ������]</a>", x->userid);
	printf("<hr>");
	printf("<center><form action=bbsqry>\n");
	printf("�������û���: <input name=userid maxlength=12 size=12>\n");
	printf("<input type=submit value=��ѯ�û�>\n");
	printf("</form><hr>\n");
	printf("</body>\n");
	http_quit();
	return 0;
}
Example #5
0
void disply_userinfo( struct userec *u )
{
	int     num, exp;
	char		buf[80];
	//#ifdef REG_EXPIRED
	time_t  now;
#ifndef AUTOGETPERM
	//#endif
#endif

	move(2, 0);
	clrtobot();
	now = time (0);
	set_safe_record();
//	prints("���Ĵ���     : %-14s", u->userid);
//	prints("���Ĵ���     : \033[%dm%-14s\033[37m%", GetAuthUserDispColor(u->userid),u->userid);
	prints("���Ĵ���     : ");
	PrintColorUser(u->userid);
	prints("\033[37m");
	prints("     �dz� : %-20s", u->username);
	prints("     �Ա� : %s", (u->gender == 'M' ? "��" : "Ů"));
	prints("\n��ʵ����     : %-40s", u->realname);
	prints("  �������� : %d/%d/%d",
	       u->birthmonth, u->birthday, u->birthyear + 1900);
	prints("\n��ססַ     : %-38s", u->address);
	{
		int tyear,tmonth,tday;
		tyear = u->birthyear+1900;
		tmonth = u->birthmonth;
		tday = u->birthday;
		countdays(&tyear,&tmonth,&tday,now);
		prints("�ۼ��������� : %d\n",abs(tyear));
	}
	prints("�����ʼ����� : %s\n", u->email);
	prints("��ʵ E-mail  : %s\n", u->reginfo);
	if HAS_PERM (PERM_ADMINMENU)
		prints("Ident ����   : %s\n", u->ident);
	prints("������ٻ��� : %-22s", u->lasthost);
	prints("�ն˻���̬ : %s\n", u->termtype);
	getdatestring(u->firstlogin,NA);
	prints("�ʺŽ������� : %s[��� %d ��]\n",
	       datestring,(now-(u->firstlogin))/86400);
	getdatestring(u->lastlogin,NA);
	prints("����������� : %s[��� %d ��]\n",
	       datestring,(now-(u->lastlogin))/86400);
#ifndef AUTOGETPERM
	/*#ifndef REG_EXPIRED
	   getdatestring(u->lastjustify,NA);
	   prints("���ȷ������ : %s\n",(u->lastjustify==0)? "δ��ע��" :datestring);
	#else
	   if(u->lastjustify == 0) prints("���ȷ��     : δ��ע��\n");
	   else {
	      prints("���ȷ��     : ����ɣ���Ч����: ");
	      nextreg = u->lastjustify + REG_EXPIRED * 86400;
	      getdatestring(nextreg,NA);
	      sprintf(genbuf,"%14.14s[%s]������ %d ��\n", 
	         datestring ,datestring+23,(nextreg - now) / 86400);
	      prints(genbuf);
	   }      
	#endif*/
#endif
#ifdef ALLOWGAME

	prints("������Ŀ     : %-20d ������Ŀ : %d\n",u->numposts,u->nummedals);
	prints("˽������     : %d ��\n", u->nummails);
	prints("������д�� : %dԪ  ���� : %dԪ (%s)\n",
	       u->money,u->bet,cmoney(u->money-u->bet));
#else

	prints("������Ŀ     : %-20d \n", u->numposts);
	
#ifdef ALLOW_MEDALS
	
	int sum = 0;
	int i;
	for(i = 1; i <= 7; i++){
		sum += (u -> nummedals >> (i << 2)) & 0x0f;
	}
	
	prints ("������Ŀ     : %d\n", sum);
#endif

	prints("˽������     : %d �� \n", u->nummails);
#endif

	prints("��վ����     : %d ��      ", u->numlogins);
	prints("��վ��ʱ��   : %d Сʱ %d ����\n",u->stay/3600,(u->stay/60)%60);
	exp = countexp(u);
	prints("����ֵ       : %d  (%s)    ", exp, cexp(exp));
	exp = countperf(u);
	prints("����ֵ : %d  (%s)\n", exp, cperf(exp));
	strcpy(genbuf, "bTCPRD#@XWBA#VS-DOM-F0s2345678");
	for (num = 0; num < strlen(genbuf) ; num++)
		if (!(u->userlevel & (1 << num)))
			genbuf[num] = '-';
	prints("ʹ����Ȩ��   : %s\n", genbuf);
	prints("\n");
	if (u->userlevel & PERM_SYSOP)
	{
		prints("  ���DZ�վ��վ��, ��л���������Ͷ�.\n");
	}
	else if (u->userlevel & PERM_BOARDS)
	{
		prints("  ���DZ�վ�İ���, ��л���ĸ���.\n");
	}
	else if (u->userlevel & PERM_LOGINOK)
	{
		prints("  ����ע������Ѿ����, ��ӭ���뱾վ.\n");
	}
	else if (u->lastlogin - u->firstlogin < 3 * 86400)
	{
		prints("  ������·, ���Ķ� BBSHelp ������.\n");
	}
	else
	{
		prints("  ע����δ�ɹ�, ��ο���վ��վ����˵��.\n");
	}
	if(HAS_PERM(PERM_LOOKADMIN))
	{
		sprintf(buf, "ADMINQuery '%s'", u->userid);
		report(buf);
	}
	/*  added report for all users */
	else	//if(HAS_PERM(PERM_LOOKADMIN))
	{
		sprintf(buf, "ADMINQuery2 '%s'", u->userid);
		report(buf);
	}

}
Example #6
0
File: talk.c Project: icewwn/fbbs-1
int tui_query_result(const char *userid)
{
	struct userec user;
	int unum = getuserec(userid, &user);
	if (!unum)
		return -1;

	screen_move(0, 0);
	screen_clrtobot();

	int color = 2;
	if (HAS_DEFINE(user.userdefine, DEF_COLOREDSEX))
		color = (user.gender == 'F') ? 5 : 6;
	char horo[32] = "";
	if (HAS_DEFINE(user.userdefine, DEF_S_HOROSCOPE)
			&& strcasecmp(user.userid, "guest") != 0) {
		snprintf(horo, sizeof(horo), "[\033[1;3%dm%s\033[m] ",
				color, horoscope(user.birthmonth, user.birthday));
	}
	//% prints("\033[0;1;37m%s \033[m(\033[1;33m%s\033[m) 共上站 \033[1;32m%d\033[m "
	prints("\033[0;1;37m%s \033[m(\033[1;33m%s\033[m) \xb9\xb2\xc9\xcf\xd5\xbe \033[1;32m%d\033[m "
			//% "次  %s\n", user.userid, user.username, user.numlogins, horo);
			"\xb4\xce  %s\n", user.userid, user.username, user.numlogins, horo);

	bool self = !strcmp(currentuser.userid, user.userid);
	const char *host;
	if (user.lasthost[0] == '\0') {
		//% host = "(不详)";
		host = "(\xb2\xbb\xcf\xea)";
	} else {
		if (self || HAS_PERM2(PERM_OCHAT, &currentuser))
			host = user.lasthost;
		else 
			host = mask_host(user.lasthost);
	}
	//% prints("进站 [\033[1;32m%s\033[m] %s[\033[1;32m%s\033[m]\n",
	prints("\xbd\xf8\xd5\xbe [\033[1;32m%s\033[m] %s[\033[1;32m%s\033[m]\n",
			format_time(user.lastlogin, TIME_FORMAT_ZH),
			//% strlen(host) > IPADDR_OMIT_THRES ? "" : "来自 ", host);
			strlen(host) > IPADDR_OMIT_THRES ? "" : "\xc0\xb4\xd7\xd4 ", host);

	user_id_t uid = get_user_id(userid);
	session_basic_info_t *res = get_sessions(uid);

	bool any_session_visible = false;
	for (int i = 0; i < (res ? session_basic_info_count(res) : 0); ++i) {
		if (HAS_PERM(PERM_SEECLOAK) || session_basic_info_visible(res, i)) {
			any_session_visible = true;
			break;
		}
	}

	if (any_session_visible) {
		//% prints("在线 [\033[1;32m讯息器:(\033[36m%s\033[32m)\033[m] ",
		prints("\xd4\xda\xcf\xdf [\033[1;32m\xd1\xb6\xcf\xa2\xc6\xf7:(\033[36m%s\033[32m)\033[m] ",
				//% "打开");
				"\xb4\xf2\xbf\xaa");
	} else {
		fb_time_t t = user.lastlogout;
		if (user.lastlogout < user.lastlogin)
			t = ((fb_time() - user.lastlogin) / 120) % 47 + 1 + user.lastlogin;
		//% prints("离站 [\033[1;32m%s\033[m] ", format_time(t, TIME_FORMAT_ZH));
		prints("\xc0\xeb\xd5\xbe [\033[1;32m%s\033[m] ", format_time(t, TIME_FORMAT_ZH));
	}

	char path[HOMELEN];
	snprintf(path, sizeof(path), "mail/%c/%s/%s",
			toupper(user.userid[0]), user.userid, DOT_DIR);
	int perf = countperf(&user);
	//% prints("表现值 "
	prints("\xb1\xed\xcf\xd6\xd6\xb5 "
#ifdef SHOW_PERF
			"%d(\033[1;33m%s\033[m)"
#else
			"[\033[1;33m%s\033[m]"
#endif
			//% " 信箱 [\033[1;5;32m%2s\033[m]\n"
			" \xd0\xc5\xcf\xe4 [\033[1;5;32m%2s\033[m]\n"
#ifdef SHOW_PERF
			, perf
#endif
			//% , cperf(perf), (check_query_mail(path) == 1) ? "信" : "  ");
			, cperf(perf), (check_query_mail(path) == 1) ? "\xd0\xc5" : "  ");

	int exp = countexp(&user);

	uinfo_t u;
	uinfo_load(user.userid, &u);

#ifdef ENABLE_BANK
	//% prints("贡献 [\033[1;32m%d\033[m", TO_YUAN_INT(u.contrib));
	prints("\xb9\xb1\xcf\xd7 [\033[1;32m%d\033[m", TO_YUAN_INT(u.contrib));
	if (self || HAS_PERM2(PERM_OCHAT, &currentuser)) {
		prints("/\033[1;33m%d\033[m", TO_YUAN_INT(u.money));
	}
	{
		char rank_buf[8];
		snprintf(rank_buf, sizeof(rank_buf), "%.1f%%", PERCENT_RANK(u.rank));
		prints("](%s) ", rank_buf);
	}

#endif

#ifdef ALLOWGAME
	//% prints("存贷款 [\033[1;32m%d\033[m/\033[1;32m%d\033[m]"
	prints("\xb4\xe6\xb4\xfb\xbf\xee [\033[1;32m%d\033[m/\033[1;32m%d\033[m]"
			//% "(\033[1;33m%s\033[m) 经验值 [\033[1;32m%d\033[m]\n",
			"(\033[1;33m%s\033[m) \xbe\xad\xd1\xe9\xd6\xb5 [\033[1;32m%d\033[m]\n",
			user.money, user.bet, cmoney(user.money - user.bet), exp);
	//% prints("发文 [\033[1;32m%d\033[m] 奖章 [\033[1;32m%d\033[m]"
	prints("\xb7\xa2\xce\xc4 [\033[1;32m%d\033[m] \xbd\xb1\xd5\xc2 [\033[1;32m%d\033[m]"
			//% "(\033[1;33m%s\033[m) 生命力 [\033[1;32m%d\033[m]\n",
			"(\033[1;33m%s\033[m) \xc9\xfa\xc3\xfc\xc1\xa6 [\033[1;32m%d\033[m]\n",
			user.numposts, user.nummedals, cnummedals(user.nummedals),
			compute_user_value(&user));
#else
	//% prints("发文 [\033[1;32m%d\033[m] ", user.numposts);
	prints("\xb7\xa2\xce\xc4 [\033[1;32m%d\033[m] ", user.numposts);
	//% prints("经验值 [\033[1;33m%-10s\033[m]", cexpstr(exp));
	prints("\xbe\xad\xd1\xe9\xd6\xb5 [\033[1;33m%-10s\033[m]", cexpstr(exp));
#ifdef SHOWEXP
	prints("(%d)", exp);
#endif
	//% prints(" 生命力 [\033[1;32m%d\033[m]\n", compute_user_value(&user));
	prints(" \xc9\xfa\xc3\xfc\xc1\xa6 [\033[1;32m%d\033[m]\n", compute_user_value(&user));
#endif

	char buf[160];
	show_position(&user, buf, sizeof(buf), u.title);
	//% prints("身份 %s\n", buf);
	prints("\xc9\xed\xb7\xdd %s\n", buf);
	
	uinfo_free(&u);

	if (any_session_visible)
		show_statuses(res);
	session_basic_info_clear(res);

	show_user_plan(userid);
	return 0;
}