Esempio n. 1
0
        private void HandlePlugin(XmlNode contentNode, string[] args, Process process)
        {
            if (contentNode.Attributes != null)
            {
                IPlugin provider = GetProvider(contentNode.Attributes["provider"].Value);
                if (provider != null)
                {
                    switch (contentNode.Name)
                    {
                    case "load":
                        ControlList control   = process.Content.GetSubControl(CommonXml.GetAttributeValue(contentNode, "place"));
                        string      action    = CommonXml.GetAttributeValue(contentNode, "action");
                        string      value     = GetValue(contentNode, process);
                        string      pathTrail = JoinPath(Common.Common.RemoveOne(args));
                        if (provider is IPlugin2)
                        {
                            ((IPlugin2)provider).Load(control, action, value, pathTrail);
                        }
                        else
                        {
                            provider.Load(control, action, pathTrail);
                        }
                        break;

                    case "handle":
                        string mainEvent = process.QueryEvents["main"];
                        if (mainEvent != string.Empty)
                        {
                            provider.Handle(mainEvent);
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 2
0
        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);
                }
            }
        }
Esempio n. 3
0
        public ControlList GetSubControl(string name)
        {
            ControlList subControl = name != string.Empty ? new ControlList(GetControlNode(name)) : null;

            return(subControl);
        }
Esempio n. 4
0
        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...
        }