Beispiel #1
0
void run_user_flag(char *name, char *what, NickList *user, NickList *kicker)
{
	char *tmp = NULL;
	char *name_copy, *stuff_copy;
	int sa = 0;
	char buffer[BIG_BUFFER_SIZE*5+1];
	*buffer = 0;
	strmopencat(buffer, BIG_BUFFER_SIZE*5, user->nick, space, user->host, space, user->ip, space, user->userlist?one:zero, space, NULL);
	if (user->userlist)
		strmopencat(buffer, BIG_BUFFER_SIZE*5, user->userlist->nick, space, user->userlist->host, space, user->userlist->channels, space, ltoa(user->userlist->flags), space, NULL);
	if (kicker)
	{
		strmopencat(buffer, BIG_BUFFER_SIZE*5, kicker->nick, space, kicker->host, space, kicker->ip, space, kicker->userlist?one:zero, NULL);
		if (kicker->userlist)
			strmopencat(buffer, BIG_BUFFER_SIZE*5, space, kicker->userlist->nick, space, kicker->userlist->host, space, kicker->userlist->channels, space, ltoa(kicker->userlist->flags), NULL);
	}
	if ((tmp = expand_alias(what, empty_string, &sa, NULL)))
	{
		stuff_copy = alloca(strlen(tmp) + 1);
		name_copy = LOCAL_COPY(name);
		stuff_copy = LOCAL_COPY(tmp);
		will_catch_return_exceptions++;
		parse_line(name_copy, stuff_copy, buffer, 0, 0, 1);
		will_catch_return_exceptions--;
		return_exception = 0;
	}
	new_free(&tmp);
}
Beispiel #2
0
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;
}
Beispiel #3
0
void whoreply(char *from, char **ArgList)
{
    static char format[40];
    static int last_width = -1;
    int ok = 1, voice = 0, opped = 0;
    char *channel, *user, *host, *server, *nick, *stat, *name;
    struct channel *chan = NULL;
    char buf_data[BIG_BUFFER_SIZE + 1];

    if (!ArgList[5])
	return;

    if (last_width != get_int_var(CHANNEL_NAME_WIDTH_VAR)) {
	if ((last_width = get_int_var(CHANNEL_NAME_WIDTH_VAR)) != 0)
	    snprintf(format, 39, "%%-%u.%us \002%%-9s\002 %%-3s %%s@%%s (%%s)",
		     (unsigned char) last_width, (unsigned char) last_width);
	else
	    strcpy(format, "%s\t\002%-9s\002 %-3s %s@%s (%s)");
    }
    channel = ArgList[0];
    user = ArgList[1];
    host = ArgList[2];
    server = ArgList[3];
    nick = ArgList[4];
    stat = ArgList[5];
    name = ArgList[6];
    PasteArgs(ArgList, 6);

    message_from(channel, LOG_CRAP);
    *buf_data = 0;
    strmopencat(buf_data, BIG_BUFFER_SIZE, user, "@", host, NULL);
    voice = (strchr(stat, '+') != NULL);
    opped = (strchr(stat, '@') != NULL);

    if (*stat == 'S') {		/* this only true for the header WHOREPLY */
	char buffer[BIG_BUFFER_SIZE + 1];

	channel = "Channel";
	snprintf(buffer, BIG_BUFFER_SIZE, "%s %s %s %s %s %s %s", channel, nick, stat, user, host, server, name);
	if (do_hook(WHO_LIST, "%s", buffer))
	    put_it("%s",
		   convert_output_format(get_format(FORMAT_WHO_FSET), "%s %s %s %s %s %s %s", channel, nick, stat, user, host, server,
					 name));
	message_from(NULL, LOG_CRAP);
	return;
    }

    if (who_mask) {
	if (who_mask & WHO_HERE)
	    ok = ok && (*stat == 'H');
	if (who_mask & WHO_AWAY)
	    ok = ok && (*stat == 'G');
	if (who_mask & WHO_OPS)
	    ok = ok && (*(stat + 1) == '*');
	if (who_mask & WHO_LUSERS)
	    ok = ok && (*(stat + 1) != '*');
	if (who_mask & WHO_CHOPS)
	    ok = ok && ((*(stat + 1) == '@') || (*(stat + 2) == '@'));
	if (who_mask & WHO_NAME)
	    ok = ok && wild_match(who_name, user);
	if (who_mask & WHO_NICK)
	    ok = ok && wild_match(who_nick, nick);
	if (who_mask & WHO_HOST)
	    ok = ok && wild_match(who_host, host);
	if (who_mask & WHO_REAL)
	    ok = ok && wild_match(who_real, name);
	if (who_mask & WHO_SERVER)
	    ok = ok && wild_match(who_server, server);
    }

    if (ok) {
	char buffer[BIG_BUFFER_SIZE + 1];

	snprintf(buffer, BIG_BUFFER_SIZE, "%s %s %s %s %s %s %s", channel, nick, stat, user, host, server, name);
	chan = add_to_channel(channel, nick, from_server, opped, voice, buf_data, server, stat);
	if (do_hook(WHO_LIST, "%s", buffer)) {
	    if (!get_int_var(SHOW_WHO_HOPCOUNT_VAR))
		next_arg(name, &name);
	    put_it("%s",
		   convert_output_format(get_format(FORMAT_WHO_FSET), "%s %s %s %s %s %s %s", channel, nick, stat, user, host, server,
					 name));
	}
    }
/*      
   else if ((who_mask && WHO_KILL) && !ok)
   {
   put_it("%s", convert_output_format("$G No such match for /whokill", NULL, NULL));
   }
 */
    message_from(NULL, LOG_CRAP);
}