Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ItemID < 1)
            {
                function.WriteErrMsg("[产生错误的可能原因:内容信息不存在或未开放!调用方法:Content.aspx?ID=内容ID]");
            }
            M_CommonData ItemInfo = bcontent.GetCommonData(ItemID);
            M_Node       nodeinfo = bnode.GetNode(ItemInfo.NodeID);

            if (ItemInfo.IsNull)
            {
                function.WriteErrMsg("[产生错误的可能原因:内容信息不存在或未开放!]");
            }
            else if (ItemInfo.Status == -2)
            {
                function.WriteErrMsg("[对不起,当前信息已删除,您无法浏览!]");
            }
            else if (ItemInfo.Status == 0)
            {
                function.WriteErrMsg("[对不起,当前信息待审核状态,您无法浏览!]");
            }
            else if (ItemInfo.Status != 99)
            {
                function.WriteErrMsg("[对不起,当前信息未通过审核,您无法浏览!]");
            }
            if (nodeinfo.PurviewType)
            {
                if (!buser.CheckLogin())
                {
                    function.WriteErrMsg("该信息所属栏目需登录验证,请先<a href='/User/login.aspx' target='_top'>登录</a>再进行此操作!", "/User/login.aspx");
                }
                else
                {
                    //此处以后可以加上用户组权限检测
                }
            }
            if (nodeinfo.ConsumePoint > 0)
            {
                M_UserInfo userinfo = buser.GetUserByUserID(buser.GetLogin().UserID);
                int        groupID  = 0; //会员级别id
                int        groupNum = 0; //浏览文章的次数

                if (nodeinfo.Viewinglimit != "" || nodeinfo.Viewinglimit != null)
                {
                    #region 查找当前登录会员浏览该文章规定的次数
                    string   Viewinglimits     = nodeinfo.Viewinglimit;
                    string[] ViewinglimitArray = Viewinglimits.Split(new char[] { '|' });
                    if (ViewinglimitArray.Length > 1)
                    {
                        for (int i = 0; i < ViewinglimitArray.Length; i++)
                        {
                            if (userinfo.GroupID == int.Parse(ViewinglimitArray[i].Substring(0, ViewinglimitArray[i].IndexOf("="))))
                            {
                                groupID  = int.Parse(ViewinglimitArray[i].Substring(0, ViewinglimitArray[i].IndexOf("=")));
                                groupNum = int.Parse(ViewinglimitArray[i].Substring(ViewinglimitArray[i].IndexOf("=") + 1, ViewinglimitArray[i].Length - ViewinglimitArray[i].Substring(0, ViewinglimitArray[i].IndexOf("=") + 1).Length));
                                break;
                            }
                        }
                    }
                    #endregion
                }
                if (buser.CheckLogin() && (userinfo.UserPoint - nodeinfo.ConsumePoint) > 0)
                {
                    B_CompleteHistory bcomhistory = new B_CompleteHistory();
                    switch (nodeinfo.ConsumeType)
                    {
                    case 0:        //0-不重复收费
                        ReadArticleStandardCharges(userinfo, nodeinfo, buser, bcomhistory, ItemInfo.GeneralID, nodeinfo.ConsumeType, groupID, groupNum);
                        break;

                    case 1:        //1-距离上次收费时间多少小时后重新收费
                        ReadArticleStandardCharges(userinfo, nodeinfo, buser, bcomhistory, ItemInfo.GeneralID, nodeinfo.ConsumeType, groupID, groupNum);
                        break;

                    case 2:        //2-重复阅读内容多少次重新收费
                        ReadArticleStandardCharges(userinfo, nodeinfo, buser, bcomhistory, ItemInfo.GeneralID, nodeinfo.ConsumeType, groupID, groupNum);
                        break;

                    case 3:        //3-上述两者都满足时重新收费
                        ReadArticleStandardCharges(userinfo, nodeinfo, buser, bcomhistory, ItemInfo.GeneralID, nodeinfo.ConsumeType, groupID, groupNum);
                        break;

                    case 4:        //4- 1、2两者任一个满足时就重新收费
                        ReadArticleStandardCharges(userinfo, nodeinfo, buser, bcomhistory, ItemInfo.GeneralID, nodeinfo.ConsumeType, groupID, groupNum);
                        break;

                    case 5:         //5-每阅读一次就重复收费一次
                        ReadArticleStandardCharges(userinfo, nodeinfo, buser, bcomhistory, ItemInfo.GeneralID, nodeinfo.ConsumeType, groupID, groupNum);
                        break;

                    default:
                        ReadArticleStandardCharges(userinfo, nodeinfo, buser, bcomhistory, ItemInfo.GeneralID, nodeinfo.ConsumeType, groupID, groupNum);        //不重复收费
                        break;
                    }
                }
                else
                {
                    function.WriteErrMsg("您的点券不足,请充值!");
                }
            }
            M_ModelInfo modelinfo   = bmode.GetModelById(ItemInfo.ModelID);
            string      TempNode    = bnode.GetModelTemplate(ItemInfo.NodeID, ItemInfo.ModelID);
            string      TempContent = ItemInfo.Template;
            string      TemplateDir = modelinfo.ContentModule;
            if (!string.IsNullOrEmpty(TempContent))
            {
                TemplateDir = TempContent;
            }
            else
            {
                if (!string.IsNullOrEmpty(TempNode))
                {
                    TemplateDir = TempNode;
                }
            }
            if (string.IsNullOrEmpty(TemplateDir))
            {
                function.WriteErrMsg("该内容所属模型未指定模板");
            }
            else
            {
                GetNodePreate(nodeinfo.NodeID);
                if (!(TemplateDir.ToLower().IndexOf("site") > 0 && TemplateDir.ToLower().IndexOf("site") <= 2))
                {
                    TemplateDir = base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir + "/" + TemplateDir;
                }
                else
                {
                    TemplateDir = base.Request.PhysicalApplicationPath + "/" + TemplateDir;
                }
                int    pid = bnode.GetContrarily(DataConverter.CLng(ItemInfo.NodeID), 5); //子站判断
                M_Node mn  = bnode.GetNodeXML(DataConverter.CLng(pid));
                mn = bnode.dal_GetNode(DataConverter.CLng(pid));
                if (mn.NodeBySite == 5)
                {
                    string NodeDir = mn.NodeDir;
                    mn          = bnode.GetNodeXML(DataConverter.CLng(ItemInfo.NodeID));
                    TemplateDir = modelinfo.ContentModule;
                    if (!string.IsNullOrEmpty(TempNode))
                    {
                        TemplateDir = TempNode;
                    }
                    if (TemplateDir.IndexOf("SiteTemplate") < 0)
                    {
                        TemplateDir = "\\Site\\" + NodeDir + "\\Template" + TemplateDir;
                    }
                    TemplateDir = base.Request.PhysicalApplicationPath + TemplateDir;    // "\\Site\\" + NodeDir + "\\Template" +
                }
                TemplateDir = TemplateDir.Replace("/", @"\").Replace(@"\\", @"\");
                string Templatestrstr = FileSystemObject.ReadFile(TemplateDir);
                string ContentHtml    = this.bll.CreateHtml(Templatestrstr, Cpage, ItemID, "0"); //Templatestrstr:模板页面字符串,页码,该文章ID
                /* --------------------判断是否分页 并做处理------------------------------------------------*/
                if (!string.IsNullOrEmpty(ContentHtml))
                {
                    string infoContent = "";     //进行处理的内容字段
                    string pagelabel   = "";
                    string infotmp     = "";

                    #region 分页符分页

                    string pattern = @"{\#PageCode}([\s\S])*?{\/\#PageCode}";      //查找要分页的内容
                    if (Regex.IsMatch(ContentHtml, pattern, RegexOptions.IgnoreCase))
                    {
                        infoContent = Regex.Match(ContentHtml, pattern, RegexOptions.IgnoreCase).Value;
                        infotmp     = infoContent;
                        infoContent = infoContent.Replace("{#PageCode}", "").Replace("{/#PageCode}", "");
                        //查找分页标签
                        bool   isPage   = false;
                        string pattern1 = @"{ZL\.Page([\s\S])*?\/}";

                        if (Regex.IsMatch(ContentHtml, pattern1, RegexOptions.IgnoreCase))
                        {
                            pagelabel = Regex.Match(ContentHtml, pattern1, RegexOptions.IgnoreCase).Value;
                            isPage    = true;
                        }
                        if (isPage)
                        {
                            if (string.IsNullOrEmpty(infoContent))     //没有设定要分页的字段内容
                            {
                                ContentHtml = ContentHtml.Replace(pagelabel, "");
                            }
                            else       //进行内容分页处理
                            {
                                //文件名
                                string file1 = "Content.aspx?ID=" + ItemID.ToString();
                                //取分页标签处理结果 返回字符串数组 根据数组元素个数生成几页
                                string         ilbl       = pagelabel.Replace("{ZL.Page ", "").Replace("/}", "").Replace(" ", ",");
                                string         lblContent = "";
                                IList <string> ContentArr = new List <string>();

                                if (string.IsNullOrEmpty(ilbl))
                                {
                                    lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}";     //默认格式的分页导航
                                    ContentArr = this.bll.GetContentPage(infoContent);
                                }
                                else
                                {
                                    string[] paArr = ilbl.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                    if (paArr.Length == 0)
                                    {
                                        lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}";     //默认格式的分页导航
                                        ContentArr = this.bll.GetContentPage(infoContent);
                                    }
                                    else
                                    {
                                        string  lblname = paArr[0].Split(new char[] { '=' })[1].Replace("\"", "");
                                        B_Label blbl    = new B_Label();
                                        lblContent = blbl.GetLabelXML(lblname).Content;
                                        if (string.IsNullOrEmpty(lblContent))
                                        {
                                            lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}";     //默认格式的分页导航
                                        }
                                        ContentArr = this.bll.GetContentPage(infoContent);
                                    }
                                }

                                if (ContentArr.Count > 0) //存在分页数据
                                {
                                    if (Cpage == 0)       //显示全部
                                    {
                                        ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                                        ContentHtml = ContentHtml.Replace("[PageCode/]", "");
                                    }
                                    else
                                    {
                                        ContentHtml = ContentHtml.Replace(infotmp, ContentArr[Cpage - 1]);
                                    }
                                    ContentHtml = ContentHtml.Replace(pagelabel, this.bll.GetPage(lblContent, ItemID, Cpage, ContentArr.Count, ContentArr.Count));    //输出分页
                                }
                                else
                                {
                                    ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                                    ContentHtml = ContentHtml.Replace(pagelabel, "");
                                }
                            }
                        }
                        else      //没有分页标签
                        {
                            //如果设定了分页内容字段 将该字段内容的分页标志清除
                            if (!string.IsNullOrEmpty(infoContent))
                            {
                                ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                            }
                        }
                    }
                    #endregion

                    pattern = @"{\#Content}([\s\S])*?{\/\#Content}";      //查找要分页的内容
                    if (Regex.IsMatch(ContentHtml, pattern, RegexOptions.IgnoreCase))
                    {
                        infoContent = Regex.Match(ContentHtml, pattern, RegexOptions.IgnoreCase).Value;
                        infotmp     = infoContent;
                        infoContent = infoContent.Replace("{#Content}", "").Replace("{/#Content}", "");
                        //查找分页标签
                        bool   isPage   = false;
                        string pattern1 = @"{ZL\.Page([\s\S])*?\/}";
                        if (Regex.IsMatch(ContentHtml, pattern1, RegexOptions.IgnoreCase))
                        {
                            pagelabel = Regex.Match(ContentHtml, pattern1, RegexOptions.IgnoreCase).Value;
                            isPage    = true;
                        }
                        if (isPage)
                        {
                            if (string.IsNullOrEmpty(infoContent))     //没有设定要分页的字段内容
                            {
                                ContentHtml = ContentHtml.Replace(pagelabel, "");
                            }
                            else       //进行内容分页处理
                            {
                                //文件名
                                string file1 = "Content.aspx?ID=" + ItemID.ToString();
                                //取分页标签处理结果 返回字符串数组 根据数组元素个数生成几页
                                string         ilbl       = pagelabel.Replace("{ZL.Page ", "").Replace("/}", "").Replace(" ", ",");
                                string         lblContent = "";
                                int            NumPerPage = 500;
                                IList <string> ContentArr = new List <string>();

                                if (string.IsNullOrEmpty(ilbl))
                                {
                                    lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}";     //默认格式的分页导航
                                    ContentArr = this.bll.GetContentPage(infoContent, NumPerPage);
                                }
                                else
                                {
                                    string[] paArr = ilbl.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                    if (paArr.Length == 0)
                                    {
                                        lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}";     //默认格式的分页导航
                                        ContentArr = this.bll.GetContentPage(infoContent, NumPerPage);
                                    }
                                    else
                                    {
                                        string lblname = paArr[0].Split(new char[] { '=' })[1].Replace("\"", "");
                                        if (paArr.Length > 1)
                                        {
                                            NumPerPage = DataConverter.CLng(paArr[1].Split(new char[] { '=' })[1].Replace("\"", ""));
                                        }
                                        B_Label blbl = new B_Label();
                                        lblContent = blbl.GetLabelXML(lblname).Content;
                                        if (string.IsNullOrEmpty(lblContent))
                                        {
                                            lblContent = "{loop}<a href=\"{$pageurl/}\">{$pageid/}</a>$$$<b>[{$pageid/}]</b>{/loop}";     //默认格式的分页导航
                                        }
                                        ContentArr = this.bll.GetContentPage(infoContent, NumPerPage);
                                    }
                                }
                                if (ContentArr.Count > 0)     //存在分页数据
                                {
                                    ContentHtml = ContentHtml.Replace(infotmp, ContentArr[Cpage - 1]);
                                    ContentHtml = ContentHtml.Replace(pagelabel, this.bll.GetPage(lblContent, ItemID, Cpage, ContentArr.Count, NumPerPage));
                                }
                                else
                                {
                                    ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                                    ContentHtml = ContentHtml.Replace(pagelabel, "");
                                }
                            }
                        }
                        else    //没有分页标签
                        {
                            //如果设定了分页内容字段 将该字段内容的分页标志清除
                            if (!string.IsNullOrEmpty(infoContent))
                            {
                                ContentHtml = ContentHtml.Replace(infotmp, infoContent);
                            }
                        }
                    }
                }

                string patterns   = @"{ZL\.Page([\s\S])*?\/}";
                string pagelabels = Regex.Match(ContentHtml, patterns, RegexOptions.IgnoreCase).Value;
                if (pagelabels != "")
                {
                    ContentHtml = ContentHtml.Replace(pagelabels, "");
                }
                if (nodeinfo.SafeGuard == 1 && File.Exists(Server.MapPath("/JS/Guard.js")))
                {
                    ContentHtml = ContentHtml + SafeSC.ReadFileStr("/JS/Guard.js");
                }
                if (SiteConfig.SiteOption.IsSensitivity == 1)
                {
                    ContentHtml = sell.ProcessSen(ContentHtml);
                }
                Response.Write(ContentHtml);
            }
        }