diff -urN ircservices.stock/modules/chanserv/check.c ircservices.new/modules/chanserv/check.c
--- ircservices.stock/modules/chanserv/check.c	2009-08-08 20:40:23.000000000 -0400
+++ ircservices.new/modules/chanserv/check.c	2009-11-28 12:23:28.000000000 -0500
@@ -454,7 +454,8 @@
         }
     }
     free(mask);
-    send_channel_cmd(s_ChanServ, "KICK %s %s :%s", chan, user->nick, reason);
+    send_channel_cmd(s_ChanServ, "REMOVE %s %s :%s", chan, user->nick, reason);
+    notice(s_ChanServ, user->nick, "You were removed from %s (%s)", chan, reason);
     if (!on_join) {
         /* The user is already in the channel userlist, so get them out */
         char *av[3];
diff -urN ircservices.stock/modules/chanserv/main.c ircservices.new/modules/chanserv/main.c
--- ircservices.stock/modules/chanserv/main.c	2009-08-08 20:40:23.000000000 -0400
+++ ircservices.new/modules/chanserv/main.c	2009-11-27 17:24:48.000000000 -0500
@@ -2059,7 +2059,7 @@
                  reason ? " (" : "", reason ? reason : "", reason ? ")" : "");
 
         /* Actually kick user */
-        send_cmd(s_ChanServ, "KICK %s %s :%s", chan, target, reasonbuf);
+        send_cmd(s_ChanServ, "REMOVE %s %s :%s", chan, target, reasonbuf);
         kick_av[0] = chan;
         kick_av[1] = target;
         kick_av[2] = reasonbuf;
diff -urN ircservices.stock/modules/protocol/hybrid.c ircservices.new/modules/protocol/hybrid.c
--- ircservices.stock/modules/protocol/hybrid.c	2009-08-08 20:40:23.000000000 -0400
+++ ircservices.new/modules/protocol/hybrid.c	2010-05-26 10:59:39.000000000 -0400
@@ -7,16 +7,40 @@
  * details.
  */
 
+
+ /* some hacks for use w/ oftc-hybrid7/bc:
+    - modes (see below)
+    - halfops
+    - svsjoin (bc3r1+)
+    - remote klines on akill (hyb7-compat syntax)
+    - sgline support for remote xline
+    - sqline support for remote resv
+    - proper +S mlock checks (bc5+)
+
+   note that using REMOVE (bc5+) instead of KICK is a Good Idea
+   this prevents +R/+S entrance mode check joinfloods if autorejoin is on
+   chanserv's main.c/check.c issue removes now, you may want to modify.
+   we also notify users when they're removed from channels they can't be on
+		-- avenj
+*/
+
 #include "services.h"
 #include "modules.h"
 #include "conffile.h"
 #include "messages.h"
 
+#include "modules/operserv/operserv.h"
+#include "modules/operserv/maskdata.h"
+#include "modules/nickserv/nickserv.h"
+#include "modules/chanserv/chanserv.h"
+
 #define BAHAMUT_HACK
 #include "banexcept.c"
 #include "invitemask.c"
 #include "sjoin.c"
 #include "svsnick.c"
+#include "halfop.c"
+
 
 /*************************************************************************/
 
@@ -31,36 +55,80 @@
 /************************** User/channel modes ***************************/
 /*************************************************************************/
 
+/* for bc5 +E, lets us do proper +S entrance mode checks */
+#define MI_SECURE_ONLY  0x01000000
+#define MI_SECURE       0x01000000  /* Usermode for users on secure conn's */
+
+static int32 usermode_secure = 0;       /* +E */
+static int32 chanmode_secure_only = 0;  /* +S */
+
 struct modedata_init {
     uint8 mode;
     ModeData data;
 };
 
