public static string GetURL(string code, string ParaStr, string url, string langcode) { Lebi_Site site = new Lebi_Site(); if (ShopPage.IsAPP() || ShopPage.IsWechat() || ShopPage.IsWap()) { site = B_Lebi_Site.GetModel("IsMobile = 1 order by Sort asc"); if (site == null) { site = B_Lebi_Site.GetModel("IsMobile = 0 order by Sort asc"); } } else { site = B_Lebi_Site.GetModel("IsMobile = 0 order by Sort asc"); if (site == null) { site = B_Lebi_Site.GetModel("IsMobile = 1 order by Sort asc"); } } Lebi_Language lang = B_Lebi_Language.GetModel("Site_id =" + site.id + " and Code = '" + langcode + "'"); if (lang == null) { lang = new Lebi_Language(); } return(GetURL(code, ParaStr, url, lang)); }
public static string GetURL(string code, string ParaStr, string url, Lebi_Language lang) { if (lang == null) { lang = new Lebi_Language(); } Lebi_Site site = B_Lebi_Site.GetModel(lang.Site_id); if (site == null) { if (ShopPage.IsAPP() || ShopPage.IsWechat() || ShopPage.IsWap()) { site = B_Lebi_Site.GetModel("IsMobile = 1 order by Sort asc"); } else { site = B_Lebi_Site.GetModel("IsMobile = 0 order by Sort asc"); } if (site == null) { site = new Lebi_Site(); } } return(GetURL(code, ParaStr, url, site, lang)); }
/// <summary> /// 站点名称 /// </summary> /// <param name="siteid"></param> /// <returns></returns> public string SiteName(int siteid) { Lebi_Site model = B_Lebi_Site.GetModel(siteid); if (model == null) { model = ShopCache.GetMainSite(); } return(model.SubName); }
/// <summary> /// 设置主站点 /// </summary> public static void SetMainSite() { Lebi_Site model = B_Lebi_Site.GetModel("1=1 order by Sort desc"); if (model == null) { model = new Lebi_Site(); } CacheTool.Permanent("MainSite", model); }
/// <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"); }
/// <summary> /// 站点名称 /// </summary> /// <param name="siteid"></param> /// <returns></returns> public string SiteName(int siteid, int DT_id, string LanuageCode) { if (DT_id == 0) { Lebi_Site model = B_Lebi_Site.GetModel(siteid); if (model == null) { model = ShopCache.GetMainSite(); } return(model.SubName); } else { Lebi_DT model = B_Lebi_DT.GetModel(DT_id); if (model == null) { model = new Lebi_DT(); } return(Shop.Bussiness.Language.Content(model.Site_Name, LanuageCode)); } }
/// <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(); }
public static string ReplaceSMSTag(string instr, Lebi_User user, BaseConfig conf) { string language = Language.DefaultLanguage().Code; instr = instr.Replace("{$Domain}", conf.Domain); instr = instr.Replace("{$Time}", DateTime.Now.ToString()); if (user != null) { instr = instr.Replace("{$UserName}", user.UserName); instr = instr.Replace("{$RealName}", user.RealName); instr = instr.Replace("{$UserID}", user.id.ToString()); instr = instr.Replace("{$UserNumber}", user.UserNumber); instr = instr.Replace("{$NickName}", user.NickName); language = user.Language; if (language == "") { user.Language = "CN"; } } else { user = new Lebi_User(); user.Language = "CN"; } string Phone = ""; string Email = ""; string QQ = ""; string Fax = ""; string Name = ""; string Domain = ""; Lebi_Site site = B_Lebi_Site.GetModel(user.Site_id); if (site == null) { site = B_Lebi_Site.GetList("", "Sort desc").FirstOrDefault(); Phone = Language.Content(site.Phone, user.Language); Email = Language.Content(site.Email, user.Language); QQ = Language.Content(site.QQ, user.Language); Fax = Language.Content(site.Fax, user.Language); Name = Language.Content(site.Name, user.Language); Domain = Language.Content(site.Domain, user.Language); } else { Phone = Language.Content(site.Phone, user.Language); Email = Language.Content(site.Email, user.Language); QQ = Language.Content(site.QQ, user.Language); Fax = Language.Content(site.Fax, user.Language); Name = Language.Content(site.Name, user.Language); Domain = Language.Content(site.Domain, user.Language); Lebi_Site mainsite = B_Lebi_Site.GetList("", "Sort desc").FirstOrDefault(); if (Phone == "") { Phone = Language.Content(mainsite.Phone, user.Language); } if (Email == "") { Email = Language.Content(mainsite.Email, user.Language); } if (QQ == "") { QQ = Language.Content(mainsite.QQ, user.Language); } if (Fax == "") { Fax = Language.Content(mainsite.Fax, user.Language); } if (Name == "") { Name = Language.Content(mainsite.Name, user.Language); } if (Domain == "") { Domain = Language.Content(mainsite.Domain, user.Language); } } instr = instr.Replace("{$UserName}", user.UserName); instr = instr.Replace("{$UserID}", user.id.ToString()); //instr = instr.Replace("{$Phone}", Language.Content(conf.Phone, user.Language)); //instr = instr.Replace("{$Email}", Language.Content(conf.Email, user.Language)); //instr = instr.Replace("{$QQ}", Language.Content(conf.QQ, user.Language)); //instr = instr.Replace("{$Fax}", Language.Content(conf.Fax, user.Language)); //instr = instr.Replace("{$SiteName}", Language.Content(conf.Name, user.Language)); //instr = instr.Replace("{$Domain}", conf.Domain); instr = instr.Replace("{$Phone}", Phone); instr = instr.Replace("{$Email}", Email); instr = instr.Replace("{$QQ}", QQ); instr = instr.Replace("{$Fax}", Fax); instr = instr.Replace("{$SiteName}", Name); instr = instr.Replace("{$Domain}", Domain); return(instr); }
/// <summary> /// 载入主题 /// </summary> /// <param name="themecode"></param> /// <param name="siteid"></param> /// <param name="languagecode"></param> /// <param name="pcode"></param> /// <param name="checklogin">是否检查用户登录</param> public void LoadTheme(string themecode, int siteid, string languagecode, string pcode, bool checklogin) { CurrentSite_ = B_Lebi_Site.GetModel(siteid); if (ShopCache.GetMainSite().id == CurrentSite_.id || CurrentSite_.Domain == "") { IsMainSite = true; } CurrentLanguage_ = B_Lebi_Language.GetModel("Code='" + languagecode + "' and Site_id=" + siteid + ""); if (CurrentLanguage_ == null) { CurrentLanguage_ = new Lebi_Language(); } if (IsMainSite) { CurrentLanguage_.Path = (CurrentSite_.Path + CurrentLanguage_.Path).Replace("//", "/").TrimEnd('/'); } if (checklogin) { if (CurrentUser.id == 0 || CurrentUser.IsAnonymous == 1) { HttpContext.Current.Response.Redirect(URL("P_Login", "" + HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain()) + "," + GetUrlToken(RequestTool.GetRequestUrlNonDomain()) + "")); } } CurrentTheme_ = B_Lebi_Theme.GetModel("Code='" + themecode + "'"); CurrentPage = B_Lebi_Theme_Page.GetModel("Code='" + pcode + "'"); if (CurrentTheme_ == null) { CurrentTheme_ = new Lebi_Theme(); } Lebi_Theme_Skin skin = B_Lebi_Theme_Skin.GetModel("Theme_id=" + CurrentTheme_.id + " and Code='" + pcode + "'"); if (skin != null) { if (skin.PageSize > 0) { PageSize = skin.PageSize; } } if (CurrentSite_ != null) { SYS.Copyright = CurrentSite_.Copyright; SYS.Domain = CurrentSite_.Domain; SYS.Email = CurrentSite_.Email; SYS.Fax = CurrentSite_.Fax; SYS.Keywords = CurrentSite_.Keywords; SYS.Logoimg = CurrentSite_.Logoimg; SYS.Description = CurrentSite_.Description; SYS.Phone = CurrentSite_.Phone; SYS.QQ = CurrentSite_.QQ; SYS.ServiceP = CurrentSite_.ServiceP; SYS.Name = CurrentSite_.Name; SYS.Title = CurrentSite_.Title; SYS.FootHtml = CurrentSite_.FootHtml; SYS.TopAreaid = CurrentLanguage_.TopAreaid.ToString(); } LBTITLE = ""; LBTITLE += " - Powered by LebiShop"; //底部版权信息 //if (CurrentPage != null) //{ // StringBuilder sb = new StringBuilder(); // sb.Append("Powered by <a style=\"font-size:12px;color:#00497f\" href=\"http://www.lebi.cn\" target=\"_blank\" title=\"LebiShop多语言网上商店系统\">LebiShop</a> "); // sb.Append("V" + SYS.Version + "." + SYS.Version_Son); // try // { // Label label = (Label)this.Page.FindControl("LeBiLicense"); // label.Text = sb.ToString(); // } // catch (System.NullReferenceException) // { // Response.Write("<div style=\"height:100px;padding-top:10px;text-align:left;font-size:12;\">内部错误,请到【配置】=》【站点语言】栏目中重新生成网站<br>"); // Response.Write(sb.ToString() + "</div>"); // Response.End(); // } //} Session["CurrentTheme"] = CurrentTheme_;//session主要是为那些没有LoadTheme方法的页面服务的,如ajax Session["CurrentLanguage"] = CurrentLanguage_; Session["CurrentSite"] = CurrentSite_; //写入cookie NameValueCollection nvs = new NameValueCollection(); nvs.Add("theme", CurrentTheme_.Code); nvs.Add("language", CurrentLanguage_.Code); nvs.Add("site", CurrentSite_.id.ToString()); CookieTool.WriteCookie("ThemeStatus", nvs, 10); //多站点商品显示 if (Shop.Bussiness.Site.Instance.SiteCount > 1) { //if (Shop.LebiAPI.Service.Instanse.Check("domain3admin")) //{ if (DataBase.DBType == "sqlserver") { ProductWhere = "(Charindex('," + CurrentSite_.id + ",',','+Site_ids+',')>0 or Site_ids='') and Product_id = 0 and Type_id_ProductStatus = 101"; ProductCategoryWhere = "(Charindex('," + CurrentSite_.id + ",',','+Site_ids+',')>0 or Site_ids='')"; } if (DataBase.DBType == "access") { ProductWhere = "(Instr(','+Site_ids+',','," + CurrentSite_.id + ",')>0 or Site_ids='') and Product_id = 0 and Type_id_ProductStatus = 101"; ProductCategoryWhere = "(Instr(','+Site_ids+',','," + CurrentSite_.id + ",')>0 or Site_ids='')"; } //} //else //{ // ProductWhere = "Product_id = 0 and Type_id_ProductStatus = 101"; //} } else { ProductWhere = "Product_id = 0 and Type_id_ProductStatus = 101"; ProductCategoryWhere = "1=1"; } //ProductWhere += " and (UserLevel_ids_show='' or UserLevel_ids_show is null or ','+UserLevel_ids_show+',' like '%," + CurrentUserLevel.id + ",%' )"; ProductWhere += " and (IsDel!=1 or IsDel is null)"; }