- Conf = new ConfigReader();
- usertable = Conf->ReadValue("sqlauth","usertable",0); // user table name
- dbid = Conf->ReadInteger("sqlauth","dbid",0,true); // database id of a database configured in m_sql (see m_sql config)
- userfield = Conf->ReadValue("sqlauth","userfield",0); // field name where username can be found
- passfield = Conf->ReadValue("sqlauth","passfield",0); // field name where password can be found
- killreason = Conf->ReadValue("sqlauth","killreason",0); // reason to give when access is denied to a user (put your reg details here)
- encryption = Conf->ReadValue("sqlauth","encryption",0); // name of sql function used to encrypt password, e.g. "md5" or "passwd".
- // define, but leave blank if no encryption is to be used.
- WallOperFail = Conf->ReadFlag("sqlauth","verbose",0); // set to 1 if failed connects should be reported to operators
- allowpattern = Conf->ReadValue("sqlauth","allowpattern",0); // allow nicks matching the pattern without requiring auth
- delete Conf;
- SQLModule = Srv->FindModule("m_sql.so");
- if (!SQLModule)
- Srv->Log(DEFAULT,"WARNING: m_sqlauth.so could not initialize because m_sql.so is not loaded. Load the module and rehash your server.");
- return (SQLModule);
+ ServerInstance->Modules->UseInterface("SQLutils");
+ ServerInstance->Modules->UseInterface("SQL");
+
+ SQLutils = ServerInstance->Modules->Find("m_sqlutils.so");
+ if (!SQLutils)
+ throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqlauth.so.");
+
+ SQLprovider = ServerInstance->Modules->FindFeature("SQL");
+ if (!SQLprovider)
+ throw ModuleException("Can't find an SQL provider module. Please load one before attempting to load m_sqlauth.");
+
+ OnRehash(NULL,"");
+ Implementation eventlist[] = { I_OnUserDisconnect, I_OnCheckReady, I_OnRequest, I_OnRehash, I_OnUserRegister };
+ ServerInstance->Modules->Attach(eventlist, this, 5);