+  /* mode changes:
+  30 mar 2010 avenj
+  bc6dev5: cmode +C
+
+  26 nov 2009 avenj
+  bc5 prep: +E UMODE_SSL
+
+  17 nov 2009 avenj
+  +d gecos denylist for bc4+
+  kill +z, busted, scheduled for removal
+
+  07 nov 2009  avenj
+
+  kill cmode +a, we don't have it (hideops)
+  added umode +R
+  added cmode +M +R +S +z +q
+  */
+
 static const struct modedata_init new_usermodes[] = {
     {'a', {0x00000008,0,0}},    /* Server admin */
+    {'P', {0x00000800}},        /* Services client */
+    {'R', {0x00000020,0,0,0,MI_REGISTERED}},   /* Registered */
+    {'E', {0x00000100,0,0,0,MI_SECURE}}, /* +E UMODE_SSL */
 };
 
 static const struct modedata_init new_chanmodes[] = {
-    {'a', {0x00000100,0,0}},    /* Hide ops */
-    {'e', {0x80000000,1,1,0,MI_MULTIPLE}},
-                                /* Ban exceptions */
-    {'I', {0x80000000,1,1,0,MI_MULTIPLE}},
-            /* Auto-invite masks (Hybrid calls these "invite exceptions") */
+    /* 'list' modes */
+    {'q', {0x80000000,1,1,0,MI_MULTIPLE}}, /* Quiet */
+    {'e', {0x80000000,1,1,0,MI_MULTIPLE}}, /* Ban exceptions */
+    {'I', {0x80000000,1,1,0,MI_MULTIPLE}}, /* Invite exceptions */
+    {'d', {0x80000000,1,1,0,MI_MULTIPLE}}, /* +d gecos deny (bc4+) */
+    /* oftc-hybrid chanmodes */
+    {'M', {0x02000000,0,0}},    /* unregistered are moderated */
+    {'R', {0x00000100,0,0,0,MI_REGNICKS_ONLY}},   /* registered-only */
+    {'S', {0x00002000,0,0,0,MI_SECURE_ONLY}},  /* secure-only */
+    {'c', {0x00004000,0,0}},    /* No ANSI colors in channel */
+    {'C', {0x00008000,0,0}},    /* No channel-wide CTCP */
 };
 
 static const struct modedata_init new_chanusermodes[] = {
+	{'h', {0x00000004,1,1,'%'}}, /* halfop */
 };
 
 static void init_modes(void)
 {
     int i;
 
-    for (i = 0; i < lenof(new_usermodes); i++)
+    for (i = 0; i < lenof(new_usermodes); i++) {
         usermodes[new_usermodes[i].mode] = new_usermodes[i].data;
-    for (i = 0; i < lenof(new_chanmodes); i++)
+        if (new_usermodes[i].data.info & MI_SECURE)
+            usermode_secure |= new_usermodes[i].data.flag;
+    }
+
+    for (i = 0; i < lenof(new_chanmodes); i++) {
         chanmodes[new_chanmodes[i].mode] = new_chanmodes[i].data;
-    for (i = 0; i < lenof(new_chanusermodes); i++)
+        if (new_chanmodes[i].data.info & MI_SECURE_ONLY)
+            chanmode_secure_only |= new_chanmodes[i].data.flag;
+    }
+
+    for (i = 0; i < lenof(new_chanusermodes); i++) {
         chanusermodes[new_chanusermodes[i].mode] = new_chanusermodes[i].data;
+    }
 
     mode_setup();
 };
@@ -185,9 +253,8 @@
     { NULL }
 };
 
-/*************************************************************************/
+
 /************************** IRC message sending **************************/
-/*************************************************************************/
 
 /* Send a NICK command for a new user. */
 
@@ -215,7 +282,7 @@
 
 static void do_send_namechange(const char *nick, const char *newname)
 {
-    /* Not supported by this protocol. */
+    send_cmd(s_OperServ, "ENCAP * CHGNAME %s :%s", nick, newname);
 }
 
 /*************************************************************************/
@@ -227,7 +294,7 @@
 static void do_send_server(void)
 {
     send_cmd(NULL, "PASS %s :TS", RemotePassword);
-    send_cmd(NULL, "CAPAB :EX IE KLN UNKLN HUB TBURST");
+    send_cmd(NULL, "CAPAB :EX DE IE KLN UNKLN HUB TBURST ENCAP");
     send_cmd(NULL, "SERVER %s 1 :%s", ServerName, ServerDesc);
     send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long)time(NULL));
 }
@@ -268,16 +335,19 @@
     va_start(args, fmt);
     vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
     va_end(args);
