コード例 #1
0
ファイル: ThemeUrl.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 生成域名绑定规则
        /// </summary>
        public static void CreateURLRewrite_shop()
        {
            HtmlEngine    save = new HtmlEngine();
            StringBuilder sb   = new StringBuilder();
            StringBuilder sb1  = new StringBuilder();
            string        str  = HtmlEngine.ReadTxt("httpd.ini");
            string        str1 = HtmlEngine.ReadTxt(".htaccess");

            if (str == "")
            {
                sb.AppendLine("[ISAPI_Rewrite]");
            }
            else
            {
                sb.AppendLine(HtmlEngine.ReadTxt("httpd.ini"));
            }
            if (str1 == "")
            {
                sb1.AppendLine("RewriteEngine On");
                sb1.AppendLine("RewriteCompatibility2 On");
                sb1.AppendLine("RepeatLimit 200");
                sb1.AppendLine("RewriteBase");
            }
            else
            {
                sb1.AppendLine(HtmlEngine.ReadTxt(".htaccess"));
            }
            List <Lebi_Supplier> models = B_Lebi_Supplier.GetList("Domain!=''", "");

            if (models.Count == 0)
            {
                return;
            }
            //RewriteCond %{HTTP_HOST} ^www.shop0769.top$
            //RewriteRule ^(.*)$ http://www.shop0769.com/shop/?id=11
            Lebi_Site site = B_Lebi_Site.GetModel("1=1 order by Sort desc");

            if (site != null)
            {
                foreach (Lebi_Supplier model in models)
                {
                    //sb1.AppendLine(@"RewriteRule //" + model.Domain + "(.*)$ /shop/?id=" + model.id + " [NC,N]");
                    //sb.AppendLine(@"RewriteRule //" + model.Domain + "/(.*) /$1/shop/?id=" + model.id + " [N,I]");

                    sb.AppendLine(@"RewriteCond Host ^" + model.Domain + "$");
                    sb.AppendLine(@"RewriteRule (.*) " + ShopCache.GetBaseConfig().HTTPServer + "://" + site.Domain + "/shop/?id=" + model.id + "$ [N,I]");

                    sb1.AppendLine(@"RewriteCond  %{HTTP_HOST} ^" + model.Domain + "$");
                    sb1.AppendLine(@"RewriteRule ^(.*)$ " + ShopCache.GetBaseConfig().HTTPServer + "://" + site.Domain + "/shop/?id=" + model.id + " [NC,N]");
                }
            }
            save.CreateFile("httpd.ini", sb.ToString(), "ascii");
            save.CreateFile(".htaccess", sb1.ToString(), "ascii");
        }
コード例 #2
0
ファイル: Sitemap.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 保存Site文件
        /// </summary>
        /// <param name=”FilePath”>路径</param>
        public static void SaveSiteMap(string FilePath)
        {
            HtmlEngine save = new HtmlEngine();

            save.CreateFile(FilePath, GenerateSiteMapString());
            //System.IO.File.Write(FilePath, GenerateSiteMapString());//保存在指定目录下
        }
