private void LoadBaseData() { XmlNode userNode = Content.GetSubControl("basedata")["currentuser"]; CommonXml.GetNode(userNode, "username").InnerText = CurrentUser; XmlNode groupNode = CommonXml.GetNode(userNode, "groups"); object[] resultsGroups = Plugins.InvokeAll("users", "list_groups", CurrentUser); List <string> userGroups = new List <string>(Common.Common.FlattenToStrings(resultsGroups)); foreach (string group in userGroups) { CommonXml.GetNode(groupNode, "group", EmptyNodeHandling.ForceCreateNew).InnerText = group; } ControlList baseData = Content.GetSubControl("basedata"); baseData["pageviewcount"].InnerText = PageViewCount().ToString(CultureInfo.InvariantCulture); baseData["defaultpage"].InnerText = Settings["sitetree/stdpage"]; foreach (string pageInHistory in History()) { XmlDocument ownerDocument = baseData["history"].OwnerDocument; if (ownerDocument != null) { XmlNode historyNode = ownerDocument.CreateElement("item"); historyNode.InnerText = pageInHistory; baseData["history"].AppendChild(historyNode); } } }
/// <summary> /// Pluginses the specified page. /// </summary> /// <param name="page">The page.</param> private void Plugins(Page page) { for (int i = 0; i < page.Containers.Count; i++) { for (int b = 0; b < page.Containers[i].Elements.Count; b++) { XmlNode xmlElementNode = page.Containers[i].Elements[b].Node; String plugin = CommonXml.GetNode(xmlElementNode, "plugin").InnerText; String action = CommonXml.GetNode(xmlElementNode, "action").InnerText; if (plugin != String.Empty & action != String.Empty) { String pathTrail = CommonXml.GetNode(xmlElementNode, "value").InnerText; AvailablePlugin availablePlugin = Process.Plugins.AvailablePlugins.Find(plugin); if (availablePlugin != null) { IPlugin2 plugin2 = availablePlugin.Instance as IPlugin2; if (plugin2 != null) { IPlugin2 iPlugin = availablePlugin.Instance as IPlugin2; iPlugin.Load(new ControlList(xmlElementNode), action, String.Empty, pathTrail); } else { IPlugin iPlugin = availablePlugin.Instance; iPlugin.Load(new ControlList(xmlElementNode), action, pathTrail); } } } } } }
private XmlNode GetControlNode(String name) { String xPath = String.Format("{0}", name); XmlNode node = CommonXml.GetNode(ParentNode, xPath); return(node); }
private void LoadCookies(ControlList control) { XmlItemList cookieData = new XmlItemList(CommonXml.GetNode(control.ParentNode, "items", EmptyNodeHandling.CreateNew)); foreach (String key in Process.HttpPage.Response.Cookies.Keys) { if (Process.Settings["general/cookies"].Contains("," + key + ",")) { HttpCookie httpCookie = Process.HttpPage.Response.Cookies[key]; if (httpCookie != null) { cookieData[key.Replace(".", String.Empty)] = HttpUtility.UrlEncode(httpCookie.Value); } } } foreach (String key in Process.HttpPage.Request.Cookies.Keys) { if (Process.Settings["general/cookies"].Contains("," + key + ",") && String.IsNullOrEmpty(cookieData[key.Replace(".", String.Empty)])) { HttpCookie httpCookie = Process.HttpPage.Request.Cookies[key]; if (httpCookie != null) { cookieData[key.Replace(".", String.Empty)] = HttpUtility.UrlEncode(httpCookie.Value); } } } }
public void GetXml(XmlNode xmlNode, SubFolder subFolder) { XmlNode folderNode = CommonXml.GetNode(xmlNode, "folder", EmptyNodeHandling.ForceCreateNew); CommonXml.SetAttributeValue(folderNode, "name", Name); foreach (FileInfo fileInfo in _directoryInfo.GetFiles()) { XmlNode fileNode = CommonXml.GetNode(folderNode, "file", EmptyNodeHandling.ForceCreateNew); CommonXml.SetAttributeValue(fileNode, "name", fileInfo.Name); CommonXml.SetAttributeValue(fileNode, "extension", fileInfo.Extension); GetFileAttributes(fileNode, fileInfo.Name); } if (subFolder == SubFolder.IncludeSubfolders) { foreach (DirectoryInfo directoryInfo in _directoryInfo.GetDirectories()) { if (Filter(directoryInfo.Name)) { FolderElement folderElement = new FolderElement(directoryInfo.FullName); folderElement.GetXml(folderNode, SubFolder.IncludeSubfolders); } } } }
public Users(Process.Process process) { _userFileName = process.Settings["users/filename"]; _userDocument = new XmlDocument(); _userDocument.Load(_userFileName); _userList = new UserList(CommonXml.GetNode(_userDocument.DocumentElement, "users")); _groupList = new GroupList(CommonXml.GetNode(_userDocument.DocumentElement, "groups")); }
public bool CheckPassword(String password) { String pwd1 = CommonXml.GetNode(Node, "password").InnerText; String pwd2 = Common.Common.CleanToSafeString(password).GetHashCode().ToString(CultureInfo.InvariantCulture); bool isValid = pwd1.Equals(pwd2); return(isValid); }
public Page(XmlNode pageNode, XmlNode treeNode, SiteTree siteTree) : base(pageNode) { _treeNode = treeNode; _siteTree = siteTree; CopyInfoFromTree(); _containers = new ContainerList(CommonXml.GetNode(Node, "containers")); }
public void AddMessage(string message, MessageType messageType, string type) { XmlNode xmlNode = CommonXml.GetNode(XmlData.DocumentElement, "messages", EmptyNodeHandling.CreateNew); xmlNode = CommonXml.GetNode(xmlNode, "item", EmptyNodeHandling.ForceCreateNew); xmlNode.InnerText = message; CommonXml.SetAttributeValue(xmlNode, "messagetype", messageType.ToString()); CommonXml.SetAttributeValue(xmlNode, "type", type); }
/// <summary> /// Creates the file. /// </summary> /// <param name="path">The path.</param> /// <param name="name">The name.</param> /// <param name="menuName">Name of the menu.</param> private void CreateFile(string path, string name, string menuName) { string fileDirectory = GetDocumentDirectory(path); string filename = GetDocumentFilename(path, name); Directory.CreateDirectory(fileDirectory); XmlDocument document = new XmlDocument(); CommonXml.GetNode(document, "page/attributes/pagename", EmptyNodeHandling.CreateNew).InnerText = menuName; CommonXml.SaveXmlDocument(filename, document); }
private void HandleLog() { XmlNode messagesNode = CommonXml.GetNode(Process.XmlData, "messages", EmptyNodeHandling.Ignore); if (messagesNode == null) { return; } String logFileName = Process.Settings["errorlog/logpath"]; XmlNodeList items = messagesNode.SelectNodes("item"); if (items != null) { foreach (XmlNode item in items) { bool writtenToLogFile = false; try { if (CommonXml.GetAttributeValue(item, "writtenToLogFile") == "true") { writtenToLogFile = true; } } catch { writtenToLogFile = false; } if (writtenToLogFile) { continue; } if (CommonXml.GetAttributeValue(item, "messagetype") != "Error") { continue; } String errorType = CommonXml.GetAttributeValue(item, "type"); String message = item.InnerText; File.AppendAllText(logFileName, String.Format("{0};{1};{2}\r\n", DateTime.Now.ToUniversalTime(), errorType, message)); CommonXml.SetAttributeValue(item, "writtenToLogFile", "true"); } } }
private void AddMessage(String message, MessageType messageType, String type) { XmlNode xmlNode = CommonXml.GetNode(XmlData.DocumentElement, "messages", EmptyNodeHandling.CreateNew); xmlNode = CommonXml.GetNode(xmlNode, "item", EmptyNodeHandling.ForceCreateNew); xmlNode.InnerText = message; CommonXml.SetAttributeValue(xmlNode, "messagetype", messageType.ToString()); CommonXml.SetAttributeValue(xmlNode, "type", type); IPlugin plugin = Plugins["ErrorLog"]; if (plugin != null) { plugin.Handle("log"); } }
private string this[string path, RelativePathHandling relativePathHandling] { get { XmlNode settingsNode = CommonXml.GetNode(_combinedSettings.SelectSingleNode("settings"), path, EmptyNodeHandling.CreateNew); string value = settingsNode.InnerText; return(relativePathHandling == RelativePathHandling.ConvertToAbsolute ? ConvertPath(value) : value); } set { CommonXml.GetNode(_customSettings.SelectSingleNode("settings"), path, EmptyNodeHandling.CreateNew).InnerText = value; CommonXml.GetNode(_combinedSettings.SelectSingleNode("settings"), path, EmptyNodeHandling.CreateNew).InnerText = value; Save(); } }
/// <summary> /// Sets the current page. /// </summary> /// <param name="xmlNode">The XML node.</param> /// <param name="pathArray">The path.</param> private static void SetCurrentPage(XmlNode xmlNode, String[] pathArray) { try { XmlNode currentNode = xmlNode; for (int i = 0; i < pathArray.Length; i++) { String path = pathArray[i]; currentNode = CommonXml.GetNode(currentNode, path, EmptyNodeHandling.Ignore); CommonXml.SetAttributeValue(currentNode, "inpath", "true"); if (i + 1 == pathArray.Length) { CommonXml.SetAttributeValue(currentNode, "currentpage", "true"); } } } catch { } }
public XmlNode GetAsNode(string path) { XmlNode xmlNode = CommonXml.GetNode(_combinedSettings.SelectSingleNode("settings"), path); return(xmlNode); }
public bool CheckPassword(string password) { return(CommonXml.GetNode(Node, "password").InnerText == Common.CleanToSafeString(password).GetHashCode().ToString()); }
public Container(XmlNode node) : base(node) { XmlNode elementNode = CommonXml.GetNode(Node, "elements", EmptyNodeHandling.CreateNew); Elements = new ElementList(elementNode); }
public Process(Page httpPage, PluginServices pluginServices) { Plugins = pluginServices; HttpPage = httpPage; XmlData = new XmlDocument(); Plugins.FindPlugins(this, Common.Common.CombinePaths(Root, "Bin")); XmlNode xmlNode = XmlData.CreateElement("data"); XmlData.AppendChild(xmlNode); Content = new ControlList(xmlNode); if (httpPage.Request.ApplicationPath != null) { if (httpPage.Request.ServerVariables["SERVER_PORT"] == "80") { _basePath = httpPage.Request.ServerVariables["SERVER_PROTOCOL"].Split('/')[0].ToLower() + "://" + httpPage.Request.ServerVariables["SERVER_NAME"] + httpPage.Request.ApplicationPath.TrimEnd('/') + string.Empty; } else { _basePath = httpPage.Request.ServerVariables["SERVER_PROTOCOL"].Split('/')[0].ToLower() + "://" + httpPage.Request.ServerVariables["SERVER_NAME"] + ":" + httpPage.Request.ServerVariables["SERVER_PORT"] + httpPage.Request.ApplicationPath.TrimEnd('/') + string.Empty; } } Content["basepath"].InnerText = _basePath; Content["referrer"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_REFERER"]); Content["domain"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["SERVER_NAME"]); Content["useragent"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_USER_AGENT"]); Content["sessionid"].InnerText = httpPage.Server.UrlEncode(httpPage.Session.LCID.ToString(CultureInfo.InvariantCulture)); Content["ip"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["REMOTE_ADDR"]); Attributes = new XmlItemList(CommonXml.GetNode(xmlNode, "attributes", EmptyNodeHandling.CreateNew)); QueryData = new XmlItemList(CommonXml.GetNode(xmlNode, "query/data", EmptyNodeHandling.CreateNew)); QueryEvents = new XmlItemList(CommonXml.GetNode(xmlNode, "query/events", EmptyNodeHandling.CreateNew)); QueryOther = new XmlItemList(CommonXml.GetNode(xmlNode, "query/other", EmptyNodeHandling.CreateNew)); ProcessQueries(); ConfigureDebugging(); LoginByCookie(); if (QueryEvents["main"] == "login") { if (!Login(QueryData["login"], QueryData["password"])) { if (_settings != null && _settings["messages/loginerror"] != string.Empty) { httpPage.Response.Redirect(GetErrorUrl(httpPage.Server.UrlEncode(_settings["messages/loginerror"]))); } else { httpPage.Response.Redirect(GetRedirectUrl()); } } } else if (QueryEvents["main"] == "logout") { Logout(); if (QueryEvents["mainValue"] != string.Empty) { HttpPage.Response.Redirect(QueryEvents["mainValue"]); } } UpdateCookieTimeout(); LoadBaseData(); // loads new user... }
public Process(System.Web.UI.Page httpPage, PluginServices pluginServices) { Plugins = pluginServices; HttpPage = httpPage; XmlData = new XmlDocument(); Plugins.FindPlugins(this, Common.CombinePaths(Root, "Bin")); XmlNode xmlNode = XmlData.CreateElement("data"); XmlData.AppendChild(xmlNode); Content = new ControlList(xmlNode); m_BasePath = httpPage.Request.ServerVariables["SERVER_PROTOCOL"].Split('/')[0].ToLower() + "://" + httpPage.Request.ServerVariables["SERVER_NAME"] + ":" + httpPage.Request.ServerVariables["SERVER_PORT"] + httpPage.Request.ApplicationPath.TrimEnd('/') + ""; Content["basepath"].InnerText = m_BasePath; Content["referrer"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_REFERER"]); Content["domain"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["SERVER_NAME"]); Content["useragent"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_USER_AGENT"]); Content["sessionid"].InnerText = httpPage.Server.UrlEncode(httpPage.Session.LCID.ToString()); Content["ip"].InnerText = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["REMOTE_ADDR"]); QueryData = new XmlItemList(CommonXml.GetNode(xmlNode, "query/data", EmptyNodeHandling.CreateNew)); Attributes = new XmlItemList(CommonXml.GetNode(xmlNode, "attributes", EmptyNodeHandling.CreateNew)); QueryEvents = new XmlItemList(CommonXml.GetNode(xmlNode, "query/events", EmptyNodeHandling.CreateNew)); QueryOther = new XmlItemList(CommonXml.GetNode(xmlNode, "query/other", EmptyNodeHandling.CreateNew)); processQueries(); ConfigureDebugging(); CookieLoginDuringProcessInit(httpPage); LoadBaseData(); // loads new user... if (this.QueryEvents["main"] == "login") { if (!Login(QueryData["login"], QueryData["password"])) { if (m_Settings["messages/loginerror"] != string.Empty) { httpPage.Response.Redirect(BasePath + "/login.aspx?error=" + httpPage.Server.UrlEncode(m_Settings["messages/loginerror"])); } else { httpPage.Response.Redirect(BasePath + "/login.aspx"); } } else { SetLoginCookie(httpPage); // Set session timeout to 3 hours httpPage.Session.Timeout = 180; } } else if (this.QueryEvents["main"] == "logout") { System.Web.HttpCookie loginCookie = new System.Web.HttpCookie("login_cookie", ""); httpPage.Response.SetCookie(loginCookie); Logout(); } }
public User(XmlNode node) : base(node) { _groupList = new GroupList(CommonXml.GetNode(node, "groups")); }
/// <summary> /// Handles the save. /// </summary> private void HandleSave() { String elementName = String.Empty; Page currentPage = new SiteTree(Process).GetPage(Process.QueryData["pageidentifier"]); for (int i = 0; i < Process.QueryData.Count; i++) { Query query = Process.QueryData[i]; String[] queryParts = query.Name.Split('_'); if (queryParts.Length > 1) { switch (queryParts[0]) { case "attribute": if (queryParts[1].EndsWith("-list")) { XmlNode xmlNode = currentPage.GetAttribute(queryParts[1]); xmlNode.InnerText = String.Empty; foreach (String tmpString in query.Value.Split('\n')) { CommonXml.GetNode(xmlNode, "item", EmptyNodeHandling.ForceCreateNew).InnerText = tmpString; } } else { currentPage[queryParts[1]] = query.Value; } break; case "element": Container container = currentPage.Containers[int.Parse(queryParts[1]) - 1]; if (queryParts[3].EndsWith("-list")) { XmlNode xmlNode = CommonXml.GetNode(container.Elements[int.Parse(queryParts[2]) - 1].Node, queryParts[3]); xmlNode.InnerText = String.Empty; foreach (String tmpString in query.Value.Split('\n')) { if (tmpString != String.Empty) { XmlNode tmpNode = CommonXml.GetNode(xmlNode, "item", EmptyNodeHandling.ForceCreateNew); tmpNode.InnerText = tmpString; CommonXml.AppendAttribute(tmpNode, "id", Common.CleanToSafeString(tmpString)); } } } else { if (elementName != query.Name.Substring(0, query.Name.LastIndexOf('_'))) { elementName = query.Name.Substring(0, query.Name.LastIndexOf('_')); container.Elements[int.Parse(queryParts[2]) - 1].Publish = false.ToString(CultureInfo.InvariantCulture).ToLower(); } if (query.Name.EndsWith("elementtitle")) { container.Elements[int.Parse(queryParts[2]) - 1].Name = query.Value; } else if (query.Name.EndsWith("elementpublish")) { container.Elements[int.Parse(queryParts[2]) - 1].Publish = query.Value.ToLower() == "publish" ? true.ToString(CultureInfo.InvariantCulture).ToLower() : false.ToString(CultureInfo.InvariantCulture).ToLower(); } else { container.Elements[int.Parse(queryParts[2]) - 1][queryParts[3]] = query.Value; } } break; } } } currentPage.Save(); }
public bool CheckPassword(string password) { bool validPassword = CommonXml.GetNode(Node, "password").InnerText == Common.Common.CleanToSafeString(password).GetHashCode().ToString(CultureInfo.InvariantCulture); return(validPassword); }
/// <summary> /// Gets the page node. /// </summary> /// <param name="path">The path.</param> /// <returns></returns> private XmlNode GetPageNode(string path) { XmlNode pageNode = CommonXml.GetNode(_treeDocument, path, EmptyNodeHandling.Ignore); return(pageNode); }
public Process(Page httpPage, PluginServices pluginServices) { _currentProcess = String.Empty; Plugins = pluginServices; HttpPage = httpPage; XmlData = new XmlDocument(); Plugins.FindPlugins(this, Common.Common.CombinePaths(Root, "Bin")); XmlNode xmlNode = XmlData.CreateElement("data"); XmlData.AppendChild(xmlNode); Content = new ControlList(xmlNode); _basePath = GetBasePath(httpPage); Content["basepath"].InnerText = _basePath; String referrer = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_REFERER"]); Content["referrer"].InnerText = referrer ?? String.Empty; String domain = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["SERVER_NAME"]); Content["domain"].InnerText = domain ?? String.Empty; String useragent = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["HTTP_USER_AGENT"]); Content["useragent"].InnerText = useragent ?? String.Empty; String sessionid = httpPage.Server.UrlEncode(httpPage.Session.LCID.ToString(CultureInfo.InvariantCulture)); Content["sessionid"].InnerText = sessionid ?? String.Empty; String ip = httpPage.Server.UrlEncode(httpPage.Request.ServerVariables["REMOTE_ADDR"]); Content["ip"].InnerText = ip ?? String.Empty; Attributes = new XmlItemList(CommonXml.GetNode(xmlNode, "attributes", EmptyNodeHandling.CreateNew)); QueryData = new XmlItemList(CommonXml.GetNode(xmlNode, "query/data", EmptyNodeHandling.CreateNew)); QueryEvents = new XmlItemList(CommonXml.GetNode(xmlNode, "query/events", EmptyNodeHandling.CreateNew)); QueryOther = new XmlItemList(CommonXml.GetNode(xmlNode, "query/other", EmptyNodeHandling.CreateNew)); ProcessQueries(); ConfigureDebugging(); LoginByCookie(); String mainEvent = QueryEvents["main"]; String mainEventValue = QueryEvents["mainValue"]; if (mainEvent == "login") { if (!Login(QueryData["login"], QueryData["password"])) { if (_settings != null && _settings["messages/loginerror"] != String.Empty) { httpPage.Response.Redirect(GetErrorUrl(httpPage.Server.UrlEncode(_settings["messages/loginerror"]))); } else { httpPage.Response.Redirect(GetRedirectUrl()); } } } else if (mainEvent == "logout") { Logout(); if (mainEventValue != String.Empty) { HttpPage.Response.Redirect(mainEventValue); } } else if (mainEvent == String.Empty) { if (mainEventValue != String.Empty) { HttpPage.Response.Redirect("/"); } } UpdateCookieTimeout(); LoadBaseData(); // loads new user... }
protected XmlNode GetNode(string cleanPath, EmptyNodeHandling emptyNode) { XmlNode xmlNode = CommonXml.GetNode(_parentNode, cleanPath, emptyNode); return(xmlNode); }