示例#1
0
文件: bbsmsg.c 项目: bmybbs/bmybbs
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;
}
示例#2
0
int
bbsgetmsg_main()
{
    char buf[MAX_MSG_SIZE], msg[MAX_MSG_SIZE * 50];
//      static int r = 0;
    int count, line;
    struct msghead head;
    html_header(11);
    if (!loginok || isguest) {
        printf
        ("<body topmargin=1 MARGINHEIGHT=1><script>top.document.getElementById('fs1').rows=\"2, *, 15\";</script>\n</html>\n");
        return 0;
    }
    if (u_info->unreadmsg > 0) {
        count = get_unreadmsg(currentuser.userid);
        if (count == -1 || count == 0)
            goto outthere;
        if (currentuser.userdefine & DEF_SOUNDMSG)
            printf("<bgsound src=/msg.wav>\n");
        load_msghead(1, currentuser.userid, &head, count);
        load_msgtext(currentuser.userid, &head, buf);
        line = translate_msg(buf, &head, msg, 0);
        printf
        ("<body topmargin=1 MARGINHEIGHT=1 style='BACKGROUND-COLOR: #f0ffd0'>\n");
        printf
        ("<script>top.document.getElementById('fs1').rows=\"%d, *, 15\";</script>\n",
         (line + 11) * 16 + 32);
        emotion_print(msg);
        printf("<form name=form0 action=bbssendmsg method=post>\n"
               "<input type=hidden name=dr value=1>\n"
               "<input type=hidden name=destpid value=%d>\n"
               "<input type=hidden name=destid value='%s'>\n",
               head.frompid, head.id);
        printf("在下面直接回复讯息或 \n");
        printf("<a href=bbsgetmsg>[忽略该消息]</a><br>\n");
        printf("<table><tr><td>\n");
        printf("<textarea name=msg rows=5 cols=76>"
               "</textarea><br>\n");
        printf("</td><td>\n");
        print_emote_table("form0", "msg");
        printf("</td></tr></table><br>\n");
        printf("<input type=submit value=确认 width=6></form>\n");
        u_info->unreadmsg--;
        http_quit();
    }
outthere:
    u_info->unreadmsg = 0;
    printf
    ("<body topmargin=1 MARGINHEIGHT=1><script>top.document.getElementById('fs1').rows=\"2, *, 15\";</script>");
//      printf("<script>function t(){return (new Date()).valueOf();}</script>");
//      printf("<script>setTimeout('self.location.replace(\"bbsgetmsg?sn='+t()+'\")', %d);</script>", 235000+r * 1000);
//      r = (r + now_t + u_info->uid) % 10;
    printf("</body>");
    http_quit();
    return 0;
}
示例#3
0
文件: chat.c 项目: 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);
}