-    if (NetworkDomain) {
-        send_cmd(source, "NOTICE $$*.%s :%s", NetworkDomain, msgbuf);
-    } else {
-        /* Go through all common top-level domains.  If you have others,
-         * add them here. */
         send_cmd(source, "NOTICE $$*.com :%s", msgbuf);
         send_cmd(source, "NOTICE $$*.net :%s", msgbuf);
         send_cmd(source, "NOTICE $$*.org :%s", msgbuf);
         send_cmd(source, "NOTICE $$*.edu :%s", msgbuf);
-    }
+        send_cmd(source, "NOTICE $$*.us :%s", msgbuf);
+        /*
+         send_cmd(source, "NOTICE $$.uk :%s", msgbuf);
+         send_cmd(source, "NOTICE $$.nl :%s", msgbuf);
+         send_cmd(source, "NOTICE $$.de :%s", msgbuf);
+         send_cmd(source, "NOTICE $$.dk :%s", msgbuf);
+         send_cmd(source, "NOTICE $$.fi :%s", msgbuf);
+         send_cmd(source, "NOTICE $$.br :%s", msgbuf);
+        */
 }
 
 /*************************************************************************/
@@ -293,6 +363,27 @@
     va_end(args);
 }
 
+
+/* +S check for bc5 */
+static int do_check_kick(User *user, const char *chan, ChannelInfo *ci,
+                         char **mask_ret, const char **reason_ret)
+{
+    /* Retrieve the channel's Channel record, if present */
+    Channel *c = get_channel(chan);
+
+    /* Don't let users not on secure connections (-S) into +S channels */
+    if ((((c?c->mode:0) | (ci?ci->mlock.on:0)) & chanmode_secure_only)
+     && !(user->mode & usermode_secure)
+    ) {
+        *mask_ret = create_mask(user, 1);
+        *reason_ret = getstring(user->ngi, CHAN_NOT_ALLOWED_TO_JOIN);
+        return 1;
+    }
+
+    /* Let other processing continue as usual */
+    return 0;
+}
+
 /*************************************************************************/
 /******************************* Callbacks *******************************/
 /*************************************************************************/
@@ -303,18 +394,22 @@
     if (setter)
         return 0;
     c->topic_time = t;
-    send_cmd(source, "TBURST %ld %s %ld %s :%s", (long)c->creation_time,
+    /* this is ugly, but unless the TS is older hybrid will reject the TBURST... */
+    c->creation_time -= 900;
+    send_cmd(ServerName, "TBURST %ld %s %ld %s :%s", (long)c->creation_time,
              c->name, (long)c->topic_time, c->topic_setter,
              c->topic ? c->topic : "");
     return 1;
 }
 
-/*************************************************************************/
+   /***************** Bans *****************/
+   /* we don't have akill, but we do have remote kline. hyb7 compat */
 
 static int do_send_akill(const char *username, const char *host,
                          time_t expires, const char *who, const char *reason)
 {
     if (expires) {
+         /* hyb7 expiries are in seconds from now */
         expires -= time(NULL);
         if (expires < 1)
             expires = 1;
@@ -324,14 +419,60 @@
     return 1;
 }
 
-/*************************************************************************/
-
 static int do_cancel_akill(const char *username, const char *host)
 {
     send_cmd(s_OperServ, "UNKLINE * %s %s", username, host);
     return 1;
 }
 
+
+  /* we don't have sgline, but we do have xline for gecos bans */
+
+static int do_send_sgline(const char *mask, time_t expires, const char *who,
+                          const char *reason)
+{
+    if (expires) {
+        expires -= time(NULL);
+        if (expires < 1)
+            expires = 1;
+    }
+    send_cmd(s_OperServ, "ENCAP * XLINE * %s %ld :%s", mask, (long)expires, reason);
+    return 1;
+}
+
+static int do_cancel_sgline(const char *mask)
+{
+    send_cmd(s_OperServ, "UNXLINE * %s", mask);
+    return 1;
+}
+
+
+  /* ...and we don't have qlines but we do have remote resv */
+
+static int do_send_sqline(const char *mask, time_t expires, const char *who,
+                          const char *reason)
+{
+    send_cmd(s_OperServ, "RESV * %s :%s", mask, reason);
+    return 1;
+}
+
+static int do_cancel_sqline(const char *mask)
+{
+    send_cmd(s_OperServ, "UNRESV * %s", mask);
+    return 1;
+}
+
+
+/*************************************************************************/
+  /* SVSJOIN, force a user to join a channel (bc3r1+) */
+
+static int do_send_svsjoin(const char *nick, const char *channel)
+{
+    send_cmd(ServerName, "FORCEJOIN %s %s", nick, channel);
+    return 1;
+}
+
+
 /*************************************************************************/
 /***************************** Module stuff ******************************/
 /*************************************************************************/
@@ -356,7 +497,23 @@
             module_log("Unable to add send_akill callback");
         if (!add_callback(mod, "cancel_akill", do_cancel_akill))
             module_log("Unable to add cancel_akill callback");
+    } else if (strcmp(modname, "operserv/sline") == 0) {
+        if (!add_callback(mod, "send_sgline", do_send_sgline))
+            module_log("Unable to add send_sgline callback");
+        if (!add_callback(mod, "cancel_sgline", do_cancel_sgline))
+            module_log("Unable to add cancel_sgline callback");
+        if (!add_callback(mod, "send_sqline", do_send_sqline))
+            module_log("Unable to add send_sqline callback");
+        if (!add_callback(mod, "cancel_sqline", do_cancel_sqline))
+            module_log("Unable to add cancel_sqline callback");
+    } else if (strcmp(modname, "nickserv/autojoin") == 0) {
+        if (!add_callback(mod, "send_svsjoin", do_send_svsjoin))
+            module_log("Unable to add NickServ send_svsjoin callback");
+    } else if (strcmp(modname, "chanserv/main") == 0) {
+        if (!add_callback(mod, "check_kick", do_check_kick))
+            module_log("Unable to add ChanServ check_kick callback");
     }
