*
* x3 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
#define KEY_NOTES "notes"
#define KEY_TOPIC_MASK "topic_mask"
#define KEY_OWNER_TRANSFER "owner_transfer"
+#define KEY_MAXSETINFO "maxsetinfo"
/* User data */
#define KEY_LEVEL "level"
{ "CSMSG_BAN_DONE", "Banned $b%s$b from %s." },
{ "CSMSG_REASON_CHANGE", "Reason for LAMER $b%s$b changed." },
{ "CSMSG_LAMER_EXTENDED", "Extended LAMER for $b%s$b, now expires in %s." },
- { "CSMSG_BAN_REMOVED", "Matching ban(s) and LAMER(s) in $b%s$b were removed." },
+ { "CSMSG_BAN_REMOVED", "Ban(s) and LAMER(s) matching $b%s$b were removed." },
{ "CSMSG_TRIMMED_LAMERS", "Trimmed $b%d LAMERs$b from the %s LAMER list that were inactive for at least %s." },
{ "CSMSG_REDUNDANT_BAN", "$b%s$b is already banned in %s." },
{ "CSMSG_REDUNDANT_LAMER", "$b%s$b is already LAMER'd in %s." },
{ "CSMSG_SET_TOPICREFRESH", "$bTopicRefresh$b %d - %s" },
{ "CSMSG_SET_RESYNC", "$bResync $b %d - %s" },
{ "CSMSG_SET_BANTIMEOUT", "$bBanTimeout $b %d - %s" },
+ { "CSMSG_SET_MAXSETINFO", "$bMaxSetInfo $b %d - maximum characters in a setinfo line." },
{ "CSMSG_USET_AUTOOP", "$bAutoOp $b %s" },
{ "CSMSG_USET_AUTOVOICE", "$bAutoVoice $b %s" },
/* Initialize the channel's max user record. */
cData->max = channel->members.used;
+ cData->maxsetinfo = chanserv_conf.max_userinfo_length;
if(handle != user->handle_info)
reply("CSMSG_PROXY_SUCCESS", handle->handle, channel->name);
if(argc > 2)
{
access = user_level_from_name(argv[1], UL_OWNER);
+ char *useraccess = user_level_name_from_level(victim->access);
if(!access)
{
reply("CSMSG_INVALID_ACCESS", argv[1]);
return 0;
}
- if(access != victim->access)
+ if(strcasecmp(argv[1], useraccess))
{
reply("CSMSG_INCORRECT_ACCESS", handle->handle, user_level_name_from_level(victim->access), argv[1]);
return 0;
return opt_greeting_common(user, cmd, argc, argv, "CSMSG_SET_USERGREETING", &channel->channel_info->user_greeting);
}
+static MODCMD_FUNC(chan_opt_maxsetinfo)
+{
+ unsigned int charmax;
+
+ if(argc > 1) {
+ charmax = atoi(argv[1]);
+ if ((charmax > 0) && (charmax < chanserv_conf.max_userinfo_length))
+ channel->channel_info->maxsetinfo = charmax;
+ }
+
+ reply("CSMSG_SET_MAXSETINFO", channel->channel_info->maxsetinfo);
+ return 1;
+}
+
static MODCMD_FUNC(chan_opt_modes)
{
struct mod_chanmode *new_modes;
{
size_t bp;
infoline = unsplit_string(argv + 1, argc - 1, NULL);
- if(strlen(infoline) > chanserv_conf.max_userinfo_length)
+ if(strlen(infoline) > channel->channel_info->maxsetinfo)
{
- reply("CSMSG_INFOLINE_TOO_LONG", chanserv_conf.max_userinfo_length);
+ reply("CSMSG_INFOLINE_TOO_LONG", channel->channel_info->maxsetinfo);
return 0;
}
bp = strcspn(infoline, "\001");
giveownership = calloc(1, sizeof(*giveownership));
giveownership->issued = now;
- giveownership->old_owner = curr_user->handle->handle;
- giveownership->target = new_owner_hi->handle;
+ giveownership->old_owner = strdup(curr_user->handle->handle);
+ giveownership->target = strdup(new_owner_hi->handle);
giveownership->target_access = new_owner_old_access;
if(override)
{
int
trace_check_bans(struct userNode *user, struct chanNode *chan)
{
- struct chanData *cData;
struct banData *bData;
struct mod_chanmode *change;
- if(!(cData = chan->channel_info))
- return 0;
-
change = find_matching_bans(&chan->banlist, user, NULL);
if (change)
return 1;
- /* ircd list
- if (chan->banlist.used) {
- unsigned int i;
- for (i=0; i<chan->banlist.used; i++) {
- if (!user_matches_glob(user, chan->banlist.list[i], MATCH_USENICK))
- return 1;
- }
- }
-*/
/* lamer list */
- if(chan->banlist.used < MAXBANS)
- {
- for(bData = cData->bans;
- bData && !user_matches_glob(user, bData->mask, MATCH_USENICK);
- bData = bData->next);
+ if (chan->channel_info) {
+ for(bData = chan->channel_info->bans; bData; bData = bData->next) {
- if(bData) {
- return 1;
+ if(!user_matches_glob(user, bData->mask, MATCH_USENICK))
+ continue;
+
+ if(bData)
+ return 1;
}
}
return 0;
}
+int
+channel_user_is_exempt(struct userNode *user, struct chanNode *channel)
+{
+ unsigned int ii;
+ for(ii = 0; ii < channel->exemptlist.used; ii++)
+ {
+ if(user_matches_glob(user, channel->exemptlist.list[ii]->exempt, MATCH_USENICK))
+ return true;
+ }
+ return false;
+}
+
/* Welcome to my worst nightmare. Warning: Read (or modify)
the code below at your own risk. */
unsigned int modes = 0, info = 0;
char *greeting;
- if(IsLocal(user) || !channel->channel_info || IsSuspended(channel->channel_info))
+ if(IsLocal(user) || !channel || !channel->channel_info || IsSuspended(channel->channel_info))
return 0;
cData = channel->channel_info;
/* TODO: maybe only people above inviteme level? -Rubin */
/* We don't kick people with access */
- if(!uData)
+ if(!uData && !channel_user_is_exempt(user, channel))
{
if(channel->banlist.used < MAXBANS)
{
str = database_get_data(channel, KEY_TOPIC, RECDB_QSTRING);
cData->topic = str ? strdup(str) : NULL;
+ str = database_get_data(channel, KEY_MAXSETINFO, RECDB_QSTRING);
+ cData->maxsetinfo = str ? strtoul(str, NULL, 0) : chanserv_conf.max_userinfo_length;
+
if(!IsSuspended(cData)
&& (str = database_get_data(channel, KEY_MODES, RECDB_QSTRING))
&& (argc = split_line(str, 0, ArrayLength(argv), argv))
}
saxdb_end_record(ctx);
+ if (channel->maxsetinfo)
+ saxdb_write_int(ctx, KEY_MAXSETINFO, channel->maxsetinfo);
+
if(channel->modes.modes_set || channel->modes.modes_clear)
{
mod_chanmode_format(&channel->modes, buf);
DEFINE_CHANNEL_OPTION(ctcpreaction);
DEFINE_CHANNEL_OPTION(bantimeout);
DEFINE_CHANNEL_OPTION(inviteme);
+ DEFINE_CHANNEL_OPTION(maxsetinfo);
if(off_channel > 1)
DEFINE_CHANNEL_OPTION(offchannel);
modcmd_register(chanserv_module, "set defaults", chan_opt_defaults, 1, 0, "access", "owner", NULL);