Ejemplo n.º 1
0
        private void SetPage()
        {
            int listY     = 122;
            int spaceLeft = listSpace;

            if (totalPages > pg)
            {
                AddHtml(431, 431, 100, 20, MC.ColorText(defaultTextColor, String.Format("Page {0}", (pg + 1))), false, false);
                AddButton(380, 430, 4005, 4007, -3, GumpButtonType.Reply, 0);
            }

            if (pg > 1)
            {
                int length = ((pg - 1).ToString().Length - 1) * 10;

                int pageX = 280 - length;

                AddHtml(pageX + 1, 431, 100, 20, MC.ColorText(defaultTextColor, String.Format("Page {0}", (pg - 1))), false, false);
                AddButton(340, 430, 4014, 4016, -4, GumpButtonType.Reply, 0);
            }

            GetOffsets();

            for (int i = offsetMin; i <= offsetMax; i++)
            {
                MC.DisplayBackground(this, BackgroundTypeConfig, 100, listY, 338, 20);
                MC.DisplayBackground(this, BackgroundTypeConfig, 440, listY, 200, 20);

                string accountName = (string)MC.AccountsList[i];
                string textColor   = defaultTextColor;

                if (MC.AccountNotExist(accountName) || MC.AccountBanned(accountName))
                {
                    textColor = flagTextColor;
                }

                AddButton(100, listY, 9904, 9905, i + numOffset, GumpButtonType.Reply, 0);
                AddHtml(141, listY + 1, 520, 20, MC.ColorText(textColor, accountName), false, false);

                string AccessLevel = null;
                Access accessLevel = (Access)MC.AccessList[i];

                switch (accessLevel)
                {
                case Access.MasterAdmin: { AccessLevel = "Master Admin"; break; }

                case Access.HeadAdmin: { AccessLevel = "Head Admin"; break; }

                case Access.Admin: { AccessLevel = "Admin"; break; }

                case Access.User: { AccessLevel = "User"; break; }

                case Access.None: { AccessLevel = "None"; break; }
                }

                AddHtml(441, listY + 1, 200, 20, MC.ColorText(textColor, String.Format("<center>{0}</center>", AccessLevel)), false, false);

                if (i > 1)
                {
                    AddCheck(640, listY, 210, 211, (bool)AMGCheckBoxesList[i], i);
                }
                else
                {
                    AddImage(640, listY, 210);
                }

                listY     += 21;
                spaceLeft -= 21;
            }

            MC.DisplayBackground(this, BackgroundTypeConfig, 100, listY, 560, spaceLeft);
        }
