void sync_nicklist(UserList *added, int type) { ChannelList *chan; NickList *nick; int i; char *check; check = clear_server_flags(added->host); for (i = 0; i < server_list_size(); i ++) { for (chan = get_server_channels(i); chan; chan = chan->next) { for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick)) { if (wild_match(check, nick->host)) { if (type) { nick->userlist = added; check_auto(chan->channel, nick, chan); } else nick->userlist = NULL; } } } } }
void prepare_addshit(UserhostItem *stuff, char *nick, char *args) { char *uh; char *channels, *reason; char listbuf[BIG_BUFFER_SIZE+1]; int thetype = 0, shit = 0; if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) { bitchsay("No such nick [%s] found", nick); return; } thetype = my_atol(args); next_arg(args, &args); shit = my_atol(args); next_arg(args, &args); channels = next_arg(args, &args); reason = args; uh = clear_server_flags(stuff->user); while (strlen(uh) > 7) uh++; sprintf(listbuf, "*%s@%s", uh, stuff->host); add_to_a_list(listbuf, thetype, "*", channels, reason, shit); }
char * ban_it(char *nick, char *user, char *host, char *ip) { static char banstr[BIG_BUFFER_SIZE/4+1]; char *t = user; char *t1 = user; char *tmp; *banstr = 0; while (strlen(t1)>9) t1++; t1 = clear_server_flags(t1); switch (defban) { case 7: if (ip) { snprintf(banstr, sizeof banstr, "*!*@%s", cluster(ip)); break; } case 2: /* Better */ snprintf(banstr, sizeof banstr, "*!*%s@%s", t1, cluster(host)); break; case 3: /* Host */ snprintf(banstr, sizeof banstr, "*!*@%s", host); break; case 4: /* Domain */ tmp = strrchr(host, '.'); if (tmp) { snprintf(banstr, sizeof banstr, "*!*@*%s", tmp); } else { snprintf(banstr, sizeof banstr, "*!*@%s", host); } break; case 5: /* User */ snprintf(banstr, sizeof banstr, "*!%s@%s", t, cluster(host)); break; case 6: /* Screw */ snprintf(banstr, sizeof banstr, "*!*%s@%s", t1, host); screw(banstr); break; case 1: /* Normal */ default: snprintf(banstr, sizeof banstr, "%s!*%s@%s", nick, t1, host); break; } return banstr; }
ShitList *nickinshit(char *niq, char *uh) { char theuh[BIG_BUFFER_SIZE+1]; register ShitList *thisptr = shitlist_list; char *u; if (!uh || !niq) return NULL; u = clear_server_flags(uh); sprintf(theuh, "%s!%s", niq, u); while (thisptr) { if (!strcmp(thisptr->filter, theuh) || (/*wild_match(theuh, thisptr->filter) || */wild_match(thisptr->filter, theuh))) return(thisptr); thisptr = thisptr->next; } return NULL; }
void sync_shitlist(ShitList *added, int type) { ChannelList *chan; NickList *nick; int i; char tmp[BIG_BUFFER_SIZE+1]; char *check; for (i = 0; i < server_list_size(); i ++) { for (chan = get_server_channels(i); chan; chan = chan->next) { for (nick = next_nicklist(chan, NULL); nick; nick = next_nicklist(chan, nick)) { check = clear_server_flags(nick->host); sprintf(tmp, "%s!%s", nick->nick, check); if (wild_match(added->filter, tmp)) { if (type) { nick->shitlist = added; check_auto(chan->channel, nick, chan); } else { BanList *b = NULL; nick->shitlist = NULL; if ((b = ban_is_on_channel(tmp, chan)) && !eban_is_on_channel(tmp, chan)) add_mode(chan, "b", 0, b->ban, NULL, get_int_var(NUM_BANMODES_VAR)); } } } flush_mode_all(chan); } } }
int BX_flood_prot (char *nick, char *userhost, char *type, int ctcp_type, int ignoretime, char *channel) { ChannelList *chan; NickList *Nick; char tmp[BIG_BUFFER_SIZE+1]; char *uh; int old_window_display; int kick_on_flood = 1; if ((ctcp_type == CDCC_FLOOD || ctcp_type == CTCP_FLOOD || ctcp_type == CTCP_ACTION_FLOOD) && !get_int_var(CTCP_FLOOD_PROTECTION_VAR)) return 0; else if (!get_int_var(FLOOD_PROTECTION_VAR)) return 0; else if (!my_stricmp(nick, get_server_nickname(from_server))) return 0; switch (ctcp_type) { case WALL_FLOOD: case MSG_FLOOD: break; case NOTICE_FLOOD: break; case PUBLIC_FLOOD: if (channel) { if ((chan = lookup_channel(channel, from_server, 0))) { kick_on_flood = get_cset_int_var(chan->csets, PUBFLOOD_CSET); if (kick_on_flood && (Nick = find_nicklist_in_channellist(nick, chan, 0))) { if (chan->have_op && (!Nick->userlist || (Nick->userlist && !(Nick->userlist->flags & ADD_FLOOD)))) if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET)) send_to_server("KICK %s %s :\002%s\002 flooder", chan->channel, nick, type); } } } break; case CTCP_FLOOD: case CTCP_ACTION_FLOOD: check_ctcp_ban_flood(channel, nick); default: if (get_int_var(FLOOD_KICK_VAR) && kick_on_flood && channel) { for (chan = get_server_channels(from_server); chan; chan = chan->next) { if (chan->have_op && (Nick = find_nicklist_in_channellist(nick, chan, 0))) { if ((!Nick->userlist || (Nick->userlist && !(Nick->userlist->flags & ADD_FLOOD)))) if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET)) send_to_server("KICK %s %s :\002%s\002 flooder", chan->channel, nick, type); } } } } if (!ignoretime) return 0; uh = clear_server_flags(userhost); sprintf(tmp, "*!*%s", uh); old_window_display = window_display; window_display = 0; ignore_nickname(tmp, ignore_type(type, strlen(type)), 0); window_display = old_window_display; sprintf(tmp, "%d ^IGNORE *!*%s NONE", ignoretime, uh); timercmd("TIMER", tmp, NULL, NULL); bitchsay("Auto-ignoring %s for %d minutes [\002%s\002 flood]", nick, ignoretime/60, type); return 1; }
void userhost_ban(UserhostItem *stuff, char *nick1, char *args) { char *temp; char *str= NULL; char *channel; ChannelList *c = NULL; NickList *n = NULL; char *ob = "-o+b"; char *b = "+b"; char *host = NULL, *nick = NULL, *user = NULL, *chan = NULL; WhowasList *whowas = NULL; int f**k = 0; int set_ignore = 0; channel = next_arg(args, &args); temp = next_arg(args, &args); f**k = !my_stricmp("F**K", args); set_ignore = !my_stricmp("BKI", args); if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) { if (nick1 && channel && (whowas = check_whowas_nick_buffer(nick1, channel, 0))) { nick = whowas->nicklist->nick; user = m_strdup(clear_server_flags(whowas->nicklist->host)); host = strchr(user, '@'); *host++ = 0; bitchsay("Using WhoWas info for ban of %s ", nick1); n = whowas->nicklist; } else if (nick1) { bitchsay("No match for the %s of %s on %s", f**k ? "F**k":"Ban", nick1, channel); return; } } else { nick = stuff->nick; user = m_strdup(clear_server_flags(stuff->user)); host = stuff->host; } if (!(my_stricmp(nick, get_server_nickname(from_server)))) { bitchsay("Try to kick yourself again!!"); new_free(&user); return; } if (is_on_channel(channel, from_server, nick)) chan = channel; c = lookup_channel(channel, from_server, 0); if (c && !n) n = find_nicklist_in_channellist(nick, c, 0); send_to_server("MODE %s %s %s %s", channel, chan ? ob : b, chan?nick:empty_string, ban_it(nick, user, host, (n && n->ip)?n->ip:NULL)); if (f**k) { malloc_sprintf(&str, "%s!*%s@%s %s 3 Auto-Shit", nick, user, host, channel); #ifdef WANT_USERLIST add_shit(NULL, str, NULL, NULL); #endif new_free(&str); } else if (set_ignore) ignore_nickname(ban_it("*", user, host, NULL) , IGNORE_ALL, 0); new_free(&user); }
void userhost_unban(UserhostItem *stuff, char *nick1, char *args) { char *tmp; ChannelList *chan; char *channel = NULL; BanList *bans; char *host = NULL; char *ip_str = NULL; WhowasList *whowas = NULL; NickList *n = NULL; int count = 0; int old_server = from_server; if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) { if (nick1 && (whowas = check_whowas_nick_buffer(nick1, args, 0))) { malloc_sprintf(&host, "%s!%s", whowas->nicklist->nick, whowas->nicklist->host); bitchsay("Using WhoWas info for unban of %s ", nick1); n = whowas->nicklist; } else if (nick1) { bitchsay("No match for the unban of %s on %s", nick1, args); return; } if (!nick1) return; } else { tmp = clear_server_flags(stuff->user); malloc_sprintf(&host, "%s!%s@%s",stuff->nick, tmp, stuff->host); } channel = next_arg(args, &args); if (args && *args) from_server = atoi(args); if (!(chan = prepare_command(&from_server, channel, NEED_OP))) { new_free(&host); return; } if (!n) n = find_nicklist_in_channellist(stuff->nick, chan, 0); if (n && n->ip) { size_t len = strlen(n->nick)+strlen(n->host)+strlen(n->ip)+10; ip_str = alloca(len); *ip_str = 0; strmopencat(ip_str, len, stuff->nick, "!", stuff->user, "@", n->ip, NULL); } for (bans = chan->bans; bans; bans = bans->next) { if (!bans->sent_unban && (wild_match(bans->ban, host) || (ip_str && wild_match(bans->ban, ip_str))) ) { add_mode(chan, "b", 0, bans->ban, NULL, get_int_var(NUM_BANMODES_VAR)); bans->sent_unban++; count++; } } flush_mode_all(chan); if (!count) bitchsay("No match for Unban of %s on %s", nick1, args); new_free(&host); from_server = old_server; }
void prepare_adduser(UserhostItem *stuff, char *nick, char *args) { int thetype = 0; unsigned long flags = 0; int ppp = 0; UserList *uptr = NULL; char *channels = NULL, *passwd = NULL, *p = NULL, *uh, *e_host, *host; if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) { bitchsay("No such nick [%s] found", nick); return; } thetype = my_atol(args); next_arg(args, &args); ppp = my_atol(args); next_arg(args, &args); channels = next_arg(args, &args); p = next_arg(args, &args); flags = convert_str_to_flags(p); passwd = next_arg(args, &args); uh = clear_server_flags(stuff->user); if (*stuff->user == '~' || *stuff->user == '^') { while ((strlen(uh) > 8)) uh++; host = m_sprintf("*%s@%s", uh, ppp ? cluster(stuff->host) : stuff->host); } else host = m_sprintf("%s@%s", uh, ppp ? cluster(stuff->host) : stuff->host); e_host = m_sprintf("%s@%s", stuff->user, stuff->host); if (thetype == USERLIST_ADD) { char *e_pass = NULL; if (passwd) e_pass = cryptit(passwd); if (!(uptr = lookup_userlevelc(stuff->nick, e_host, channels, NULL))) { add_userhost_to_userlist(stuff->nick, host, channels, e_pass, flags); send_to_server("NOTICE %s :You have been added to my Userlist as *!%s with [%s]", nick, host, convert_flags_to_str(flags)); send_to_server("NOTICE %s :You are allowed on channels [%s]", nick, channels); if (passwd) send_to_server("NOTICE %s :Your password is [%s]", nick, passwd); put_it("%s", convert_output_format("$G Added [*!$0] on $1. Password is [$2] and flags are [$3-]", "%s %s %s %s", host, channels, passwd?passwd:"None", convert_flags_to_str(flags))); } else if (passwd) { send_to_server("NOTICE %s :Your password is %s[%s]", nick, uptr->password ? "changed to " : "", passwd); malloc_strcpy(&uptr->password, e_pass); } } else { if (!(remove_userhost_from_userlist(host, channels))) bitchsay("User not found on the userlist"); else put_it("%s", convert_output_format("$G Removed [$0] on $1 from userlist", "%s %s", host, channels)); } new_free(&e_host); new_free(&host); }