summaryrefslogtreecommitdiff
path: root/src/login/ipban_sql.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-15 16:47:08 -0300
committershennetsind <ind@henn.et>2013-05-15 16:47:08 -0300
commit0aee4fd57f2f4135361f4182a08a98cf52ed9d10 (patch)
treed7f43f0a5a63e73e21291f906e33109232ce7830 /src/login/ipban_sql.c
parent75942979098d34d52adc2537b6f28e02be7d7bae (diff)
downloadhercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.gz
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.bz2
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.xz
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.zip
HPM Update
Made SQL and strlib functions HPM-friendly, special thanks to Yommy for bringing the issue up. Added partial map.c support, for the all-handy map[] array, beware that soon the whole map.c renewal design will be commit and when that happens your usage of map.c functions in plugins might require some updates. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/login/ipban_sql.c')
-rw-r--r--src/login/ipban_sql.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index c75a1f956..701d3bc1d 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/db.h"
@@ -73,14 +74,14 @@ void ipban_init(void)
}
// establish connections
- sql_handle = Sql_Malloc();
- if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) )
+ sql_handle = SQL->Malloc();
+ if( SQL_ERROR == SQL->Connect(sql_handle, username, password, hostname, port, database) )
{
Sql_ShowDebug(sql_handle);
- Sql_Free(sql_handle);
+ SQL->Free(sql_handle);
exit(EXIT_FAILURE);
}
- if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) )
+ if( codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, codepage) )
Sql_ShowDebug(sql_handle);
if( login_config.ipban_cleanup_interval > 0 )
@@ -104,7 +105,7 @@ void ipban_final(void)
ipban_cleanup(0,0,0,0); // always clean up on login-server stop
// close connections
- Sql_Free(sql_handle);
+ SQL->Free(sql_handle);
sql_handle = NULL;
}
@@ -207,7 +208,7 @@ bool ipban_check(uint32 ip)
if( !login_config.ipban )
return false;// ipban disabled
- if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `rtime` > NOW() AND (`list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u')",
+ if( SQL_ERROR == SQL->Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `rtime` > NOW() AND (`list` = '%u.*.*.*' OR `list` = '%u.%u.*.*' OR `list` = '%u.%u.%u.*' OR `list` = '%u.%u.%u.%u')",
ipban_table, p[3], p[3], p[2], p[3], p[2], p[1], p[3], p[2], p[1], p[0]) )
{
Sql_ShowDebug(sql_handle);
@@ -215,12 +216,12 @@ bool ipban_check(uint32 ip)
return true;
}
- if( SQL_ERROR == Sql_NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->NextRow(sql_handle) )
return true;// Shouldn't happen, but just in case...
- Sql_GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(sql_handle, 0, &data, NULL);
matches = atoi(data);
- Sql_FreeResult(sql_handle);
+ SQL->FreeResult(sql_handle);
return( matches > 0 );
}
@@ -239,7 +240,7 @@ void ipban_log(uint32 ip)
if( failures >= login_config.dynamic_pass_failure_ban_limit )
{
uint8* p = (uint8*)&ip;
- if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')",
+ if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`list`,`btime`,`rtime`,`reason`) VALUES ('%u.%u.%u.*', NOW() , NOW() + INTERVAL %d MINUTE ,'Password error ban')",
ipban_table, p[3], p[2], p[1], login_config.dynamic_pass_failure_ban_duration) )
Sql_ShowDebug(sql_handle);
}
@@ -251,7 +252,7 @@ int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data)
if( !login_config.ipban )
return 0;// ipban disabled
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()") )
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()") )
Sql_ShowDebug(sql_handle);
return 0;