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; }
int bbssendmsg_main() { int pos, mode, destpid = 0; int usernum, direct_reply; char destid[20], msg[MAX_MSG_SIZE]; struct userec *u; struct user_info *ui; int offline = 0; html_header(1); changemode(MSG); if (!loginok || isguest) http_fatal("匆匆过客不能发短消息, 请先登录!"); strsncpy(destid, getparm("destid"), 13); strsncpy(msg, getparm("msg"), MAX_MSG_SIZE); direct_reply = atoi(getparm("dr")); destpid = atoi(getparm("destpid")); if (destid[0] == 0 || msg[0] == 0) { char buf3[256]; strcpy(buf3, "<body onload='document.form0.msg.focus()'>"); if (destid[0] == 0) strcpy(buf3, "<body onload='document.form0.destid.focus()'>"); printf("%s\n", buf3); printf("<form name=form0 action=bbssendmsg method=post>" "<input type=hidden name=destpid value=%d>" "送短消息给: <input name=destid maxlength=12 value='%s' size=12><br>" "短消息内容:\n<br>", destpid, destid); printf("<table><tr><td><textarea name=msg rows=7 cols=76>" "%s" "</textarea></td><td>", nohtml(void1(msg))); print_emote_table("form0", "msg"); printf("</td></tr></table><br>" "<input type=submit value=确认 width=6></form>"); http_quit(); } if (checkmsgbuf(msg)) http_fatal("消息太长了?最多11行(每行最多80个字符)哦"); usernum = getuser(destid, &u); if (usernum <= 0) http_fatal("错误的帐号"); strcpy(destid, u->userid); if (!strcasecmp(destid, currentuser->userid)) http_fatal("你不能给自己发短消息!"); if (!strcasecmp(destid, "guest") || !strcmp(destid, "SYSOP")) http_fatal("无法发短消息给这个人 1"); if (!((u->userdefine & DEF_ALLMSG) || ((u->userdefine & DEF_FRIENDMSG) && inoverride(currentuser->userid, destid, "friends")))) http_fatal("无法发短消息给这个人 2"); if (!strcmp(destid, "SYSOP")) http_fatal("无法发短消息给这个人 3"); if (inoverride(currentuser->userid, destid, "rejects")) http_fatal("无法发短消息给这个人 4"); if (get_unreadcount(destid) > MAXMESSAGE) http_fatal ("对方尚有一些短消息未处理,请稍候再发或给他(她)写信..."); printf("<body>\n"); ui = queryUIndex(usernum, NULL, destpid, &pos); if (ui == NULL) ui = queryUIndex(usernum, NULL, 0, &pos); if (ui != NULL) { destpid = ui->pid; mode = ui->mode; if (mode == BBSNET || mode == PAGE || mode == LOCKSCREEN) offline = 1; if (send_msg(currentuser->userid, pos - 1, destid, destpid, msg, offline) == 1) { char buf[64]; sprintf(buf, "4 %s %s", currentuser->userid, destid); friendslog(buf); printf("已经帮你送出%s消息, %d", offline ? "离线" : "", pos); } else printf("发送消息失败"); printf("<script>top.fmsg.location='bbsgetmsg'</script>\n"); if (!direct_reply) { printf ("<br><form name=form1><input name=b1 type=button onclick='history.go(-2)' value='[返回]'>"); printf("</form>"); } http_quit(); } if (send_msg(currentuser->userid, 0,destid, destpid, msg, 1) == 1) printf("已经帮你送出离线消息"); else printf("发送消息失败"); printf("<script>top.fmsg.location='bbsgetmsg'</script>\n"); if (!direct_reply) { printf ("<br><form name=form1><input name=b1 type=button onclick='history.go(-2)' value='[返回]'>"); printf("</form>"); } http_quit(); return 0; }