void chat_sendmsg(chatcontext * pthis, const char *arg) { /* send msg in chatroom , by alex, 96.9.5 */ char userid[IDLEN + 1]; char msg[STRLEN * 2]; struct user_info *uin; int state; nextword(&arg, userid, sizeof(userid)); if (!userid[0]) { printchatline(pthis, "\x1b[37m*** \x1b[32m请输入你要发消息的 ID\x1b[37m ***\x1b[m"); return; } else if (!*arg) { printchatline(pthis, "\x1b[37m*** \x1b[32m请输入你要发的消息\x1b[37m ***\x1b[m"); return; } else if (!HAS_PERM(getCurrentUser(), PERM_PAGE)) { /* Leeward 98.07.30 */ sprintf(msg, "\x1b[32m你没有发信息的权限\x1b[m"); } else { uin = t_search(userid, false); if (uin == NULL) { sprintf(msg, "\x1b[32m%s\x1b[37m 并没有上站\x1b[m", userid); } else if (LOCKSCREEN == uin->mode) /* Leeward 98.02.28 */ sprintf(msg, "\x1b[32m%s\x1b[37m已经锁定屏幕,请稍候再发或给他(她)写信.\n", uin->userid); else { if (!canmsg(getCurrentUser(), uin)) sprintf(msg, "\x1b[32m%s\x1b[37m已经关闭接受讯息的呼叫器.\n", uin->userid); else if (false == canIsend2(getCurrentUser(),uin->userid)) sprintf(msg, "\x1b[32m%s\x1b[37m拒绝接受你的讯息.\n", uin->userid); /*Haohmaru.99.6.6,检查是否被ignore */ else { if (get_unreadcount(uin->userid) > MAXMESSAGE) sprintf(msg, "对方尚有一些讯息未处理,请稍候再发或给他(她)写信...\n"); else { /* 保存所发msg的目的uid 1998.7.5 by dong */ strcpy(getSession()->MsgDesUid, uin->userid); state = do_sendmsg(uin, arg, 2); if (state == 1) sprintf(msg, "\x1b[37m已经发消息给 \x1b[32m%s\x1b[37m 了\x1b[m", uin->userid); else if (state == -2) sprintf(msg, "\x1b[37m对方已经离线了...\x1b[m"); else sprintf(msg, "\033[37对方不接受你的消息...\033[m"); } } } } printchatline(pthis, msg); }
void call_user(chatcontext * pthis, const char *arg) { /* invite user online to chatroom */ char msg[STRLEN * 2]; struct user_info *uin; int state; if (!*arg) { printchatline(pthis, "\033[37m*** \033[32m请输入你要邀请的 ID\033[37m ***\033[m"); return; } if (!strcasecmp(arg, getCurrentUser()->userid)) sprintf(msg, "\033[32m你不用邀请自己啊\033[m"); else if (!HAS_PERM(getCurrentUser(), PERM_PAGE)) /* Leeward 98.07.30 */ sprintf(msg, "\033[32m你没有发信息的权限\033[m"); else { uin = t_search(arg, false); if (uin == NULL) sprintf(msg, "\033[32m%s\033[37m 并没有上站\033[m", arg); else if (LOCKSCREEN == uin->mode) /* Leeward 98.02.28 */ sprintf(msg, "\033[32m%s\033[37m已经锁定屏幕,请稍候再邀请或给他(她)写信.\n", uin->userid); else if (!canmsg(getCurrentUser(), uin)) sprintf(msg, "%s 已经关闭接受讯息的呼叫器.\n", uin->userid); else { if (get_unreadcount(uin->userid) > MAXMESSAGE) sprintf(msg, "对方尚有一些讯息未处理,请稍候再邀请或给他(她)写信...\n"); else { sprintf(msg, "到聊天广场的 %s 聊天室 聊聊天", pthis->chatroom); /* 保存所发msg的目的uid 1998.7.5 by dong */ strcpy(getSession()->MsgDesUid, uin->userid); state = do_sendmsg(uin, msg, 1); if (state == 1) sprintf(msg, "\033[37m已经帮你邀请 %s 了\033[m", uin->userid); else if (state == -2) sprintf(msg, "\033[37m对方已经离线了...\033[m"); else sprintf(msg, "\033[37对方不接受你的消息...\033[m"); } } } printchatline(pthis, msg); }
char * wwwlogin(struct userec *user, int ipmask) { FILE *fp1; int fd; int n, uid; struct user_info u; char *urlbase, fname[80]; char buf[20]; uid = getuser(user->userid, NULL); fd = open(MY_BBS_HOME "/" ULIST_BASE "." MY_BBS_DOMAIN, O_WRONLY); flock(fd, LOCK_EX); if ((urlbase = check_multi(user->userid, uid))) { flock(fd, LOCK_UN); close(fd); return urlbase; } if (strcasecmp(user->userid, "guest") && count_uindex(uid) >= 3) { flock(fd, LOCK_UN); close(fd); http_fatal("您已经登录了三个帐号,不能再登录了"); } bzero(&u, sizeof (struct user_info)); u.active = 1; u.uid = uid; u.pid = 1; u.mode = LOGIN; u.userlevel = user->userlevel; u.lasttime = now_t; u.curboard = 0; if (user_perm(user, PERM_LOGINCLOAK) && (user->flags[0] & CLOAK_FLAG)) u.invisible = YEA; u.pager = 0; if (user->userdefine & DEF_FRIENDCALL) u.pager |= FRIEND_PAGER; if (user->flags[0] & PAGER_FLAG) { u.pager |= ALL_PAGER; u.pager |= FRIEND_PAGER; } if (user->userdefine & DEF_FRIENDMSG) u.pager |= FRIENDMSG_PAGER; if (user->userdefine & DEF_ALLMSG) { u.pager |= ALLMSG_PAGER; u.pager |= FRIENDMSG_PAGER; } strsncpy(u.from, fromhost, sizeof (u.from)); u.fromIP = from_addr.s_addr; strsncpy(u.username, user->username, NAMELEN); strsncpy(u.userid, user->userid, IDLEN + 1); getrandomstr(u.sessionid); n = utmp_login(&u); if (n > MAXACTIVERUN || n <= 0) { flock(fd, LOCK_UN); close(fd); http_fatal ("抱歉,目前在线用户数已达上限%d,无法登录。请稍后再来。", MAXACTIVERUN); } flock(fd, LOCK_UN); close(fd); n--; urlbase = makeurlbase(n, uid); u_info = &(shm_utmp->uinfo[n]); w_info = &(u_info->wwwinfo); w_info->login_start_time = now_t; w_info->ipmask = ipmask; if (strcasecmp(user->userid, "guest")) { u_info->unreadmsg = get_unreadcount(user->userid); initfriends(u_info); sethomefile(fname, user->userid, "clubrights"); if ((fp1 = fopen(fname, "r")) == NULL) { memset(u_info->clubrights, 0, CLUB_SIZE * sizeof (int)); } else { fread(&(u_info->clubrights), sizeof (int), CLUB_SIZE, fp1); fclose(fp1); } if (readuservalue(user->userid, "signature", buf, sizeof (buf)) >= 0) u_info->signature = atoi(buf); w_info->edit_mode = 1; set_my_cookie(); } else { u_info->unreadmsg = 0; memset(u_info->friend, 0, sizeof (u.friend)); memset(u_info->clubrights, 0, CLUB_SIZE * sizeof (int)); w_info->t_lines = 20; w_info->att_mode = 0; w_info->doc_mode = 1; } if ((user->userlevel & PERM_BOARDS)) setbmstatus(user, 1); return urlbase; }
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; }