限制ip访问_dtcms限制部分IP访问文章

一、新建数据表dt_ipa

45c471960b210892581c7a82fb4eeff7.png

二、DAL数据访问层:DTcms.DALarticle.cs

///        /// 获取ip       ///        ///        ///        public bool GetIp(string ipa) //判断是否存在ip      {    StringBuilder strSql = new StringBuilder();           strSql.Append("select count(1) from " + databaseprefix + "ipa");           strSql.Append(" where ipa=@ipa ");           SqlParameter[] parameters = {new SqlParameter("@ipa", SqlDbType.NVarChar,50)};           parameters[0].Value = ipa;           return DbHelperSQL.Exists(strSql.ToString(), parameters);     }

三、BLL业务逻辑层:DTcms.BLLarticle.cs

///        /// 是否存在于IP列表       ///        ///        public bool Getip(string ipa)      {             return dal.GetIp(ipa);      }

四、Web.UI标签:DTcms.Web.UILabelarticle.cs

///        /// 是否存在于IP列表      ///       ///        protected bool getip()      {             string guestip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();            return new BLL.article().Getip(guestip);     }

五、发布网站后,将Bin文件夹里的文件覆盖,新建频道,修改模板:*_show.html

1、新建频道:控制面板---站点管理---频道管理---新增(以kaohetongbao为例)

69ee50111ae8b39453dd2414ff69d13c.png

2、频道URL配置:

列表页kaohetongbao_all表达式:

(1)kaohetongbao_all.aspx

(2)kaohetongbao-{0}-{1}.aspx,类别ID=数字,分页页码=字符串,设置分页大小条数

列表页kaohetongbao_list表达式:

(1)kaohetongbao/{0}.aspx,类别ID=数字

(2)kaohetongbao/{0}/{1}.aspx,类别ID=数字,分页页码=字符串,设置分页大小条数

详细页kaohetongbao_show表达式:

(1)kaohetongbao/show-{0}.aspx,文章ID=数字

3、修改模板:kaohetongbao_show.html

                    {model.content}   
您没有访问权限!
   
8f8f4f9ce3d61690ee94bb4aa07022a2.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值