- SQLrequest req = SQLreq(this, SQLprovider, databaseid, "SELECT ? FROM ? WHERE ? = '?' AND ? = ?'?')", userfield, usertable, userfield, user->nick, passfield, encryption, user->password);
-
+ std::string::size_type x = newline.find(find);
+ while (x != std::string::npos)
+ {
+ newline.erase(x, find.length());
+ if (!replace.empty())
+ newline.insert(x, replace);
+ x = newline.find(find);
+ }
+ }
+
+ bool CheckCredentials(User* user)
+ {
+ std::string thisquery = freeformquery;
+ std::string safepass = user->password;
+
+ /* Search and replace the escaped nick and escaped pass into the query */
+
+ SearchAndReplace(safepass, "\"", "");
+
+ SearchAndReplace(thisquery, "$nick", user->nick);
+ SearchAndReplace(thisquery, "$pass", safepass);
+ SearchAndReplace(thisquery, "$host", user->host);
+ SearchAndReplace(thisquery, "$ip", user->GetIPString());
+
+ Module* HashMod = ServerInstance->Modules->Find("m_md5.so");
+
+ if (HashMod)
+ {
+ HashResetRequest(this, HashMod).Send();
+ SearchAndReplace(thisquery, "$md5pass", HashSumRequest(this, HashMod, user->password).Send());
+ }
+
+ HashMod = ServerInstance->Modules->Find("m_sha256.so");
+
+ if (HashMod)
+ {
+ HashResetRequest(this, HashMod).Send();
+ SearchAndReplace(thisquery, "$sha256pass", HashSumRequest(this, HashMod, user->password).Send());
+ }
+
+ /* Build the query */
+ SQLrequest req = SQLrequest(this, SQLprovider, databaseid, SQLquery(thisquery));
+