Esempio n. 1
0
        public BannedIP InsertBanIp(string ip, DateTime time)
        {
            MySqlConnection connection = DAO.GetConnection();
            BannedIP        result     = null;

            try
            {
                connection.Open();
                string       cmdText      = "REPLACE INTO banned_ip(mask, time_end) VALUES (?mask, ?time_end)";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?mask", ip);
                mySqlCommand.Parameters.AddWithValue("?time_end", time);
                mySqlCommand.ExecuteNonQuery();
                result = new BannedIP(ip, time);
                return(result);
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2);
                ProjectData.ClearProjectError();
                return(result);
            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 2
0
        public static bool IsBannedIp(string ip)
        {
            BannedIP value = null;

            if (Banips.TryGetValue(ip, out value))
            {
                if (DateTime.Compare(value.TimeEnd, DateAndTime.Now) > 0)
                {
                    return(true);
                }
                Banips.Remove(ip);
            }
            return(false);
        }
Esempio n. 3
0
        public static bool BanIP(string ip, DateTime time)
        {
            if (ip.Equals("127.0.0.1"))
            {
                return(false);
            }
            BannedIP bannedIP = DAOManager.BannedIpDAO.InsertBanIp(ip, time);

            if (!Information.IsNothing(bannedIP))
            {
                Banips.Add(ip, bannedIP);
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public override bool Equals(object obj)
        {
            if (Information.IsNothing(RuntimeHelpers.GetObjectValue(obj)))
            {
                return(false);
            }
            if (obj.GetType() != typeof(BannedIP))
            {
                return(false);
            }
            if (Operators.ConditionalCompareObjectEqual(this, obj, TextCompare: false))
            {
                return(true);
            }
            BannedIP bannedIP = (BannedIP)obj;

            return(BanIp.Equals(bannedIP.BanIp));
        }
Esempio n. 5
0
 internal void _Lambda_0024__5_002D1(BannedIP b)
 {
     Banips.Remove(b.BanIp);
     DAOManager.BannedIpDAO.DeleteBannedIp(b.BanIp);
 }
Esempio n. 6
0
 internal bool _Lambda_0024__5_002D0(BannedIP b)
 {
     return(DateTime.Compare(b.TimeEnd, DateAndTime.Now) <= 0);
 }