Beispiel #1
0
        public ActionResult Edit(BannedIPModel model, int id = -1)
        {
            BannedIPInfo bannedIPInfo = AdminBannedIPs.GetBannedIPById(id);

            if (bannedIPInfo == null)
            {
                return(PromptView("禁止IP不存在"));
            }

            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);
            }

            int id2 = AdminBannedIPs.GetBannedIPIdByIP(ip);

            if (id2 > 0 && id2 != id)
            {
                ModelState.AddModelError("IP4", "IP已经存在");
            }

            if (ModelState.IsValid)
            {
                bannedIPInfo.IP          = ip;
                bannedIPInfo.LiftBanTime = model.LiftBanTime;

                AdminBannedIPs.UpdateBannedIP(bannedIPInfo);
                AddAdminOperateLog("修改禁止IP", "修改禁止IP,禁止IPID为:" + id);
                return(PromptView("禁止IP修改成功"));
            }

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();
            return(View(model));
        }
Beispiel #2
0
        public ActionResult Edit(int id = -1)
        {
            BannedIPInfo bannedIPInfo = AdminBannedIPs.GetBannedIPById(id);

            if (bannedIPInfo == null)
            {
                return(PromptView("禁止IP不存在"));
            }

            string[] ipList = StringHelper.SplitString(bannedIPInfo.IP, ".");

            BannedIPModel model = new BannedIPModel();

            model.IP1         = ipList[0];
            model.IP2         = ipList[1];
            model.IP3         = ipList[2];
            model.IP4         = ipList.Length == 4 ? ipList[3] : "";
            model.LiftBanTime = bannedIPInfo.LiftBanTime;

            ViewData["referer"] = ShopUtils.GetAdminRefererCookie();

            return(View(model));
        }