Simple optimization and cut-and-paste kill in SQL code. Patch against inspircd-1.0.4.

diff -urN inspircd/src/modules/extra/m_sql.h inspircd.mqpr/src/modules/extra/m_sql.h
--- inspircd/src/modules/extra/m_sql.h	2006-01-28 19:33:12.000000000 +0100
+++ inspircd.mqpr/src/modules/extra/m_sql.h	2006-03-28 13:25:50.000000000 +0200
@@ -230,7 +230,7 @@
                 rowresult = NULL;
         }
 
-        std::string Sanitise(std::string crap)
+        static std::string Sanitise(const std::string& crap)
         {
                 std::string temp = "";
                 for (unsigned int q = 0; q < crap.length(); q++)
diff -urN inspircd/src/modules/extra/m_sqlauth.cpp inspircd.mqpr/src/modules/extra/m_sqlauth.cpp
--- inspircd/src/modules/extra/m_sqlauth.cpp	2006-03-11 16:00:26.000000000 +0100
+++ inspircd.mqpr/src/modules/extra/m_sqlauth.cpp	2006-03-28 13:29:02.000000000 +0200
@@ -105,7 +105,7 @@
 		}
 	}
 
-	bool CheckCredentials(const std::string &username, std::string password)
+	bool CheckCredentials(const std::string &s_username, const std::string &s_password)
 	{
 		bool found = false;
 
@@ -114,20 +114,8 @@
 			return false;
 
 		// sanitize the password (we dont want any mysql insertion exploits!)
-		std::string temp = "";
-		for (unsigned int q = 0; q < password.length(); q++)
-		{
-			if (password[q] == '\'')
-			{
-				temp = temp + "\'";
-			}
-			else if (password[q] == '"')
-			{
-				temp = temp + "\\\"";
-			}
-			else temp = temp + password[q];
-		}
-		password = temp;
+		std::string username = SQLQuery::Sanitise(s_username);
+		std::string password = SQLQuery::Sanitise(s_password);
 
 		// Create a request containing the SQL query and send it to m_sql.so
 		std::string querystr("SELECT * FROM "+usertable+" WHERE "+userfield+"='"+username+"' AND "+passfield+"="+encryption+"'"+password+"')");
diff -urN inspircd/src/modules/extra/m_sqloper.cpp inspircd.mqpr/src/modules/extra/m_sqloper.cpp
--- inspircd/src/modules/extra/m_sqloper.cpp	2006-03-11 16:00:26.000000000 +0100
+++ inspircd.mqpr/src/modules/extra/m_sqloper.cpp	2006-03-28 13:28:34.000000000 +0200
@@ -91,7 +91,7 @@
 		return 0;
 	}
 
-	bool LookupOper(std::string username, std::string password, userrec* user)
+	bool LookupOper(const std::string &s_username, const std::string &s_password, userrec* user)
 	{
 		bool found = false;
 
@@ -100,34 +100,8 @@
 			return false;
 
 		// sanitize the password (we dont want any mysql insertion exploits!)
-		std::string temp = "";
-		for (unsigned int q = 0; q < password.length(); q++)
-		{
-			if (password[q] == '\'')
-			{
-				temp = temp + "\'";
-			}
-			else if (password[q] == '"')
-			{
-				temp = temp + "\\\"";
-			}
-			else temp = temp + password[q];
-		}
-		password = temp;
-		temp = "";
-		for (unsigned int v = 0; v < username.length(); v++)
-		{
-			if (username[v] == '\'')
-			{
-				temp = temp + "\'";
-			}
-			if (username[v] == '"')
-			{
-				temp = temp + "\\\"";
-			}
-			else temp = temp + username[v];
-		}
-		username = temp;
+		std::string username = SQLQuery::Sanitise(s_username);
+		std::string password = SQLQuery::Sanitise(s_password);
 
 		// Create a request containing the SQL query and send it to m_sql.so
 		SQLRequest* query = new SQLRequest(SQL_RESULT,dbid,"SELECT username,password,hostname,type FROM ircd_opers WHERE username='"+username+"' AND password=md5('"+password+"')");
