Esempio n. 1
0
        public bool GetBanTags(out DateTime banTime, out TimeSpan banDuration)
        {
            string tagTime     = GetTag("BanTime");
            string tagDuration = GetTag("BanDuration");

            if (tagTime != null)
            {
                banTime = Accounts.GetDateTime(tagTime, DateTime.MinValue);
            }
            else
            {
                banTime = DateTime.MinValue;
            }

            if (tagDuration == "Infinite")
            {
                banDuration = TimeSpan.MaxValue;
            }
            else if (tagDuration != null)
            {
                try{ banDuration = TimeSpan.Parse(tagDuration); }
                catch { banDuration = TimeSpan.Zero; }
            }
            else
            {
                banDuration = TimeSpan.Zero;
            }

            return(banTime != DateTime.MinValue && banDuration != TimeSpan.Zero);
        }
Esempio n. 2
0
 /// <summary>
 /// Deserializes an AccountComment instance from an xml element.
 /// </summary>
 /// <param name="node">The XmlElement instance from which to deserialize.</param>
 public AccountComment(XmlElement node)
 {
     m_AddedBy      = Accounts.GetAttribute(node, "addedBy", "empty");
     m_LastModified = Accounts.GetDateTime(Accounts.GetAttribute(node, "lastModified"), DateTime.Now);
     m_Content      = Accounts.GetText(node, "");
 }
Esempio n. 3
0
        /// <summary>
        /// Deserializes an Account instance from an xml element. Intended only to be called from Accounts.Load.
        /// </summary>
        /// <param name="node">The XmlElement instance from which to deserialize.</param>
        public Account(XmlElement node)
        {
            m_Username = Accounts.GetText(node["username"], "empty");

            string plainPassword = Accounts.GetText(node["password"], null);
            string cryptPassword = Accounts.GetText(node["cryptPassword"], null);

            if (AccountHandler.ProtectPasswords)
            {
                if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else
                {
                    SetPassword("empty");
                }
            }
            else
            {
                if (plainPassword == null)
                {
                    plainPassword = "******";
                }

                SetPassword(plainPassword);
            }

            m_AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), Accounts.GetText(node["accessLevel"], "Player"), true);
            m_Flags       = Accounts.GetInt32(Accounts.GetText(node["flags"], "0"), 0);
            m_Created     = Accounts.GetDateTime(Accounts.GetText(node["created"], null), DateTime.Now);
            m_LastLogin   = Accounts.GetDateTime(Accounts.GetText(node["lastLogin"], null), DateTime.Now);

            m_Mobiles        = LoadMobiles(node);
            m_Comments       = LoadComments(node);
            m_Tags           = LoadTags(node);
            m_LoginIPs       = LoadAddressList(node);
            m_IPRestrictions = LoadAccessCheck(node);

            for (int i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }

            TimeSpan totalGameTime = Accounts.GetTimeSpan(Accounts.GetText(node["totalGameTime"], null), TimeSpan.Zero);

            if (totalGameTime == TimeSpan.Zero)
            {
                for (int i = 0; i < m_Mobiles.Length; i++)
                {
                    PlayerMobile m = m_Mobiles[i] as PlayerMobile;

                    if (m != null)
                    {
                        totalGameTime += m.GameTime;
                    }
                }
            }
            m_TotalGameTime = totalGameTime;

            if (this.Young)
            {
                CheckYoung();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Deserializes an Account instance from an xml element. Intended only to be called from Accounts.Load.
        /// </summary>
        /// <param name="node">The XmlElement instance from which to deserialize.</param>
        public Account(XmlElement node)
        {
            m_Username = Accounts.GetText(node["username"], "empty");

            string plainPassword = Accounts.GetText(node["password"], null);
            string cryptPassword = Accounts.GetText(node["cryptPassword"], null);

            if (AccountHandler.ProtectPasswords)
            {
                if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else
                {
                    SetPassword("empty");
                }
            }
            else
            {
                if (plainPassword == null)
                {
                    plainPassword = "******";
                }

                SetPassword(plainPassword);
            }

            m_AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), Accounts.GetText(node["accessLevel"], "Player"), true);
            m_Flags       = Accounts.GetInt32(Accounts.GetText(node["flags"], "0"), 0);
            m_Created     = Accounts.GetDateTime(Accounts.GetText(node["created"], null), DateTime.Now);
            m_LastLogin   = Accounts.GetDateTime(Accounts.GetText(node["lastLogin"], null), DateTime.Now);

            m_EmailAddress = Accounts.GetText(node["email"], "empty");

            m_WatchReason = Accounts.GetText(node["watchreason"], "");
            m_WatchExpire = Accounts.GetDateTime(Accounts.GetText(node["watchexpiredate"], null), DateTime.MinValue);

            m_Mobiles        = LoadMobiles(node);
            m_Comments       = LoadComments(node);
            m_Tags           = LoadTags(node);
            m_LoginIPs       = LoadAddressList(node);
            m_IPRestrictions = LoadAccessCheck(node);
            m_EmailHistory   = LoadEmailHistory(node);

            m_bAccountActivated          = Accounts.GetBool(node["accountactivated"], false);
            m_ActivationKey              = Accounts.GetText(node["activationkey"], "");
            m_ResetPassword              = Accounts.GetText(node["resetpassword"], "");
            m_ResetPasswordRequestedTime = Accounts.GetDateTime(Accounts.GetText(node["resetpwdtime"], null), DateTime.MinValue);

            for (int i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }
        }