]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_sqlauth.cpp
Fix various rline bugs, implement /stats R, and fix the issue where you get no error...
[user/henk/code/inspircd.git] / src / modules / extra / m_sqlauth.cpp
index 9ca4473b82fb38475d2f89a35a0c8bc99b5f2c04..ffaf6e6058fbb6921e201b760c7bc8e00c95004e 100644 (file)
@@ -31,12 +31,12 @@ class ModuleSQLAuth : public Module
        std::string killreason;
        std::string allowpattern;
        std::string databaseid;
-       
+
        bool verbose;
-       
+
 public:
        ModuleSQLAuth(InspIRCd* Me)
-       : Module::Module(Me)
+       : Module(Me)
        {
                ServerInstance->Modules->UseInterface("SQLutils");
                ServerInstance->Modules->UseInterface("SQL");
@@ -74,12 +74,12 @@ public:
 
        virtual int OnUserRegister(User* user)
        {
-               if ((!allowpattern.empty()) && (ServerInstance->MatchText(user->nick,allowpattern)))
+               if ((!allowpattern.empty()) && (InspIRCd::Match(user->nick,allowpattern)))
                {
                        user->Extend("sqlauthed");
                        return 0;
                }
-               
+
                if (!CheckCredentials(user))
                {
                        ServerInstance->Users->QuitUser(user, killreason);
@@ -104,7 +104,7 @@ public:
        {
                std::string thisquery = freeformquery;
                std::string safepass = user->password;
-               
+
                /* Search and replace the escaped nick and escaped pass into the query */
 
                SearchAndReplace(safepass, "\"", "");
@@ -132,7 +132,7 @@ public:
 
                /* Build the query */
                SQLrequest req = SQLrequest(this, SQLprovider, databaseid, SQLquery(thisquery));
-                       
+
                if(req.Send())
                {
                        /* When we get the query response from the service provider we will be given an ID to play with,
@@ -143,17 +143,17 @@ public:
                         * us to discard the query.
                         */
                        AssociateUser(this, SQLutils, req.id, user).Send();
-                               
+
                        return true;
                }
                else
                {
                        if (verbose)
-                               ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host, req.error.Str());
+                               ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), req.error.Str());
                        return false;
                }
        }
-       
+
        virtual const char* OnRequest(Request* request)
        {
                if(strcmp(SQLRESID, request->GetId()) == 0)
@@ -162,10 +162,10 @@ public:
 
                        User* user = GetAssocUser(this, SQLutils, res->id).S().user;
                        UnAssociate(this, SQLutils, res->id).S();
-                       
+
                        if(user)
                        {
-                               if(res->error.Id() == NO_ERROR)
+                               if(res->error.Id() == SQL_NO_ERROR)
                                {
                                        if(res->Rows())
                                        {
@@ -175,13 +175,13 @@ public:
                                        else if (verbose)
                                        {
                                                /* No rows in result, this means there was no record matching the user */
-                                               ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick.c_str(), user->ident.c_str(), user->host);
+                                               ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query returned no matches)", user->nick.c_str(), user->ident.c_str(), user->host.c_str());
                                                user->Extend("sqlauth_failed");
                                        }
                                }
                                else if (verbose)
                                {
-                                       ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host, res->error.Str());
+                                       ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), res->error.Str());
                                        user->Extend("sqlauth_failed");
                                }
                        }
@@ -195,16 +195,16 @@ public:
                                ServerInstance->Users->QuitUser(user, killreason);
                        }
                        return SQLSUCCESS;
-               }               
+               }
                return NULL;
        }
-       
+
        virtual void OnUserDisconnect(User* user)
        {
                user->Shrink("sqlauthed");
-               user->Shrink("sqlauth_failed");         
+               user->Shrink("sqlauth_failed");
        }
-       
+
        virtual bool OnCheckReady(User* user)
        {
                return user->GetExt("sqlauthed");
@@ -212,9 +212,9 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version(1,2,1,0,VF_VENDOR,API_VERSION);
+               return Version("$Id$", VF_VENDOR, API_VERSION);
        }
-       
+
 };
 
 MODULE_INIT(ModuleSQLAuth)