]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_sqlauth.cpp
Wheeeeee
[user/henk/code/inspircd.git] / src / modules / extra / m_sqlauth.cpp
index 98b0227e5ad3157927e4dac3ace89fdab33c6bc3..e73abe0cc54952815205c7171c3990822563962c 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -52,6 +52,8 @@ public:
                        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);
        }
 
        virtual ~ModuleSQLAuth()
@@ -60,10 +62,6 @@ public:
                ServerInstance->Modules->DoneWithInterface("SQLutils");
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnUserDisconnect] = List[I_OnCheckReady] = List[I_OnRequest] = List[I_OnRehash] = List[I_OnUserRegister] = 1;
-       }
 
        virtual void OnRehash(User* user, const std::string &parameter)
        {
@@ -104,7 +102,8 @@ public:
 
        bool CheckCredentials(User* user)
        {
-               SQLrequest req = SQLreq(this, SQLprovider, databaseid, "SELECT ? FROM ? WHERE ? = '?' AND ? = ?'?')", userfield, usertable, userfield, user->nick, passfield, encryption, user->password);
+               SQLrequest req = SQLrequest(this, SQLprovider, databaseid, SQLquery("SELECT ? FROM ? WHERE ? = '?' AND ? = ?'?')") % userfield % usertable % userfield % user->nick %
+                               passfield % encryption % user->password);
                        
                if(req.Send())
                {
@@ -122,12 +121,12 @@ public:
                else
                {
                        if (verbose)
-                               ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
+                               ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
                        return false;
                }
        }
        
-       virtual char* OnRequest(Request* request)
+       virtual const char* OnRequest(Request* request)
        {
                if(strcmp(SQLRESID, request->GetId()) == 0)
                {
@@ -148,13 +147,13 @@ public:
                                        else if (verbose)
                                        {
                                                /* No rows in result, this means there was no record matching the user */
-                                               ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host);
+                                               ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick, user->ident, user->host);
                                                user->Extend("sqlauth_failed");
                                        }
                                }
                                else if (verbose)
                                {
-                                       ServerInstance->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str());
+                                       ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str());
                                        user->Extend("sqlauth_failed");
                                }
                        }