+
+ /* Extended bans */
+ tmpglob = alloca(strlen(orig_glob)+1);
+ tmpglob = strdup(orig_glob);
+
+ if (*tmpglob == '~') {
+ tmpglob++; /* get rid of the ~ */
+
+ if (*tmpglob == '!') {
+ extreverse = 1;
+ tmpglob++; /* get rid of the ! */
+ }
+
+ exttype = *tmpglob;
+ tmpglob++; /* get rid of the type */
+
+ if (*tmpglob == ':') {
+ is_extended = 1;
+ tmpglob++; /* get rid of the : */
+ glob = strdup(tmpglob);
+ }
+ }
+
+ if (is_extended) {
+ log_module(MAIN_LOG, LOG_DEBUG, "Extended ban. T (%c) R (%d) M (%s)", exttype, extreverse, glob);
+ switch (exttype) {
+ case 'a': // account
+ if (user->handle_info) {
+ if (extreverse) {
+ if (0 != strcasecmp(glob, user->handle_info->handle))
+ return 1;
+ } else {
+ if (0 == strcasecmp(glob, user->handle_info->handle))
+ return 1;
+ }
+ } else {
+ if (extreverse)
+ return 1;
+ }
+ return match_ircglob(user->hostname, glob);
+ case 'c': // another channel
+ if (!strstr(glob, "#"))
+ return -1;
+
+ if (extreverse) {
+ for (n=count=0; n<user->channels.used; n++) {
+ mn = user->channels.list[n];
+ match = 0;
+
+ if (*glob == '#') {
+ if (0 == strcasecmp(glob, mn->channel->name))
+ match = 1;
+ } else {
+ if (0 == strcasecmp(glob+1, mn->channel->name)) {
+ if ((*glob == '@') && (mn->modes & MODE_CHANOP))
+ match = 1;
+ else if ((*glob == '%') && (mn->modes & MODE_HALFOP))
+ match = 1;
+ else if ((*glob == '+') && (mn->modes & MODE_VOICE))
+ match = 1;
+ }
+ }
+
+ if (match == 0)
+ banned = 1;
+ else {
+ banned = 0;
+ break;
+ }
+ }
+ } else {
+ for (n=count=0; n<user->channels.used; n++) {
+ mn = user->channels.list[n];
+ match = 0;
+
+ if (*glob == '#') {
+ if (0 == strcasecmp(glob, mn->channel->name))
+ match = 1;
+ } else {
+ if (0 == strcasecmp(glob+1, mn->channel->name)) {
+ if ((*glob == '@') && (mn->modes & MODE_CHANOP))
+ match = 1;
+ else if ((*glob == '%') && (mn->modes & MODE_HALFOP))
+ match = 1;
+ else if ((*glob == '+') && (mn->modes & MODE_VOICE))
+ match = 1;
+ }
+ }
+
+ if (match == 1)
+ banned = 1;
+ }
+ }
+
+ if (banned)
+ return 1;
+ else
+ return match_ircglob(user->hostname, glob);
+ case 'j':
+ if (shared == 0) {
+ if (*glob != '#')
+ return -1;
+ if ((channel = GetChannel(glob))) {
+ for (n = 0; n < channel->banlist.used; n++) {
+ ban = channel->banlist.list[n];
+ if (user_matches_glob(user, ban->ban, flags, 1))
+ return 1;
+ }
+ }
+ }
+ return match_ircglob(user->hostname, glob);
+ case 'n': /* this is handled ircd side */
+ return match_ircglob(user->hostname, glob);
+ case 'q': /* this is handled ircd side */
+ return match_ircglob(user->hostname, glob);
+ case 't': /* this is handled ircd side */
+ return match_ircglob(user->hostname, glob);
+ case 'R': /* this is handled ircd side */
+ return match_ircglob(user->hostname, glob);
+ case 'm': // mute by mark
+ if(user->mark && !strcmp(glob, user->mark))
+ return true;
+ else
+ return false;
+
+ case 'M': // mute by mark unless authed
+ return false; // can never match a logged in user
+
+ default:
+ return -1;
+ }
+ }
+