From 7f135d6e55d8740aef10566e4267a87e81fca6ea Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Thu, 3 Jul 2014 15:24:09 -0700 Subject: [PATCH] AddBannedIP converted to QueryDatabase --- common/database.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index 46e31bbe3..9acb6e216 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -184,7 +184,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat } -//Lieka: Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table. +//Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table. bool Database::CheckBannedIPs(const char* loginIP) { char *query = nullptr; @@ -207,18 +207,20 @@ bool Database::CheckBannedIPs(const char* loginIP) bool Database::AddBannedIP(char* bannedIP, const char* notes) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char *query = 0; + char *query = nullptr; - if (!RunQuery(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes), errbuf)) { - std::cerr << "Error in ReserveName query '" << query << "' " << errbuf << std::endl; - safe_delete_array(query); + auto results = QueryDatabase(query, MakeAnyLenString(&query, "INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes)); + + safe_delete_array(query); + + if (!results.Success()) + { + std::cerr << "Error in ReserveName query '" << query << "' " << results.ErrorMessage() << std::endl; return false; } - safe_delete_array(query); + return true; } - //End Lieka Edit bool Database::CheckGMIPs(const char* ip_address, uint32 account_id) { char errbuf[MYSQL_ERRMSG_SIZE];