Example #1
0
int
bbsmsg_main()
{	//modify by mintbaggio 20040829 for new www
	char buf[MAX_MSG_SIZE];
	char msgbuf[MAX_MSG_SIZE*2];
	int count, i;
	struct msghead head;
	html_header(1);
	check_msg();
	printf("<body>");
	printf("<div class=rhead>%s -- 查看信息</div><hr>\n", BBSNAME);
	if (!loginok || isguest)
		http_fatal("匆匆过客无法查看讯息, 请先登录");
	changemode(LOOKMSGS);
	count =  get_msgcount(0, currentuser.userid);
	if (count == 0)
		http_fatal("没有任何讯息");
	for (i=0; i<count; i++) {
                        load_msghead(0, currentuser.userid, &head, i);
                        load_msgtext(currentuser.userid, &head, buf);
			translate_msg(buf, &head, msgbuf, 0);
		hprintf("%s", msgbuf);
	}
	u_info->unreadmsg = 0;
        printf("<a onclick='return confirm(\"你真的要清除所有讯息吗?\")' href=bbsdelmsg>清除所有讯息</a> ");
	printf("<a href=bbsmailmsg>寄回所有信息</a>");
	http_quit();
	return 0;
}
Example #2
0
File: chat.c Project: wyat/kbs
/*
 2001/5/6  modified by wwj
 聊天室看msg的函数
 */
void chat_show_allmsgs(chatcontext * pthis, const char *arg)
{
    char fname[STRLEN];
    FILE *fp;
    char buf[MAX_MSG_SIZE], showmsg[MAX_MSG_SIZE*2];
    int line, cnt, i, j=0, count;
    struct msghead head;

    line = atoi(arg);
    if (line < screen_lines - 1)
        line = screen_lines - 1;
    if (line > 300)
        line = 300;
    gettmpfilename(fname, "chatmsg");
    //sprintf(fname, "tmp/%s.msg", getCurrentUser()->userid);
    fp = fopen(fname, "w");
    count = get_msgcount(0, getCurrentUser()->userid);
    for (i=0;i<count;i++)
        if (i>=count-line) {
            j++;
            load_msghead(0, getCurrentUser()->userid, i, &head);
            load_msgtext(getCurrentUser()->userid, &head, buf);
            translate_msg(buf, &head, showmsg,getSession());
            fprintf(fp, "%s", showmsg);
        }
    fclose(fp);
    if (count) {
        fp = fopen(fname, "rb");
        sprintf(buf, "【最近 %d 条消息】", j);
        printchatline(pthis, buf);
        while (!feof(fp)) {
            bzero(buf, sizeof(buf));
            fgets(buf, sizeof(buf), fp);
            if (!buf[0])
                break;
            cnt = strlen(buf) - 1;
            buf[cnt] = 0;       /* delete \n */
            printchatline(pthis, buf);
        }
        fclose(fp);
    } else {
        printchatline(pthis, "***** 没有任何的讯息存在!!*****");
    }
    unlink(fname);
}