Ejemplo n.º 2
0
        private void SubmitAccount(RelayInfo info, bool submit, int command)
        {
            string oldMessages    = Messages;
            string oldAccountName = accountName;

            if (submit)
            {
                if (AddAccount)
                {
                    MessagesTitle = "Submit Account";
                }
                else
                {
                    MessagesTitle = "Update Account";
                }

                Messages = null;
            }

            bool invalid = false;

            if (pg == 1)
            {
                accountName = info.GetTextEntry(1).Text;

                int switchNum = MC.GetSwitchNum(info, 1, 4);
                accessSwitch = (Access)switchNum + 1;

                accountsMgmtSwitch = info.IsSwitched(5);
                systemConfigSwitch = info.IsSwitched(6);
            }

// *************** First Check ***************

            if (submit)
            {
                if (oldAccountName == "default user" && accountName != oldAccountName.ToLower())
                {
                    invalid  = true;
                    Messages = "You cannot change the name of the default user account.";
                }
                else if (oldAccountName != "default user" && accountName.ToLower() == "default user")
                {
                    invalid  = true;
                    Messages = "You cannot add default user as an account. The default user account is hard-coded and already exists.";
                }
                else if (((Account)gumpMobile.Account).Username.ToLower() == accountName)
                {
                    invalid  = true;
                    Messages = "You cannot add your own account into the system.";
                }
                else if (MC.AccountNotExist(accountName))
                {
                    invalid  = true;
                    Messages = String.Format("That account does not exist and cannot be {0}.", AddAccount ? "added" : "updated");
                }
                else if (MC.AccountBanned(accountName))
                {
                    invalid  = true;
                    Messages = "That account is banned and cannot be added for security reasons.";
                }
                else if (MC.AccountNoCommandAccess(accountName))
                {
                    invalid  = true;
                    Messages = String.Format("That account does not have access to the \"{0}MegaSpawner\" command and cannot be added.", Server.Commands.CommandPrefix);
                }
            }

// *************** Final Check ***************

            if (invalid)
            {
                UpdatePage(command);

                return;
            }

// *************** Applying Settings ***************

            if (AddAccount && submit)
            {
                if (MC.AccountExists(accountName))
                {
                    Messages = "That account is already in the Mega Spawner System.";

                    UpdatePage(command);

                    return;
                }

                MC.AccountsList.Add(accountName);
                MC.AccessList.Add(accessSwitch);

                ArrayList List = new ArrayList();

                List.Add(accountsMgmtSwitch);
                List.Add(systemConfigSwitch);

                MC.AdminMenuAccessList.Add(List);
                MC.AccountEditors.Add(null);

                Messages = String.Format("Account \"{0}\" has been added.", accountName);
            }
            else if (submit)
            {
                if (oldAccountName != accountName && MC.AccountExists(accountName))
                {
                    Messages = "That account is already in the Mega Spawner System.";

                    UpdatePage(command);

                    return;
                }

                MC.AccountsList[index] = accountName;
                MC.AccessList[index]   = accessSwitch;

                ArrayList List = new ArrayList();

                List.Add(accountsMgmtSwitch);
                List.Add(systemConfigSwitch);

                MC.AdminMenuAccessList[index] = List;
                MC.AccountEditors[index]      = null;

                Messages = String.Format("Account \"{0}\" has been updated.", accountName);
            }

            if (submit)
            {
                MC.SaveAccountsAccess();

                if (!AddAccount)
                {
                    MC.AccountEditors[index] = null;
                }

                SetArgsList();

                gumpMobile.SendGump(new AccountsManagementGump(gumpMobile, ArgsList));
            }
            else
            {
                UpdatePage(command);
            }
        }
Ejemplo n.º 3
0
        private void CheckAccounts()
        {
            bool found           = false;
            bool accountNotExist = false;
            bool banned          = false;

            for (int i = 0; i < MC.AccountsList.Count; i++)
            {
                string accountName = (string)MC.AccountsList[i];

                if (MC.AccountNotExist(accountName))
                {
                    if (!accountNotExist && OldMessages != Messages)
                    {
                        Messages = String.Format("{0}:\n{1}\n\nThe following accounts have been detected as non-existant accounts:\n{2}", MessagesTitle, Messages, MC.AccountsList[i].ToString());
                    }
                    else if (!accountNotExist)
                    {
                        Messages = String.Format("The following accounts have been detected as non-existant accounts:\n{0}", MC.AccountsList[i].ToString());
                    }
                    else
                    {
                        Messages = String.Format("{0}, {1}", Messages, MC.AccountsList[i].ToString());
                    }

                    MessagesTitle = "Account Errors Detected";

                    accountNotExist = true;
                    found           = true;
                }
            }

            for (int i = 0; i < MC.AccountsList.Count; i++)
            {
                string accountName = (string)MC.AccountsList[i];

                if (MC.AccountBanned(accountName))
                {
                    MessagesTitle = "Account Errors Detected";

                    if (!banned && accountNotExist)
                    {
                        Messages = String.Format("{0}\nThe following accounts have been detected as banned accounts:\n{1}", Messages, MC.AccountsList[i].ToString());
                    }
                    else if (!banned && !accountNotExist && OldMessages != Messages)
                    {
                        Messages = String.Format("{0}:\n{1}\n\nThe following accounts have been detected as banned accounts:\n{2}", MessagesTitle, Messages, MC.AccountsList[i].ToString());
                    }
                    else if (!banned && !accountNotExist)
                    {
                        Messages = String.Format("The following accounts have been detected as banned accounts:\n{0}", MC.AccountsList[i].ToString());
                    }
                    else
                    {
                        Messages = String.Format("{0}, {1}", Messages, MC.AccountsList.ToString());
                    }

                    found = true;
                }
            }

            if (found)
            {
                Messages = String.Format("{0}\n\nThose accounts listed either do not exist or are banned. They have been flagged a different color. You should take care of the possible security risks.", Messages);
            }

            OldMessages = Messages;
        }