29 static std::vector<ChatCommand> unbanCommandTable =
36 static std::vector<ChatCommand> banlistCommandTable =
42 static std::vector<ChatCommand> baninfoCommandTable =
48 static std::vector<ChatCommand> banCommandTable =
55 static std::vector<ChatCommand> commandTable =
75 char* nameStr = strtok((
char*)args,
" ");
79 std::string name = nameStr;
81 char* durationStr = strtok(NULL,
" ");
82 if (!durationStr || !atoi(durationStr))
85 char* reasonStr = strtok(NULL,
"");
100 if (atoi(durationStr) > 0)
134 char* cnameOrIP = strtok((
char*)args,
" ");
138 std::string nameOrIP = cnameOrIP;
140 char* durationStr = strtok(NULL,
" ");
141 if (!durationStr || !atoi(durationStr))
144 char* reasonStr = strtok(NULL,
"");
175 if (atoi(durationStr) > 0)
207 char* nameStr = strtok((
char*)args,
"");
211 std::string accountName = nameStr;
231 QueryResult result =
LoginDatabase.PQuery(
"SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate, banreason, bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC", accountId);
241 Field* fields = result->Fetch();
243 time_t unbanDate = time_t(fields[3].GetUInt32());
245 if (fields[2].GetBool() && (fields[1].GetUInt64() ==
uint64(0) || unbanDate >= time(NULL)))
251 }
while (result->NextRow());
263 std::string name(args);
271 if (!resultCharacter)
277 targetGuid = (*resultCharacter)[0].GetUInt32();
294 Field* fields = result->Fetch();
295 time_t unbanDate = time_t(fields[3].GetUInt32());
297 if (fields[2].GetUInt8() && (!fields[1].GetUInt32() || unbanDate >= time(NULL)))
303 }
while (result->NextRow());
313 char* ipStr = strtok((
char*)args,
"");
320 std::string IP = ipStr;
323 QueryResult result =
LoginDatabase.PQuery(
"SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason, bannedby, unbandate-bandate FROM ip_banned WHERE ip = '%s'", IP.c_str());
330 Field* fields = result->Fetch();
345 char* filterStr = strtok((
char*)args,
" ");
346 std::string filter = filterStr ? filterStr :
"";
380 Field* fields = result->Fetch();
383 QueryResult banResult =
LoginDatabase.PQuery(
"SELECT account.username FROM account, account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id", accountid);
386 Field* fields2 = banResult->Fetch();
389 }
while (result->NextRow());
395 handler->
SendSysMessage(
" ===============================================================================");
399 handler->
SendSysMessage(
"-------------------------------------------------------------------------------");
400 Field* fields = result->Fetch();
403 std::string accountName;
406 if (result->GetFieldCount() > 1)
413 QueryResult banInfo =
LoginDatabase.PQuery(
"SELECT bandate, unbandate, bannedby, banreason FROM account_banned WHERE id = %u ORDER BY unbandate", accountId);
416 Field* fields2 = banInfo->Fetch();
419 time_t timeBan = time_t(fields2[0].GetUInt32());
423 if (fields2[0].GetUInt32() == fields2[1].GetUInt32())
425 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
426 accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
431 time_t timeUnban = time_t(fields2[1].GetUInt32());
434 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
435 accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
436 tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
439 }
while (banInfo->NextRow());
441 }
while (result->NextRow());
443 handler->
SendSysMessage(
" ===============================================================================");
454 char* filterStr = strtok((
char*)args,
" ");
458 std::string filter(filterStr);
475 Field* fields = result->Fetch();
477 stmt2->
setUInt32(0, fields[0].GetUInt32());
481 }
while (result->NextRow());
487 handler->
SendSysMessage(
" =============================================================================== ");
491 handler->
SendSysMessage(
"-------------------------------------------------------------------------------");
493 Field* fields = result->Fetch();
495 std::string char_name = fields[1].
GetString();
498 stmt2->
setUInt32(0, fields[0].GetUInt32());
502 Field* banFields = banInfo->Fetch();
505 time_t timeBan = time_t(banFields[0].GetUInt32());
509 if (banFields[0].GetUInt32() == banFields[1].GetUInt32())
511 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
512 char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
517 time_t timeUnban = time_t(banFields[1].GetUInt32());
520 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
521 char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
522 tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
525 }
while (banInfo->NextRow());
527 }
while (result->NextRow());
528 handler->
SendSysMessage(
" =============================================================================== ");
539 char* filterStr = strtok((
char*)args,
" ");
540 std::string filter = filterStr ? filterStr :
"";
569 Field* fields = result->Fetch();
571 }
while (result->NextRow());
577 handler->
SendSysMessage(
" ===============================================================================");
581 handler->
SendSysMessage(
"-------------------------------------------------------------------------------");
582 Field* fields = result->Fetch();
583 time_t timeBan = time_t(fields[1].GetUInt32());
586 if (fields[1].GetUInt32() == fields[2].GetUInt32())
588 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
589 fields[0].GetCString(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
594 time_t timeUnban = time_t(fields[2].GetUInt32());
597 handler->
PSendSysMessage(
"|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
598 fields[0].GetCString(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
599 tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
602 }
while (result->NextRow());
604 handler->
SendSysMessage(
" ===============================================================================");
620 char* nameStr = strtok((
char*)args,
" ");
624 std::string name = nameStr;
633 if (!
sWorld->RemoveBanCharacter(name))
658 char* nameOrIPStr = strtok((
char*)args,
" ");
662 std::string nameOrIP = nameOrIPStr;
688 if (
sWorld->RemoveBanAccount(mode, nameOrIP))
@ CHAR_SEL_GUID_BY_NAME_FILTER
@ LANG_BANLIST_CHARACTERS_HEADER
@ LANG_BANINFO_NOCHARACTER
@ LANG_BANINFO_BANHISTORY
@ LANG_BANLIST_IPS_HEADER
@ LANG_BANLIST_MATCHINGIP
@ LANG_BANINFO_NOACCOUNTBAN
@ LANG_BANLIST_MATCHINGCHARACTER
@ LANG_BANLIST_MATCHINGACCOUNT
@ LANG_BANLIST_NOCHARACTER
@ LANG_BANINFO_HISTORYENTRY
@ LANG_BANLIST_CHARACTERS
@ LANG_BANLIST_ACCOUNTS_HEADER
@ LOGIN_DEL_EXPIRED_IP_BANS
@ LOGIN_SEL_IP_BANNED_BY_IP
@ LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME
@ LOGIN_SEL_IP_BANNED_ALL
@ LOGIN_SEL_ACCOUNT_BANNED_ALL
bool normalizePlayerName(std::string &name)
Skyfire::AutoPtr< PreparedResultSet, Skyfire::Mutex > PreparedQueryResult
Skyfire::AutoPtr< ResultSet, Skyfire::Mutex > QueryResult
BanMode
Ban function modes.
bool IsIPAddress(char const *ipaddress)
Check if the string is a valid ip address representation.
uint32 TimeStringToSecs(const std::string ×tring)
std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
static bool normalizeString(std::string &utf8String)
static uint32 GetId(std::string const &username)
static bool GetName(uint32 accountId, std::string &name)
WorldSession * GetSession()
void PSendSysMessage(const char *format,...) ATTR_PRINTF(2
void SetSentErrorMessage(bool val)
virtual void SendSysMessage(const char *str)
virtual const char * GetSkyFireString(int32 entry) const
CommandScript(const char *name)
std::string GetString() const
char const * GetCString() const
uint32 GetGUIDLow() const
void setString(const uint8 index, const std::string &value)
void setUInt32(const uint8 index, const uint32 value)
std::string const & GetPlayerName() const
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 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 HandleBanInfoIPCommand(ChatHandler *handler, char const *args)
static bool HandleBanListAccountCommand(ChatHandler *handler, char const *args)
static bool HandleBanCharacterCommand(ChatHandler *handler, char const *args)
std::vector< ChatCommand > GetCommands() const OVERRIDE
static bool HandleBanInfoCharacterCommand(ChatHandler *handler, char const *args)
static bool HandleUnBanAccountCommand(ChatHandler *handler, char const *args)
static bool HandleBanListHelper(PreparedQueryResult result, ChatHandler *handler)
static bool HandleBanAccountCommand(ChatHandler *handler, char const *args)
static bool HandleUnBanCharacterCommand(ChatHandler *handler, char const *args)
void AddSC_ban_commandscript()
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
bool LocalTime(time_t const &time, tm &result)
@ RBAC_PERM_COMMAND_UNBAN
@ RBAC_PERM_COMMAND_BANINFO_IP
@ RBAC_PERM_COMMAND_BANINFO_ACCOUNT
@ RBAC_PERM_COMMAND_BANINFO_CHARACTER
@ RBAC_PERM_COMMAND_BANLIST
@ 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_BANINFO
@ RBAC_PERM_COMMAND_BAN_ACCOUNT
@ RBAC_PERM_COMMAND_UNBAN_ACCOUNT
@ RBAC_PERM_COMMAND_UNBAN_IP
LoginDatabaseWorkerPool LoginDatabase