예제 #1
0
        public ActionResult Add(BannedIPModel model)
        {
            string ip = "";
            if (string.IsNullOrWhiteSpace(model.IP4))
                ip = string.Format("{0}.{1}.{2}", model.IP1, model.IP2, model.IP3);
            else
                ip = string.Format("{0}.{1}.{2}.{3}", model.IP1, model.IP2, model.IP3, model.IP4);

            if (AdminBannedIPs.GetBannedIPIdByIP(ip) > 0)
                ModelState.AddModelError("IP4", "IP已经存在");

            if (ModelState.IsValid)
            {
                BannedIPInfo bannedIPInfo = new BannedIPInfo()
                {
                    IP = ip,
                    LiftBanTime = model.LiftBanTime
                };

                AdminBannedIPs.AddBannedIP(bannedIPInfo);
                AddMallAdminLog("添加禁止IP", "添加禁止IP,禁止IP为:" + ip);
                return PromptView("禁止IP添加成功");
            }
            ViewData["referer"] = MallUtils.GetMallAdminRefererCookie();
            return View(model);
        }
예제 #2
0
        /// <summary>
        /// 获得禁止的ip
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        public static BannedIPInfo GetBannedIPById(int id)
        {
            BannedIPInfo bannedIPInfo = null;
            IDataReader reader = BrnMall.Core.BMAData.RDBS.GetBannedIPById(id);
            if (reader.Read())
            {
                bannedIPInfo = new BannedIPInfo();
                bannedIPInfo.Id = TypeHelper.ObjectToInt(reader["id"]);
                bannedIPInfo.IP = reader["ip"].ToString();
                bannedIPInfo.LiftBanTime = TypeHelper.ObjectToDateTime(reader["liftbantime"]);
            }

            reader.Close();
            return bannedIPInfo;
        }
예제 #3
0
        /// <summary>
        /// 更新禁止的ip
        /// </summary>
        public void UpdateBannedIP(BannedIPInfo bannedIPInfo)
        {
            DbParameter[] parms = {
									GenerateInParam("@ip",SqlDbType.VarChar,15, bannedIPInfo.IP),
									GenerateInParam("@liftbantime",SqlDbType.DateTime,8, bannedIPInfo.LiftBanTime),
									GenerateInParam("@id",SqlDbType.Int,4, bannedIPInfo.Id)
			                       };
            string commandText = string.Format("UPDATE [{0}bannedips] SET [ip]=@ip,[liftbantime]=@liftbantime WHERE [id]=@id",
                                                RDBSHelper.RDBSTablePre);
            RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
        }
예제 #4
0
        /// <summary>
        /// 添加禁止的ip
        /// </summary>
        public void AddBannedIP(BannedIPInfo bannedIPInfo)
        {
            DbParameter[] parms = {
									GenerateInParam("@ip",SqlDbType.VarChar,15, bannedIPInfo.IP),
									GenerateInParam("@liftbantime",SqlDbType.DateTime,8, bannedIPInfo.LiftBanTime)
			                       };
            string commandText = string.Format("INSERT INTO [{0}bannedips]([ip],[liftbantime]) VALUES(@ip,@liftbantime)",
                                                RDBSHelper.RDBSTablePre);
            RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
        }
예제 #5
0
 /// <summary>
 /// 更新禁止的ip
 /// </summary>
 public static void UpdateBannedIP(BannedIPInfo bannedIPInfo)
 {
     BrnMall.Core.BMAData.RDBS.UpdateBannedIP(bannedIPInfo);
 }
예제 #6
0
 /// <summary>
 /// 添加禁止的ip
 /// </summary>
 public static void AddBannedIP(BannedIPInfo bannedIPInfo)
 {
     BrnMall.Core.BMAData.RDBS.AddBannedIP(bannedIPInfo);
 }
예제 #7
0
 /// <summary>
 /// 更新禁止的ip
 /// </summary>
 public static void UpdateBannedIP(BannedIPInfo bannedIPInfo)
 {
     BrnMall.Data.BannedIPs.UpdateBannedIP(bannedIPInfo);
     BrnMall.Core.BMACache.Remove(CacheKeys.MALL_BANNEDIP_HASHSET);
 }