Exemplo n.º 1
0
        public static string BanUser(string userName, string banMessage = "You have been permanently banned. Contact staff for additional info.", int duration = 0)
        {
            string banResult   = null;
            string characterId = UserFunctions.getUserIdFromCharacterName(userName);
            string accountName = null;

            if (!string.IsNullOrEmpty(characterId))
            {
                accountName = UserFunctions.getAccountNameFromID(characterId);
                if (string.IsNullOrEmpty(accountName))
                {
                    accountName = userName;
                }
            }
            else
            {
                accountName = userName;
            }
            string preBanCheck = isBanned(accountName);

            if (!string.IsNullOrEmpty(preBanCheck) && preBanCheck.Contains("is banned."))
            {
                return("The user " + userName + " is all ready banned.");
            }
            //INSERT INTO UserBan ([ID], [Status], [ExpireTime], [Reason]) VALUES (N'Gigawiz', '4', '2099-03-25 17:00:00.000', N'Testing');
            try
            {
                using (conn = new SqlConnection())
                {
                    conn.ConnectionString = "Server=" + ini.IniReadValue("mssql", "ipandport") + "; Database=heroes; User Id=" + ini.IniReadValue("mssql", "username") + "; password="******"mssql", "password");
                    string     oString = "INSERT INTO UserBan ([ID], [Status], [ExpireTime], [Reason]) VALUES (@fName, '4', '2099-03-25 17:00:00.000', @fReason);";
                    SqlCommand oCmd    = new SqlCommand(oString, conn);
                    oCmd.Parameters.AddWithValue("@fName", accountName);
                    oCmd.Parameters.AddWithValue("@fReason", banMessage);
                    conn.Open();
                    oCmd.ExecuteNonQuery();
                    conn.Close();
                }
                //"The user " + userName + " was successfully banned.";
                string banStatus = isBanned(accountName);
                if (!string.IsNullOrEmpty(banStatus) && banStatus.Contains("is banned."))
                {
                    banResult = "The user " + userName + " was successfully banned.";
                }
                else
                {
                    banResult = "The user " + userName + " was _NOT_ banned.";
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return(banResult);
        }
Exemplo n.º 2
0
        public static string isBanned(string playername)
        {
            string bannedStatus  = "is _not_ banned.";
            string characterName = UserFunctions.getUserIdFromCharacterName(playername);
            string accountName   = null;

            if (!string.IsNullOrEmpty(characterName))
            {
                accountName = UserFunctions.getAccountNameFromID(characterName);
                if (string.IsNullOrEmpty(accountName))
                {
                    accountName = playername;
                }
            }
            else
            {
                accountName = playername;
            }
            try
            {
                using (conn = new SqlConnection())
                {
                    conn.ConnectionString = "Server=" + ini.IniReadValue("mssql", "ipandport") + "; Database=heroes; User Id=" + ini.IniReadValue("mssql", "username") + "; password="******"mssql", "password");
                    string     oString = "Select * from UserBan where ID=@fName";
                    SqlCommand oCmd    = new SqlCommand(oString, conn);
                    oCmd.Parameters.AddWithValue("@fName", accountName);
                    conn.Open();
                    using (SqlDataReader oReader = oCmd.ExecuteReader())
                    {
                        while (oReader.Read())
                        {
                            if (!string.IsNullOrEmpty(oReader["ID"].ToString()))
                            {
                                bannedStatus = "is banned." + Environment.NewLine + "Ban Expires on: " + oReader["ExpireTime"].ToString() + Environment.NewLine + "Ban Reason: " + oReader["Reason"].ToString();
                            }
                        }
                        conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return(bannedStatus);
        }
Exemplo n.º 3
0
        public static string forceRestoreItem(string character, string wepcode, string staff)
        //!restoreweapon <charactername> <enhancement level> <weapon type> [quality] [prefix] [suffix] [fusion]
        {
            string charid      = UserFunctions.getCharacterIdFromName(character);
            string accountId   = UserFunctions.getUserIdFromCharacterName(character);
            string accountName = UserFunctions.getAccountNameFromID(accountId);

            if (string.IsNullOrEmpty(charid))
            {
                return("Invalid character name!");
            }
            List <string> restoredItems      = hasRestored(accountId);
            int           maxRestoredWeapons = 1;

            int.TryParse(ini.IniReadValue("misc", "maxitemrestoresperaccount"), out maxRestoredWeapons);
            if (restoredItems.Count() >= maxRestoredWeapons)
            {
                string retstr = "An item has allready been restored for " + character + "!";
                return(retstr);
            }
            string wepToRestore = null;

            try
            {
                if (string.IsNullOrEmpty(wepcode))
                {
                    return("Invalid or missing weapon code!");
                }
                wepToRestore = wepcode;
                if (!string.IsNullOrEmpty(wepToRestore))
                {
                    SendMail(character, wepToRestore, 1, "Here is your weapon restore. Please be warned, the next destruction of this weapon will be permanant! You now have 0 weapon/item restores available.", "BloodRedDawn Item Restoration");
                    logRestore(staff, accountId, accountName, character, wepToRestore);
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            Logging.LogItem(character + " has had an item restored by " + staff + ". Item code: " + wepToRestore, staff, "forcerestoreweapon - " + character, wepToRestore);
            return("The weapon has been found and restored for " + character + "!");
        }
Exemplo n.º 4
0
        public static string resetSecondary(string playername)
        {
            string retmsg        = null;
            string characterName = UserFunctions.getUserIdFromCharacterName(playername);
            string accountName   = null;

            if (!string.IsNullOrEmpty(characterName))
            {
                accountName = UserFunctions.getAccountNameFromID(characterName);
                if (string.IsNullOrEmpty(accountName))
                {
                    accountName = playername;
                }
            }
            else
            {
                accountName = playername;
            }
            try
            {
                using (conn = new SqlConnection())
                {
                    conn.ConnectionString = "Server=" + ini.IniReadValue("mssql", "ipandport") + "; Database=heroes; User Id=" + ini.IniReadValue("mssql", "username") + "; password="******"mssql", "password");
                    string     oString = "UPDATE [User] SET SecondPassword=@fSecondary WHERE Name=@fName";
                    SqlCommand oCmd    = new SqlCommand(oString, conn);
                    oCmd.Parameters.AddWithValue("@fName", accountName);
                    oCmd.Parameters.AddWithValue("@fSecondary", DBNull.Value);
                    conn.Open();
                    oCmd.ExecuteNonQuery();
                    conn.Close();
                }
                retmsg = "The secondary password for " + playername + " has been reset.";
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return(retmsg);
        }
Exemplo n.º 5
0
        public static string restoreItem(string character, string enhancement, string weapontype, string staff)
        //!restoreweapon <charactername> <enhancement level> <weapon type> [quality] [prefix] [suffix] [fusion]
        {
            string charid      = UserFunctions.getCharacterIdFromName(character);
            string accountId   = UserFunctions.getUserIdFromCharacterName(character);
            string accountName = UserFunctions.getAccountNameFromID(accountId);

            if (string.IsNullOrEmpty(charid))
            {
                return("Invalid character name!");
            }
            List <string> restoredItems      = hasRestored(accountId);
            int           maxRestoredWeapons = 1;

            int.TryParse(ini.IniReadValue("misc", "maxitemrestoresperaccount"), out maxRestoredWeapons);
            if (restoredItems.Count() >= maxRestoredWeapons)
            {
                string retstr = "An item has allready been restored for " + character + "!";
                return(retstr);
            }
            string wepToRestore = null;

            try
            {
                using (conn = new SqlConnection())
                {
                    conn.ConnectionString = "Server=" + ini.IniReadValue("mssql", "ipandport") + "; Database=heroesLog; User Id=" + ini.IniReadValue("mssql", "username") + "; password="******"mssql", "password");
                    string     oString = "SELECT TOP 1 ItemClass FROM ItemLedger01 WHERE ItemClass LIKE @fWeaponType ESCAPE ' ' AND ItemClass LIKE @fEnhance AND CharacterID = @fName ORDER BY TIME ASC";
                    SqlCommand oCmd    = new SqlCommand(oString, conn);
                    oCmd.Parameters.AddWithValue("@fName", charid);
                    oCmd.Parameters.AddWithValue("@fEnhance", "%ENHANCE:" + enhancement + "%");
                    oCmd.Parameters.AddWithValue("@fWeaponType", "%" + weapontype + "%");
                    conn.Open();
                    using (SqlDataReader oReader = oCmd.ExecuteReader())
                    {
                        while (oReader.Read())
                        {
                            if (!string.IsNullOrEmpty(oReader["ItemClass"].ToString()))
                            {
                                wepToRestore = oReader["ItemClass"].ToString();
                            }
                        }
                        conn.Close();
                    }
                }
                if (string.IsNullOrEmpty(wepToRestore))
                {
                    using (conn = new SqlConnection())
                    {
                        conn.ConnectionString = "Server=" + ini.IniReadValue("mssql", "ipandport") + "; Database=heroesLog; User Id=" + ini.IniReadValue("mssql", "username") + "; password="******"mssql", "password");
                        string     oString = "SELECT TOP 1 ItemClass FROM ItemLedger02 WHERE ItemClass LIKE @fWeaponType ESCAPE ' ' AND ItemClass LIKE @fEnhance AND CharacterID = @fName ORDER BY TIME ASC";
                        SqlCommand oCmd    = new SqlCommand(oString, conn);
                        oCmd.Parameters.AddWithValue("@fName", charid);
                        oCmd.Parameters.AddWithValue("@fEnhance", "%ENHANCE:" + enhancement + "%");
                        oCmd.Parameters.AddWithValue("@fWeaponType", "%" + weapontype + "%");
                        conn.Open();
                        using (SqlDataReader oReader = oCmd.ExecuteReader())
                        {
                            while (oReader.Read())
                            {
                                if (!string.IsNullOrEmpty(oReader["ItemClass"].ToString()))
                                {
                                    wepToRestore = oReader["ItemClass"].ToString();
                                }
                            }
                            conn.Close();
                        }
                    }
                    if (string.IsNullOrEmpty(wepToRestore))
                    {
                        return("Weapon not found!");
                    }
                }
                if (!string.IsNullOrEmpty(wepToRestore))
                {
                    SendMail(character, wepToRestore, 1, "Here is your weapon restore. Please be warned, the next destruction of this weapon will be permanant! You now have 0 weapon/item restores available.", "BloodRedDawn Item Restoration");
                    logRestore(staff, accountId, accountName, character, wepToRestore);
                }
            }
            catch (SqlException ex)
            {
                Logging.OldLogItem(ex.Message);
                return(ex.Message);
            }
            Logging.LogItem(character + " has had an item restored by " + staff + ". Item code: " + wepToRestore, staff, "restoreweapon - " + character, wepToRestore);
            return("The weapon has been found and restored for " + character + "!");
        }