public static HttpHandlerResult ExternalView(string name, object param) { if (Path.DirectorySeparatorChar != '\\') { name = name.Replace("\\", Path.DirectorySeparatorChar.ToString()); } var filename = Path.GetFullPath(name); if (!File.Exists(filename)) { throw new ApplicationException($"External View '{filename}' could not be found!"); } string content; using (var stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var reader = new StreamReader(stream)) { content = reader.ReadToEnd(); } var moustache = new HtmlEngine(); content = moustache.Process(content, ToDictionary(param)); return(new HttpHandlerResult { StatusCode = (int)HttpStatusCode.OK, StatusDescription = "OK.", Content = content, }); }
/// <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());//保存在指定目录下 }
/// <summary> /// 取得一个文件的内容 /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetSkinStr(string filename) { string str = ""; string path = "/theme/system/" + filename; str = HtmlEngine.ReadTxt(path); return(str); }
/// <summary> /// 生成插件页面 /// </summary> /// <param name="pgconf"></param> /// <param name="site"></param> /// <param name="type"></param> /// <param name="parentpath"></param> public static void CreatePluginPage(PluginConfig pgconf, string type, string parentpath) { string WebPath = Site.Instance.WebPath; string path = System.Web.HttpRuntime.AppDomainAppPath + "/plugin/" + pgconf.Assembly.ToLower() + "/systempage/" + type + "/page/" + parentpath; string filepath = WebPath + "/plugin/" + pgconf.Assembly.ToLower() + "/systempage/" + type + "/page/" + parentpath; string mediapath = "/plugin/" + pgconf.Assembly.ToLower() + "/systempage/" + type; if (type == "admin") { if (!string.IsNullOrEmpty(RequestTool.GetConfigKey("SystemAdmin").Trim())) { path = System.Web.HttpRuntime.AppDomainAppPath + "/plugin/" + pgconf.Assembly.ToLower() + "/systempage/" + RequestTool.GetConfigKey("SystemAdmin").Trim() + "/page/" + parentpath; filepath = WebPath + "/plugin/" + pgconf.Assembly.ToLower() + "/systempage/" + RequestTool.GetConfigKey("SystemAdmin").Trim() + "/page/" + parentpath; mediapath = "/plugin/" + pgconf.Assembly.ToLower() + "/systempage/" + RequestTool.GetConfigKey("SystemAdmin").Trim(); } } if (!Directory.Exists(path)) { return; } DirectoryInfo mydir = new DirectoryInfo(path); DirectoryInfo[] dirs = mydir.GetDirectories(); foreach (DirectoryInfo dir in dirs) { CreatePluginPage(pgconf, type, parentpath + "/" + dir.Name);//递归全部文件夹 } FileInfo[] files = mydir.GetFiles(); string content = ""; string pagename = ""; parentpath = parentpath.ToLower().Trim('/'); string createpath = type; if (type == "admin") { createpath = Site.Instance.AdminPath; } else if (type == "supplier") { createpath = Site.Instance.SupplierPath; } //parentpath = parentpath.Substring(type.Length, parentpath.Length - type.Length); if (!Directory.Exists(System.Web.HttpRuntime.AppDomainAppPath + "/" + createpath)) { Directory.CreateDirectory(System.Web.HttpRuntime.AppDomainAppPath + "/" + createpath); } foreach (FileInfo f in files) { pagename = f.Name.Replace(".html", ".aspx"); pagename = ThemeUrl.GetFullPath(WebPath + "/" + createpath + "/" + parentpath + "/" + pagename); content = HtmlEngine.ReadTxt(filepath + "/" + f.Name); CreatAdminAspx(pagename, content, type, mediapath); } }
/// <summary> /// /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetSkinStr(Lebi_AdminSkin skin) { string str = ""; string path = site.AdminPath + "/custom/skin/" + skin.Code + ".html"; path = ThemeUrl.GetFullPath(path); str = HtmlEngine.ReadTxt(path); return(str); }
public static string AndroidPush(string token, string msg) { //SystemLog.Add("AndroidPush: user_id=" + token + "&msg=" + msg +""); string url = RequestTool.GetConfigKey("AndroidPushAddress"); url = url + "?user_id=" + token + "&msg=" + msg; string res = HtmlEngine.Get(url); return(res); }
public void CreateSingleNewsTest2() { HtmlEngine target = new HtmlEngine(); // TODO: 初始化为适当的值 int newsId = 0; // TODO: 初始化为适当的值 string operateType = string.Empty; // TODO: 初始化为适当的值 target.CreateSingleNews(newsId, operateType); Assert.Inconclusive("无法验证不返回值的方法。"); }
public static string GetHighlightedHtml(string definition, string source) { var engine = new HtmlEngine(); var highlighter = new Highlighter(engine); var sourceHtml = highlighter.Highlight(definition, source); sourceHtml = string.Format("<pre>{0}</pre>", sourceHtml); return(sourceHtml); }
/// <summary> /// /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetSkinStr(Lebi_Supplier_Skin skin) { string str = ""; string path = skin.Path.TrimEnd('/') + "/index.html"; path = ThemeUrl.GetFullPath(path); str = HtmlEngine.ReadTxt(path); return(str); }
/// <summary> /// /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetSkinStr(Lebi_Theme theme, Lebi_Theme_Skin skin) { string str = ""; string path = theme.Path_Files + "/" + skin.Path_Skin; path = ThemeUrl.GetFullPath(path); str = HtmlEngine.ReadTxt(path); return(str); }
/// <summary> /// 生成后台|供应商文件 /// </summary> /// <param name="type">admin或supplier或前台文件夹名</param> /// <param name="parentpath"></param> public static string CreateAdmin(string type, string parentpath) { string msg = ""; Site site = new Site(); string content = ""; string createpath = type; if (type == "admin") { createpath = site.AdminPath == "" ? "admin" : site.AdminPath; } else if (type == "supplier") { if (!Shop.LebiAPI.Service.Instanse.Check("plugin_gongyingshang")) { return(""); } createpath = site.SupplierPath == "" ? "supplier" : site.SupplierPath; } else if (type == "front") { createpath = "/"; } try { string path = ""; path = System.Web.HttpRuntime.AppDomainAppPath + "theme/system/systempage/" + type + "/page/" + parentpath; if (!Directory.Exists(path)) { return("模板目录不存在"); } DirectoryInfo mydir = new DirectoryInfo(path); DirectoryInfo[] dirs = mydir.GetDirectories(); foreach (DirectoryInfo dir in dirs) { CreateAdmin(type, parentpath + "/" + dir.Name); } FileInfo[] files = mydir.GetFiles(); foreach (FileInfo f in files) { content = HtmlEngine.ReadTxt("theme/system/systempage/" + type + "/page/" + parentpath + "/" + f.Name); CreatAdminAspx(createpath + parentpath + "/" + f.Name.Replace(".html", ".aspx"), content, type, ""); } //生成插件页面 List <PluginConfig> plgs = Event.GetPluginConfig(); foreach (PluginConfig plg in plgs) { CreateALLPluginPage(plg); } } catch (Exception ex) { } return(msg); }
public void CreateTemplatePageTest() { HtmlEngine target = new HtmlEngine(); // TODO: 初始化为适当的值 int templateId = 63; // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.CreateTemplatePage(templateId); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void CreateTemplatePageByChannelIdTest() { HtmlEngine target = new HtmlEngine(); // TODO: 初始化为适当的值 string channelId = "001006"; // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.CreateTemplatePageByChannelId(channelId); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void GetTemplagePreviewTest() { HtmlEngine target = new HtmlEngine(); // TODO: 初始化为适当的值 int templateId = 63; // TODO: 初始化为适当的值 string expected = string.Empty; // TODO: 初始化为适当的值 string actual; actual = target.GetTemplagePreview(templateId, null); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> /// 获取接口数据 /// </summary> /// <param name="action"></param> /// <param name="para"></param> /// <returns></returns> private string API(string action, string para) { StringBuilder sb = new StringBuilder(); sb.Append(url); sb.Append(action); sb.Append(para); string str = HtmlEngine.Get(sb.ToString()); return(str); }
/// <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"); }
public void CreateSingleNewsTest() { HtmlEngine target = new HtmlEngine(); // TODO: 初始化为适当的值 int newsId = 360; // TODO: 初始化为适当的值 string operateType = "edit"; // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.CreateSingleNews(newsId, operateType); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
/// <summary> /// 生成页面皮肤 /// 针对单个皮肤生成的情况 /// </summary> /// <returns></returns> public void CreateSkin() { string Msg = ""; int ThemeID = 0; int SkinID = 0; string Content = ""; string SkinPath = ""; //皮肤路径 string Path = ""; //输入Path要包含路径及文件名 SkinID = RequestTool.RequestInt("id", 0); Lebi_Theme_Skin skin = B_Lebi_Theme_Skin.GetModel(SkinID); Lebi_Theme theme; if (skin == null) { Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}"); return; } ThemeID = skin.Theme_id; theme = B_Lebi_Theme.GetModel(ThemeID); SkinPath = theme.Path_Files + "/" + skin.Path_Skin; SkinPath = ThemeUrl.GetFullPath(SkinPath); Content = HtmlEngine.ReadTxt(SkinPath); List <Lebi_Language> langs = B_Lebi_Language.GetList("Theme_id=" + theme.id + "", ""); if (langs.Count == 0) { Response.Write("{\"msg\":\"" + Tag("请在站点语言设置中关联此模板") + "\"}"); return; } Site site = new Site(); foreach (Lebi_Language lang in langs) { if (lang.Theme_id != ThemeID) { continue; } Lebi_Site s = B_Lebi_Site.GetModel(lang.Site_id); if (s == null) { Path = lang.Path + "/" + skin.PageName; } else { Path = s.Path + lang.Path + "/" + skin.PageName; } Msg = Shop.Bussiness.Theme.CreatAspx(s, lang, theme, skin, Path, Content); } Response.Write("{\"msg\":\"" + Msg + "\"}"); }
internal bool CreateLines(Graphics g, bool fromStart, bool forceResize) { int position = fromStart ? 0 : renderingIndex; ArrayList parameterPositions = new ArrayList(); ArrayList parameterEnds = new ArrayList(); string fullText = this.ResolveParameterValues(content, parameterPositions, parameterEnds); string text = section.Document.DesignMode ? content.Substring(position) : fullText.Substring(position); Rectangle bounds = this.Section.Document.DesignMode ? theRegion : Bounds; bounds.Inflate(-innerPadding, -innerPadding); Context previousContext = null; if (previousState != null && previousState.Context != null) { previousContext = previousState.Context; } Com.Delta.Print.Engine.Parse.Html.HtmlEngine engine = section.Document.DesignMode ? new Com.Delta.Print.Engine.Parse.Html.HtmlEngine(this, g, bounds, this.font, this.foregroundColor) : (previousContext == null ? new Com.Delta.Print.Engine.Parse.Html.HtmlEngine(this, g, bounds, this.font, this.foregroundColor) : new Com.Delta.Print.Engine.Parse.Html.HtmlEngine(this, g, bounds, previousContext.Font, previousContext.Color)); engine.InitState(previousState, section.Document.DesignMode); int parsingLength = engine.Parse(text, lines); double minimalHeight = 0; foreach (TextLine line in lines) { minimalHeight += line.Height; } int netHeight = (int)minimalHeight + 2 * innerPadding + 2; if (forceResize) { Bounds.Height = netHeight; } this.previousState = engine; renderingIndex += parsingLength; return(renderingIndex < fullText.Length || engine.Residual != null || engine.ResidualText != string.Empty); }
/// <summary> /// 取得一个文件的内容 /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetSkinStr(string filename) { string str = ""; string path = "/" + filename; if (filename.ToLower().Contains("web.config")) { str = ""; } else { str = HtmlEngine.ReadTxt(path); } return(str); }
/// <summary> /// 取得一个文件内的备注 /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetRemark(string filename) { string str = ""; string path = "/theme/system/" + filename; str = HtmlEngine.ReadTxt(path); if (str.IndexOf("<!--") == 0) { str = RegexTool.GetRegValue(str, @"<!--(.*?)-->"); str = str.Trim() + "\r\n"; //str = str.Replace("\r\n",""); } else { str = ""; } return(str); }
/// <summary> /// /// </summary> /// <param name="theme"></param> /// <param name="skin"></param> /// <returns></returns> private string GetSkinStr(Lebi_AdminSkin skin) { string str = ""; string path = ""; if (!string.IsNullOrEmpty(RequestTool.GetConfigKey("SystemAdmin").Trim())) { path = site.AdminPath + "/custom/skin2/" + skin.Code + ".html"; } else { path = site.AdminPath + "/custom/skin/" + skin.Code + ".html"; } path = ThemeUrl.GetFullPath(path); str = HtmlEngine.ReadTxt(path); return(str); }
/// <summary> /// Returns a named view from the <see cref="ViewCollection"/>. /// </summary> /// <param name="name">The name of the view.</param> /// <param name="param">Optional view-model object.</param> public static HttpHandlerResult View(HttpReceiverContext context, string name, object param = null) { if (!context.Views.TryFind(name, out var content)) { throw new ApplicationException($"View '{name}' was not found!"); } var engine = new HtmlEngine(context.Views) { UrlRoot = context.ListenerPath, }; content = engine.Process(content, param); return(new HttpHandlerResult { StatusCode = (int)HttpStatusCode.OK, StatusDescription = "OK.", }.SetText(content)); }
private string PostFiles(string fileName, string savepath, string name) { if (Shop.LebiAPI.Service.Instanse.Check("imageserver") && WebConfig.Instrance.UpLoadURL != "") { try { string url = WebConfig.Instrance.UpLoadURL; if (url.Contains("?")) { url += "&filename=" + fileName; } else { url += "?filename=" + fileName; } if (WebConfig.Instrance.ImageServerKey != "") { url += "&key=" + WebConfig.Instrance.ImageServerKey; } string res = HtmlEngine.PostFile(url, ImageHelper.rootpath(savepath + name)); //api = jss.Deserialize<LBAPI>(res); ImageHelper.DeleteImage(savepath + name); return(res); } catch (Exception ex) { return("{\"msg\":\"" + ex.Message + "\"}"); } } string OldImage = savepath + name; string size = ""; Lebi_Image model = new Lebi_Image(); model.Image = OldImage; model.Keyid = 0; model.Size = size; model.TableName = "Product"; B_Lebi_Image.Add(model); return("{\"msg\":\"OK\",\"img\":\"" + OldImage + "\",\"file\":\"" + fileName + "\"}"); }
/// <summary> /// 获取模板页面内容 /// </summary> public void GetSkinContent() { if (!EX_Admin.Power("theme_edit", "编辑模板")) { AjaxNoPower(); return; } string filename = RequestTool.RequestString("filename"); string str = ""; string path = site.WebPath + "/theme/system/" + filename; path = path.ToLower().Replace(".aspx", ".html"); string FileName = HttpContext.Current.Server.MapPath(@"~/" + path); if (File.Exists(FileName)) { str = HtmlEngine.ReadTxt(path); } else { str = ""; } Response.Write(str); }
/// <summary> /// 付款操作 /// 创建用户:shiyuankao /// 创建时间:2014-08-07 /// </summary> /// <param name="orderId">订单号</param> /// <param name="productName">商品名称</param> /// <param name="amount">支付金额</param> /// <returns></returns> PayMessage Payment(UmsPayConfig config, Lebi_Order order, decimal amount) { var message = new PayMessage() { IsSuccess = true }; var now = DateTime.Now; // 参数组装 var inParams = new Dictionary <string, string> { { "TransCode", "201201" }, { "OrderTime", now.ToString("HHmmss") }, { "OrderDate", now.ToString("yyyyMMdd") }, { "MerOrderId", order.Code }, { "TransType", "NoticePay" }, { "TransAmt", (amount * 100).ToString("F0") }, { "MerId", config.MerId }, { "MerTermId", config.MerTermId }, { "NotifyUrl", config.NotifyUrl }, { "Reserve", order.Code }, { "OrderDesc", order.Code }, { "EffectiveTime", "0" } }; var signContent = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}", inParams["OrderTime"], inParams["EffectiveTime"], inParams["OrderDate"], inParams["MerOrderId"], inParams["TransType"], inParams["TransAmt"], inParams["MerId"], inParams["MerTermId"], inParams["NotifyUrl"], inParams["Reserve"], inParams["OrderDesc"]); var merSign = RSAUtil.RSASign(signContent, config.PrivateKey); inParams.Add("MerSign", merSign); var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(inParams); //client.PostingData.Add("jsonString", jsonString); //var result = client.GetString(); System.Collections.Specialized.NameValueCollection nv = new System.Collections.Specialized.NameValueCollection(); nv.Add("jsonString", jsonString); string result = HtmlEngine.Post(config.OrderUrl, nv); if (string.IsNullOrEmpty(result)) { message.IsSuccess = false; message.Msg = "调用支付下单接口无数据返回。"; return(message); } var dictionary = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(result); // 判断是否下单成功 var respCode = dictionary["RespCode"]; if (respCode != "00000") { message.IsSuccess = false; message.Msg = dictionary["RespMsg"]; return(message); } // 组装验签字符串 var content = string.Format("{0}{1}{2}{3}{4}{5}", dictionary["MerOrderId"], dictionary["ChrCode"], dictionary["TransId"], dictionary["Reserve"].Trim(), dictionary["RespCode"], dictionary["RespMsg"].Trim()); var r = RSAUtil.Verify(content, dictionary["Signature"], config.PublicKey); if (!r) { message.IsSuccess = false; message.Msg = "下单成功,返回数据签名验证失败。"; return(message); } var chrCode = dictionary["ChrCode"]; var transId = dictionary["TransId"]; inParams.Add("ChrCode", chrCode); inParams.Add("TransId", transId); merSign = RSAUtil.RSASign(string.Format("{0}{1}", transId, chrCode), config.PrivateKey); inParams["MerSign"] = merSign; // 处理各个支付渠道对应的订单编码 // 以下处理是根据自己业务处理,添加业务订单号 if (!inParams.ContainsKey("OrderId")) { inParams.Add("OrderId", inParams["MerOrderId"]); } var data = new Dictionary <string, string> { { "MerSign", merSign }, { "ChrCode", chrCode }, { "TransId", transId }, { "MerchantId", config.MerId } }; message.Data = data; message.OtherData = inParams; return(message); }
/// <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\"}"); }
private string TestUpload() { HttpFileCollection files = HttpContext.Current.Request.Files; B_WaterConfig bc = new B_WaterConfig(); WaterConfig mx = bc.LoadConfig(); BaseConfig conf = ShopCache.GetBaseConfig(); string result = ""; string name = ""; StringBuilder strMsg = new StringBuilder(); string savepath = GetPath(conf.UpLoadPath); try { for (int iFile = 0; iFile < files.Count; iFile++) { ///'检查文件扩展名字 HttpPostedFile postedFile = files[iFile]; string fileName, fileExtension; fileName = System.IO.Path.GetFileName(postedFile.FileName); fileExtension = System.IO.Path.GetExtension(fileName); if (conf.UpLoadSaveName == "" || conf.UpLoadSaveName == null) { conf.UpLoadSaveName = "0"; } if (conf.UpLoadSaveName == "0") { name = DateTime.Now.ToString("yyMMddssfff") + "_w$h_"; } else { name = System.IO.Path.GetFileNameWithoutExtension(fileName) + "_w$h_"; } name = conf.UpLoadRName + name + fileExtension; int status = ImageHelper.SaveImage(postedFile, savepath, name); if (status != 290) { continue; } if (Shop.LebiAPI.Service.Instanse.Check("imageserver") && WebConfig.Instrance.UpLoadURL != "") { try { string res = HtmlEngine.PostFile(WebConfig.Instrance.UpLoadURL, ImageHelper.rootpath(savepath + name)); JavaScriptSerializer jss = new JavaScriptSerializer(); LBAPI api = jss.Deserialize <LBAPI>(res); result = res; } catch (Exception ex) { result = "{\"msg\":\"" + ex.Message + "\"}"; } } else { string OldImage = savepath + name; //string ImageBig = name.Replace("_w$h_", "_" + conf.ImageBigWidth + "$" + conf.ImageBigHeight + "_"); //string ImageMedium = name.Replace("_w$h_", "_" + conf.ImageMediumWidth + "$" + conf.ImageMediumHeight + "_"); //string ImageSmall = name.Replace("_w$h_", "_" + conf.ImageSmallWidth + "$" + conf.ImageSmallHeight + "_"); //string size = conf.ImageBigWidth + "$" + conf.ImageBigHeight + "," + conf.ImageMediumWidth + "$" + conf.ImageMediumHeight + "," + conf.ImageSmallWidth + "$" + conf.ImageSmallHeight; //if (mx.OnAndOff == "1") //{ // ImageHelper.UPLoad(OldImage, savepath, "temp_" + name, Convert.ToInt32(conf.ImageBigWidth), Convert.ToInt32(conf.ImageBigHeight)); // ImageHelper.MakeWater(System.Web.HttpContext.Current.Server.MapPath(savepath) + "temp_" + name, savepath, ImageBig, mx); // ImageHelper.DeleteImage(savepath + "temp_" + name); //} //else //{ // ImageHelper.UPLoad(OldImage, savepath, ImageBig, Convert.ToInt32(conf.ImageBigWidth), Convert.ToInt32(conf.ImageBigHeight)); //} //ImageHelper.UPLoad(OldImage, savepath, ImageMedium, Convert.ToInt32(conf.ImageMediumWidth), Convert.ToInt32(conf.ImageMediumHeight)); //ImageHelper.UPLoad(OldImage, savepath, ImageSmall, Convert.ToInt32(conf.ImageSmallWidth), Convert.ToInt32(conf.ImageSmallHeight)); ////生成所有规格 //string where = "id not in (select id from Lebi_ImageSize where (Width=" + conf.ImageBigWidth + " and Height=" + conf.ImageBigHeight + ") or (Width=" + conf.ImageMediumWidth + " and Height=" + conf.ImageMediumHeight + ") or (Width=" + conf.ImageSmallWidth + " and Height=" + conf.ImageSmallHeight + "))"; //List<Lebi_ImageSize> ss = B_Lebi_ImageSize.GetList(where, ""); //foreach (Lebi_ImageSize s in ss) //{ // ImageHelper.UPLoad(OldImage, savepath, name.Replace("_w$h_", "_" + s.Width + "$" + s.Height + "_"), s.Width, s.Height); // size += "," + s.Width + "$" + s.Height; //} //写入数据库 Lebi_Image model = new Lebi_Image(); model.Image = savepath + name; model.Keyid = 0; model.Size = ""; model.TableName = "temp"; B_Lebi_Image.Add(model); result = "{\"img\":\"" + OldImage + "\",\"msg\":\"OK\"}"; } } } catch (System.Exception ex) { result = "{\"msg\":\"" + ex.Message + "\"}"; } return(result); }
/// <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(); }
/// <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); }