コード例 #1
0
ファイル: userlist.c プロジェクト: nikolatesla/BitchXMPP
int find_user_level(char *from, char *host, char *channel)
{
UserList *tmp;
	if ((tmp = (UserList *) lookup_userlevelc(from, host, channel, NULL)))
		return tmp->flags;
	return 0;
}
コード例 #2
0
ファイル: notify.c プロジェクト: BitchX/BitchX1.2
void check_auto_invite(char *nick, char *userhost)
{
#ifdef WANT_USERLIST
ChannelList *chan = NULL;
UserList *tmp = NULL;
	for (chan = get_server_channels(from_server); chan; chan = chan->next)
	{
		if ((tmp = lookup_userlevelc("*", userhost, chan->channel, NULL)))
		{
			NickList *n = NULL;
			n = find_nicklist_in_channellist(nick, chan, 0);
			if (!n && chan->have_op && get_cset_int_var(chan->csets, AINV_CSET) && (tmp->flags & ADD_INVITE) && get_cset_int_var(chan->csets, AINV_CSET))
			{
				bitchsay("Auto-inviting %s to %s", nick, chan->channel);
				send_to_server("NOTICE %s :Auto-invite from %s", nick, get_server_nickname(from_server));
				send_to_server("INVITE %s %s%s%s", nick, chan->channel, chan->key?space:empty_string, chan->key?chan->key:empty_string);
			}
		}
		tmp = NULL;
	}
#endif
}
コード例 #3
0
ファイル: userlist.c プロジェクト: nikolatesla/BitchXMPP
int change_pass(char *from, char *msg)
{
UserList *tmp;
char *old_pass, *new_pass, *args;
	args = LOCAL_COPY(msg);
	next_arg(args, &args);
	old_pass = next_arg(args, &args);
	new_pass = next_arg(args, &args);
	if ((tmp = (UserList *) lookup_userlevelc(from, FromUserHost, "*", NULL)))
	{
		if (tmp->password)
		{
			if (!old_pass || !new_pass)
				return 0;
			if (!(checkpass(old_pass, tmp->password)))
			{
				int old_display_win = window_display;
				window_display = 0;
				malloc_strcpy(&tmp->password, cryptit(new_pass));
				savelists(NULL, NULL, NULL, NULL);
				window_display = old_display_win;
				return 1;
			}
		}
		/* user doesn't have a pass, so set it up */
		if (old_pass)
		{
			int old_display_win = window_display;
			window_display = 0;
			tmp->password = m_strdup(cryptit(old_pass));
			savelists(NULL, NULL, NULL, NULL);
			window_display = old_display_win;
			return 1;
		}
	}
	return 0;
}
コード例 #4
0
ファイル: userlist.c プロジェクト: nikolatesla/BitchXMPP
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);
}