]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_sqloper.cpp
Convert remaining InspIRCd::Log() calls to new logging system
[user/henk/code/inspircd.git] / src / modules / extra / m_sqloper.cpp
index c697d6a9b5b067a30c81c0c30797aa24e0abf639..01ff0b3d4f4d9b5270251e1f384351374d9b3699 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
@@ -49,6 +49,8 @@ public:
                        throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqloper.so.");
 
                OnRehash(NULL,"");
+               Implementation eventlist[] = { I_OnRequest, I_OnRehash, I_OnPreCommand };
+               ServerInstance->Modules->Attach(eventlist, this, 3);
        }
 
        virtual ~ModuleSQLOper()
@@ -58,10 +60,6 @@ public:
                ServerInstance->Modules->DoneWithInterface("HashRequest");
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnRequest] = List[I_OnRehash] = List[I_OnPreCommand] = 1;
-       }
 
        virtual void OnRehash(User* user, const std::string &parameter)
        {
@@ -70,7 +68,7 @@ public:
                databaseid = Conf.ReadValue("sqloper", "dbid", 0); /* Database ID of a database configured for the service provider module */
        }
 
-       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, User *user, bool validated, const std::string &original_line)
+       virtual int OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line)
        {
                if ((validated) && (command == "OPER"))
                {
@@ -104,7 +102,8 @@ public:
                         * also hashing it in the module and only passing a remote query containing a hash is more secure.
                         */
 
-                       SQLrequest req = SQLreq(this, target, databaseid, "SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password='?'", username, md5_pass_hash);
+                       SQLrequest req = SQLrequest(this, target, databaseid,
+                                       SQLquery("SELECT username, password, hostname, type FROM ircd_opers WHERE username = '?' AND password='?'") % username % md5_pass_hash);
                        
                        if (req.Send())
                        {
@@ -129,12 +128,12 @@ public:
                }
                else
                {
-                       ServerInstance->Log(SPARSE, "WARNING: Couldn't find SQL provider module. NOBODY will be able to oper up unless their o:line is statically configured");
+                       ServerInstance->Logs->Log("m_sqloper",SPARSE, "WARNING: Couldn't find SQL provider module. NOBODY will be able to oper up unless their o:line is statically configured");
                        return false;
                }
        }
        
-       virtual char* OnRequest(Request* request)
+       virtual const char* OnRequest(Request* request)
        {
                if (strcmp(SQLRESID, request->GetId()) == 0)
                {
@@ -236,7 +235,7 @@ public:
                }
                else
                {
-                       ServerInstance->Log(DEBUG, "BUG: WHAT?! Why do we have no OPER command?!");
+                       ServerInstance->Logs->Log("m_sqloper",DEBUG, "BUG: WHAT?! Why do we have no OPER command?!");
                }
        }
 
@@ -263,7 +262,7 @@ public:
                                user->WriteServ("381 %s :You are now %s %s",user->nick, strchr("aeiouAEIOU", type[0]) ? "an" : "a", irc::Spacify(type.c_str()));
 
                                if (!user->modes[UM_OPERATOR])
-                                       user->Oper(type);
+                                       user->Oper(type, tname);
 
                                return true;
                        }
@@ -279,4 +278,4 @@ public:
        
 };
 
-MODULE_INIT(ModuleSQLOper);
+MODULE_INIT(ModuleSQLOper)