mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[sql/updates/2008_10_21_03_mangos_command.sql]
slit ban/baninfi/banlist/unban commands to subcommands (this allow write not full subcomand string ".ban acc ...". Fixed crash at unexpected use .account in console. Fixed hide .gm on by .gm online (renamed to .gm ingame)
This commit is contained in:
parent
88981a4c25
commit
6892cc3d2c
10 changed files with 523 additions and 309 deletions
|
|
@ -185,10 +185,16 @@ INSERT INTO `command` VALUES
|
||||||
('addmove',2,'Syntax: .addmove #creature_guid [#waittime]\r\n\r\nAdd your current location as a waypoint for creature with guid #creature_guid. And optional add wait time.'),
|
('addmove',2,'Syntax: .addmove #creature_guid [#waittime]\r\n\r\nAdd your current location as a waypoint for creature with guid #creature_guid. And optional add wait time.'),
|
||||||
('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'),
|
('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'),
|
||||||
('aura',3,'Syntax: .aura #spellid\r\n\r\nAdd the aura from spell #spellid to the selected Unit.'),
|
('aura',3,'Syntax: .aura #spellid\r\n\r\nAdd the aura from spell #spellid to the selected Unit.'),
|
||||||
('ban',3,'Syntax is: ban <account|ip|character> $NameOrIp $bantime $reason\r\nBan account or IP and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
|
('ban account',3,'Syntax is: ban account $Name $bantime $reason\r\nBan account kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
|
||||||
('baninfo',3,'Syntax is: baninfo <account|ip|character>\r\nWatch full information about a specific ban.'),
|
('ban character',3,'Syntax is: ban character $Name $bantime $reason\r\nBan account and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
|
||||||
|
('ban ip',3,'Syntax is: ban ip $Ip $bantime $reason\r\nBan IP.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
|
||||||
|
('baninfo account',3,'Syntax is: baninfo account\r\nWatch full information about a specific ban.'),
|
||||||
|
('baninfo character',3,'Syntax is: baninfo character\r\nWatch full information about a specific ban.'),
|
||||||
|
('baninfo ip',3,'Syntax is: baninfo ip\r\nWatch full information about a specific ban.'),
|
||||||
('bank',3,'Syntax: .bank\r\n\r\nShow your bank inventory.'),
|
('bank',3,'Syntax: .bank\r\n\r\nShow your bank inventory.'),
|
||||||
('banlist',3,'Syntax is: banlist <account|ip|character> $NameOrIp\r\nsearches the banlist for a pattern.'),
|
('banlist account',3,'Syntax is: banlist account [$Name]\r\nSearches the banlist for a account name pattern or show full list account bans.'),
|
||||||
|
('banlist character',3,'Syntax is: banlist character $Name\r\nSearches the banlist for a character name pattern. Pattern required.'),
|
||||||
|
('banlist ip',3,'Syntax is: banlist ip [$Ip]\r\nSearches the banlist for a IP pattern or show full list of IP bans.'),
|
||||||
('cast',3,'Syntax: .cast #spellid [triggered]\r\n Cast #spellid to selected target. If no target selected cast to self. If \'trigered\' or part provided then spell casted with triggered flag.'),
|
('cast',3,'Syntax: .cast #spellid [triggered]\r\n Cast #spellid to selected target. If no target selected cast to self. If \'trigered\' or part provided then spell casted with triggered flag.'),
|
||||||
('cast back',3,'Syntax: .cast back #spellid [triggered]\r\n Selected target will cast #spellid to your character. If \'trigered\' or part provided then spell casted with triggered flag.'),
|
('cast back',3,'Syntax: .cast back #spellid [triggered]\r\n Selected target will cast #spellid to your character. If \'trigered\' or part provided then spell casted with triggered flag.'),
|
||||||
('cast dist',3,'Syntax: .cast dist #spellid [#dist [triggered]]\r\n You will cast spell to pint at distance #dist. If \'trigered\' or part provided then spell casted with triggered flag. Not all spells can be casted as area spells.'),
|
('cast dist',3,'Syntax: .cast dist #spellid [#dist [triggered]]\r\n You will cast spell to pint at distance #dist. If \'trigered\' or part provided then spell casted with triggered flag. Not all spells can be casted as area spells.'),
|
||||||
|
|
@ -218,7 +224,7 @@ INSERT INTO `command` VALUES
|
||||||
('gm',1,'Syntax: .gm [on/off]\r\n\r\nEnable or Disable in game GM MODE or show current state of on/off not provided.'),
|
('gm',1,'Syntax: .gm [on/off]\r\n\r\nEnable or Disable in game GM MODE or show current state of on/off not provided.'),
|
||||||
('gm chat',1,'Syntax: .gm chat [on/off]\r\n\r\nEnable or disable chat GM MODE (show gm badge in messages) or show current state of on/off not provided.'),
|
('gm chat',1,'Syntax: .gm chat [on/off]\r\n\r\nEnable or disable chat GM MODE (show gm badge in messages) or show current state of on/off not provided.'),
|
||||||
('gm fly',3,'Syntax: .gm fly on/off\r\nEnable/disable gm fly mode.'),
|
('gm fly',3,'Syntax: .gm fly on/off\r\nEnable/disable gm fly mode.'),
|
||||||
|
('gm ingame',0,'Syntax: .gm ingame\r\n\r\nDisplay a list of available in game Game Masters.'),
|
||||||
('gm list',3,'Syntax: .gm list\r\n\r\nDisplay a list of all Game Masters accounts and security levels.'),
|
('gm list',3,'Syntax: .gm list\r\n\r\nDisplay a list of all Game Masters accounts and security levels.'),
|
||||||
('gm online',0,'Syntax: .gm online\r\n\r\nDisplay a list of available Game Masters.'),
|
('gm online',0,'Syntax: .gm online\r\n\r\nDisplay a list of available Game Masters.'),
|
||||||
('gm visible',1,'Syntax: .gm visible on/off\r\n\r\nOutput current visibility state or make GM visible(on) and invisible(off) for other players.'),
|
('gm visible',1,'Syntax: .gm visible on/off\r\n\r\nOutput current visibility state or make GM visible(on) and invisible(off) for other players.'),
|
||||||
|
|
@ -384,7 +390,9 @@ INSERT INTO `command` VALUES
|
||||||
('ticket',2,'Syntax: .ticket on\r\n .ticket off\r\n .ticket #num\r\n .ticket $character_name\r\n\r\non/off for GMs to show or not a new ticket directly, $character_name to show ticket of this character, #num to show ticket #num.'),
|
('ticket',2,'Syntax: .ticket on\r\n .ticket off\r\n .ticket #num\r\n .ticket $character_name\r\n\r\non/off for GMs to show or not a new ticket directly, $character_name to show ticket of this character, #num to show ticket #num.'),
|
||||||
('transport',3,'Not yet implemented.'),
|
('transport',3,'Not yet implemented.'),
|
||||||
('unaura',3,'Syntax: .unaura #spellid\r\n\r\nRemove aura due to spell #spellid from the selected Unit.'),
|
('unaura',3,'Syntax: .unaura #spellid\r\n\r\nRemove aura due to spell #spellid from the selected Unit.'),
|
||||||
('unban',3,'Syntax is: unban <account|ip|character> $NameOrIp\r\nUnban account or IP.'),
|
('unban account',3,'Syntax is: unban account $Name\r\nUnban accounts for account name pattern.'),
|
||||||
|
('unban character',3,'Syntax is: unban character $Name\r\nUnban accounts for character name pattern.'),
|
||||||
|
('unban ip',3,'Syntax is: unban ip $Ip\r\nUnban accounts for IP pattern.'),
|
||||||
('unlearn',3,'Syntax: .unlearn #startspell #endspell\r\n\r\nUnlearn for selected player the range of spells between id #startspell and #endspell. If no #endspell is provided, just unlearn spell of id #startspell.'),
|
('unlearn',3,'Syntax: .unlearn #startspell #endspell\r\n\r\nUnlearn for selected player the range of spells between id #startspell and #endspell. If no #endspell is provided, just unlearn spell of id #startspell.'),
|
||||||
('unmute',1,'Syntax: .unmute $playerName\r\n\r\nRestore chat messaging for any character from account of character $playerName.'),
|
('unmute',1,'Syntax: .unmute $playerName\r\n\r\nRestore chat messaging for any character from account of character $playerName.'),
|
||||||
('wchange',3,'Syntax: .wchange #weathertype #status\r\n\r\nSet current weather to #weathertype with an intensity of #status.\r\n\r\n#weathertype can be 1 for rain, 2 for snow, and 3 for sand. #status can be 0 for disabled, and 1 for enabled.'),
|
('wchange',3,'Syntax: .wchange #weathertype #status\r\n\r\nSet current weather to #weathertype with an intensity of #status.\r\n\r\n#weathertype can be 1 for rain, 2 for snow, and 3 for sand. #status can be 0 for disabled, and 1 for enabled.'),
|
||||||
|
|
|
||||||
22
sql/updates/2008_10_21_03_mangos_command.sql
Normal file
22
sql/updates/2008_10_21_03_mangos_command.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
DELETE FROM command WHERE name IN (
|
||||||
|
'gm ingame','gm online',
|
||||||
|
'ban','ban account','ban character','ban ip',
|
||||||
|
'baninfo','baninfo account','baninfo character','baninfo ip',
|
||||||
|
'banlist','banlist account','banlist character','banlist ip',
|
||||||
|
'unban','unban account','unban character','unban ip'
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO command VALUES
|
||||||
|
('gm ingame',0,'Syntax: .gm ingame\r\n\r\nDisplay a list of available in game Game Masters.'),
|
||||||
|
('ban account',3,'Syntax is: ban account $Name $bantime $reason\r\nBan account kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
|
||||||
|
('ban character',3,'Syntax is: ban character $Name $bantime $reason\r\nBan account and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
|
||||||
|
('ban ip',3,'Syntax is: ban ip $Ip $bantime $reason\r\nBan IP.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
|
||||||
|
('baninfo account',3,'Syntax is: baninfo account\r\nWatch full information about a specific ban.'),
|
||||||
|
('baninfo character',3,'Syntax is: baninfo character\r\nWatch full information about a specific ban.'),
|
||||||
|
('baninfo ip',3,'Syntax is: baninfo ip\r\nWatch full information about a specific ban.'),
|
||||||
|
('banlist account',3,'Syntax is: banlist account [$Name]\r\nSearches the banlist for a account name pattern or show full list account bans.'),
|
||||||
|
('banlist character',3,'Syntax is: banlist character $Name\r\nSearches the banlist for a character name pattern. Pattern required.'),
|
||||||
|
('banlist ip',3,'Syntax is: banlist ip [$Ip]\r\nSearches the banlist for a IP pattern or show full list of IP bans.'),
|
||||||
|
('unban account',3,'Syntax is: unban account $Name\r\nUnban accounts for account name pattern.'),
|
||||||
|
('unban character',3,'Syntax is: unban character $Name\r\nUnban accounts for character name pattern.'),
|
||||||
|
('unban ip',3,'Syntax is: unban ip $Ip\r\nUnban accounts for IP pattern.');
|
||||||
|
|
@ -98,6 +98,7 @@ pkgdata_DATA = \
|
||||||
2008_10_19_02_mangos_spell_proc_event.sql \
|
2008_10_19_02_mangos_spell_proc_event.sql \
|
||||||
2008_10_21_01_mangos_mangos_string.sql \
|
2008_10_21_01_mangos_mangos_string.sql \
|
||||||
2008_10_21_02_mangos_command.sql \
|
2008_10_21_02_mangos_command.sql \
|
||||||
|
2008_10_21_03_mangos_command.sql \
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -177,4 +178,5 @@ EXTRA_DIST = \
|
||||||
2008_10_19_02_mangos_spell_proc_event.sql \
|
2008_10_19_02_mangos_spell_proc_event.sql \
|
||||||
2008_10_21_01_mangos_mangos_string.sql \
|
2008_10_21_01_mangos_mangos_string.sql \
|
||||||
2008_10_21_02_mangos_command.sql \
|
2008_10_21_02_mangos_command.sql \
|
||||||
|
2008_10_21_03_mangos_command.sql \
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
{ "delete", SEC_CONSOLE, true, &ChatHandler::HandleAccountDeleteCommand, "", NULL },
|
{ "delete", SEC_CONSOLE, true, &ChatHandler::HandleAccountDeleteCommand, "", NULL },
|
||||||
{ "onlinelist", SEC_CONSOLE, true, &ChatHandler::HandleAccountOnlineListCommand, "", NULL },
|
{ "onlinelist", SEC_CONSOLE, true, &ChatHandler::HandleAccountOnlineListCommand, "", NULL },
|
||||||
{ "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable },
|
{ "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable },
|
||||||
{ "", SEC_PLAYER, true, &ChatHandler::HandleAccountCommand, "", NULL },
|
{ "", SEC_PLAYER, false, &ChatHandler::HandleAccountCommand, "", NULL },
|
||||||
{ NULL, 0, false, NULL, "", NULL }
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -113,6 +113,38 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
{ NULL, 0, false, NULL, "", NULL }
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static ChatCommand banCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanAccountCommand, "", NULL },
|
||||||
|
{ "character", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanCharacterCommand, "", NULL },
|
||||||
|
{ "ip", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanIPCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static ChatCommand baninfoCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanInfoAccountCommand, "", NULL },
|
||||||
|
{ "character", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanInfoCharacterCommand, "", NULL },
|
||||||
|
{ "ip", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanInfoIPCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static ChatCommand banlistCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanListAccountCommand, "", NULL },
|
||||||
|
{ "character", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanListCharacterCommand, "", NULL },
|
||||||
|
{ "ip", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanListIPCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static ChatCommand unbanCommandTable[] =
|
||||||
|
{
|
||||||
|
{ "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleUnBanAccountCommand, "", NULL },
|
||||||
|
{ "character", SEC_ADMINISTRATOR, true, &ChatHandler::HandleUnBanCharacterCommand, "", NULL },
|
||||||
|
{ "ip", SEC_ADMINISTRATOR, true, &ChatHandler::HandleUnBanIPCommand, "", NULL },
|
||||||
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static ChatCommand debugCommandTable[] =
|
static ChatCommand debugCommandTable[] =
|
||||||
{
|
{
|
||||||
{ "inarc", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugInArcCommand, "", NULL },
|
{ "inarc", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugInArcCommand, "", NULL },
|
||||||
|
|
@ -390,7 +422,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
static ChatCommand gmCommandTable[] =
|
static ChatCommand gmCommandTable[] =
|
||||||
{
|
{
|
||||||
{ "chat", SEC_MODERATOR, false, &ChatHandler::HandleGMChatCommand, "", NULL },
|
{ "chat", SEC_MODERATOR, false, &ChatHandler::HandleGMChatCommand, "", NULL },
|
||||||
{ "online", SEC_PLAYER, true, &ChatHandler::HandleGMListOnlineCommand, "", NULL },
|
{ "ingame", SEC_PLAYER, true, &ChatHandler::HandleGMListIngameCommand, "", NULL },
|
||||||
{ "list", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMListFullCommand, "", NULL },
|
{ "list", SEC_ADMINISTRATOR, true, &ChatHandler::HandleGMListFullCommand, "", NULL },
|
||||||
{ "visible", SEC_MODERATOR, false, &ChatHandler::HandleVisibleCommand, "", NULL },
|
{ "visible", SEC_MODERATOR, false, &ChatHandler::HandleVisibleCommand, "", NULL },
|
||||||
{ "fly", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlyModeCommand, "", NULL },
|
{ "fly", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlyModeCommand, "", NULL },
|
||||||
|
|
@ -455,10 +487,10 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
{ "save", SEC_PLAYER, false, &ChatHandler::HandleSaveCommand, "", NULL },
|
{ "save", SEC_PLAYER, false, &ChatHandler::HandleSaveCommand, "", NULL },
|
||||||
{ "saveall", SEC_MODERATOR, true, &ChatHandler::HandleSaveAllCommand, "", NULL },
|
{ "saveall", SEC_MODERATOR, true, &ChatHandler::HandleSaveAllCommand, "", NULL },
|
||||||
{ "kick", SEC_GAMEMASTER, true, &ChatHandler::HandleKickPlayerCommand, "", NULL },
|
{ "kick", SEC_GAMEMASTER, true, &ChatHandler::HandleKickPlayerCommand, "", NULL },
|
||||||
{ "ban", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanCommand, "", NULL },
|
{ "ban", SEC_ADMINISTRATOR, true, NULL, "", banCommandTable },
|
||||||
{ "unban", SEC_ADMINISTRATOR, true, &ChatHandler::HandleUnBanCommand, "", NULL },
|
{ "unban", SEC_ADMINISTRATOR, true, NULL, "", unbanCommandTable },
|
||||||
{ "baninfo", SEC_ADMINISTRATOR, false, &ChatHandler::HandleBanInfoCommand, "", NULL },
|
{ "baninfo", SEC_ADMINISTRATOR, false, NULL, "", baninfoCommandTable },
|
||||||
{ "banlist", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanListCommand, "", NULL },
|
{ "banlist", SEC_ADMINISTRATOR, true, NULL, "", banlistCommandTable },
|
||||||
{ "plimit", SEC_ADMINISTRATOR, true, &ChatHandler::HandlePLimitCommand, "", NULL },
|
{ "plimit", SEC_ADMINISTRATOR, true, &ChatHandler::HandlePLimitCommand, "", NULL },
|
||||||
{ "start", SEC_PLAYER, false, &ChatHandler::HandleStartCommand, "", NULL },
|
{ "start", SEC_PLAYER, false, &ChatHandler::HandleStartCommand, "", NULL },
|
||||||
{ "taxicheat", SEC_MODERATOR, false, &ChatHandler::HandleTaxiCheatCommand, "", NULL },
|
{ "taxicheat", SEC_MODERATOR, false, &ChatHandler::HandleTaxiCheatCommand, "", NULL },
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class ChatHandler
|
||||||
bool HandleInfoCommand(const char* args);
|
bool HandleInfoCommand(const char* args);
|
||||||
bool HandleDismountCommand(const char* args);
|
bool HandleDismountCommand(const char* args);
|
||||||
bool HandleSaveCommand(const char* args);
|
bool HandleSaveCommand(const char* args);
|
||||||
bool HandleGMListOnlineCommand(const char* args);
|
bool HandleGMListIngameCommand(const char* args);
|
||||||
bool HandleGMListFullCommand(const char* args);
|
bool HandleGMListFullCommand(const char* args);
|
||||||
|
|
||||||
bool HandleNamegoCommand(const char* args);
|
bool HandleNamegoCommand(const char* args);
|
||||||
|
|
@ -270,10 +270,18 @@ class ChatHandler
|
||||||
bool HandleMovegensCommand(const char* args);
|
bool HandleMovegensCommand(const char* args);
|
||||||
|
|
||||||
bool HandleCharacterDeleteCommand(const char* args);
|
bool HandleCharacterDeleteCommand(const char* args);
|
||||||
bool HandleBanCommand(const char* args);
|
bool HandleBanAccountCommand(const char* args);
|
||||||
bool HandleUnBanCommand(const char* args);
|
bool HandleBanCharacterCommand(const char* args);
|
||||||
bool HandleBanInfoCommand(const char* args);
|
bool HandleBanIPCommand(const char* args);
|
||||||
bool HandleBanListCommand(const char* args);
|
bool HandleUnBanAccountCommand(const char* args);
|
||||||
|
bool HandleUnBanCharacterCommand(const char* args);
|
||||||
|
bool HandleUnBanIPCommand(const char* args);
|
||||||
|
bool HandleBanInfoAccountCommand(const char* args);
|
||||||
|
bool HandleBanInfoCharacterCommand(const char* args);
|
||||||
|
bool HandleBanInfoIPCommand(const char* args);
|
||||||
|
bool HandleBanListAccountCommand(const char* args);
|
||||||
|
bool HandleBanListCharacterCommand(const char* args);
|
||||||
|
bool HandleBanListIPCommand(const char* args);
|
||||||
bool HandleIdleRestartCommand(const char* args);
|
bool HandleIdleRestartCommand(const char* args);
|
||||||
bool HandleIdleShutDownCommand(const char* args);
|
bool HandleIdleShutDownCommand(const char* args);
|
||||||
bool HandleShutDownCommand(const char* args);
|
bool HandleShutDownCommand(const char* args);
|
||||||
|
|
@ -423,6 +431,10 @@ class ChatHandler
|
||||||
void ShowTicket(uint64 guid, char const* text, char const* time);
|
void ShowTicket(uint64 guid, char const* text, char const* time);
|
||||||
uint32 GetTicketIDByNum(uint32 num);
|
uint32 GetTicketIDByNum(uint32 num);
|
||||||
bool LookupPlayerSearchCommand(QueryResult* result, int32 limit);
|
bool LookupPlayerSearchCommand(QueryResult* result, int32 limit);
|
||||||
|
bool HandleBanListHelper(QueryResult* result);
|
||||||
|
bool HandleBanHelper(BanMode mode,char const* args);
|
||||||
|
bool HandleBanInfoHelper(uint32 accountid, char const* accountname);
|
||||||
|
bool HandleUnBanHelper(BanMode mode,char const* args);
|
||||||
|
|
||||||
void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
|
void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleGMListOnlineCommand(const char* /*args*/)
|
bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/)
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4735,19 +4735,31 @@ bool ChatHandler::HandleCompleteQuest(const char* args)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleBanCommand(const char* args)
|
bool ChatHandler::HandleBanAccountCommand(const char* args)
|
||||||
|
{
|
||||||
|
return HandleBanHelper(BAN_ACCOUNT,args);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanCharacterCommand(const char* args)
|
||||||
|
{
|
||||||
|
return HandleBanHelper(BAN_CHARACTER,args);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanIPCommand(const char* args)
|
||||||
|
{
|
||||||
|
return HandleBanHelper(BAN_IP,args);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanHelper(BanMode mode, const char* args)
|
||||||
{
|
{
|
||||||
if(!args)
|
if(!args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* type = strtok((char*)args, " ");
|
char* cnameOrIP = strtok ((char*)args, " ");
|
||||||
|
if (!cnameOrIP)
|
||||||
if(!type)
|
|
||||||
return false;
|
return false;
|
||||||
char* nameOrIP = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if(!nameOrIP)
|
std::string nameOrIP = cnameOrIP;
|
||||||
return false;
|
|
||||||
|
|
||||||
char* duration = strtok (NULL," ");
|
char* duration = strtok (NULL," ");
|
||||||
if(!duration || !atoi(duration))
|
if(!duration || !atoi(duration))
|
||||||
|
|
@ -4757,68 +4769,128 @@ bool ChatHandler::HandleBanCommand(const char* args)
|
||||||
if(!reason)
|
if(!reason)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch(sWorld.BanAccount(type, nameOrIP, duration, reason,m_session ? m_session->GetPlayerName() : ""))
|
switch(mode)
|
||||||
|
{
|
||||||
|
case BAN_ACCOUNT:
|
||||||
|
if(!AccountMgr::normilizeString(nameOrIP))
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str());
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BAN_CHARACTER:
|
||||||
|
if(!normalizePlayerName(nameOrIP))
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BAN_IP:
|
||||||
|
if(!IsIPAddress(nameOrIP.c_str()))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(sWorld.BanAccount(mode, nameOrIP, duration, reason,m_session ? m_session->GetPlayerName() : ""))
|
||||||
{
|
{
|
||||||
case BAN_SUCCESS:
|
case BAN_SUCCESS:
|
||||||
if(atoi(duration)>0)
|
if(atoi(duration)>0)
|
||||||
PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP,secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason);
|
PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP.c_str(),secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason);
|
||||||
else
|
else
|
||||||
PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP,reason);
|
PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP.c_str(),reason);
|
||||||
break;
|
break;
|
||||||
case BAN_SYNTAX_ERROR:
|
case BAN_SYNTAX_ERROR:
|
||||||
return false;
|
return false;
|
||||||
case BAN_NOTFOUND:
|
case BAN_NOTFOUND:
|
||||||
PSendSysMessage(LANG_BAN_NOTFOUND,type,nameOrIP);
|
switch(mode)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
PSendSysMessage(LANG_BAN_NOTFOUND,"account",nameOrIP.c_str());
|
||||||
|
break;
|
||||||
|
case BAN_CHARACTER:
|
||||||
|
PSendSysMessage(LANG_BAN_NOTFOUND,"character",nameOrIP.c_str());
|
||||||
|
break;
|
||||||
|
case BAN_IP:
|
||||||
|
PSendSysMessage(LANG_BAN_NOTFOUND,"ip",nameOrIP.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleUnBanCommand(const char* args)
|
bool ChatHandler::HandleUnBanAccountCommand(const char* args)
|
||||||
{
|
{
|
||||||
if(!args)
|
return HandleUnBanHelper(BAN_ACCOUNT,args);
|
||||||
return false;
|
|
||||||
char* type = strtok((char*)args, " ");
|
|
||||||
if(!type)
|
|
||||||
return false;
|
|
||||||
char* nameOrIP = strtok(NULL, " ");
|
|
||||||
|
|
||||||
if(!nameOrIP)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(sWorld.RemoveBanAccount(type,nameOrIP))
|
|
||||||
PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP);
|
|
||||||
else
|
|
||||||
PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleBanInfoCommand(const char* args)
|
bool ChatHandler::HandleUnBanCharacterCommand(const char* args)
|
||||||
|
{
|
||||||
|
return HandleUnBanHelper(BAN_CHARACTER,args);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleUnBanIPCommand(const char* args)
|
||||||
|
{
|
||||||
|
return HandleUnBanHelper(BAN_IP,args);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleUnBanHelper(BanMode mode, const char* args)
|
||||||
{
|
{
|
||||||
if(!args)
|
if(!args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* cType = strtok((char*)args, " ");
|
char* cnameOrIP = strtok ((char*)args, " ");
|
||||||
char* cnameOrIP = strtok(NULL, "");
|
if(!cnameOrIP)
|
||||||
if(!cType || !cnameOrIP)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string nameOrIP = cnameOrIP;
|
std::string nameOrIP = cnameOrIP;
|
||||||
std::string type = cType;
|
|
||||||
if (!IsIPAddress(cnameOrIP) && type=="ip")
|
switch(mode)
|
||||||
|
{
|
||||||
|
case BAN_ACCOUNT:
|
||||||
|
if(!AccountMgr::normilizeString(nameOrIP))
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str());
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BAN_CHARACTER:
|
||||||
|
if(!normalizePlayerName(nameOrIP))
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BAN_IP:
|
||||||
|
if(!IsIPAddress(nameOrIP.c_str()))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sWorld.RemoveBanAccount(mode,nameOrIP))
|
||||||
|
PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str());
|
||||||
|
else
|
||||||
|
PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanInfoAccountCommand(const char* args)
|
||||||
|
{
|
||||||
|
if(!args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Field *fields;
|
char* cname = strtok((char*)args, "");
|
||||||
if(type != "ip")
|
if(!cname)
|
||||||
{
|
return false;
|
||||||
//look the accountid up
|
|
||||||
uint32 accountid;
|
std::string account_name = cname;
|
||||||
std::string accountname;
|
|
||||||
if(type == "account")
|
|
||||||
{
|
|
||||||
std::string account_name = nameOrIP;
|
|
||||||
if(!AccountMgr::normilizeString(account_name))
|
if(!AccountMgr::normilizeString(account_name))
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
|
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
|
||||||
|
|
@ -4826,49 +4898,64 @@ bool ChatHandler::HandleBanInfoCommand(const char* args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
accountid = accmgr.GetId(account_name);
|
uint32 accountid = accmgr.GetId(account_name);
|
||||||
if(!accountid)
|
if(!accountid)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
|
PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return HandleBanInfoHelper(accountid,account_name.c_str());
|
||||||
}
|
}
|
||||||
else if(type == "character")
|
|
||||||
|
bool ChatHandler::HandleBanInfoCharacterCommand(const char* args)
|
||||||
{
|
{
|
||||||
if (!normalizePlayerName(nameOrIP))
|
if(!args)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char* cname = strtok ((char*)args, "");
|
||||||
|
if(!cname)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::string name = cname;
|
||||||
|
if(!normalizePlayerName(name))
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
accountid = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP);
|
uint32 accountid = objmgr.GetPlayerAccountIdByPlayerName(name);
|
||||||
if(!accountid)
|
if(!accountid)
|
||||||
{
|
{
|
||||||
PSendSysMessage (LANG_BANINFO_NOCHARACTER);
|
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||||
return true;
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string accountname;
|
||||||
if(!accmgr.GetName(accountid,accountname))
|
if(!accmgr.GetName(accountid,accountname))
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_BANINFO_NOCHARACTER);
|
PSendSysMessage(LANG_BANINFO_NOCHARACTER);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
return HandleBanInfoHelper(accountid,accountname.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname)
|
||||||
|
{
|
||||||
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);
|
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);
|
||||||
if(!result)
|
if(!result)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname.c_str());
|
PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname.c_str());
|
PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
time_t unbandate = time_t(fields[3].GetUInt64());
|
time_t unbandate = time_t(fields[3].GetUInt64());
|
||||||
bool active = false;
|
bool active = false;
|
||||||
|
|
@ -4881,83 +4968,93 @@ bool ChatHandler::HandleBanInfoCommand(const char* args)
|
||||||
}while (result->NextRow());
|
}while (result->NextRow());
|
||||||
|
|
||||||
delete result;
|
delete result;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
bool ChatHandler::HandleBanInfoIPCommand(const char* args)
|
||||||
{
|
{
|
||||||
loginDatabase.escape_string(nameOrIP);
|
if(!args)
|
||||||
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'",nameOrIP.c_str());
|
return false;
|
||||||
|
|
||||||
|
char* cIP = strtok ((char*)args, "");
|
||||||
|
if(!cIP)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!IsIPAddress(cIP))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::string IP = cIP;
|
||||||
|
|
||||||
|
loginDatabase.escape_string(IP);
|
||||||
|
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());
|
||||||
if(!result)
|
if(!result)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_BANINFO_NOIP);
|
PSendSysMessage(LANG_BANINFO_NOIP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
fields = result->Fetch();
|
|
||||||
bool permanent = (fields[6].GetUInt64()==(uint64)0);
|
Field *fields = result->Fetch();
|
||||||
|
bool permanent = !fields[6].GetUInt64();
|
||||||
PSendSysMessage(LANG_BANINFO_IPENTRY,
|
PSendSysMessage(LANG_BANINFO_IPENTRY,
|
||||||
fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER):fields[2].GetString(),
|
fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER):fields[2].GetString(),
|
||||||
permanent ? GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString());
|
permanent ? GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString());
|
||||||
delete result;
|
delete result;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleBanListCommand(const char* args)
|
bool ChatHandler::HandleBanListCharacterCommand(const char* args)
|
||||||
{
|
{
|
||||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||||
if(!*args)
|
|
||||||
|
char* cFilter = strtok ((char*)args, " ");
|
||||||
|
if(!cFilter)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* cType = strtok((char*)args, " ");
|
std::string filter = cFilter;
|
||||||
char* cFilter = strtok(NULL, "");
|
loginDatabase.escape_string(filter);
|
||||||
if(!cType || !cFilter)
|
QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str());
|
||||||
return false;
|
|
||||||
|
|
||||||
std::string Filter = cFilter;
|
|
||||||
std::string Type = cType;
|
|
||||||
loginDatabase.escape_string(Filter);
|
|
||||||
|
|
||||||
QueryResult* result = NULL;
|
|
||||||
if(Type == "ip")
|
|
||||||
{
|
|
||||||
result = loginDatabase.PQuery("SELECT ip FROM ip_banned WHERE ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str());
|
|
||||||
if(!result)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_BANLIST_NOIP);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PSendSysMessage(LANG_BANLIST_MATCHINGIP);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Field* fields = result->Fetch();
|
|
||||||
PSendSysMessage("%s",fields[0].GetString());
|
|
||||||
} while (result->NextRow());
|
|
||||||
|
|
||||||
delete result;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//lookup accountid
|
|
||||||
if(Type == "account")
|
|
||||||
{
|
|
||||||
result = loginDatabase.PQuery("SELECT id, username FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str());
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
PSendSysMessage(LANG_BANLIST_NOACCOUNT);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//do not delete result
|
|
||||||
}
|
|
||||||
else if(Type == "character")
|
|
||||||
{
|
|
||||||
result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter.c_str());
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_BANLIST_NOCHARACTER);
|
PSendSysMessage(LANG_BANLIST_NOCHARACTER);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return HandleBanListHelper(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanListAccountCommand(const char* args)
|
||||||
|
{
|
||||||
|
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||||
|
|
||||||
|
char* cFilter = strtok((char*)args, " ");
|
||||||
|
std::string filter = cFilter ? cFilter : "";
|
||||||
|
loginDatabase.escape_string(filter);
|
||||||
|
|
||||||
|
QueryResult* result;
|
||||||
|
|
||||||
|
if(filter.empty())
|
||||||
|
{
|
||||||
|
result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned"
|
||||||
|
" WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
{
|
||||||
|
result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned"
|
||||||
|
" WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id",
|
||||||
|
filter.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_BANLIST_NOACCOUNT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HandleBanListHelper(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanListHelper(QueryResult* result)
|
||||||
|
{
|
||||||
PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT);
|
PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT);
|
||||||
|
|
||||||
// Chat short output
|
// Chat short output
|
||||||
|
|
@ -4968,7 +5065,7 @@ bool ChatHandler::HandleBanListCommand(const char* args)
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
uint32 accountid = fields[0].GetUInt32();
|
uint32 accountid = fields[0].GetUInt32();
|
||||||
|
|
||||||
QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.active = '1' AND account_banned.id=account.id",accountid);
|
QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid);
|
||||||
if(banresult)
|
if(banresult)
|
||||||
{
|
{
|
||||||
Field* fields2 = banresult->Fetch();
|
Field* fields2 = banresult->Fetch();
|
||||||
|
|
@ -4979,8 +5076,6 @@ bool ChatHandler::HandleBanListCommand(const char* args)
|
||||||
}
|
}
|
||||||
// Console wide output
|
// Console wide output
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if(Type != "ip")
|
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_BANLIST_ACCOUNTS);
|
SendSysMessage(LANG_BANLIST_ACCOUNTS);
|
||||||
SendSysMessage("===============================================================================");
|
SendSysMessage("===============================================================================");
|
||||||
|
|
@ -5001,7 +5096,7 @@ bool ChatHandler::HandleBanListCommand(const char* args)
|
||||||
accmgr.GetName (account_id,account_name);
|
accmgr.GetName (account_id,account_name);
|
||||||
|
|
||||||
// No SQL injection. id is uint32.
|
// No SQL injection. id is uint32.
|
||||||
QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u AND active = 1 ORDER BY unbandate", account_id);
|
QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id);
|
||||||
if (banInfo)
|
if (banInfo)
|
||||||
{
|
{
|
||||||
Field *fields2 = banInfo->Fetch();
|
Field *fields2 = banInfo->Fetch();
|
||||||
|
|
@ -5031,6 +5126,51 @@ bool ChatHandler::HandleBanListCommand(const char* args)
|
||||||
}while( result->NextRow() );
|
}while( result->NextRow() );
|
||||||
SendSysMessage("===============================================================================");
|
SendSysMessage("===============================================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete result;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleBanListIPCommand(const char* args)
|
||||||
|
{
|
||||||
|
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||||
|
|
||||||
|
char* cFilter = strtok((char*)args, " ");
|
||||||
|
std::string filter = cFilter ? cFilter : "";
|
||||||
|
loginDatabase.escape_string(filter);
|
||||||
|
|
||||||
|
QueryResult* result;
|
||||||
|
|
||||||
|
if(filter.empty())
|
||||||
|
{
|
||||||
|
result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
|
||||||
|
" WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())"
|
||||||
|
" ORDER BY unbandate" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
|
||||||
|
" WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")
|
||||||
|
" ORDER BY unbandate",filter.c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!result)
|
||||||
|
{
|
||||||
|
PSendSysMessage(LANG_BANLIST_NOIP);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PSendSysMessage(LANG_BANLIST_MATCHINGIP);
|
||||||
|
// Chat short output
|
||||||
|
if(m_session)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Field* fields = result->Fetch();
|
||||||
|
PSendSysMessage("%s",fields[0].GetString());
|
||||||
|
} while (result->NextRow());
|
||||||
|
}
|
||||||
|
// Console wide output
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_BANLIST_IPS);
|
SendSysMessage(LANG_BANLIST_IPS);
|
||||||
|
|
@ -5060,7 +5200,6 @@ bool ChatHandler::HandleBanListCommand(const char* args)
|
||||||
}while( result->NextRow() );
|
}while( result->NextRow() );
|
||||||
SendSysMessage("===============================================================================");
|
SendSysMessage("===============================================================================");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
delete result;
|
delete result;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -2098,4 +2098,21 @@ enum ResponseCodes
|
||||||
CHAR_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 0x59,
|
CHAR_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 0x59,
|
||||||
CHAR_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 0x5A,
|
CHAR_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 0x5A,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Ban function modes
|
||||||
|
enum BanMode
|
||||||
|
{
|
||||||
|
BAN_ACCOUNT,
|
||||||
|
BAN_CHARACTER,
|
||||||
|
BAN_IP
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Ban function return codes
|
||||||
|
enum BanReturn
|
||||||
|
{
|
||||||
|
BAN_SUCCESS,
|
||||||
|
BAN_SYNTAX_ERROR,
|
||||||
|
BAN_NOTFOUND
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2205,45 +2205,43 @@ bool World::KickPlayer(std::string playerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
|
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
|
||||||
uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string duration, std::string reason, std::string author)
|
BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author)
|
||||||
{
|
{
|
||||||
loginDatabase.escape_string(nameOrIP);
|
loginDatabase.escape_string(nameOrIP);
|
||||||
loginDatabase.escape_string(reason);
|
loginDatabase.escape_string(reason);
|
||||||
std::string safe_author=author;
|
std::string safe_author=author;
|
||||||
loginDatabase.escape_string(safe_author);
|
loginDatabase.escape_string(safe_author);
|
||||||
|
|
||||||
if(type != "ip" && !normalizePlayerName(nameOrIP))
|
|
||||||
return BAN_NOTFOUND; // Nobody to ban
|
|
||||||
|
|
||||||
uint32 duration_secs = TimeStringToSecs(duration);
|
uint32 duration_secs = TimeStringToSecs(duration);
|
||||||
QueryResult *resultAccounts = NULL; //used for kicking
|
QueryResult *resultAccounts = NULL; //used for kicking
|
||||||
|
|
||||||
///- Update the database with ban information
|
///- Update the database with ban information
|
||||||
|
switch(mode)
|
||||||
if(type=="ip")
|
|
||||||
{
|
{
|
||||||
|
case BAN_IP:
|
||||||
//No SQL injection as strings are escaped
|
//No SQL injection as strings are escaped
|
||||||
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str());
|
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str());
|
||||||
loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str());
|
loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str());
|
||||||
}
|
break;
|
||||||
else if(type=="account")
|
case BAN_ACCOUNT:
|
||||||
{
|
|
||||||
//No SQL injection as string is escaped
|
//No SQL injection as string is escaped
|
||||||
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str());
|
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str());
|
||||||
}
|
break;
|
||||||
else if(type=="character")
|
case BAN_CHARACTER:
|
||||||
{
|
|
||||||
//No SQL injection as string is escaped
|
//No SQL injection as string is escaped
|
||||||
resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str());
|
resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return BAN_SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return BAN_SYNTAX_ERROR; //Syntax problem
|
|
||||||
|
|
||||||
if(!resultAccounts)
|
if(!resultAccounts)
|
||||||
if(type=="ip")
|
{
|
||||||
|
if(mode==BAN_IP)
|
||||||
return BAN_SUCCESS; // ip correctly banned but nobody affected (yet)
|
return BAN_SUCCESS; // ip correctly banned but nobody affected (yet)
|
||||||
else
|
else
|
||||||
return BAN_NOTFOUND; // Nobody to ban
|
return BAN_NOTFOUND; // Nobody to ban
|
||||||
|
}
|
||||||
|
|
||||||
///- Disconnect all affected players (for IP it can be several)
|
///- Disconnect all affected players (for IP it can be several)
|
||||||
do
|
do
|
||||||
|
|
@ -2251,13 +2249,14 @@ uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string dura
|
||||||
Field* fieldsAccount = resultAccounts->Fetch();
|
Field* fieldsAccount = resultAccounts->Fetch();
|
||||||
uint32 account = fieldsAccount->GetUInt32();
|
uint32 account = fieldsAccount->GetUInt32();
|
||||||
|
|
||||||
if(type != "ip")
|
if(mode!=BAN_IP)
|
||||||
|
{
|
||||||
//No SQL injection as strings are escaped
|
//No SQL injection as strings are escaped
|
||||||
loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')",
|
loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')",
|
||||||
account,duration_secs,safe_author.c_str(),reason.c_str());
|
account,duration_secs,safe_author.c_str(),reason.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
WorldSession* sess = FindSession(account);
|
if (WorldSession* sess = FindSession(account))
|
||||||
if( sess )
|
|
||||||
if(std::string(sess->GetPlayerName()) != author)
|
if(std::string(sess->GetPlayerName()) != author)
|
||||||
sess->KickPlayer();
|
sess->KickPlayer();
|
||||||
}
|
}
|
||||||
|
|
@ -2268,9 +2267,9 @@ uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string dura
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a ban from an account or IP address
|
/// Remove a ban from an account or IP address
|
||||||
bool World::RemoveBanAccount(std::string type, std::string nameOrIP)
|
bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
|
||||||
{
|
{
|
||||||
if(type == "ip")
|
if (mode == BAN_IP)
|
||||||
{
|
{
|
||||||
loginDatabase.escape_string(nameOrIP);
|
loginDatabase.escape_string(nameOrIP);
|
||||||
loginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str());
|
loginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str());
|
||||||
|
|
@ -2278,20 +2277,10 @@ bool World::RemoveBanAccount(std::string type, std::string nameOrIP)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32 account = 0;
|
uint32 account = 0;
|
||||||
if (type == "account")
|
if (mode == BAN_ACCOUNT)
|
||||||
{
|
|
||||||
if (!AccountMgr::normilizeString (nameOrIP))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
account = accmgr.GetId (nameOrIP);
|
account = accmgr.GetId (nameOrIP);
|
||||||
}
|
else if (mode == BAN_CHARACTER)
|
||||||
else if (type == "character")
|
|
||||||
{
|
|
||||||
if (!normalizePlayerName (nameOrIP))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
account = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP);
|
account = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP);
|
||||||
}
|
|
||||||
|
|
||||||
if (!account)
|
if (!account)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Policies/Singleton.h"
|
#include "Policies/Singleton.h"
|
||||||
|
#include "SharedDefines.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
@ -269,14 +270,6 @@ enum RealmZone
|
||||||
REALM_ZONE_CN9 = 29 // basic-Latin at create, any at login
|
REALM_ZONE_CN9 = 29 // basic-Latin at create, any at login
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Ban function return codes
|
|
||||||
enum BanReturn
|
|
||||||
{
|
|
||||||
BAN_SUCCESS,
|
|
||||||
BAN_SYNTAX_ERROR,
|
|
||||||
BAN_NOTFOUND
|
|
||||||
};
|
|
||||||
|
|
||||||
// DB scripting commands
|
// DB scripting commands
|
||||||
#define SCRIPT_COMMAND_TALK 0 // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text)
|
#define SCRIPT_COMMAND_TALK 0 // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text)
|
||||||
#define SCRIPT_COMMAND_EMOTE 1 // source = unit, datalong = anim_id
|
#define SCRIPT_COMMAND_EMOTE 1 // source = unit, datalong = anim_id
|
||||||
|
|
@ -432,8 +425,8 @@ class World
|
||||||
void KickAll();
|
void KickAll();
|
||||||
void KickAllLess(AccountTypes sec);
|
void KickAllLess(AccountTypes sec);
|
||||||
void KickAllQueued();
|
void KickAllQueued();
|
||||||
uint8 BanAccount(std::string type, std::string nameOrIP, std::string duration, std::string reason, std::string author);
|
BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author);
|
||||||
bool RemoveBanAccount(std::string type, std::string nameOrIP);
|
bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
|
||||||
|
|
||||||
void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
|
void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
|
||||||
void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
|
void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue