summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/account-server/dalstorage.cpp44
-rw-r--r--src/account-server/dalstorage.hpp7
3 files changed, 7 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index 173cb5f3..d744295e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
* src/account-server/main-account.cpp,
src/account-server/dalstorage.cpp, src/account-server/dalstorage.hpp:
Added checking for expired bans.
+ * src/account-server/dalstorage.cpp, src/account-server/dalstorage.hpp:
+ ExceptionFault corrected my poor sql skills.
2008-08-18 Roderic Morris <roderic@ccs.neu.edu>
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp
index 3e3f8990..991acf19 100644
--- a/src/account-server/dalstorage.cpp
+++ b/src/account-server/dalstorage.cpp
@@ -1107,54 +1107,20 @@ void DALStorage::banCharacter(int id, int duration)
}
}
-void DALStorage::removeBan(int accountID)
+void DALStorage::checkBannedAccounts()
{
try
{
+ // update expired bans
std::ostringstream sql;
sql << "update " << ACCOUNTS_TBL_NAME
- << " set level = '" << AL_NORMAL << "', banned = '"
- << 0
- << "' where id = '" << accountID << "';";
+ << " set level = " << AL_NORMAL << ", banned = 0"
+ << " where level = " << AL_BANNED
+ << " AND banned <= " << time(NULL) << ";";
mDb->execSql(sql.str());
}
catch (dal::DbSqlQueryExecFailure const &e)
{
- LOG_ERROR("(DALStorage::removeBan) SQL query failure: " << e.what());
- }
-}
-
-void DALStorage::checkBannedAccounts()
-{
- try
- {
- // get all banned users
- std::ostringstream sql;
- sql << "select id,banned from " << ACCOUNTS_TBL_NAME
- << " where level = '" << AL_BANNED << "';";
- dal::RecordSet const &info = mDb->execSql(sql.str());
-
- // loop through all banned users, and see if they have expired
- for (int i = 0; i < info.rows(); ++i)
- {
- int t = time(NULL);
- std::stringstream expiry;
- expiry << info(i, 1);
- int banned;
- expiry >> banned;
- if (t > banned)
- {
- // ban has expired, remove it
- std::stringstream user;
- user << info(i,0);
- int id;
- user >> id;
- removeBan(id);
- }
- }
- }
- catch (dal::DbSqlQueryExecFailure const &e)
- {
LOG_ERROR("(DALStorage::checkBannedAccounts) SQL query failure: " << e.what());
}
}
diff --git a/src/account-server/dalstorage.hpp b/src/account-server/dalstorage.hpp
index 87fd855f..af3546f2 100644
--- a/src/account-server/dalstorage.hpp
+++ b/src/account-server/dalstorage.hpp
@@ -126,13 +126,6 @@ class DALStorage
void banCharacter(int id, int duration);
/**
- * Removes a ban on an account (hence on all its characters).
- *
- * @param accountID account identifier.
- */
- void removeBan(int accountID);
-
- /**
* Removes expired bans from accounts
*/
void checkBannedAccounts();