mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-07 07:14:22 +00:00
Add dashboard audit log and configuration management
- Implemented dashboard audit logging with InsertAuditLog, GetRecentAuditLogs, GetAuditLogsByIP, and CleanupOldAuditLogs methods. - Created dashboard configuration management with GetDashboardConfig and SetDashboardConfig methods. - Added new tables for dashboard_audit_log and dashboard_config in both MySQL and SQLite migrations. - Updated CMakeLists to include Crow and ASIO for dashboard server functionality. - Enhanced existing database classes to support new dashboard features, including character, play key, and property management. - Added new methods for retrieving and managing play keys, properties, and pet names. - Updated TestSQLDatabase to include stubs for new dashboard-related methods. - Modified shared and dashboard configuration files for new settings.
This commit is contained in:
@@ -41,7 +41,85 @@ void MySQLDatabase::UpdateAccountGmLevel(const uint32_t accountId, const eGameMa
|
||||
ExecuteUpdate("UPDATE accounts SET gm_level = ? WHERE id = ?;", static_cast<int32_t>(gmLevel), accountId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::UpdateAccountPlayKey(const uint32_t accountId, const uint32_t playKeyId) {
|
||||
ExecuteUpdate("UPDATE accounts SET play_key_id = ? WHERE id = ?;", playKeyId, accountId);
|
||||
}
|
||||
|
||||
uint32_t MySQLDatabase::GetAccountCount() {
|
||||
auto res = ExecuteSelect("SELECT COUNT(*) as count FROM accounts;");
|
||||
return res->next() ? res->getUInt("count") : 0;
|
||||
}
|
||||
|
||||
uint32_t MySQLDatabase::GetBannedAccountCount() {
|
||||
auto res = ExecuteSelect("SELECT COUNT(*) as count FROM accounts WHERE banned = 1;");
|
||||
return res->next() ? res->getUInt("count") : 0;
|
||||
}
|
||||
|
||||
uint32_t MySQLDatabase::GetLockedAccountCount() {
|
||||
auto res = ExecuteSelect("SELECT COUNT(*) as count FROM accounts WHERE locked = 1;");
|
||||
return res->next() ? res->getUInt("count") : 0;
|
||||
}
|
||||
|
||||
std::vector<IAccounts::ListInfo> MySQLDatabase::GetAllAccounts() {
|
||||
std::vector<IAccounts::ListInfo> out;
|
||||
auto res = ExecuteSelect("SELECT id, name, gm_level, banned, locked, mute_expire, play_key_id FROM accounts ORDER BY id ASC;");
|
||||
|
||||
while (res->next()) {
|
||||
IAccounts::ListInfo info;
|
||||
info.id = res->getUInt("id");
|
||||
info.name = res->getString("name").c_str();
|
||||
info.gm_level = static_cast<eGameMasterLevel>(res->getInt("gm_level"));
|
||||
info.banned = res->getBoolean("banned");
|
||||
info.locked = res->getBoolean("locked");
|
||||
info.mute_expire = res->getUInt64("mute_expire");
|
||||
info.play_key_id = res->getUInt("play_key_id");
|
||||
out.push_back(info);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void MySQLDatabase::UpdateAccountLock(const uint32_t accountId, const bool locked) {
|
||||
ExecuteUpdate("UPDATE accounts SET locked = ? WHERE id = ?;", locked, accountId);
|
||||
}
|
||||
|
||||
std::optional<IAccounts::DetailedInfo> MySQLDatabase::GetAccountById(const uint32_t accountId) {
|
||||
auto result = ExecuteSelect(
|
||||
"SELECT id, name, email, gm_level, banned, locked, mute_expire, play_key_id, created_at FROM accounts WHERE id = ? LIMIT 1;",
|
||||
accountId
|
||||
);
|
||||
|
||||
if (!result->next()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
IAccounts::DetailedInfo info;
|
||||
info.id = result->getUInt("id");
|
||||
info.name = result->getString("name").c_str();
|
||||
info.email = result->getString("email").c_str();
|
||||
info.gm_level = static_cast<eGameMasterLevel>(result->getInt("gm_level"));
|
||||
info.banned = result->getBoolean("banned");
|
||||
info.locked = result->getBoolean("locked");
|
||||
info.mute_expire = result->getUInt64("mute_expire");
|
||||
info.play_key_id = result->getUInt("play_key_id");
|
||||
info.created_at = result->getUInt64("created_at");
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void MySQLDatabase::UpdateAccountEmail(const uint32_t accountId, const std::string_view email) {
|
||||
ExecuteUpdate("UPDATE accounts SET email = ? WHERE id = ?;", email, accountId);
|
||||
}
|
||||
|
||||
void MySQLDatabase::DeleteAccount(const uint32_t accountId) {
|
||||
// Delete all associated data first
|
||||
// Characters and their data will be handled by CASCADE or manual deletion
|
||||
ExecuteDelete("DELETE FROM char_info WHERE account_id = ?;", accountId);
|
||||
ExecuteDelete("DELETE FROM accounts WHERE id = ?;", accountId);
|
||||
}
|
||||
|
||||
std::vector<IAccounts::SessionInfo> MySQLDatabase::GetAccountSessions(const uint32_t accountId, uint32_t limit) {
|
||||
// account_sessions table doesn't exist in the current schema
|
||||
// Session tracking would need to be implemented separately
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user