/// <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); }
public bool CheckServer() { string sql = System.Configuration.ConfigurationManager.ConnectionStrings["constr"].ToString(); sql = RegexTool.GetRegValue(sql, "data source=(.*?);"); if (sql == ".") { sql = "localhost"; } sql = sql.Replace(@"\", "/"); if (sql.Contains("/")) { sql = sql.Substring(0, sql.IndexOf("/")); } IPAddress[] IPs = Dns.GetHostAddresses(sql); string webserverip = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList[0].ToString(); bool res = false; foreach (IPAddress ip in IPs) { if (ip.ToString().Trim() == webserverip.Trim()) { res = true; } } return(res); }
public static void LogInUUids() { var uuids = File.ReadAllLines(@"C:\Users\baibq\Downloads\uuids.txt"); var lst = new List <string>(uuids); DirectoryInfo TheFolder = new DirectoryInfo(@"C:\Users\baibq\Downloads\kegg20160314"); Console.WriteLine("start " + DateTime.Now); var ff = TheFolder.GetFiles(); var rt = new RegexTool(); for (int i = 0; i < ff.Length; i++) { var reads = File.ReadLines(ff[i].FullName); //var uids = new List<string>(); foreach (var v in reads) { var uid = rt.Substring(v, @"""uid"":""", @""""); if (lst.Contains(uid)) { // uids.Add(uid); File.AppendAllLines(@"C:\Users\baibq\Downloads\0314\" + ff[i].Name, new string[] { v }); } } } }
public int Rint_Para(string para) { string key = "&" + CurrentPage.PageParameter; key = RegexTool.GetRegValue(key, @"&(.*?)=\{" + para + @"\}"); return(Rint(key)); }
private async void NextStep_Click(object sender, RoutedEventArgs args) { /** * handle checking account process HERE. * * 1.check the textbox NotNull */ var txtAcc = txtBoxAcc.Text; if (txtAcc == null || txtAcc == "") { return; } var isPhoneNum = RegexTool.IsMobilePhone(txtAcc); System.Diagnostics.Debug.WriteLine(txtAcc); System.Diagnostics.Debug.WriteLine(isPhoneNum); if (!RegexTool.IsMobilePhone(txtAcc)) { await new ContentDialog() { Title = "这个手机号无效", CloseButtonText = "确认", DefaultButton = ContentDialogButton.Close }.ShowAsync(); return; } PlayAccGotoPass(); }
/// <summary> /// 商品分类查询页面-根据筛选规格返回查询参数 /// </summary> /// <param name="sel"></param> /// <returns></returns> public string Categorywhere(string sel) { if (sel == "") { return("1=1"); } string where = ""; string[] arr = sel.Split('$'); for (int i = 0; i < arr.Length; i++) { int id = 0; string id_ = RegexTool.GetRegValue(arr[i], @"[\d]*\|([\d]*)"); int.TryParse(id_, out id); if (id > 0) { if (where == "") { where = " ProPerty132 like '%" + id + "%'"; } else { where += " and ProPerty132 like '%" + id + "%'"; } } } if (where == "") { where = "1=1"; } return(where); }
public Liter(string i, string name = null, bool escape = false) { var(tokenRule, f) = RegexTool.ReMatch(i, escape); Name = name; HasRecur = false; TokenRule = tokenRule; F = f; }
/// <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 + "\"}"); }
public static void HaveEggLog() { var filename = @"C:\Users\baibq\Desktop\webstat\ret.txt"; var lines = File.ReadAllLines(filename); var path1 = @"C:\Users\baibq\Desktop\egglog\egg20160213"; DirectoryInfo TheFolder = new DirectoryInfo(path1); Console.WriteLine("start " + DateTime.Now); var ff = TheFolder.GetFiles(); var finishLst = new List <string>(); var total = 0; for (var i = 0; i < ff.Length; i++) { var lst = new Dictionary <string, commonlog>(); Console.WriteLine("process " + ff[i].FullName); var lines1 = File.ReadLines(ff[i].FullName); var regexTool = new RegexTool(); foreach (var str in lines1) { try { var tmp = ""; Regex gex3 = new Regex(@"{([\S +|\s +])*"); var m3 = gex3.Match(str); if (m3.Success) { tmp = m3.Value; } var uid = regexTool.Substring(tmp, @"""uid"":""", @""""); if (finishLst.Contains(uid)) { continue; } if (tmp.IndexOf("{") > -1 && tmp.IndexOf("}") > -1 && tmp.IndexOf("checkupdate") > -1 && lines.Contains(uid)) { using (StreamWriter write = new StreamWriter(@"C:\Users\baibq\Desktop\webstat\finish.txt", true)) { write.WriteLine(tmp); } finishLst.Add(uid); total++; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine("finished lines " + total); } }
/// <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 + "\"}"); }
/// <summary> /// id=1&pid=1 转化为 Page_{id}_{pid}.html 形式 /// </summary> /// <param name="ParaStr">参数字符串</param> /// <param name="FormatStr">格式字符串</param> /// <returns></returns> public static string StaticUrl(string ParaStr, string FormatStr) { ParaStr = ("&" + ParaStr + "&").ToLower(); string str = FormatStr.ToLower();//小写 string[,] Arry = RegexTool.GetRegResultArray(str, @"{(.*?)}"); for (int i = 0; i < Arry.GetUpperBound(0); i++) { string d = RegexTool.GetRegValue(ParaStr, @"&" + Arry[i, 1] + "=(.*?)&"); str = str.Replace("{" + Arry[i, 1] + "}", d); } return(str); }
/// <summary> /// 页面载入检查 /// </summary> public void PageLoadCheck() { if (ShopCache.GetDomainStatus() == "0") { if (!Shop.LebiAPI.Service.Instanse.Check("lebilicense")) { 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); Response.Write("<div style=\"height:100px;padding-top:10px;text-align:left;font-size:12;\">LebiShop发现异常,您可以访问<a style=\"font-size:12px;color:#00497f\" href=\"http://www.lebi.cn\" target=\"_blank\" title=\"LebiShop多语言网店系统\">www.lebi.cn</a>寻求帮助<br>"); Response.Write(sb.ToString() + "</div>"); } else { Response.Write(SYS.Wornings); } Response.End(); return; } if (SYS.VisitTimeFlag == "1") { //开启了禁止访问 Response.Write(SYS.Wornings); Response.End(); return; } if (SYS.IPLock != "") { string ip = RequestTool.GetClientIP(); string[] locks = SYS.IPLock.Split(','); string reg; foreach (string iplock in locks) { if (iplock == ip) { Response.Write(SYS.Wornings); Response.End(); return; } reg = iplock.Replace(".", @"\."); reg = iplock.Replace("*", @"\d+"); if (RegexTool.Check(ip, reg)) { Response.Write(SYS.Wornings); Response.End(); return; } } } }
/// <summary> /// 获输入字符串内外层循环标记位置数组 /// </summary> /// <param name="strIn"></param> /// <returns></returns> private static int[,] IndexFlagArry(string strIn) { string[,] IndexArry = RegexTool.GetRegResultArray(strIn, @"(}\$|\$[\w]*{)"); //匹配 ${ 或 $Head{ 或 }$ //string[,] IndexArry = GetRegArry(strIn, @"(}\@|\@[\w\W]*{)");//匹配 ${ 或 $Head{ 或 }$ int beginFlagCount = 0; //开始标记个数 int endFlagCount = 0; //结束标记个数 string beginFlagIndex = ""; //开始标记位置 string endFlagIndex = ""; //结束标记位置 if (IndexArry.GetUpperBound(0) > 0) //包含标记时,把第一个标记作为第一个循环的开始标记 { beginFlagIndex = IndexArry[0, 0]; } List <string> indexs = new List <string>(); for (int i = 0; i < IndexArry.GetUpperBound(0); i++) { //str += i.ToString() + "-" + IndexArry[i, 0] + IndexArry[i, 1] + "\r\n"; if (IndexArry[i, 1].IndexOf("{") != -1) { beginFlagCount++; } if (IndexArry[i, 1].IndexOf("}") != -1) { endFlagCount++; } if (beginFlagCount == endFlagCount) { endFlagIndex = IndexArry[i, 0]; indexs.Add(beginFlagIndex + "-" + endFlagIndex); if (IndexArry.GetUpperBound(0) > i) { beginFlagIndex = IndexArry[i + 1, 0]; } } } int[,] FlagArry = new int[indexs.Count + 1, 2]; for (int i = 0; i < indexs.Count; i++) { string[] tempArry = indexs[i].Split('-'); FlagArry[i, 0] = Convert.ToInt32(tempArry[0]); FlagArry[i, 1] = Convert.ToInt32(tempArry[1]); } return(FlagArry); }
/// <summary> /// C#检测上传图片是否安全函数 /// </summary> /// <param name="strPictureFilePath"></param> public static bool CheckPictureSafe(string strPictureFilePath) { bool strReturn = true; if (File.Exists(strPictureFilePath)) { if (!IsAllowedExtension(strPictureFilePath)) { File.Delete(strPictureFilePath); return(false); } StringBuilder str_Temp = new StringBuilder(); try { using (StreamReader sr = new StreamReader(strPictureFilePath)) //按文本文件方式读取图片内容 { String line; while ((line = sr.ReadLine()) != null) { str_Temp.Append(line); } //检测是否包含危险字符串 if (str_Temp == null) { strReturn = false; } else { string DangerString = "<script|iframe|.getfolder|.createfolder|.deletefolder|.createdirectory|.deletedirectory|.saveas|wscript.shell|script.encode|server.|.createobject|execute|activexobject|language=|include|filesystemobject|shell.application"; strReturn = RegexTool.Check(str_Temp.ToString(), DangerString); } sr.Close(); } if (strReturn) { File.Delete(strPictureFilePath); return(false); } } catch (Exception ex) { throw new Exception(ex.Message); } } return(true); }
/// <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> /// 将 取值部分 替换model.形式 /// 字段名替换 /// </summary> /// <returns></returns> private static string ReplaceModel(string strIn, string mod) { //字段名替换 //@id@ ==》model.id //$id$ ==》<%=model.id%> //@i@ ==》model_index //$i$ ==》<%=model_index%> string str = strIn; string temp = ""; string temp_key = ""; string key = ""; string key_ = ""; str = str.Replace("{i}", mod + "_index"); str = str.Replace("{%i%}", "<%=" + mod + "_index%>"); str = str.Replace("{I}", mod + "_index"); str = str.Replace("{%I%}", "<%=" + mod + "_index%>"); Regex r = new Regex(@"{[\w]*}|{%[\w]*%}", RegexOptions.Singleline); MatchCollection mc = r.Matches(str); foreach (Match m in mc) { temp = m.Value; temp_key = ""; key_ = RegexTool.GetRegValue(temp, @"({%[\w]*%})"); key = RegexTool.GetRegValue(temp, @"{%([\w]*)%}"); if (key_ != "") { //temp_key = temp.Replace(key_, mod + "." + key); temp_key = temp.Replace(key_, "<%=" + mod + "." + key + "%>"); } else { key_ = RegexTool.GetRegValue(temp, @"({[\w]*})"); key = RegexTool.GetRegValue(temp, @"{([\w]*)}"); if (key_ != "") { temp_key = temp.Replace(key_, mod + "." + key); } } str = str.Replace(temp, temp_key); } return(str); }
/// <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 + "\"}"); }
/// <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); } }
/// <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); }
/// <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); }
/// <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); }
/// <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\"}"); }
/// <summary> /// 文字内容里面的图片处理 /// </summary> /// <param name="str"></param> /// <param name="IsLazyLoad"></param> /// <returns></returns> public string ContentImage(string str, int IsLazyLoad = 0) { string[] imgs = RegexTool.GetSimpleRegResultArray(str, @"(<[Ii][Mm][Gg].*?>)"); string temp = ""; foreach (string img in imgs) { temp = img; temp = temp.Replace("'", "\"").Replace(" ", ""); temp = RegexTool.GetRegValue(img, "[Ss][Rr][Cc]=\"(.*?)\""); if (IsLazyLoad == 1) { str = str.Replace(img, "<img class=\"contentlazy\" data-original=\"" + Image(temp) + "\"/>"); } else { str = str.Replace(img, "<img src=\"" + Image(temp) + "\"/>"); } } return(str); }
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(); }
/// <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); }
/// <summary> /// 提取限制页面 /// </summary> /// <param name="strIn"></param> /// <returns></returns> private string GetPage(string strIn) { string str = RegexTool.GetRegValue(strIn, @"[Pp][Aa][Gg][Ee]:(.*?)\r\n"); return(str); }
/// <summary> /// 提取名称 /// </summary> /// <param name="strIn"></param> /// <returns></returns> private string GetName(string strIn) { string str = RegexTool.GetRegValue(strIn, @"[Nn][Aa][Mm][Ee]:(.*?)\r\n"); return(str); }
public string Login(string back, int IsLogin = 1, int DT_id = 0) { string code = RequestTool.RequestString("code"); if (code != "") { try { StringBuilder sb = new StringBuilder(); sb.Append("?grant_type=authorization_code"); sb.Append("&client_id=" + appid); sb.Append("&client_secret=" + appkey); sb.Append("&code=" + code); string uri = reurnurl + "?backurl=" + back; uri = System.Web.HttpUtility.UrlEncode(uri); sb.Append("&redirect_uri=" + uri); string res = API("oauth2.0/token", sb.ToString()); res = res + "&"; string access_token = RegexTool.GetRegValue(res, "access_token=(.*?)&"); //获取openid sb = new StringBuilder(); sb.Append("?access_token=" + access_token); res = API("oauth2.0/me", sb.ToString()); string openid = RegexTool.GetRegValue(res, "openid\":\"(.*?)\"}"); //获取用户资料 sb = new StringBuilder(); sb.Append("?access_token=" + access_token); sb.Append("&oauth_consumer_key=" + appid); sb.Append("&openid=" + openid); res = API("user/get_user_info", sb.ToString()); JavaScriptSerializer jss = new JavaScriptSerializer(); Model.QQ.userinfo model = jss.Deserialize <Model.QQ.userinfo>(res); string where = "bind_qq_id='" + openid + "'"; //if (DT_id > 0) //{ // where += " and DT_id =" + DT_id + ""; //} Lebi_User user = B_Lebi_User.GetModel(where); Lebi_User CurrentUser = EX_User.CurrentUser(); if (CurrentUser.id > 0)//已经登录 { if (IsLogin == 0) { if (user != null) { if (CurrentUser.id != user.id) { return("已绑定其它帐号"); } } } CurrentUser.bind_qq_id = openid; CurrentUser.bind_qq_nickname = model.nickname; CurrentUser.bind_qq_token = access_token; if (CurrentUser.Face == "") { CurrentUser.Face = model.figureurl_qq_1;//头像 } CurrentUser.DT_id = DT_id; B_Lebi_User.Update(CurrentUser); } else { if (user == null) { Lebi_UserLevel defaultlevel = B_Lebi_UserLevel.GetModel("Grade>0 order by Grade asc"); if (defaultlevel == null) { defaultlevel = new Lebi_UserLevel(); } if (defaultlevel.RegisterType == 0) //关闭注册 { return("会员注册已关闭"); } user = new Lebi_User(); user.bind_qq_id = openid; user.bind_qq_nickname = model.nickname; user.bind_qq_token = access_token; user.Face = model.figureurl_qq_1;//头像 user.UserName = "******" + openid; user.NickName = model.nickname; user.Password = EX_User.MD5(openid); user.Language = Language.CurrentLanguage().Code; user.Sex = model.gender; user.UserLevel_id = B_Lebi_UserLevel.GetList("Grade>0", "Grade asc").FirstOrDefault().id; user.IsPlatformAccount = 1; if (CurrentSite != null) { user.Site_id = CurrentSite.id; } user.DT_id = DT_id; B_Lebi_User.Add(user); user.id = B_Lebi_User.GetMaxId(); EX_User.LoginOK(user); } else { user.bind_qq_id = openid; user.bind_qq_nickname = model.nickname; user.bind_qq_token = access_token; if (user.Face == "") { user.Face = model.figureurl_qq_1;//头像 } //user.Sex = model.gender; user.DT_id = DT_id; B_Lebi_User.Update(user); EX_User.LoginOK(user); } } return("OK"); } catch { return("授权失败"); } } return("授权失败"); }
private static int CreateModel(Dictionary <string, List <Dict> > dict) { var space = ConfigurationManager.AppSettings["modelnamespace"]; var modelsPath = ConfigurationManager.AppSettings["path"]; if (string.IsNullOrEmpty(space)) { space = "Default.Models"; } if (string.IsNullOrEmpty(modelsPath) || !BaseTool.IsValidPath(modelsPath)) { modelsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Models"); } if (!Directory.Exists(modelsPath)) { Directory.CreateDirectory(modelsPath); } var count = 0; foreach (var tableName in dict) { var sb = new StringBuilder(); var sb1 = new StringBuilder(); var className = string.Empty; if (tableName.Key.LastIndexOf('_') != -1) { foreach (var str in tableName.Key.Split('_')) { if (!string.IsNullOrEmpty(str)) { className += str.Substring(0, 1).ToUpper() + str.Substring(1).ToLower(); } } } else { className = tableName.Key.Substring(0, 1).ToUpper() + tableName.Key.Substring(1).ToLower(); } var firstLetter = className.Substring(0, 1); if (firstLetter != "_" && !RegexTool.IsLetter(firstLetter)) { className = $"_{className}"; } sb.Append("using System;\r\nusing System.ComponentModel.DataAnnotations;\r\nusing System.ComponentModel.DataAnnotations.Schema;\r\n\r\nnamespace "); sb.Append(space); sb.Append("\r\n{\r\n"); var columns = tableName.Value; if (columns.Count > 0) { sb.Append("\t/// <summary>\r\n"); sb.Append("\t/// ").Append(tableName.Value[0].表说明).Append("\r\n"); sb.Append("\t/// </summary>\r\n"); } sb.Append("\t[Table(\"").Append(tableName.Key).Append("\")]\r\n"); //数据标记 sb.Append("\tpublic class "); sb.Append(className); sb.Append("\r\n\t{\r\n"); sb.Append("\t\t#region Model\r\n"); var order = 0; foreach (var column in columns) { var propertieName = string.Empty; if (column.字段名.LastIndexOf('_') != -1) { foreach (var str in column.字段名.Split('_')) { if (!string.IsNullOrEmpty(str)) { propertieName += str.Substring(0, 1).ToUpper() + str.Substring(1).ToLower(); } } } else { propertieName = column.字段名.Substring(0, 1).ToUpper() + column.字段名.Substring(1).ToLower(); } if (propertieName == className) { propertieName = $"_{propertieName}"; } else { firstLetter = propertieName.Substring(0, 1); if (firstLetter != "_" && !RegexTool.IsLetter(firstLetter)) { propertieName = $"_{propertieName}"; if (propertieName == className) { propertieName = $"_{propertieName}"; } } } if (!string.IsNullOrEmpty(column.字段说明)) { sb.Append("\t\t/// <summary>\r\n"); sb.Append("\t\t/// ").Append(column.字段说明).Append("\r\n"); sb.Append("\t\t/// </summary>\r\n"); } if (!string.IsNullOrEmpty(column.主键)) { sb.Append("\t\t[Key, Column(\"").Append(column.字段名).Append("\", Order = ").Append(order).Append(")]\r\n"); order++; } else { sb.Append("\t\t[Column(\"").Append(column.字段名).Append("\")]\r\n"); //数据标记 } if (string.IsNullOrEmpty(column.类型)) { sb.Append("\t\tpublic string " + propertieName + "\r\n\t\t{\r\n"); } else { switch (column.类型.ToLower()) { case "tinyint": { sb.Append("\t\tpublic bool? " + propertieName + "\r\n\t\t{\r\n"); } break; case "smallint": { sb.Append("\t\tpublic short? " + propertieName + "\r\n\t\t{\r\n"); } break; case "int": { sb.Append("\t\tpublic int? " + propertieName + "\r\n\t\t{\r\n"); } break; case "bigint": { sb.Append("\t\tpublic long? " + propertieName + "\r\n\t\t{\r\n"); } break; case "decimal": { sb.Append("\t\tpublic decimal? " + propertieName + "\r\n\t\t{\r\n"); } break; case "timestamp": { sb.Append("\t\tpublic DateTime? " + propertieName + "\r\n\t\t{\r\n"); } break; case "datetime": { sb.Append("\t\tpublic DateTime? " + propertieName + "\r\n\t\t{\r\n"); } break; case "bit": { sb.Append("\t\tpublic bool " + propertieName + "\r\n\t\t{\r\n"); } break; case "money": { sb.Append("\t\tpublic decimal? " + propertieName + "\r\n\t\t{\r\n"); } break; case "image": { sb.Append("\t\tpublic string " + propertieName + "\r\n\t\t{\r\n"); } break; case "nvarchar": { sb.Append("\t\tpublic string " + propertieName + "\r\n\t\t{\r\n"); } break; case "varchar": { sb.Append("\t\tpublic string " + propertieName + "\r\n\t\t{\r\n"); } break; case "text": { sb.Append("\t\tpublic string " + propertieName + "\r\n\t\t{\r\n"); } break; default: { sb.Append("\t\tpublic string " + propertieName + "\r\n\t\t{\r\n"); } break; } } sb.Append("\t\t\tset;\r\n"); sb.Append("\t\t\tget;\r\n"); sb.Append("\t\t}\r\n"); sb.Append("\r\n"); sb1.Append(propertieName); sb1.Append("=\" + "); sb1.Append(propertieName); sb1.Append(" + \","); } if (sb1.Length >= 5) { sb1.Remove(sb1.Length - 5, 5); } sb.Append("\t\tpublic override string ToString()\r\n"); sb.Append("\t\t{\r\n"); sb.Append("\t\t\treturn \""); sb.Append(sb1); sb.Append(";"); sb.Append("\r\n"); sb.Append("\t\t}\r\n"); sb.Append("\t\t#endregion Model\r\n"); sb.Append("\t}\r\n").Append("}"); var filePath = Path.Combine(modelsPath, $"{className}.cs"); if (WriteFile(filePath, sb.ToString())) { count++; } } return(count); }
/// <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(); }