DLLFUNC char *restrictcolors_checkmsg(aClient *cptr, aClient *sptr, aChannel *chptr, char *text, int notice) { if (IsULine(sptr) || IsServer(sptr)) return text; if (chptr->mode.extmode && RESTRICT_COLORS && !is_chan_op(sptr, chptr) && !is_halfop(sptr, chptr)) return StripColors(text); return text; }
/* ** m_kick ** parv[0] = sender prefix ** parv[1] = channel ** parv[2] = client to kick ** parv[3] = kick comment */ static int m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct membership *msptr; struct Client *who; struct Channel *chptr; int chasing = 0; int halfop = 0; char *comment; const char *name; char *p = NULL; const char *user; static char buf[BUFSIZE]; if (MyClient(source_p) && !IsFloodDone(source_p)) flood_endgrace(source_p); *buf = '\0'; if ((p = strchr(parv[1], ','))) *p = '\0'; name = parv[1]; chptr = find_channel(name); if (chptr == NULL) { sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); return 0; } if (!IsServer(source_p)) { msptr = find_channel_membership(chptr, source_p); if ((msptr == NULL) && MyConnect(source_p)) { sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name); return 0; } if (!is_chanop(msptr) && !is_halfop(msptr)) { if (MyConnect(source_p)) { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name, source_p->name, name); return 0; } /* If its a TS 0 channel, do it the old way */ if (chptr->channelts == 0) { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), get_id(&me, source_p), get_id(source_p, source_p), name); return 0; } } halfop = !is_chanop(msptr) && is_halfop(msptr); /* Its a user doing a kick, but is not showing as chanop locally * its also not a user ON -my- server, and the channel has a TS. * There are two cases we can get to this point then... * * 1) connect burst is happening, and for some reason a legit * op has sent a KICK, but the SJOIN hasn't happened yet or * been seen. (who knows.. due to lag...) * * 2) The channel is desynced. That can STILL happen with TS * * Now, the old code roger wrote, would allow the KICK to * go through. Thats quite legit, but lets weird things like * KICKS by users who appear not to be chanopped happen, * or even neater, they appear not to be on the channel. * This fits every definition of a desync, doesn't it? ;-) * So I will allow the KICK, otherwise, things are MUCH worse. * But I will warn it as a possible desync. * * -Dianora */ } if ((p = strchr(parv[2], ','))) *p = '\0'; user = parv[2]; if (!(who = find_chasing(source_p, user, &chasing))) { return 0; } msptr = find_channel_membership(chptr, who); if (msptr != NULL) { if (MyClient(source_p) && IsService(who)) { sendto_one(source_p, form_str(ERR_ISCHANSERVICE), me.name, source_p->name, who->name, chptr->chname); return 0; } if (halfop && (is_chanop(msptr) || is_halfop(msptr))) { if (MyConnect(source_p)) { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), me.name, source_p->name, name); return 0; } /* If its a TS 0 channel, do it the old way */ if (chptr->channelts == 0) { sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), get_id(&me, source_p), get_id(source_p, source_p), name); return 0; } } comment = LOCAL_COPY_N((EmptyString(parv[3])) ? who->name : parv[3], REASONLEN); /* jdc * - In the case of a server kicking a user (i.e. CLEARCHAN), * the kick should show up as coming from the server which did * the kick. * - Personally, flame and I believe that server kicks shouldn't * be sent anyways. Just waiting for some oper to abuse it... */ if (IsServer(source_p)) sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s", source_p->name, name, who->name, comment); else sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s KICK %s %s :%s", source_p->name, source_p->username, IsCloaked(source_p) ? source_p->virthost : source_p->host, name, who->name, comment); sendto_server(client_p, chptr, CAP_TS6, NOCAPS, ":%s KICK %s %s :%s", use_id(source_p), chptr->chname, use_id(who), comment); sendto_server(client_p, chptr, NOCAPS, CAP_TS6, ":%s KICK %s %s :%s", source_p->name, chptr->chname, who->name, comment); remove_user_from_channel(msptr); } else if (MyClient(source_p)) sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, form_str(ERR_USERNOTINCHANNEL), user, name); return 0; }
/* ** m_part ** parv[0] = sender prefix ** parv[1] = channel ** parv[2] = comment (added by Lefler) */ DLLFUNC CMD_FUNC(m_part) { aChannel *chptr; Membership *lp; char *p = NULL, *name; char *commentx = (parc > 2 && parv[2]) ? parv[2] : NULL; char *comment; int n; if (parc < 2 || parv[1][0] == '\0') { sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0], "PART"); return 0; } if (MyClient(sptr)) { if (IsShunned(sptr)) commentx = NULL; if (STATIC_PART) { if (!strcasecmp(STATIC_PART, "yes") || !strcmp(STATIC_PART, "1")) commentx = NULL; else if (!strcasecmp(STATIC_PART, "no") || !strcmp(STATIC_PART, "0")) ; /* keep original reason */ else commentx = STATIC_PART; } if (commentx) { n = dospamfilter(sptr, commentx, SPAMF_PART, parv[1], 0, NULL); if (n == FLUSH_BUFFER) return n; if (n < 0) commentx = NULL; } } for (; (name = strtoken(&p, parv[1], ",")); parv[1] = NULL) { chptr = get_channel(sptr, name, 0); if (!chptr) { sendto_one(sptr, err_str(ERR_NOSUCHCHANNEL), me.name, parv[0], name); continue; } if (check_channelmask(sptr, cptr, name)) continue; /* 'commentx' is the general part msg, but it can be changed * per-channel (eg some chans block badwords, strip colors, etc) * so we copy it to 'comment' and use that in this for loop :) */ comment = commentx; if (!(lp = find_membership_link(sptr->user->channel, chptr))) { /* Normal to get get when our client did a kick ** for a remote client (who sends back a PART), ** so check for remote client or not --Run */ if (MyClient(sptr)) sendto_one(sptr, err_str(ERR_NOTONCHANNEL), me.name, parv[0], name); continue; } if (!IsAnOper(sptr) && !is_chanownprotop(sptr, chptr)) { #ifdef STRIPBADWORDS int blocked = 0; #endif /* Banned? No comment allowed ;) */ if (comment && is_banned(sptr, chptr, BANCHK_MSG)) comment = NULL; /* And other things... */ if ((chptr->mode.mode & MODE_NOCOLOR) && comment) { if (strchr((char *)comment, 3) || strchr((char *)comment, 27)) { comment = NULL; } } if ((chptr->mode.mode & MODE_MODERATED) && comment && !has_voice(sptr, chptr) && !is_halfop(sptr, chptr)) { comment = NULL; } if ((chptr->mode.mode & MODE_STRIP) && comment) { comment = (char *)StripColors(comment); } #ifdef STRIPBADWORDS #ifdef STRIPBADWORDS_CHAN_ALWAYS if (comment) { comment = (char *)stripbadwords_channel(comment, &blocked); } #else if ((chptr->mode.extmode & EXTMODE_STRIPBADWORDS) && comment) { comment = (char *)stripbadwords_channel(comment, &blocked); } #endif #endif } /* +M and not logged in to services? */ if ((chptr->mode.mode & MODE_MODREG) && !IsLoggedIn(sptr) && !IsAnOper(sptr)) comment = NULL; if (MyConnect(sptr)) { Hook *tmphook; for (tmphook = Hooks[HOOKTYPE_PRE_LOCAL_PART]; tmphook; tmphook = tmphook->next) { comment = (*(tmphook->func.pcharfunc))(sptr, chptr, comment); if (!comment) break; } } /* Send to other servers... */ if (!comment) sendto_serv_butone_token(cptr, parv[0], MSG_PART, TOK_PART, "%s", chptr->chname); else sendto_serv_butone_token(cptr, parv[0], MSG_PART, TOK_PART, "%s :%s", chptr->chname, comment); if (1) { if ((chptr->mode.mode & MODE_AUDITORIUM) && !is_chanownprotop(sptr, chptr)) { if (!comment) { sendto_chanops_butone(NULL, chptr, ":%s!%s@%s PART %s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname); if (!is_chan_op(sptr, chptr) && MyClient(sptr)) sendto_one(sptr, ":%s!%s@%s PART %s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname); } else { sendto_chanops_butone(NULL, chptr, ":%s!%s@%s PART %s %s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname, comment); if (!is_chan_op(cptr, chptr) && MyClient(sptr)) sendto_one(sptr, ":%s!%s@%s PART %s %s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname, comment); } } else { if (!comment) sendto_channel_butserv(chptr, sptr, PARTFMT, parv[0], chptr->chname); else sendto_channel_butserv(chptr, sptr, PARTFMT2, parv[0], chptr->chname, comment); } if (MyClient(sptr)) RunHook4(HOOKTYPE_LOCAL_PART, cptr, sptr, chptr, comment); else RunHook4(HOOKTYPE_REMOTE_PART, cptr, sptr, chptr, comment); remove_user_from_channel(sptr, chptr); } } return 0; }