40#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
41#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
51 std::span<ChatCommandBuilder const>
GetCommands()
const override
81 {
"ban", banCommandTable },
82 {
"baninfo", baninfoCommandTable },
83 {
"banlist", banlistCommandTable },
84 {
"unban", unbanCommandTable },
99 char* nameStr = strtok((
char*)args,
" ");
103 std::string name = nameStr;
105 char* durationStr = strtok(
nullptr,
" ");
106 if (!durationStr || !atoi(durationStr))
109 char* reasonStr = strtok(
nullptr,
"");
122 switch (
sWorld->BanCharacter(name, durationStr, reasonStr, author))
126 if (atoi(durationStr) > 0)
167 boost::system::error_code error;
168 Trinity::Net::make_address(text, error);
177 char* cnameOrIP = strtok((
char*)args,
" ");
181 std::string nameOrIP = cnameOrIP;
183 char* durationStr = strtok(
nullptr,
" ");
184 if (!durationStr || !atoi(durationStr))
187 char* reasonStr = strtok(
nullptr,
"");
217 switch (
sWorld->BanAccount(mode, nameOrIP, durationStr, reasonStr, author))
220 if (atoi(durationStr) > 0)
265 char* nameStr = strtok((
char*)args,
"");
269 std::string accountName = nameStr;
289 QueryResult result =
LoginDatabase.PQuery(
"SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate, banreason, bannedby FROM account_banned WHERE id = '{}' ORDER BY bandate ASC", accountId);
299 Field* fields = result->Fetch();
301 time_t unbanDate = time_t(fields[3].GetUInt32());
310 while (result->NextRow());
320 std::string name(args);
342 targetGuid = target->
GetGUID();
356 Field* fields = result->Fetch();
357 time_t unbanDate = fields[3].
GetInt64();
366 while (result->NextRow());
377 QueryResult result =
LoginDatabase.PQuery(
"SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason, bannedby, unbandate-bandate FROM ip_banned WHERE ip = '{}'", ip);
384 Field* fields = result->Fetch();
400 char* filterStr = strtok((
char*)args,
" ");
401 std::string filter = filterStr ? filterStr :
"";
435 Field* fields = result->Fetch();
438 QueryResult banResult =
LoginDatabase.PQuery(
"SELECT account.username FROM account, account_banned WHERE account_banned.id='{}' AND account_banned.id = account.id", accountid);
441 Field* fields2 = banResult->Fetch();
445 while (result->NextRow());
451 handler->
SendSysMessage(
" ===============================================================================");
455 handler->
SendSysMessage(
"-------------------------------------------------------------------------------");
456 Field* fields = result->Fetch();
459 std::string accountName;
462 if (result->GetFieldCount() > 1)
469 QueryResult banInfo =
LoginDatabase.PQuery(
"SELECT bandate, unbandate, bannedby, banreason FROM account_banned WHERE id = {} ORDER BY unbandate", accountId);
472 Field* fields2 = banInfo->Fetch();
475 time_t timeBan = time_t(fields2[0].GetUInt32());
477 localtime_r(&timeBan, &tmBan);
479 if (fields2[0].GetUInt32() == fields2[1].GetUInt32())
481 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
482 accountName.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
487 time_t timeUnban = time_t(fields2[1].GetUInt32());
489 localtime_r(&timeUnban, &tmUnban);
490 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
491 accountName.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
492 tmUnban.tm_year%100, tmUnban.tm_mon+1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
496 while (banInfo->NextRow());
499 while (result->NextRow());
501 handler->
SendSysMessage(
" ===============================================================================");
512 char* filterStr = strtok((
char*)args,
" ");
516 std::string filter(filterStr);
533 Field* fields = result->Fetch();
535 stmt2->
setUInt64(0, fields[0].GetUInt64());
540 while (result->NextRow());
546 handler->
SendSysMessage(
" =============================================================================== ");
550 handler->
SendSysMessage(
"-------------------------------------------------------------------------------");
552 Field* fields = result->Fetch();
554 std::string char_name = fields[1].
GetString();
557 stmt2->
setUInt64(0, fields[0].GetUInt64());
561 Field* banFields = banInfo->Fetch();
564 time_t timeBan = banFields[0].
GetInt64();
566 localtime_r(&timeBan, &tmBan);
568 if (banFields[0].GetInt64() == banFields[1].GetInt64())
570 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
571 char_name.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
576 time_t timeUnban = banFields[1].
GetInt64();
578 localtime_r(&timeUnban, &tmUnban);
579 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
580 char_name.c_str(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
581 tmUnban.tm_year%100, tmUnban.tm_mon+1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
585 while (banInfo->NextRow());
588 while (result->NextRow());
589 handler->
SendSysMessage(
" =============================================================================== ");
600 char* filterStr = strtok((
char*)args,
" ");
601 std::string filter = filterStr ? filterStr :
"";
630 Field* fields = result->Fetch();
633 while (result->NextRow());
639 handler->
SendSysMessage(
" ===============================================================================");
643 handler->
SendSysMessage(
"-------------------------------------------------------------------------------");
644 Field* fields = result->Fetch();
645 time_t timeBan = time_t(fields[1].GetUInt32());
647 localtime_r(&timeBan, &tmBan);
648 if (fields[1].GetUInt32() == fields[2].GetUInt32())
650 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
651 fields[0].GetCString(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
656 time_t timeUnban = time_t(fields[2].GetUInt32());
658 localtime_r(&timeUnban, &tmUnban);
659 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
660 fields[0].GetCString(), tmBan.tm_year%100, tmBan.tm_mon+1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
661 tmUnban.tm_year%100, tmUnban.tm_mon+1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
665 while (result->NextRow());
667 handler->
SendSysMessage(
" ===============================================================================");
683 char* nameStr = strtok((
char*)args,
" ");
687 std::string name = nameStr;
696 if (!
sWorld->RemoveBanCharacter(name))
722 char* nameOrIPStr = strtok((
char*)args,
" ");
726 std::string nameOrIP = nameOrIPStr;
752 if (
sWorld->RemoveBanAccount(mode, nameOrIP))
@ CHAR_SEL_GUID_BY_NAME_FILTER
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< LoginDatabaseConnection > LoginDatabase
Accessor to the realm/login database.
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
@ LANG_BANLIST_CHARACTERS_HEADER
@ LANG_BANINFO_NOCHARACTER
@ LANG_BANINFO_BANHISTORY
@ LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD
@ LANG_BANLIST_IPS_HEADER
@ LANG_BANLIST_MATCHINGIP
@ LANG_BANINFO_NOACCOUNTBAN
@ LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD
@ LANG_BANLIST_MATCHINGCHARACTER
@ LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD
@ LANG_BANLIST_MATCHINGACCOUNT
@ LANG_BANLIST_NOCHARACTER
@ LANG_BANINFO_HISTORYENTRY
@ LANG_BANLIST_CHARACTERS
@ LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD
@ LANG_BANLIST_ACCOUNTS_HEADER
@ LOGIN_SEL_ACCOUNT_BANNED_BY_FILTER
@ LOGIN_DEL_EXPIRED_IP_BANS
@ LOGIN_SEL_IP_BANNED_BY_IP
@ LOGIN_SEL_IP_BANNED_ALL
@ LOGIN_SEL_ACCOUNT_BANNED_ALL
bool normalizePlayerName(std::string &name)
BanMode
Ban function modes.
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
std::string TimeToTimestampStr(time_t t)
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
uint32 TimeStringToSecs(std::string const ×tring)
static uint32 GetId(std::string_view username)
static bool GetName(uint32 accountId, std::string &name)
ObjectGuid const & GetGUID() const
WorldSession * GetSession()
void SetSentErrorMessage(bool val)
void PSendSysMessage(char const *fmt, Args &&... args)
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
virtual char const * GetTrinityString(uint32 entry) const
Class used to access individual fields of database query result.
char const * GetCString() const noexcept
uint64 GetUInt64() const noexcept
uint32 GetUInt32() const noexcept
std::string GetString() const noexcept
int64 GetInt64() const noexcept
LowType GetCounter() const
void setString(uint8 index, std::string &&value)
void setUInt64(uint8 index, uint64 value)
std::string const & GetPlayerName() const
static bool HandleBanInfoIPCommand(ChatHandler *handler, std::string &ip)
static bool HandleBanHelper(BanMode mode, char const *args, ChatHandler *handler)
static bool HandleUnBanHelper(BanMode mode, char const *args, ChatHandler *handler)
static bool HandleBanAccountByCharCommand(ChatHandler *handler, char const *args)
static bool HandleUnBanIPCommand(ChatHandler *handler, char const *args)
static bool HandleUnBanAccountByCharCommand(ChatHandler *handler, char const *args)
static bool HandleBanInfoAccountCommand(ChatHandler *handler, char const *args)
static bool IsIPAddress(std::string const &text)
static bool HandleBanListIPCommand(ChatHandler *handler, char const *args)
static bool HandleBanIPCommand(ChatHandler *handler, char const *args)
static bool HandleBanInfoHelper(uint32 accountId, char const *accountName, ChatHandler *handler)
static bool HandleBanListCharacterCommand(ChatHandler *handler, char const *args)
static bool HandleBanListAccountCommand(ChatHandler *handler, char const *args)
static bool HandleBanCharacterCommand(ChatHandler *handler, char const *args)
static bool HandleBanInfoCharacterCommand(ChatHandler *handler, char const *args)
static bool HandleUnBanAccountCommand(ChatHandler *handler, char const *args)
static bool HandleBanListHelper(PreparedQueryResult result, ChatHandler *handler)
std::span< ChatCommandBuilder const > GetCommands() const override
static bool HandleBanAccountCommand(ChatHandler *handler, char const *args)
static bool HandleUnBanCharacterCommand(ChatHandler *handler, char const *args)
void AddSC_ban_commandscript()
@ CONFIG_SHOW_BAN_IN_WORLD
TC_GAME_API Player * FindPlayerByName(std::string_view name)
ChatCommandBuilder const [] ChatCommandTable
@ RBAC_PERM_COMMAND_BANINFO_IP
@ RBAC_PERM_COMMAND_BANINFO_ACCOUNT
@ RBAC_PERM_COMMAND_BANINFO_CHARACTER
@ RBAC_PERM_COMMAND_BAN_PLAYERACCOUNT
@ RBAC_PERM_COMMAND_UNBAN_CHARACTER
@ RBAC_PERM_COMMAND_UNBAN_PLAYERACCOUNT
@ RBAC_PERM_COMMAND_BAN_CHARACTER
@ RBAC_PERM_COMMAND_BANLIST_ACCOUNT
@ RBAC_PERM_COMMAND_BAN_IP
@ RBAC_PERM_COMMAND_BANLIST_CHARACTER
@ RBAC_PERM_COMMAND_BANLIST_IP
@ RBAC_PERM_COMMAND_BAN_ACCOUNT
@ RBAC_PERM_COMMAND_UNBAN_ACCOUNT
@ RBAC_PERM_COMMAND_UNBAN_IP