mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-06-08 15:54: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:
@@ -42,9 +42,91 @@ void SQLiteDatabase::UpdateAccountGmLevel(const uint32_t accountId, const eGameM
|
||||
ExecuteUpdate("UPDATE accounts SET gm_level = ? WHERE id = ?;", static_cast<int32_t>(gmLevel), accountId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::UpdateAccountPlayKey(const uint32_t accountId, const uint32_t playKeyId) {
|
||||
ExecuteUpdate("UPDATE accounts SET play_key_id = ? WHERE id = ?;", playKeyId, accountId);
|
||||
}
|
||||
|
||||
uint32_t SQLiteDatabase::GetAccountCount() {
|
||||
auto [_, res] = ExecuteSelect("SELECT COUNT(*) as count FROM accounts;");
|
||||
if (res.eof()) return 0;
|
||||
|
||||
return res.getIntField("count");
|
||||
}
|
||||
|
||||
uint32_t SQLiteDatabase::GetBannedAccountCount() {
|
||||
auto [_, res] = ExecuteSelect("SELECT COUNT(*) as count FROM accounts WHERE banned = 1;");
|
||||
if (res.eof()) return 0;
|
||||
|
||||
return res.getIntField("count");
|
||||
}
|
||||
|
||||
uint32_t SQLiteDatabase::GetLockedAccountCount() {
|
||||
auto [_, res] = ExecuteSelect("SELECT COUNT(*) as count FROM accounts WHERE locked = 1;");
|
||||
if (res.eof()) return 0;
|
||||
|
||||
return res.getIntField("count");
|
||||
}
|
||||
|
||||
std::vector<IAccounts::ListInfo> SQLiteDatabase::GetAllAccounts() {
|
||||
std::vector<IAccounts::ListInfo> out;
|
||||
auto [stmt, res] = ExecuteSelect("SELECT id, name, gm_level, banned, locked, mute_expire, play_key_id FROM accounts ORDER BY id ASC;");
|
||||
|
||||
while (!res.eof()) {
|
||||
IAccounts::ListInfo info;
|
||||
info.id = res.getIntField("id");
|
||||
info.name = res.getStringField("name");
|
||||
info.gm_level = static_cast<eGameMasterLevel>(res.getIntField("gm_level"));
|
||||
info.banned = res.getIntField("banned");
|
||||
info.locked = res.getIntField("locked");
|
||||
info.mute_expire = static_cast<uint64_t>(res.getInt64Field("mute_expire"));
|
||||
info.play_key_id = res.getIntField("play_key_id");
|
||||
out.push_back(info);
|
||||
res.nextRow();
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void SQLiteDatabase::UpdateAccountLock(const uint32_t accountId, const bool locked) {
|
||||
ExecuteUpdate("UPDATE accounts SET locked = ? WHERE id = ?;", locked, accountId);
|
||||
}
|
||||
|
||||
std::optional<IAccounts::DetailedInfo> SQLiteDatabase::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.eof()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
IAccounts::DetailedInfo info;
|
||||
info.id = result.getIntField("id");
|
||||
info.name = result.getStringField("name");
|
||||
info.email = result.getStringField("email");
|
||||
info.gm_level = static_cast<eGameMasterLevel>(result.getIntField("gm_level"));
|
||||
info.banned = result.getIntField("banned") != 0;
|
||||
info.locked = result.getIntField("locked") != 0;
|
||||
info.mute_expire = static_cast<uint64_t>(result.getInt64Field("mute_expire"));
|
||||
info.play_key_id = result.getIntField("play_key_id");
|
||||
info.created_at = static_cast<uint64_t>(result.getInt64Field("created_at"));
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void SQLiteDatabase::UpdateAccountEmail(const uint32_t accountId, const std::string_view email) {
|
||||
ExecuteUpdate("UPDATE accounts SET email = ? WHERE id = ?;", email, accountId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::DeleteAccount(const uint32_t accountId) {
|
||||
// Delete all associated data first
|
||||
ExecuteDelete("DELETE FROM char_info WHERE account_id = ?;", accountId);
|
||||
ExecuteDelete("DELETE FROM accounts WHERE id = ?;", accountId);
|
||||
}
|
||||
|
||||
std::vector<IAccounts::SessionInfo> SQLiteDatabase::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