public static List <SiteConfig> GetMapSiteList() { List <SiteConfig> list = new List <SiteConfig>(); string mapPath = FPFile.GetMapPath(WebConfig.WebPath + "sites"); if (Directory.Exists(mapPath)) { DirectoryInfo[] directories = new DirectoryInfo(mapPath).GetDirectories(); foreach (DirectoryInfo directoryInfo in directories) { if (File.Exists(directoryInfo.FullName + "\\site.config") && directoryInfo.Name.ToLower() != "app" && directoryInfo.Name.ToLower() != "plugins") { SiteConfig siteConfig = FPSerializer.Load <SiteConfig>(directoryInfo.FullName + "\\site.config"); siteConfig.sitepath = directoryInfo.Name; string mapPath2 = FPFile.GetMapPath(WebConfig.WebPath + directoryInfo.Name); if (Directory.Exists(mapPath2)) { siteConfig.size = FPFile.FormatBytesStr(FPFile.GetDirSize(mapPath2)); } else { siteConfig.size = FPFile.FormatBytesStr(FPFile.GetDirSize(directoryInfo.FullName)); } list.Add(siteConfig); } } } return(list); }
public static SiteConfig LoadSiteConfig(string sitepath) { SiteConfig siteConfig = new SiteConfig(); if (sitepath.ToLower() == "app") { siteConfig.name = "系统应用"; siteConfig.sitepath = "app"; siteConfig.version = "1.0.0"; siteConfig.urltype = 0; } else if (sitepath.ToLower() == "plugins") { siteConfig.name = "系统插件"; siteConfig.sitepath = "plugins"; siteConfig.version = "1.0.0"; siteConfig.urltype = 0; } else if (File.Exists(FPFile.GetMapPath(WebConfig.WebPath + "sites/" + sitepath + "/site.config"))) { siteConfig = FPSerializer.Load <SiteConfig>(FPFile.GetMapPath(WebConfig.WebPath + "sites/" + sitepath + "/site.config")); } else if (File.Exists(FPFile.GetMapPath(WebConfig.WebPath + sitepath + "/site.config"))) { siteConfig = FPSerializer.Load <SiteConfig>(FPFile.GetMapPath(WebConfig.WebPath + sitepath + "/site.config")); } else if (File.Exists(FPFile.GetMapPath(WebConfig.WebPath + "/site.config"))) { siteConfig = FPSerializer.Load <SiteConfig>(FPFile.GetMapPath(WebConfig.WebPath + "/site.config")); } return(siteConfig); }
public static void Log(string logfile, object obj) { if (obj != null) { FPFile.AppendFile(FPFile.GetMapPath(WebConfig.WebPath + "log/" + logfile), obj.ToString()); } }
public static void SaveViewConfig(List <ViewConfig> viewlist) { string mapPath = FPFile.GetMapPath(WebConfig.WebPath + "config/view.config"); FPXml.SaveXml(viewlist, mapPath); FPCache.Remove("FP_VIEWLIST"); }
public static SiteConfig GetMapSiteConfig(string sitepath) { SiteConfig result = new SiteConfig(); string mapPath = FPFile.GetMapPath(WebConfig.WebPath + "sites/" + sitepath + "/site.config"); if (File.Exists(mapPath)) { result = FPSerializer.Load <SiteConfig>(mapPath); } return(result); }
public static string GetThumbnail(string imgpath, int maxsize) { int num = maxsize; if (num <= 0) { num = 600; } string text = FPFile.GetMapPath(WebConfig.WebPath) + imgpath; if (!File.Exists(text)) { return(""); } string fileName = Path.GetFileName(imgpath); string text2 = Path.GetExtension(imgpath).ToLower(); switch (text2) { case ".jpg": case ".bmp": case ".png": { fileName = Path.GetFileNameWithoutExtension(imgpath); string text3 = $"{WebConfig.WebPath}cache/thumbnail/{fileName}_{num}{text2}"; string mapPath = FPFile.GetMapPath(text3); if (!File.Exists(mapPath)) { string mapPath2 = FPFile.GetMapPath(WebConfig.WebPath + "cache/thumbnail/"); if (!Directory.Exists(mapPath2)) { try { Directory.CreateDirectory(mapPath2); } catch { throw new Exception("请检查程序目录下cache文件夹的用户权限!"); } } CreateThumbnail(mapPath, text, num); } return(text3); } case ".gif": return(imgpath); default: return(""); } }
public bool SetImage(string FileName) { srcFileName = FPFile.GetMapPath(FileName); try { srcImage = Image.FromFile(srcFileName); } catch { return(false); } return(true); }
public static void ReSetViewConfig() { List <ViewConfig> viewList = GetViewList(); for (int num = viewList.Count - 1; num >= 0; num--) { if (!File.Exists(FPFile.GetMapPath(WebConfig.WebPath + viewList[num].path))) { viewList.RemoveAt(num); } } SaveViewConfig(viewList); }
public static List <ViewConfig> GetViewList() { object obj = FPCache.Get("FP_VIEWLIST"); List <ViewConfig> list = new List <ViewConfig>(); if (obj != null) { list = (obj as List <ViewConfig>); } else { string mapPath = FPFile.GetMapPath(WebConfig.WebPath + "config/view.config"); list = FPXml.LoadList <ViewConfig>(mapPath); FPCache.Insert("FP_VIEWLIST", list, mapPath); } return(list); }
public static List <SiteConfig> GetSysSiteList() { List <SiteConfig> list = new List <SiteConfig>(); string mapPath = FPFile.GetMapPath(WebConfig.WebPath); if (Directory.Exists(mapPath)) { DirectoryInfo[] directories = new DirectoryInfo(mapPath).GetDirectories(); foreach (DirectoryInfo directoryInfo in directories) { if (File.Exists(directoryInfo.FullName + "\\site.config")) { SiteConfig siteConfig = FPSerializer.Load <SiteConfig>(directoryInfo.FullName + "\\site.config"); siteConfig.sitepath = directoryInfo.Name; list.Add(siteConfig); } } } return(list); }
public static void SaveViewConfig(ViewConfig viewconfig) { bool flag = false; List <ViewConfig> viewList = GetViewList(); for (int i = 0; i < viewList.Count; i++) { if (viewList[i].path.ToLower() == viewconfig.path.ToLower()) { viewList[i].include = viewconfig.include; flag = true; } } if (!flag) { viewList.Add(viewconfig); } string mapPath = FPFile.GetMapPath(WebConfig.WebPath + "config/view.config"); FPXml.SaveXml(viewList, mapPath); FPCache.Remove("FP_VIEWLIST"); }
public static void SaveSiteConfig(SiteConfig siteconfig) { string mapPath = FPFile.GetMapPath(WebConfig.WebPath + "sites/" + siteconfig.sitepath + "/site.config"); SaveSiteConfig(siteconfig, mapPath); }
public FPController() { port = FPArray.SplitInt(domain, ":", 2)[1]; if (rawurl.IndexOf("/") >= 0) { if (rawurl.IndexOf("?") >= 0) { rawpath = rawurl.Substring(0, rawurl.IndexOf("?")); rawpath = rawpath.Substring(0, rawpath.LastIndexOf("/")) + "/"; } else { rawpath = rawurl.Substring(0, rawurl.LastIndexOf("/")) + "/"; } } else { rawpath = webpath; } cururl = rawurl.Substring(webpath.Length); pageurl = pagename; if (cururl.Contains("?")) { curname = cururl.Substring(0, cururl.IndexOf("?")); query = cururl.Substring(cururl.IndexOf("?") + 1); pageurl = pagename + "?" + query; } else { curname = cururl; } if (curname.IndexOf("/") > 0) { curpath = curname.Substring(0, curname.LastIndexOf("/")) + "/"; } if (curname.IndexOf("/") >= 0) { sitepath = curname.Substring(0, curname.IndexOf("/")); } else { sitepath = WebConfig.SitePath; } if (sitepath == "sites") { sitepath = curpath.Substring(curpath.IndexOf("/") + 1).TrimEnd('/'); } if (!Directory.Exists(FPFile.GetMapPath(webpath + sitepath))) { sitepath = WebConfig.SitePath; } pagepath = webpath + sitepath + "/"; siteinfo = SiteConfigs.GetSiteInfo(sitepath); adminpath = webpath + "admin/"; plupath = webpath + "plugins/"; apppath = webpath + "app/"; sitetitle = siteinfo.sitetitle; pagetitle = siteinfo.sitetitle; CreateSeoInfo(siteinfo.keywords, siteinfo.description, siteinfo.otherhead); ispost = FPRequest.IsPost(); isget = FPRequest.IsGet(); isfile = FPRequest.IsPostFile(); action = FPRequest.GetString("action"); op = FPRequest.GetInt("op"); try { ua = HttpContext.Current.Request.UserAgent.ToLower(); } catch { } browser = getBrowserName(ua, out isie); args = FPArray.SplitString(Path.GetFileNameWithoutExtension(pagename), "-"); }