+
     return 0;
 }
 
@@ -368,6 +525,7 @@
         module_operserv = NULL;
         p_s_OperServ = &ServerName;
     }
+
     return 0;
 }
 
@@ -377,7 +535,7 @@
 {
     protocol_name     = "Hybrid";
     protocol_version  = "7.0";
-    protocol_features = 0;
+    protocol_features = PF_HALFOP | PF_SVSJOIN;
     protocol_nickmax  = 30;
 
     if (!register_messages(hybrid_messages)) {
@@ -395,7 +553,10 @@
         return 0;
     }
 
-    if (!init_sjoin() || !init_svsnick("SVSNICK")) {
+    if (!init_sjoin()
+	|| !init_svsnick("SVSNICK")
+	|| !init_halfop()
+	) {
         return 0;
     }
 
@@ -411,9 +572,11 @@
     wallops            = do_wallops;
     notice_all         = do_notice_all;
     send_channel_cmd   = do_send_channel_cmd;
-    pseudoclient_modes = "+i";
+    pseudoclient_modes = "+iP";
     enforcer_modes     = "+i";
-    pseudoclient_oper  = 1;
+    /* as of bc5 we shouldn't need to oper pseudoclients.
+       if we do it's an ircd bug */
+    pseudoclient_oper  = 0;
 
     return 1;
 }
@@ -433,6 +596,7 @@
         exit_banexcept();
     exit_svsnick();
     exit_sjoin();
+    exit_halfop();
 
     remove_callback(NULL, "set topic", do_set_topic);
     remove_callback(NULL, "unload module", do_unload_module);
diff -urN ircservices.stock/modules/protocol/Makefile ircservices.new/modules/protocol/Makefile
--- ircservices.stock/modules/protocol/Makefile	2009-08-08 20:40:22.000000000 -0400
+++ ircservices.new/modules/protocol/Makefile	2009-10-13 18:43:23.000000000 -0400
@@ -26,7 +26,7 @@
 	$(TOPDIR)/modules/operserv/operserv.h \
 	$(TOPDIR)/modules/nickserv/nickserv.h
 INCLUDES-hybrid.o = $(BANEXCEPT_C) $(INVITEMASK_C) $(SJOIN_C) $(SVSNICK_C) \
-	$(TOPDIR)/messages.h
+	$(TOPDIR)/messages.h $(HALFOP_C)
 INCLUDES-inspircd.o = $(BANEXCEPT_C) $(CHANPROT_C) $(HALFOP_C) \
 	$(INVITEMASK_C) $(SVSNICK_C) \
 	$(TOPDIR)/messages.h $(TOPDIR)/language.h $(TOPDIR)/timeout.h \

