static bool HandleAccountSetAddonCommand(CommandHandler handler, string accountName, byte expansion) { uint accountId; if (!accountName.IsEmpty()) { // Convert Account name to Upper Format accountName = accountName.ToUpper(); accountId = Global.AccountMgr.GetId(accountName); if (accountId == 0) { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } } else { Player player = handler.GetSelectedPlayer(); if (!player) { return(false); } accountId = player.GetSession().GetAccountId(); Global.AccountMgr.GetName(accountId, out accountName); } // Let set addon state only for lesser (strong) security level // or to self account if (handler.GetSession() != null && handler.GetSession().GetAccountId() != accountId && handler.HasLowerSecurityAccount(null, accountId, true)) { return(false); } if (expansion > WorldConfig.GetIntValue(WorldCfg.Expansion)) { return(false); } PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_EXPANSION); stmt.AddValue(0, expansion); stmt.AddValue(1, accountId); DB.Login.Execute(stmt); handler.SendSysMessage(CypherStrings.AccountSetaddon, accountName, accountId, expansion); return(true); }
static bool HandleAccountDeleteCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } string accountName = args.NextString(); if (string.IsNullOrEmpty(accountName)) { return(false); } uint accountId = Global.AccountMgr.GetId(accountName); if (accountId == 0) { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } if (handler.HasLowerSecurityAccount(null, accountId, true)) { return(false); } AccountOpResult result = Global.AccountMgr.DeleteAccount(accountId); switch (result) { case AccountOpResult.Ok: handler.SendSysMessage(CypherStrings.AccountDeleted, accountName); break; case AccountOpResult.NameNotExist: handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); case AccountOpResult.DBInternalError: handler.SendSysMessage(CypherStrings.AccountNotDeletedSqlError, accountName); return(false); default: handler.SendSysMessage(CypherStrings.AccountNotDeleted, accountName); return(false); } return(true); }
static bool HandleAccountSetRegEmailCommand(CommandHandler handler, string accountName, string email, string confirmEmail) { uint targetAccountId = Global.AccountMgr.GetId(accountName); if (targetAccountId == 0) { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } // can set email only for target with less security // This also restricts setting handler's own email. if (handler.HasLowerSecurityAccount(null, targetAccountId, true)) { return(false); } if (!email.Equals(confirmEmail)) { handler.SendSysMessage(CypherStrings.NewEmailsNotMatch); return(false); } AccountOpResult result = Global.AccountMgr.ChangeRegEmail(targetAccountId, email); switch (result) { case AccountOpResult.Ok: handler.SendSysMessage(CypherStrings.CommandEmail); Log.outInfo(LogFilter.Player, "ChangeRegEmail: Account {0} [Id: {1}] had it's Registration Email changed to {2}.", accountName, targetAccountId, email); break; case AccountOpResult.NameNotExist: handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); case AccountOpResult.EmailTooLong: handler.SendSysMessage(CypherStrings.EmailTooLong); return(false); default: handler.SendSysMessage(CypherStrings.CommandNotchangeemail); return(false); } return(true); }
static bool HandleAccountSetPasswordCommand(CommandHandler handler, string accountName, string password, string confirmPassword) { uint targetAccountId = Global.AccountMgr.GetId(accountName); if (targetAccountId == 0) { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } // can set password only for target with less security // This also restricts setting handler's own password if (handler.HasLowerSecurityAccount(null, targetAccountId, true)) { return(false); } if (!password.Equals(confirmPassword)) { handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch); return(false); } AccountOpResult result = Global.AccountMgr.ChangePassword(targetAccountId, password); switch (result) { case AccountOpResult.Ok: handler.SendSysMessage(CypherStrings.CommandPassword); break; case AccountOpResult.NameNotExist: handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); case AccountOpResult.PassTooLong: handler.SendSysMessage(CypherStrings.PasswordTooLong); return(false); default: handler.SendSysMessage(CypherStrings.CommandNotchangepassword); return(false); } return(true); }
static bool HandleSetRegEmailCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } //- We do not want anything short of console to use this by default. //- So we force that. if (handler.GetSession()) { return(false); } // Get the command line arguments string accountName = args.NextString(); string email = args.NextString(); string emailConfirmation = args.NextString(); if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(emailConfirmation)) { handler.SendSysMessage(CypherStrings.CmdSyntax); return(false); } uint targetAccountId = Global.AccountMgr.GetId(accountName); if (targetAccountId == 0) { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } // can set email only for target with less security // This also restricts setting handler's own email. if (handler.HasLowerSecurityAccount(null, targetAccountId, true)) { return(false); } if (!email.Equals(emailConfirmation)) { handler.SendSysMessage(CypherStrings.NewEmailsNotMatch); return(false); } AccountOpResult result = Global.AccountMgr.ChangeRegEmail(targetAccountId, email); switch (result) { case AccountOpResult.Ok: handler.SendSysMessage(CypherStrings.CommandEmail); Log.outInfo(LogFilter.Player, "ChangeRegEmail: Account {0} [Id: {1}] had it's Registration Email changed to {2}.", accountName, targetAccountId, email); break; case AccountOpResult.NameNotExist: handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); case AccountOpResult.EmailTooLong: handler.SendSysMessage(CypherStrings.EmailTooLong); return(false); default: handler.SendSysMessage(CypherStrings.CommandNotchangeemail); return(false); } return(true); }
static bool HandleSetAddonCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { return(false); } // Get the command line arguments string account = args.NextString(); string exp = args.NextString(); if (string.IsNullOrEmpty(account)) { return(false); } string accountName; uint accountId; if (string.IsNullOrEmpty(exp)) { Player player = handler.getSelectedPlayer(); if (!player) { return(false); } accountId = player.GetSession().GetAccountId(); Global.AccountMgr.GetName(accountId, out accountName); exp = account; } else { // Convert Account name to Upper Format accountName = account.ToUpper(); accountId = Global.AccountMgr.GetId(accountName); if (accountId == 0) { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } } // Let set addon state only for lesser (strong) security level // or to self account if (handler.GetSession() != null && handler.GetSession().GetAccountId() != accountId && handler.HasLowerSecurityAccount(null, accountId, true)) { return(false); } if (!byte.TryParse(exp, out byte expansion)) { return(false); } if (expansion > WorldConfig.GetIntValue(WorldCfg.Expansion)) { return(false); } PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_EXPANSION); stmt.AddValue(0, expansion); stmt.AddValue(1, accountId); DB.Login.Execute(stmt); handler.SendSysMessage(CypherStrings.AccountSetaddon, accountName, accountId, expansion); return(true); }
static bool HandleSetPasswordCommand(StringArguments args, CommandHandler handler) { if (args.Empty()) { handler.SendSysMessage(CypherStrings.CmdSyntax); return(false); } // Get the command line arguments string accountName = args.NextString(); string password = args.NextString(); string passwordConfirmation = args.NextString(); if (string.IsNullOrEmpty(accountName) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(passwordConfirmation)) { return(false); } uint targetAccountId = Global.AccountMgr.GetId(accountName); if (targetAccountId == 0) { handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); } // can set password only for target with less security // This also restricts setting handler's own password if (handler.HasLowerSecurityAccount(null, targetAccountId, true)) { return(false); } if (!password.Equals(passwordConfirmation)) { handler.SendSysMessage(CypherStrings.NewPasswordsNotMatch); return(false); } AccountOpResult result = Global.AccountMgr.ChangePassword(targetAccountId, password); switch (result) { case AccountOpResult.Ok: handler.SendSysMessage(CypherStrings.CommandPassword); break; case AccountOpResult.NameNotExist: handler.SendSysMessage(CypherStrings.AccountNotExist, accountName); return(false); case AccountOpResult.PassTooLong: handler.SendSysMessage(CypherStrings.PasswordTooLong); return(false); default: handler.SendSysMessage(CypherStrings.CommandNotchangepassword); return(false); } return(true); }