summaryrefslogtreecommitdiff
path: root/src/account-server/dalstorage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/account-server/dalstorage.cpp')
-rw-r--r--src/account-server/dalstorage.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp
index cd618a43..3e3f8990 100644
--- a/src/account-server/dalstorage.cpp
+++ b/src/account-server/dalstorage.cpp
@@ -1106,3 +1106,55 @@ void DALStorage::banCharacter(int id, int duration)
LOG_ERROR("(DALStorage::banAccount) SQL query failure: " << e.what());
}
}
+
+void DALStorage::removeBan(int accountID)
+{
+ try
+ {
+ std::ostringstream sql;
+ sql << "update " << ACCOUNTS_TBL_NAME
+ << " set level = '" << AL_NORMAL << "', banned = '"
+ << 0
+ << "' where id = '" << accountID << "';";
+ 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());
+ }
+}