// Parts all insecure users on a +z channel (NOT KICK) void f_part_insecure_users (aChannel *chptr) { Member *member, *mb2; aClient *cptr; char *comment = "Insecure user not allowed on secure channel (+z)"; for (member = chptr->members; member; member = mb2) { mb2 = member->next; cptr = member->cptr; if (MyClient(cptr) && !IsSecureConnect(cptr) && !IsULine(cptr)) { RunHook4(HOOKTYPE_LOCAL_PART, cptr, &me, chptr, comment); if ((chptr->mode.mode & MODE_AUDITORIUM) && is_chanownprotop(cptr, chptr)) { sendto_chanops_butone(cptr, chptr, ":%s!%s@%s PART %s :%s", cptr->name, cptr->user->username, GetHost(cptr), chptr->chname, comment); sendto_prefix_one(cptr, &me, ":%s!%s@%s PART %s :%s", cptr->name, cptr->user->username, GetHost(cptr), chptr->chname, comment); } else { sendto_channel_butserv(chptr, &me, ":%s!%s@%s PART %s :%s", cptr->name, cptr->user->username, GetHost(cptr), chptr->chname, comment); } sendto_one(cptr, err_str(ERR_SECUREONLYCHAN), me.name, cptr->name, chptr->chname); sendto_serv_butone_token(&me, cptr->name, MSG_PART, TOK_PART, "%s :%s", chptr->chname, comment); remove_user_from_channel(cptr, chptr); } } }
/* * rejoin_doparts: * sends a PART to all channels (to local users only) */ void rejoin_doparts(aClient *sptr, char did_parts[]) { Membership *tmp; aChannel *chptr; char *comment = "Rejoining because of user@host change"; int i = 0; for (tmp = sptr->user->channel; tmp; tmp = tmp->next) { chptr = tmp->chptr; if (!chptr) continue; /* Possible? */ /* If the user is banned, don't do it */ if (is_banned(sptr, chptr, BANCHK_JOIN)) { did_parts[i++] = 0; continue; } did_parts[i++] = 1; if ((chptr->mode.mode & MODE_AUDITORIUM) && !(tmp->flags & (CHFL_CHANOWNER|CHFL_CHANPROT|CHFL_CHANOP))) { sendto_chanops_butone(sptr, chptr, ":%s!%s@%s PART %s :%s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname, comment); } else sendto_channel_butserv_butone(chptr, sptr, sptr, ":%s PART %s :%s", sptr->name, chptr->chname, comment); } }
/* * rejoin_dojoinandmode: * sends a JOIN and a MODE (if needed) to restore qaohv modes (to local users only) */ void rejoin_dojoinandmode(aClient *sptr, char did_parts[]) { Membership *tmp; aChannel *chptr; int i, j = 0, n, flags; char flagbuf[8]; /* For holding "qohva" and "*~@%+" */ for (tmp = sptr->user->channel; tmp; tmp = tmp->next) { flags = tmp->flags; chptr = tmp->chptr; if (!chptr) continue; /* Is it possible? */ /* If the user is banned, don't do it */ if (!did_parts[j++]) continue; if ((chptr->mode.mode & MODE_AUDITORIUM) && !(flags & (CHFL_CHANOWNER|CHFL_CHANPROT|CHFL_CHANOP))) { sendto_chanops_butone(sptr, chptr, ":%s!%s@%s JOIN :%s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname); } else sendto_channel_butserv_butone(chptr, sptr, sptr, ":%s JOIN :%s", sptr->name, chptr->chname); /* Set the modes (if any) */ if (flags) { char *p = flagbuf; if (flags & MODE_CHANOP) *p++ = 'o'; if (flags & MODE_VOICE) *p++ = 'v'; if (flags & MODE_HALFOP) *p++ = 'h'; if (flags & MODE_CHANOWNER) *p++ = 'q'; if (flags & MODE_CHANPROT) *p++ = 'a'; *p = '\0'; parabuf[0] = '\0'; n = strlen(flagbuf); if (n) { for (i=0; i < n; i++) { strcat(parabuf, sptr->name); if (i < n - 1) strcat(parabuf, " "); } sendto_channel_butserv_butone(chptr, &me, sptr, ":%s MODE %s +%s %s", me.name, chptr->chname, flagbuf, parabuf); } } } }
/** Kicks all insecure users on a +z channel */ static void secureonly_kick_insecure_users(aChannel *chptr) { Member *member, *mb2; aClient *cptr; int i = 0; Hook *h; char *comment = "Insecure user not allowed on secure channel (+z)"; if (!IsSecureOnly(chptr)) return; for (member = chptr->members; member; member = mb2) { mb2 = member->next; cptr = member->cptr; if (MyClient(cptr) && !IsSecureConnect(cptr) && !IsULine(cptr)) { RunHook5(HOOKTYPE_LOCAL_KICK, &me, &me, cptr, chptr, comment); i = 0; for (h = Hooks[HOOKTYPE_VISIBLE_IN_CHANNEL]; h; h = h->next) { i = (*(h->func.intfunc))(cptr,chptr); if (i != 0) break; } if (i != 0 && !(is_skochanop(cptr, chptr) || has_voice(cptr,chptr))) { sendto_chanops_butone(cptr, chptr, ":%s KICK %s %s :%s", me.name, chptr->chname, cptr->name, comment); sendto_prefix_one(cptr, &me, ":%s KICK %s %s :%s", me.name, chptr->chname, cptr->name, comment); } else { sendto_channel_butserv(chptr, &me, ":%s KICK %s %s :%s", me.name, chptr->chname, cptr->name, comment); } sendto_server(&me, 0, 0, ":%s KICK %s %s :%s", me.name, chptr->chname, cptr->name, comment); remove_user_from_channel(cptr, chptr); } } }
/* Routine that actually makes a user join the channel * this does no actual checking (banned, etc.) it just adds the user */ DLLFUNC void _join_channel(aChannel *chptr, aClient *cptr, aClient *sptr, int flags) { char *parv[] = { 0, 0 }; /* ** Complete user entry to the new channel (if any) */ add_user_to_channel(chptr, sptr, flags); /* ** notify all other users on the new channel */ if (chptr->mode.mode & MODE_AUDITORIUM) { if (MyClient(sptr)) sendto_one(sptr, ":%s!%s@%s JOIN :%s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname); sendto_chanops_butone(NULL, chptr, ":%s!%s@%s JOIN :%s", sptr->name, sptr->user->username, GetHost(sptr), chptr->chname); } else sendto_channel_butserv(chptr, sptr, ":%s JOIN :%s", sptr->name, chptr->chname); sendto_serv_butone_token_opt(cptr, OPT_NOT_SJ3, sptr->name, MSG_JOIN, TOK_JOIN, "%s", chptr->chname); #ifdef JOIN_INSTEAD_OF_SJOIN_ON_REMOTEJOIN if ((MyClient(sptr) && !(flags & CHFL_CHANOP)) || !MyClient(sptr)) sendto_serv_butone_token_opt(cptr, OPT_SJ3, sptr->name, MSG_JOIN, TOK_JOIN, "%s", chptr->chname); if (flags && !(flags & CHFL_DEOPPED)) { #endif /* I _know_ that the "@%s " look a bit wierd with the space and all .. but its to get around a SJOIN bug --stskeeps */ sendto_serv_butone_token_opt(cptr, OPT_SJ3|OPT_SJB64, me.name, MSG_SJOIN, TOK_SJOIN, "%B %s :%s%s ", (long)chptr->creationtime, chptr->chname, chfl_to_sjoin_symbol(flags), sptr->name); sendto_serv_butone_token_opt(cptr, OPT_SJ3|OPT_NOT_SJB64, me.name, MSG_SJOIN, TOK_SJOIN, "%li %s :%s%s ", chptr->creationtime, chptr->chname, chfl_to_sjoin_symbol(flags), sptr->name); #ifdef JOIN_INSTEAD_OF_SJOIN_ON_REMOTEJOIN } #endif if (MyClient(sptr)) { /* ** Make a (temporal) creationtime, if someone joins ** during a net.reconnect : between remote join and ** the mode with TS. --Run */ if (chptr->creationtime == 0) { chptr->creationtime = TStime(); sendto_serv_butone_token(cptr, me.name, MSG_MODE, TOK_MODE, "%s + %lu", chptr->chname, chptr->creationtime); } del_invite(sptr, chptr); if (flags && !(flags & CHFL_DEOPPED)) { #ifndef PREFIX_AQ if ((flags & CHFL_CHANOWNER) || (flags & CHFL_CHANPROT)) { /* +ao / +qo for when PREFIX_AQ is off */ sendto_serv_butone_token_opt(cptr, OPT_NOT_SJ3, me.name, MSG_MODE, TOK_MODE, "%s +o%c %s %s %lu", chptr->chname, chfl_to_chanmode(flags), sptr->name, sptr->name, chptr->creationtime); } else { #endif /* +v/+h/+o (and +a/+q if PREFIX_AQ is on) */ sendto_serv_butone_token_opt(cptr, OPT_NOT_SJ3, me.name, MSG_MODE, TOK_MODE, "%s +%c %s %lu", chptr->chname, chfl_to_chanmode(flags), sptr->name, chptr->creationtime); #ifndef PREFIX_AQ } #endif } if (chptr->topic) { sendto_one(sptr, rpl_str(RPL_TOPIC), me.name, sptr->name, chptr->chname, chptr->topic); sendto_one(sptr, rpl_str(RPL_TOPICWHOTIME), me.name, sptr->name, chptr->chname, chptr->topic_nick, chptr->topic_time); } if (chptr->users == 1 && (MODES_ON_JOIN #ifdef EXTCMODE || iConf.modes_on_join.extmodes) #endif ) { #ifdef EXTCMODE int i; chptr->mode.extmode = iConf.modes_on_join.extmodes; /* Param fun */ for (i = 0; i <= Channelmode_highest; i++) { if (!Channelmode_Table[i].flag || !Channelmode_Table[i].paracount) continue; if (chptr->mode.extmode & Channelmode_Table[i].mode) { CmodeParam *p; p = Channelmode_Table[i].put_param(NULL, iConf.modes_on_join.extparams[i]); AddListItem(p, chptr->mode.extmodeparam); } } #endif chptr->mode.mode = MODES_ON_JOIN; #ifdef NEWCHFLOODPROT if (iConf.modes_on_join.floodprot.per) { chptr->mode.floodprot = MyMalloc(sizeof(ChanFloodProt)); memcpy(chptr->mode.floodprot, &iConf.modes_on_join.floodprot, sizeof(ChanFloodProt)); } #else chptr->mode.kmode = iConf.modes_on_join.kmode; chptr->mode.per = iConf.modes_on_join.per; chptr->mode.msgs = iConf.modes_on_join.msgs; #endif *modebuf = *parabuf = 0; channel_modes(sptr, modebuf, parabuf, chptr); /* This should probably be in the SJOIN stuff */ sendto_serv_butone_token(&me, me.name, MSG_MODE, TOK_MODE, "%s %s %s %lu", chptr->chname, modebuf, parabuf, chptr->creationtime); sendto_one(sptr, ":%s MODE %s %s %s", me.name, chptr->chname, modebuf, parabuf); } parv[0] = sptr->name; parv[1] = chptr->chname; do_cmd(cptr, sptr, "NAMES", 2, parv); RunHook4(HOOKTYPE_LOCAL_JOIN, cptr, sptr,chptr,parv); } else { RunHook4(HOOKTYPE_REMOTE_JOIN, cptr, sptr, chptr, parv); /* (rarely used) */ } #ifdef NEWCHFLOODPROT /* I'll explain this only once: * 1. if channel is +f * 2. local client OR synced server * 3. then, increase floodcounter * 4. if we reached the limit AND only if source was a local client.. do the action (+i). * Nr 4 is done because otherwise you would have a noticeflood with 'joinflood detected' * from all servers. */ if (chptr->mode.floodprot && (MyClient(sptr) || sptr->srvptr->serv->flags.synced) && !IsULine(sptr) && do_chanflood(chptr->mode.floodprot, FLD_JOIN) && MyClient(sptr)) { do_chanflood_action(chptr, FLD_JOIN, "join"); } #endif }
/* ** 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; }