コード例 #3
0
ファイル: ajax_config.aspx.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 客服面板设置信息
        /// </summary>
        public void ServicePanel_Config()
        {
            if (!Power("supplier_servicepanel_list", "客服面板"))
            {
                AjaxNoPower();
                return;
            }
            Model.ServicePanel sp = new Model.ServicePanel();
            sp.X       = RequestTool.RequestSafeString("X");
            sp.Y       = RequestTool.RequestSafeString("Y");
            sp.Theme   = RequestTool.RequestSafeString("Theme");
            sp.Status  = RequestTool.RequestSafeString("Status");
            sp.IsFloat = RequestTool.RequestSafeString("IsFloat");
            sp.Style   = RequestTool.RequestSafeString("Style");
            string con = B_ServicePanel.ToJson(sp);
            //BaseConfig bconf = ShopCache.GetBaseConfig();
            Lebi_Supplier model = B_Lebi_Supplier.GetModel(CurrentSupplier.id);

            if (model == null)
            {
                Response.Write("{\"msg\":\"账号不存在\"}");
                return;
            }
            model.ServicePanel = con;
            B_Lebi_Supplier.Update(model);
            Log.Add("配置客服面板", "ServicePanel", CurrentSupplier.id.ToString(), CurrentSupplier, "");
            string temp = "";

            temp += "var ShopstartX = document.body.clientWidth-" + RequestTool.RequestSafeString("X") + ";\n";
            if (RequestTool.RequestSafeString("IsFloat") == "1" && RequestTool.RequestSafeString("Style") == "1")
            {
                temp += "var ShopstartY = " + RequestTool.RequestSafeString("Y") + ";\n";
            }
            else if (RequestTool.RequestSafeString("IsFloat") == "0" && RequestTool.RequestSafeString("Style") == "1")
            {
                temp += "var ShopstartY = " + RequestTool.RequestSafeString("Y") + ";\n";
            }
            if (RequestTool.RequestSafeString("IsFloat") == "1" && RequestTool.RequestSafeString("Style") == "1")
            {
                temp += "var verticalpos='fromtop';\n";
            }
            else if (RequestTool.RequestSafeString("IsFloat") == "0" && RequestTool.RequestSafeString("Style") == "1")
            {
                temp += "var verticalpos='frombottom';\n";
            }
            temp += "var winWidth = 0;\n";
            temp += "function iecompattest(){\n";
            temp += "   return (document.compatMode && document.compatMode!='BackCompat')? document.documentElement : document.body\n";
            temp += "}\n";

            temp += "function ShopServicePannelstaticbar(){\n";
            temp += "	if (window.innerWidth)\n";
            temp += "	winWidth = window.innerWidth;\n";
            temp += "	else if ((document.body) && (document.body.clientWidth))\n";
            temp += "	winWidth = document.body.clientWidth;\n";
            temp += "	if (document.documentElement && document.documentElement.clientWidth){winWidth = document.documentElement.clientWidth;}\n";
            temp += "	ShopstartX = winWidth-"+ RequestTool.RequestSafeString("X") + ";\n";
            temp += "	barheight=document.getElementById('divShopServicePannel').offsetHeight\n";
            temp += "	var ns = (navigator.appName.indexOf('Netscape') != -1) || window.opera;\n";
            temp += "	var d = document;\n";
            temp += "	function ml(id){\n";
            temp += "		var el=d.getElementById(id);\n";
            temp += "		el.style.visibility='visible'\n";
            temp += "		if(d.layers)el.style=el;\n";
            temp += "		el.sP=function(x,y){this.style.left=x+'px';this.style.top=y+'px';};\n";
            temp += "		el.x = ShopstartX;\n";
            temp += "		if (verticalpos=='fromtop')\n";
            temp += "		el.y = ShopstartY;\n";
            temp += "		else{\n";
            temp += "		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;\n";
            temp += "		el.y -= ShopstartY;\n";
            temp += "		}\n";
            temp += "		return el;\n";
            temp += "	}\n";
            temp += "	window.ShopServicePannel=function(){\n";
            temp += "		if (verticalpos=='fromtop'){\n";
            temp += "		var pY = ns ? pageYOffset : iecompattest().scrollTop;\n";
            temp += "		ftlObj.y += (pY + ShopstartY - ftlObj.y)/8;\n";
            temp += "		}\n";
            temp += "		else{\n";
            temp += "		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;\n";
            temp += "		ftlObj.y += (pY - ShopstartY - ftlObj.y)/8;\n";
            temp += "		}\n";
            temp += "		ftlObj.sP(ftlObj.x, ftlObj.y);\n";
            temp += "		setTimeout('stayTopLeft()', 10);\n";
            temp += "	}\n";
            temp += "	ftlObj = ml('ShopServicePannel');\n";
            temp += "	ShopServicePannel();\n";
            temp += "}\n";
            temp += "if(typeof(HTMLElement)!='undefined'){\n";
            temp += "  HTMLElement.prototype.contains=function (obj)\n";
            temp += "  {\n";
            temp += "	  while(obj!=null&&typeof(obj.tagName)!='undefind'){\n";
            temp += "    if(obj==this) return true;\n";
            temp += "  	 obj=obj.parentNode;\n";
            temp += " 	  }\n";
            temp += "	  return false;\n";
            temp += "  }\n";
            temp += "}\n";
            temp += "if (window.addEventListener)\n";
            temp += "window.addEventListener('load', ShopServicePannelstaticbar, false)\n";
            temp += "else if (window.attachEvent)\n";
            temp += "window.attachEvent('onload', ShopServicePannelstaticbar)\n";
            temp += "else if (document.getElementById)\n";
            temp += "window.onload=ShopServicePannelstaticbar;\n";
            temp += "window.onresize=ShopServicePannelstaticbar;\n";
            temp += "function ShopServicePannelOver(){\n";
            temp += "   document.getElementById('ShopServicePannelMenu').style.display = 'none';\n";
            temp += "   document.getElementById('ShopServicePannelOnline').style.display = 'block';\n";
            temp += "   document.getElementById('divShopServicePannel').style.width = '170px';\n";
            temp += "}\n";
            temp += "function ShopServicePannelOut(){\n";
            temp += "   document.getElementById('ShopServicePannelMenu').style.display = 'block';\n";
            temp += "   document.getElementById('ShopServicePannelOnline').style.display = 'none';\n";
            temp += "}\n";
            temp += "if(typeof(HTMLElement)!='undefined') \n";
            temp += "{\n";
            temp += "   HTMLElement.prototype.contains=function(obj)\n";
            temp += "   {\n";
            temp += "       while(obj!=null&&typeof(obj.tagName)!='undefind'){\n";
            temp += "       if(obj==this) return true;\n";
            temp += "       obj=obj.parentNode;\n";
            temp += "     }\n";
            temp += "          return false;\n";
            temp += "   };\n";
            temp += "}\n";
            temp += "function ShowShopServicePannel(theEvent){\n";
            temp += "  if (theEvent){\n";
            temp += "     var browser=navigator.userAgent;\n";
            temp += " 	if (browser.indexOf('Firefox')>0){\n";
            temp += "       if (document.getElementById('ShopServicePannelOnline').contains(theEvent.relatedTarget)) {\n";
            temp += "           return;\n";
            temp += "         }\n";
            temp += "      }\n";
            temp += "	    if (browser.indexOf('MSIE')>0 || browser.indexOf('Safari')>0){ //IE Safari\n";
            temp += "          if (document.getElementById('ShopServicePannelOnline').contains(event.toElement)) {\n";
            temp += "	          return;\n";
            temp += "          }\n";
            temp += "      }\n";
            temp += "   }\n";
            temp += "   document.getElementById('ShopServicePannelMenu').style.display = 'block';\n";
            temp += "   document.getElementById('ShopServicePannelOnline').style.display = 'none';\n";
            temp += "}";
            HtmlEngine save = new HtmlEngine();

            save.CreateFile("/supplier/js/user/ServicePanel" + CurrentSupplier.id + ".js", temp);
            Response.Write("{\"msg\":\"OK\"}");
        }
コード例 #4
0
ファイル: ThemeUrl.cs プロジェクト: zwkjgs/LebiShop
        /// <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();
        }