+ if(strcmp(SQLRESID, request->GetId()) == 0)
+ {
+ SQLresult* res;
+
+ res = static_cast<SQLresult*>(request);
+
+ ServerInstance->Log(DEBUG, "Got SQL result (%s) with ID %lu", res->GetId(), res->id);
+
+ userrec* user = GetAssocUser(this, SQLutils, res->id).S().user;
+ UnAssociate(this, SQLutils, res->id).S();
+
+ if(user)
+ {
+ if(res->error.Id() == NO_ERROR)
+ {
+ ServerInstance->Log(DEBUG, "Associated query ID %lu with user %s", res->id, user->nick);
+ ServerInstance->Log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
+
+ if(res->Rows())
+ {
+ /* We got a row in the result, this is enough really */
+ user->Extend("sqlauthed");
+ }
+ else if (verbose)
+ {
+ /* No rows in result, this means there was no record matching the user */
+ Srv->WriteOpers("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->Log(DEBUG, "Query failed: %s", res->error.Str());
+ Srv->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, res->error.Str());
+ user->Extend("sqlauth_failed");
+ }
+ }
+ else
+ {
+ ServerInstance->Log(DEBUG, "Got query with unknown ID, this probably means the user quit while the query was in progress");
+ return NULL;
+ }