Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
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));
                        var         plugin2   = provider as IPlugin2;
                        if (plugin2 != null)
                        {
                            plugin2.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;
                    }
                }
            }
        }
        public ControlList GetSubControl(String name)
        {
            ControlList subControl = name != String.Empty ? new ControlList(GetControlNode(name)) : null;

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