Exemplo n.º 1
0
        /// <summary>
        /// 生成帮助中心
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public static bool Greate_Help(Lebi_Theme_Page page)
        {
            string               url;
            Site                 site    = new Site();
            Lebi_Node            pnode   = NodePage.GetNodeByCode("Help");
            List <Lebi_Language> langs   = Language.AllLanguages();
            string               urlpath = "http://" + HttpContext.Current.Request.Url.Authority + site.WebPath;

            foreach (Lebi_Language lang in langs)
            {
                string           path  = lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
                string           file  = "";
                List <Lebi_Node> nodes = B_Lebi_Node.GetList("parentid=" + pnode.id + " and Language_Code like '%" + lang.Code + "%'", "");
                foreach (Lebi_Node node in nodes)
                {
                    url  = page.PageName + "?" + page.PageParameter;
                    url  = url.Replace("{0}", node.id.ToString());
                    url  = urlpath + "/" + url;
                    file = path.Replace("{0}", node.id.ToString());
                    file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                    url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                    url  = ThemeUrl.CheckURL(url);
                    HtmlEngine.Instance.CreatHtml(url, file);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 商品页面
        /// </summary>
        /// <param name="lang"></param>
        /// <param name="model"></param>
        /// <param name="theme"></param>
        /// <param name="urlpath"></param>
        private void P_Product(List <Lebi_Language> langs, Lebi_Theme_Page page, string urlpath)
        {
            string   url;
            string   ids   = RequestTool.RequestString("Pro_Type_id");
            DateTime time1 = RequestTool.RequestTime("time1");
            DateTime time2 = RequestTool.RequestTime("time2");

            string file      = "";
            int    pageindex = RequestTool.RequestInt("pageindex", 0);
            int    pagesize  = RequestTool.RequestInt("pagesize", 0);

            string where = "Time_Add>='" + time1 + "' and Time_Add<='" + time2 + "'";
            if (ids != "")
            {
                where += " and Pro_Type_id in (lbsql{" + ids + "})";
            }
            List <Lebi_Product> models = B_Lebi_Product.GetList(where, "", pagesize, pageindex);
            int count     = B_Lebi_Product.Counts(where);
            int pagecount = Pager.GetPageCount(pagesize, count);
            int per       = 100;

            if (pagecount > 0)
            {
                per = Convert.ToInt32(pageindex * 100 / pagecount);
            }
            List <Lebi_Site> sites = GetSites();
            Lebi_Site        site;

            foreach (Lebi_Product model in models)
            {
                foreach (Lebi_Language lang in langs)
                {
                    site = GetSite(sites, lang.Site_id);
                    file = site.Path + "/" + lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
                    file = file.Replace("{0}", model.id.ToString());
                    file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                    file = ThemeUrl.CheckPath(file);

                    url = page.PageName + "?" + page.PageParameter;
                    url = url.Replace("{0}", model.id.ToString());
                    url = urlpath + "/" + site.Path + "/" + lang.Path + "/" + url;
                    url = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                    url = ThemeUrl.CheckURL(url);
                    try
                    {
                        HtmlEngine.Instance.CreatHtml(url, file);
                    }
                    catch (System.Net.WebException)
                    {
                        //Log.Add(url + "---------" + file);
                        continue;
                    }
                }
            }
            Response.Write("{\"msg\":\"OK\",\"per\":\"" + per + "\"}");
        }
Exemplo n.º 3
0
        /// <summary>
        /// 文章查看页面
        /// </summary>
        /// <param name="lang"></param>
        /// <param name="model"></param>
        /// <param name="theme"></param>
        /// <param name="urlpath"></param>
        private void P_ArticleDetails(List <Lebi_Language> langs, Lebi_Theme_Page model, string urlpath)
        {
            string   url;
            string   file    = "";
            DateTime time1   = RequestTool.RequestTime("time1");
            DateTime time2   = RequestTool.RequestTime("time2");
            string   nodeids = RequestTool.RequestString("node");

            if (nodeids == null)
            {
                return;
            }
            int pageindex = RequestTool.RequestInt("pageindex", 0);
            int pagesize  = RequestTool.RequestInt("pagesize", 0);

            string where = "Time_Add>='" + time1 + "' and Time_Add<='" + time2 + "'";
            if (nodeids != "")
            {
                where += " and Node_id in (" + nodeids + ") ";
            }
            List <Lebi_Page> pages = B_Lebi_Page.GetList(where, "", pagesize, pageindex);
            int count     = B_Lebi_Page.Counts(where);
            int pagecount = Pager.GetPageCount(pagesize, count);
            int per       = 100;

            if (pagecount > 0)
            {
                per = Convert.ToInt32(pageindex * 100 / pagecount);
            }
            List <Lebi_Site> sites = GetSites();
            Lebi_Site        site;

            foreach (Lebi_Page page in pages)
            {
                foreach (Lebi_Language lang in langs)
                {
                    if (page.Language.ToLower().Contains(lang.Code.ToLower()))
                    {
                        site = GetSite(sites, lang.Site_id);
                        file = site.Path + "/" + lang.Path + "/" + model.StaticPath + "/" + model.StaticPageName;
                        file = file.Replace("{0}", page.id.ToString());
                        file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                        file = ThemeUrl.CheckPath(file);

                        url = model.PageName + "?" + model.PageParameter;
                        url = url.Replace("{0}", page.id.ToString());
                        url = urlpath + "/" + site.Path + "/" + lang.Path + "/" + url;
                        url = ThemeUrl.CheckURL(url);
                        HtmlEngine.Instance.CreatHtml(url, file);
                    }
                }
            }
            Response.Write("{\"msg\":\"OK\",\"per\":\"" + per + "\"}");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 帮助中心页面
        /// </summary>
        /// <param name="lang"></param>
        /// <param name="model"></param>
        /// <param name="theme"></param>
        /// <param name="urlpath"></param>
        private void P_Help(List <Lebi_Language> langs, Lebi_Theme_Page model, string urlpath)
        {
            string    url;
            Lebi_Node pnode     = NodePage.GetNodeByCode("Help");
            string    file      = "";
            int       pageindex = RequestTool.RequestInt("pageindex", 0);
            int       pagesize  = RequestTool.RequestInt("pagesize", 0);

            string where = "parentid=" + pnode.id + "";
            List <Lebi_Node> nodes = B_Lebi_Node.GetList(where, "", pagesize, pageindex);
            int count     = B_Lebi_Node.Counts(where);
            int pagecount = Pager.GetPageCount(pagesize, count);
            int per       = 100;

            if (pagecount > 0)
            {
                per = Convert.ToInt32(pageindex * 100 / pagecount);
            }
            List <Lebi_Site> sites = GetSites();
            Lebi_Site        site;

            foreach (Lebi_Node node in nodes)
            {
                foreach (Lebi_Language lang in langs)
                {
                    if (node.Language.ToLower().Contains(lang.Code.ToLower()))
                    {
                        site = GetSite(sites, lang.Site_id);
                        file = site.Path + "/" + lang.Path + "/" + model.StaticPath + "/" + model.StaticPageName;
                        file = file.Replace("{0}", node.id.ToString());
                        file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                        file = ThemeUrl.CheckPath(file);

                        url = model.PageName + "?" + model.PageParameter;
                        url = url.Replace("{0}", node.id.ToString());
                        url = urlpath + "/" + site.Path + "/" + lang.Path + "/" + url;
                        url = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                        url = ThemeUrl.CheckURL(url);
                        HtmlEngine.Instance.CreatHtml(url, file);
                    }
                }
            }
            Response.Write("{\"msg\":\"OK\",\"per\":\"" + per + "\"}");
        }
Exemplo n.º 5
0
        /// <summary>
        /// 品牌页面
        /// </summary>
        /// <param name="lang"></param>
        /// <param name="model"></param>
        /// <param name="theme"></param>
        /// <param name="urlpath"></param>
        private void P_Brand(Lebi_Language lang, Lebi_Theme_Page page, Lebi_Theme theme, string urlpath)
        {
            string            url;
            string            path   = lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
            string            file   = "";
            List <Lebi_Brand> models = B_Lebi_Brand.GetList("", "");

            foreach (Lebi_Brand model in models)
            {
                url  = page.PageName + "?" + page.PageParameter;
                url  = url.Replace("{0}", model.id.ToString());
                url  = urlpath + "/" + url;
                file = path.Replace("{0}", model.id.ToString());
                file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                url  = ThemeUrl.CheckURL(url);
                HtmlEngine.Instance.CreatHtml(url, file);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 商品分类查询页面的规格筛选参数
        /// sel 格式为
        /// 面料id_子id,颜色id——子id  如 14_0,47_22
        /// </summary>
        /// <param name="pro"></param>
        /// <param name="sel"></param>
        /// <returns></returns>
        public string Categoryhref(int pid, int id, string sel)
        {
            if (sel == "")
            {
                return(pid + "_" + id);
            }

            string reg   = @"" + pid + "_[\\d]*";
            int    count = RegexTool.GetRegCount(sel, reg);

            if (count > 0)
            {
                sel = RegexTool.ReplaceRegValue(sel, reg, pid + "_" + id);
            }
            if (count == 0)
            {
                sel += "," + pid + "_" + id;
            }
            return(sel);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 商品分类页面
        /// </summary>
        public static bool Greate_OnePage(Lebi_Theme_Page page)
        {
            Site site = new Site();
            //Lebi_Theme_Page page = B_Lebi_Theme_Page.GetModel("Code='P_AllProductCategories'");
            string urlpath = "http://" + HttpContext.Current.Request.Url.Authority + site.WebPath;
            string url     = "";
            string file    = "";

            foreach (Lebi_Language lang in Language.AllLanguages())
            {
                string path = lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
                url  = page.PageName + "?" + page.PageParameter;
                url  = urlpath + "/" + url;
                file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                url  = ThemeUrl.CheckURL(url);
                HtmlEngine.Instance.CreatHtml(url, file);
            }
            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 商品分类查询页面的规格筛选参数
        /// sel 格式为
        /// 面料id_子id,颜色id——子id  如 14|0$47|22
        /// </summary>
        /// <param name="pro"></param>
        /// <param name="sel"></param>
        /// <returns></returns>
        public string Categoryhref(int pid, int id, string sel)
        {
            if (sel == "")
            {
                return(pid + "|" + id);
            }

            string reg   = pid + @"\|[\d]*";
            int    count = RegexTool.GetRegCount(sel, reg);

            if (count > 0)
            {
                sel = RegexTool.ReplaceRegValue(sel, reg, pid + "|" + id);
            }
            else
            {
                sel += "$" + pid + "|" + id;
            }
            return(sel);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 单个页面
        /// </summary>
        /// <param name="lang"></param>
        private void OnePage(List <Lebi_Language> langs, Lebi_Theme_Page model, string urlpath)
        {
            string           url   = "";
            string           file  = "";
            List <Lebi_Site> sites = GetSites();
            Lebi_Site        site;

            foreach (Lebi_Language lang in langs)
            {
                site = GetSite(sites, lang.Site_id);

                file = site.Path + "/" + lang.Path + "/" + model.StaticPath + "/" + model.StaticPageName;
                file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                file = ThemeUrl.CheckPath(file);
                url  = urlpath + "/" + site.Path + "/" + lang.Path + "/" + model.PageName;
                url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                url  = ThemeUrl.CheckURL(url);
                HtmlEngine.Instance.CreatHtml(url, file);
            }
            Response.Write("{\"msg\":\"OK\",\"per\":\"100\"}");
        }
Exemplo n.º 10
0
 public SQLPara(string where, string order, string field)
 {
     //解析where串
     //where = "Name like lbsql{'%" + k + "%'}";
     //where = "id in in_lbsql{'%" + k + "%'}";
     _ht         = new Hashtable();
     _showField  = field;
     _orderField = order;
     _where      = where;
     //处理in 查询
     string[] inArry = RegexTool.GetSimpleRegResultArray(_where, "[Ii][Nn] \\([Ll][Bb][Ss][Qq][Ll]\\{(.*?)\\}\\)");
     for (int i = 0; i < inArry.Length; i++)
     {
         string val = inArry[i];
         val = val.Replace("'", "");
         string   cols = "";
         string[] vals = inArry[i].Split(',');
         for (int j = 0; j < vals.Length; j++)
         {
             string col = "inpara" + i + j;
             cols = cols + "@" + col + ",";
             _ht.Add(col, vals[j]);
         }
         _where = RegexTool.ReplaceRegValue(_where, "[Ii][Nn] \\([Ll][Bb][Ss][Qq][Ll]\\{" + inArry[i] + "\\}\\)", "in (" + cols.TrimEnd(',') + ")", 1);
     }
     //处理一般查询
     string[] Arry = RegexTool.GetSimpleRegResultArray(_where, "[Ll][Bb][Ss][Qq][Ll]\\{(.*?)\\}");
     for (int i = 0; i < Arry.Length; i++)
     {
         string val = Arry[i];
         string col = "para" + i;
         val    = val.Replace("'", "");
         _where = RegexTool.ReplaceRegValue(_where, "[Ll][Bb][Ss][Qq][Ll]\\{" + Arry[i] + "\\}", "@" + col, 1);
         _ht.Add(col, val);
     }
     CreateSqlPara();
 }
Exemplo n.º 11
0
        /// <summary>
        /// 关于我们页面/新闻/文章
        /// </summary>
        public static bool Greate_InfoPage(Lebi_Page model, Lebi_Theme_Page page)
        {
            Site site = new Site();

            string[] langcodes = model.Language.Split(',');
            string   urlpath   = "http://" + HttpContext.Current.Request.Url.Authority + site.WebPath;
            string   url       = "";
            string   file      = "";

            foreach (string langcode in langcodes)
            {
                Lebi_Language lang = B_Lebi_Language.GetModel("Code='" + langcode + "'");
                string        path = lang.Path + "/" + page.StaticPath + "/" + page.StaticPageName;
                url  = page.PageName + "?" + page.PageParameter;
                url  = url.Replace("{0}", model.id.ToString());
                url  = urlpath + "/" + url;
                file = path.Replace("{0}", model.id.ToString());
                file = RegexTool.ReplaceRegValue(file, @"{.*?}", "");
                url  = RegexTool.ReplaceRegValue(url, @"{.*?}", "");
                url  = ThemeUrl.CheckURL(url);
                HtmlEngine.Instance.CreatHtml(url, file);
            }
            return(true);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 处理一个标记块
        /// </summary>
        /// <param name="StrIn"></param>
        /// <returns></returns>
        private static string DoPart(string StrIn, string type, string webpath)
        {
            string str = StrIn;

            //============================================================================
            str = DoCodeConvert(str, type, webpath, "");//递归调用
            //============================================================================
            string str_Head = "";
            string str_Foot = "";
            string str_B    = "";    //循环第一次的字符串
            string str_E    = "";    //循环最后一次的字符串
            bool   BEFlag   = false; //开始结尾特殊处理标志
            string temp     = "";
            string Table    = "";
            string Order    = "";
            string Where    = "";
            string PageSize = "";
            string page     = "";
            string model    = "";       //MODEL名字
            string Source   = "";
            string Top      = "";
            string Tag      = "";

            //============================================================================
            //参数处理
            //------------------------------
            temp = str.Replace("\r\n", "");
            //string key_ = "";
            //string key = "";
            //------------------------------

            //SQL = GetRegValue(temp, @"\$SQL:(.*?)[\n|\$]");      //这是SQL语句读取数据的方式,由于当前分页方式、分页存储过程的限制,不能实现

            Table  = RegexTool.GetRegValue(temp, @"#[tT][aA][bB][lL][eE][:=](.*?)[#;]").Trim();   //参数结尾标记兼容 '换行'(\n) 和 '#',分号,空格
            model  = RegexTool.GetRegValue(temp, @"#[mM][oO][dD][eE][lL][:=](.*?)[#;]").Trim();
            Source = RegexTool.GetRegValue(temp, @"#[Ss][Oo][Uu][Rr][Cc][Ee][:=](.*?)[#;]").Trim();
            model  = RegexTool.GetRegValue(temp, @"#[mM][oO][dD][eE][lL][:=](.*?)[#;]").Trim();
            Tag    = RegexTool.GetRegValue(temp, @"#[Tt][Aa][Gg][:=](.*?)[#;]").Trim().ToLower();


            Order    = RegexTool.GetRegValue(temp, @"#[oO][rR][dD][eE][rR][:=](.*?)[#;]").Trim();
            Where    = RegexTool.GetRegValue(temp, @"#[wW][hH][eE][rR][eE][:=](.*?)[#;]").Trim();
            PageSize = RegexTool.GetRegValue(temp, @"#[pP][aA][gG][eE][sS][iI][zZ][eE][:=](.*?)[#;]").Trim();
            page     = RegexTool.GetRegValue(temp, @"#[pP][aA][gG][eE][iI][nN][dD][eE][xX][:=](.*?)[#;]").Trim();
            Top      = RegexTool.GetRegValue(temp, @"#[Tt][Oo][Pp][:=](.*?)[#;]").Trim();

            if (Top != "")
            {
                PageSize = Top;
                page     = "1";
            }
            //-------------------------------
            //过滤换行
            Table    = RegexTool.ReplaceRegValue(Table, @"\r\n");
            Order    = RegexTool.ReplaceRegValue(Order, @"\r\n");
            Where    = RegexTool.ReplaceRegValue(Where, @"\r\n");
            PageSize = RegexTool.ReplaceRegValue(PageSize, @"\r\n");
            page     = RegexTool.ReplaceRegValue(page, @"\r\n");
            model    = RegexTool.ReplaceRegValue(model, @"\r\n");
            Source   = RegexTool.ReplaceRegValue(Source, @"\r\n");
            //-------------------------------
            //-------------------------------
            //过滤多个空格
            Regex r = new Regex(@" +", RegexOptions.Singleline);//目的:防止类似“///”“////”“//////”的情况

            Table    = r.Replace(Table, " ");
            Order    = r.Replace(Order, " ");
            Where    = r.Replace(Where, " ");
            PageSize = r.Replace(PageSize, " ");
            page     = r.Replace(page, " ");
            model    = r.Replace(model, " ");
            //-------------------------------

            if (model == "" || model == "$")
            {
                model = GetRnd(4, false, true, true, false, ""); //取8个字母的随机字符串作为MODEL名字
            }
            string RowsIndex = model + "_index";                 //行号的索引

            //============================================================================

            str_B = RegexTool.GetRegValue(str, @"[Bb]{(.*?)}[Bb]");
            str_E = RegexTool.GetRegValue(str, @"[Ee]{(.*?)}[Ee]");
            //============================================================================
            //过滤掉参数部分
            //str = ReplaceRegValue(str, @"#.*?[\n#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[tT][aA][bB][lL][eE][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[oO][rR][dD][eE][rR][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[wW][hH][eE][rR][eE][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[pP][aA][gG][eE][sS][iI][zZ][eE][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[pP][aA][gG][eE][iI][nN][dD][eE][xX][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[mM][oO][dD][eE][lL][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[Ss][Oo][Uu][Rr][Cc][Ee][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[tT][Oo][Pp][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"#[tT][Aa][Gg][:=](.*?)[#;]");
            str = RegexTool.ReplaceRegValue(str, @"[Bb]{.*?}[Bb]");
            str = RegexTool.ReplaceRegValue(str, @"[Ee]{.*?}[Ee]");

            //============================================================================


            //自定义格式
            //===================================================================================
            str_Head += "<%";
            if (Table != "$")
            {
                str_Head += "Table=\"" + Table + "\";";
            }
            if (Where != "$")
            {
                str_Head += "Where=\"" + Where + "\";";
            }
            if (Order != "" && Order != "$")
            {
                str_Head += "Order=\"" + Order + "\";";
            }

            if (PageSize == "")
            {
                str_Head += "PageSize=20;";
            }
            else if (PageSize == "$")
            {
            }
            else
            {
                str_Head += "PageSize=" + PageSize + ";";
            }
            if (page == "")
            {
                str_Head += "pageindex=Rint(\"page\");";
            }
            else if (PageSize == "$")
            {
            }
            else
            {
                str_Head += "pageindex=" + page + ";";
            }
            str_Head += "RecordCount=B_" + Table + ".Counts(Where);";
            //str_Head += temp;

            str_Head += "int " + RowsIndex + "=1;\r\n";//循环的行号
            str_Head += "List<" + Table + "> " + model + "s = B_" + Table + ".GetList(Where, Order,PageSize ,pageindex);";
            str_Head += "foreach (" + Table + " " + model + " in " + model + "s)";
            str_Head += "{";
            str_Head += "%>";

            str_Foot += "<%";
            str_Foot += RowsIndex + "++;";
            str_Foot += "}";
            str_Foot += "%>";

            if (str_B != "" || str_E != "")
            {
                BEFlag = true;
            }
            //============================================================================
            if (BEFlag)
            {
                temp = "";
                if (str_B != "")
                {
                    temp += "<%if(" + RowsIndex + "==1)";
                    temp += "{%>";
                    temp += ReplaceModel(str_B, model);
                    temp += "<%}%>";
                    if (str_E != "")
                    {
                        temp += "<%else if(" + RowsIndex + "==RecordCount || " + RowsIndex + "==PageSize)";
                        temp += "{%>";
                        temp += ReplaceModel(str_E, model);
                        temp += "<%}%>";
                    }
                    temp += "<%else";
                    temp += "{%>";
                    temp += ReplaceModel(str, model);
                    temp += "<%}%>";
                }
                else//没有开始匹配的时候
                {
                    temp += "<%if(" + RowsIndex + "==RecordCount || " + RowsIndex + "==PageSize)";
                    temp += "{%>";
                    temp += ReplaceModel(str_E, model);
                    temp += "<%}%>";
                    temp += "<%else";
                    temp += "{%>";
                    temp += ReplaceModel(str, model);
                    temp += "<%}%>";
                }
                str = temp;
            }
            else
            {
                str = ReplaceModel(str, model);
            }
            //============================================================================
            str = str_Head + str + str_Foot;
            return(str);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 生成地址重写规则
        /// </summary>
        public static void CreateURLRewrite()
        {
            StringBuilder sb  = new StringBuilder();
            StringBuilder sb1 = new StringBuilder();

            sb.AppendLine("[ISAPI_Rewrite]");
            sb1.AppendLine("RewriteEngine On");
            sb1.AppendLine("RewriteCompatibility2 On");
            sb1.AppendLine("RepeatLimit 200");
            sb1.AppendLine("RewriteBase");

            List <Lebi_Language>   langs  = B_Lebi_Language.GetList("", "Sort desc,id asc");
            List <Lebi_Theme_Page> models = B_Lebi_Theme_Page.GetList("Type_id_PublishType=123", "");
            string str1     = "";
            string str2     = "";
            string language = "";

            foreach (Lebi_Theme_Page model in models)
            {
                if (model.PageParameter == "")
                {
                    str1 = model.PageName;
                    str2 = model.StaticPath + "/" + model.StaticPageName;
                    str2 = ThemeUrl.CheckURL(str2);
                    str1 = str1.Trim('/');
                    str2 = str2.Trim('/');
                    str1 = str1.Replace(".", @"\.");
                    str2 = str2.Replace(".", @"\.");
                    foreach (Lebi_Language lang in langs)
                    {
                        Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id);
                        if (site == null)
                        {
                            site = new Lebi_Site();
                        }
                        language = site.Path + lang.Path.TrimEnd('/');
                        language = language.Replace("//", "/");
                        if (language == "")
                        {
                            continue;
                        }
                        sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str1 + " [N,I]");
                        sb1.AppendLine(@"RewriteRule " + language + "/" + str2 + "(.*)$ " + language + "/" + str1 + " [NC,N]");
                    }
                    sb.AppendLine(@"RewriteRule /(.*)" + str2 + "(.*) /$1" + str1 + " [N,I]");
                    sb1.AppendLine(@"RewriteRule /" + str2 + "(.*)$ /" + str1 + " [NC,N]");
                    //RewriteRule /CN/(.*)$ /CN/Basket\.aspx\?Basket\.html$1 [NC,N]
                    //RewriteRule /(.*)$ /Basket\.aspx\?Basket\.html$1 [NC,N]
                }
                else
                {
                    str1 = model.PageName + @"\?" + model.PageParameter;
                    str2 = model.StaticPath + "/" + model.StaticPageName;
                    str2 = ThemeUrl.CheckURL(str2);
                    str1 = str1.Trim('/');
                    str2 = str2.Trim('/');
                    str1 = str1.Replace(".", @"\.");
                    str2 = str2.Replace(".", @"\.");
                    str1 = RegexTool.ReplaceRegValue(str1, @"{\d+}", ",");
                    str2 = RegexTool.ReplaceRegValue(str2, @"{\d+}", "(.*)");
                    string[] arr     = str1.Split(',');
                    int      j       = 1;
                    string   str_ini = "";
                    string   str_hta = "";
                    foreach (string ar in arr)
                    {
                        if (ar != "")
                        {
                            str_hta += ar + "$" + j;
                        }
                        j++;
                        if (ar != "")
                        {
                            str_ini += ar + "$" + j;
                        }
                    }
                    foreach (Lebi_Language lang in langs)
                    {
                        Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id);
                        if (site == null)
                        {
                            site = new Lebi_Site();
                        }
                        language = site.Path + lang.Path.TrimEnd('/');
                        language = language.Replace("//", "/");
                        if (language == "")
                        {
                            continue;
                        }
                        sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str_ini + " [N,I]");
                        sb1.AppendLine(@"RewriteRule " + language + "/" + str2 + "(.*)$ " + language + "/" + str_hta + " [NC,N]");
                    }
                    sb.AppendLine(@"RewriteRule /(.*)" + str2 + "(.*) /$1" + str_ini + " [N,I]");
                    sb1.AppendLine(@"RewriteRule /" + str2 + "(.*)$ /" + str_hta + " [NC,N]");
                }
            }
            //生成商品分类重写规则
            List <Lebi_Pro_Type> tps   = B_Lebi_Pro_Type.GetList("", "");
            Lebi_Theme_Page      tpage = B_Lebi_Theme_Page.GetModel("Code='P_ProductCategory'");

            str1 = tpage.PageName + @"\?" + tpage.PageParameter;
            str1 = str1.Trim('/');
            str1 = str1.Replace(".", @"\.");
            str1 = RegexTool.ReplaceRegValue(str1, @"{\d+}", ",");
            string[] arr1     = str1.Split(',');
            string   str_ini1 = "";
            string   str_hta1 = "";

            //foreach (string ar in arr1)
            //{
            //    if (ar != "")
            //        str_hta1 += ar + "$" + j1;
            //    j1++;
            //    if (ar != "")
            //        str_ini1 += ar + "$" + j1;

            //}

            foreach (Lebi_Pro_Type tp in tps)
            {
                str_hta1 = arr1[0] + tp.id;
                str_ini1 = arr1[0] + tp.id;
                foreach (Lebi_Language lang in langs)
                {
                    if (Language.Content(tp.IsUrlrewrite, lang.Code) != "1")
                    {
                        continue;
                    }
                    str2 = Language.Content(tp.Url, lang.Code);
                    if (str2 == "")
                    {
                        continue;
                    }



                    str2 = ThemeUrl.CheckURL(str2);
                    str2 = str2.Trim('/');
                    str2 = str2.Replace(".", @"\.");
                    str2 = RegexTool.ReplaceRegValue(str2, @"{\d+}", "(.*)");


                    Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id);
                    if (site == null)
                    {
                        site = new Lebi_Site();
                    }
                    language = site.Path + lang.Path.TrimEnd('/');
                    language = language.Replace("//", "/");
                    language = language.TrimEnd('/');
                    sb.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*) /$1" + language + "/" + str_ini1 + " [N,I]");
                    sb1.AppendLine(@"RewriteRule /(.*)" + language + "/" + str2 + "(.*)$ /$1" + language + "/" + str_hta1 + " [NC,N]");
                }
            }
            HtmlEngine save = new HtmlEngine();

            save.CreateFile("httpd.ini", sb.ToString(), "ascii");
            save.CreateFile(".htaccess", sb1.ToString(), "ascii");
            CreateURLRewrite_shop();
        }
Exemplo n.º 14
0
        public static string ConvertURL(string ParaStr, string FormatStr, int t, string PageName, string PageParameter)
        {
            ParaStr = ParaStr.Replace("{0}", "[pageindex]");
            string[] arr      = ParaStr.Split(',');
            int      arrcount = arr.Length;
            string   res      = "";

            if (t == 121)//动态地址
            {
                if (PageParameter != "")
                {
                    string[] parr = PageParameter.Split('&');
                    for (int i = 0; i < arrcount; i++)
                    {
                        if (i >= parr.Length)
                        {
                            break;
                        }
                        if (arr[i] != "$" && arr[i] != "")
                        {
                            if (res == "")
                            {
                                res = parr[i].Replace("{" + i + "}", arr[i]);
                            }
                            else
                            {
                                res += "&" + parr[i].Replace("{" + i + "}", arr[i]);
                            }
                        }
                    }
                    if (res == "")
                    {
                        res = PageName;
                    }
                    else
                    {
                        res = PageName + "?" + res;
                    }
                }
                else
                {
                    res = FormatStr;
                }
            }
            else
            {
                res = FormatStr;
                if (arrcount > 0)
                {
                    for (int i = 0; i < arrcount; i++)
                    {
                        if (arr[i] == "$")
                        {
                            arr[i] = "";
                        }
                        res = res.Replace("{" + i + "}", arr[i]);
                    }
                }
                res = RegexTool.ReplaceRegValue(res, @"{\d*}", "");
            }
            res = res.Replace("[pageindex]", "{0}");
            return(res);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 生成后台的单个文件
        /// </summary>
        /// <param name="Path">生成文件名已经路径</param>
        /// <param name="Content"></param>
        /// <param name="WebPath"></param>
        /// <returns></returns>
        public static void CreatAdminAspx(string Path, string Content, string type, string mediapath)
        {
            if (Content == "")
            {
                return;
            }
            string     FileName   = "";
            BaseConfig bf         = ShopCache.GetBaseConfig();
            string     WebPath    = Site.Instance.WebPath;
            string     serverpath = "";

            if (System.Web.HttpContext.Current == null)
            {
                serverpath = System.Web.HttpRuntime.AppDomainAppPath;
            }
            else
            {
                serverpath = System.Web.HttpContext.Current.Server.MapPath(@"~/");
            }
            try
            {
                Path     = ThemeUrl.GetFullPath(Path);
                FileName = ThemeUrl.GetFileName(Path);
                Path     = ThemeUrl.GetPath(Path);
                string PhysicsPath = serverpath + Path;
                if (!Directory.Exists(PhysicsPath))
                {
                    Directory.CreateDirectory(PhysicsPath);
                }
                string PhysicsFileName = serverpath + Path + FileName;
                if (System.IO.File.Exists(PhysicsFileName))
                {
                    System.IO.File.Delete(PhysicsFileName);
                }
                Content = DoCodeConvert(Content, type, WebPath, mediapath);
                //=============================================================
                //处理特殊页面引用

                string cs = RegexTool.GetRegValue(Content, @"{[Cc][Ll][Aa][Ss][Ss]:(.*?)}");
                if (cs != "")
                {
                    string pagehead = "<%@ Page Language=\"C#\" AutoEventWireup=\"true\" Inherits=\"" + cs + "\" validateRequest=\"false\"%>";
                    Content = RegexTool.ReplaceRegValue(Content, @"<%@ Page .*? %>", "");
                    Content = pagehead + Content;
                    //if (type == "supplier")
                    //    Content = Content.Replace("Shop.Bussiness.SupplierPageBase", cs);
                    //else
                    //    Content = Content.Replace("Shop.Bussiness.AdminPageBase", cs);
                }
                //处理资源路径
                string Path_JS    = WebPath + "/system/systempage/" + type + "/js";
                string Path_Image = WebPath + "/system/systempage/" + type + "/images";
                string Path_CSS   = WebPath + "/system/systempage/" + type + "/css";
                Path_JS    = RegexTool.ReplaceRegValue(Path_JS, @"//*/", "/");
                Path_Image = RegexTool.ReplaceRegValue(Path_Image, @"//*/", "/");
                Path_CSS   = RegexTool.ReplaceRegValue(Path_CSS, @"//*/", "/");
                Content    = RegexTool.ReplaceRegValue(Content, @"{/[Jj][Ss]}", Path_JS);
                Content    = RegexTool.ReplaceRegValue(Content, @"{/[Cc][Ss][Ss]}", Path_CSS);
                Content    = RegexTool.ReplaceRegValue(Content, @"{/[Ii][Mm][Aa][Gg][eE]}", Path_Image);
                Content    = RegexTool.ReplaceRegValue(Content, @"<!--.*?-->", "");
                Content    = RegexTool.ReplaceRegValue(Content, @"{[Cc][Ll][Aa][Ss][Ss]:.*?}", "");

                HtmlEngine.Instance.WriteFile(PhysicsFileName, Content);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 载入布局文件
        /// </summary>
        /// <param name="strIn"></param>
        /// <param name="theme"></param>
        /// <returns></returns>
        public static string DoLayout(string strIn, string type, string webpath, string mediapath)
        {
            string layout = RegexTool.GetRegValue(strIn, @"{[Ll][Aa][Yy][Oo][Uu][Tt]:(.*?)}");
            string cs     = RegexTool.GetRegValue(strIn, @"({[Cc][Ll][Aa][Ss][Ss]:.*?})");

            if (layout == "")
            {
                return(cs + strIn);
            }

            string layoutpath    = "";
            string layoutContent = "";

            if (mediapath != "")
            {
                layoutpath    = webpath + mediapath + "/layout/" + layout + ".layout";
                layoutpath    = ThemeUrl.GetFullPath(layoutpath);
                layoutContent = HtmlEngine.ReadTxt(layoutpath);
            }
            if (layoutContent == "")
            {
                layoutpath    = webpath + "/theme/system/systempage/" + type + "/layout/" + layout + ".layout";
                layoutpath    = ThemeUrl.GetFullPath(layoutpath);
                layoutContent = HtmlEngine.ReadTxt(layoutpath);
            }
            if (layoutContent == "")
            {
                layoutpath    = webpath + "/theme/system/layout/" + layout + ".layout";
                layoutpath    = ThemeUrl.GetFullPath(layoutpath);
                layoutContent = HtmlEngine.ReadTxt(layoutpath);
            }
            if (layoutContent == "")
            {
                return("");
            }
            string[] holderArray = RegexTool.GetSimpleRegResultArray(layoutContent, @"({[Hh][Oo][Ll][Dd][Ee][Rr]:.*?})");
            foreach (string holder in holderArray)
            {
                string tag    = RegexTool.GetRegValue(holder, @"{[Hh][Oo][Ll][Dd][Ee][Rr]:(.*?)}");
                string regtag = "";
                foreach (char t in tag)
                {
                    regtag += "[" + t.ToString().ToUpper() + t.ToString().ToLower() + "]";
                }
                string holdercontent = RegexTool.GetRegValue(strIn, @"<" + regtag + ">(.*?)</" + regtag + ">");
                layoutContent = RegexTool.ReplaceRegValue(layoutContent, @"{[Hh][Oo][Ll][Dd][Ee][Rr]:" + tag + ".*?}", holdercontent);
            }
            //载入重写模块
            string[] rewriteArray = RegexTool.GetSimpleRegResultArray(strIn, @"({[Rr][Ee][Ww][Rr][Ii][Tt][Ee]:.*?})");
            foreach (string rewrite in rewriteArray)
            {
                string tag  = RegexTool.GetRegValue(rewrite, @"{[Rr][Ee][Ww][Rr][Ii][Tt][Ee]:(.*?)}");
                string from = "";
                string to   = "";
                from = tag.Substring(0, tag.IndexOf(" "));
                to   = tag.Substring(tag.IndexOf(" ") + 1, tag.Length - from.Length - 1);
                string regfrom = "";
                string regto   = "";
                foreach (char t in from)
                {
                    regfrom += "[" + t.ToString().ToUpper() + t.ToString().ToLower() + "]";
                }
                foreach (char t in to)
                {
                    regto += "[" + t.ToString().ToUpper() + t.ToString().ToLower() + "]";
                }
                string holdercontent = RegexTool.GetRegValue(strIn, @"<" + regto + ">(.*?)</" + regto + ">");
                if (holdercontent == "")
                {
                    holdercontent = "{MOD:" + to + "}";
                }
                layoutContent = RegexTool.ReplaceRegValue(layoutContent, @"{[Mm][Oo][Dd]:" + regfrom + "}", holdercontent);
            }
            layoutContent = cs + layoutContent;
            return(layoutContent);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 执行代码替换
        /// 在${...}$内
        /// </summary>
        /// <param name="strIn"></param>
        /// <returns></returns>
        public static string DoCodeConvert(string strIn, string type, string webpath, string mediapath)
        {
            strIn = DoLayout(strIn, type, webpath, mediapath);
            //======================================================
            string[] PartArry   = RegexTool.GetSimpleRegResultArray(strIn, @"({[Mm][Oo][Dd]:.*?})");
            string   partTag    = "";
            string   partConten = "";
            string   partPara   = "";

            webpath = webpath.TrimEnd('/');
            Lebi_Theme_Skin partskin = new Lebi_Theme_Skin();

            foreach (string partStr in PartArry)
            {
                partTag    = "";
                partConten = "";
                partPara   = "";
                if (partStr.Contains("("))
                {
                    partTag  = RegexTool.GetRegValue(partStr, @"{[Mm][Oo][Dd]:(.*?)\(.*?}");
                    partPara = RegexTool.GetRegValue(partStr, @"{[Mm][Oo][Dd]:.*?\((.*?)\)}");
                }
                else
                {
                    partTag = RegexTool.GetRegValue(partStr, @"{[Mm][Oo][Dd]:(.*?)}");
                }
                if (partTag != "")
                {
                    //模块提取优先级
                    //1插件中的BLOCK文件夹
                    //2模板中的自定义设置
                    //3系统块

                    string[] plugins = ShopCache.GetBaseConfig().PluginUsed.ToLower().Split(',');
                    foreach (string plugin in plugins)
                    {
                        partConten = HtmlEngine.ReadTxt(webpath + "/plugin/" + plugin + "/systempage/" + type + "/block/" + partTag + ".html");
                        if (partConten == "")
                        {
                            partConten = HtmlEngine.ReadTxt(webpath + "/plugin/" + plugin + "/block/" + partTag + ".html");
                        }
                        if (partConten != "")
                        {
                            break;
                        }
                    }

                    if (partConten == "")
                    {
                        partConten = HtmlEngine.ReadTxt(ThemeUrl.GetFullPath(webpath + "/system/" + type + "/block/" + partTag + ".html"));
                    }
                    if (partConten == "")
                    {
                        partConten = HtmlEngine.ReadTxt(ThemeUrl.GetFullPath(webpath + "/system/block/" + partTag + ".html"));
                    }
                    if (partConten != "")
                    {
                        partConten = "<!--MOD_start:" + partTag + "-->\r\n" + DoCodeConvert(partConten, type, webpath, "") + "<!--MOD_end:" + partTag + "-->\r\n";
                        strIn      = RegexTool.ReplaceRegValue(strIn, @"{[Mm][Oo][Dd]:" + partTag + ".*?}", partConten);
                    }
                }
            }
            //=========================================================
            string str  = "";
            Type   t    = typeof(ShopPage);
            string temp = "";

            int[,] d = IndexFlagArry(strIn);//记录开始,结尾标记的数组
            if (d.Length > 0)
            {
                int begin = 0;
                string[,] tempArry = new string[d.GetUpperBound(0) + 1, 2];//用于存放一个外层标记的临时数组
                for (int i = 0; i < d.GetUpperBound(0); i++)
                {
                    temp          += RegexTool.GetSubString(strIn, begin, d[i, 0]) + "$$$" + i + "$$$";//挑选非标记部组合,将标记部分替换为$$$0$$$,$$$1$$$形式
                    begin          = d[i, 1] + 2;
                    tempArry[i, 0] = "$$$" + i + "$$$";
                    tempArry[i, 1] = RegexTool.GetSubString(strIn, d[i, 0] + 2, d[i, 1]);//截取不包含开始,结尾标记的块
                }
                temp += RegexTool.GetSubString(strIn, begin, strIn.Length);
                str   = temp;//str已经替除了全部的标记块

                for (int i = 0; i < tempArry.GetUpperBound(0); i++)
                {
                    temp = DoPart(tempArry[i, 1], type, webpath);
                    str  = str.Replace("$$$" + i + "$$$", temp);
                }
            }
            return(str);
        }