示例#1
0
        void OnLoadRequestedPath(HttpApplication app, string path, string[] pathSections, HandleFlag handled)
        {
            if (pathSections.Length == 0)
            {
                return;
            }
            if (pathSections[0] != "admin")
            {
                return;
            }
            bool   processed = false;
            string lastchunk = pathSections[pathSections.Length - 1];

            switch (lastchunk)
            {
            case "admin.css":
                HttpContext.Current.Response.TransmitFile("~/resources/admin/admin.css");
                HttpContext.Current.Response.ContentType = "text/css";
                processed = true;
                break;

            default:
                WebAuthentication auth     = WebAuthentication.Instance;
                HttpResponse      Response = HttpContext.Current.Response;
                HttpServerUtility Server   = HttpContext.Current.Server;
                switch (path)
                {
                case "admin/login":
                    ShowLoginScreen();
                    processed = true;
                    break;

                case "admin/logout":
                    auth.ClearAuthenticationCookie();
                    Response.Redirect(WebUtility.MakeFullPath("admin/login"));
                    processed = true;
                    break;

                case "admin/login/process":
                    if (auth.ProcessLoginForm("SprocketUsername", "SprocketPassword", "SprocketPreserveLogin"))
                    {
                        Response.Redirect(WebUtility.MakeFullPath("admin"));
                    }
                    else
                    {
                        ShowLoginScreen("Invalid Username and/or Password.");
                    }
                    processed = true;
                    break;

                default:
                    if (!auth.IsLoggedIn)
                    {
                        GotoLoginScreen();
                        processed = true;
                    }
                    else if (OnCMSAdminAuthenticationSuccess != null)
                    {
                        Result result = new Result();
                        OnCMSAdminAuthenticationSuccess(auth.CurrentUsername, result);
                        if (!result.Succeeded)
                        {
                            ShowLoginScreen(result.Message);
                            processed = true;
                        }
                    }
                    break;
                }
                break;
            }
            if (processed)
            {
                handled.Set();
                return;
            }

            if (OnAdminRequest != null)
            {
                AdminInterface admin = new AdminInterface();
                OnAdminRequest(admin, path, pathSections, handled);
                if (handled.Handled)
                {
                    WebClientScripts scripts = WebClientScripts.Instance;
                    admin.AddMainMenuLink(new AdminMenuLink("Current Overview", WebUtility.MakeFullPath("admin"), -100));
                    admin.AddMainMenuLink(new AdminMenuLink("Log Out", WebUtility.MakeFullPath("admin/logout"), 100));
                    admin.AddFooterLink(new AdminMenuLink("© 2005-" + DateTime.Now.Year + " " + SprocketSettings.GetValue("WebsiteName"), "", 100));
                    string powered = SprocketSettings.GetValue("ShowPoweredBySprocket");
                    if (powered != null)
                    {
                        if (StringUtilities.MatchesAny(powered.ToLower(), "true", "yes"))
                        {
                            admin.AddFooterLink(new AdminMenuLink("Powered by Sprocket", "http://www.sprocketcms.com", 1000));
                        }
                    }
                    admin.AddHeadSection(new RankedString(scripts.BuildStandardScriptsBlock(), 1));
                    HttpContext.Current.Response.Write(admin.Render(path));
                }
            }
        }
示例#2
0
        void WebEvents_OnLoadRequestedPath(HandleFlag handled)
        {
            if (handled.Handled)
            {
                return;
            }
            if (!IsAdminRequest)
            {
                return;
            }

            PageEntry page = pages.FromPath(SprocketPath.Value);

            if (page == null)
            {
                return;
            }

            KeyValuePair <string, object>[] vars;
            if (!SprocketPath.StartsWith("admin", "login"))
            {
                if (!WebAuthentication.VerifyAccess(PermissionType.AccessAdminArea))
                {
                    WebUtility.Redirect("admin/login");
                    return;
                }

                AdminInterface   admin   = new AdminInterface();
                WebClientScripts scripts = WebClientScripts.Instance;
                admin.AddMainMenuLink(new AdminMenuLink("Website Home", WebUtility.MakeFullPath(""), ObjectRank.Last, "website_home"));
                admin.AddMainMenuLink(new AdminMenuLink("Overview", WebUtility.MakeFullPath("admin"), ObjectRank.First, "website_overview"));
                admin.AddMainMenuLink(new AdminMenuLink("Log Out", WebUtility.MakeFullPath("admin/logout"), ObjectRank.Last, "log_out"));

                admin.AddFooterLink(new AdminMenuLink("Log Out", WebUtility.MakeFullPath("admin/logout"), ObjectRank.Early));
                admin.AddFooterLink(new AdminMenuLink("&copy; 2005-" + DateTime.UtcNow.Year + " " + SprocketSettings.GetValue("WebsiteName"), "", ObjectRank.Late));
                admin.AddFooterLink(new AdminMenuLink("Powered by Sprocket", "http://www.sprocketcms.com", ObjectRank.Last));
                admin.AddHeadSection(new AdminSection(scripts.BuildStandardScriptsBlock(), ObjectRank.Late));
                admin.WebsiteName = GetWebsiteName();

                if (OnLoadAdminPage != null)
                {
                    OnLoadAdminPage(admin, page, handled);
                    if (handled.Handled)
                    {
                        return;
                    }
                }

                vars = admin.GetScriptVariables();
            }
            else
            {
                vars    = new KeyValuePair <string, object> [1];
                vars[0] = new KeyValuePair <string, object>("_admin_websitename", GetWebsiteName());
            }

            ContentManager.RequestedPage = page;
            if (pagePreProcessors.ContainsKey(page.PageCode))
            {
                foreach (PagePreprocessorHandler method in pagePreProcessors[page.PageCode])
                {
                    method(page);
                }
            }
            string txt = page.Render(vars);

            Response.ContentType = page.ContentType;
            Response.Write(txt);
            handled.Set();
        }
		void OnLoadRequestedPath(HandleFlag handled)
		{
			if (SprocketPath.Sections.Length == 0) return;
			if (SprocketPath.Sections[0] != "admin") return;
			bool processed = false;
			string lastchunk = SprocketPath.Sections[SprocketPath.Sections.Length - 1];

			switch(lastchunk)
			{
				case "admin.css":
					HttpContext.Current.Response.TransmitFile("~/resources/admin/admin.css");
					HttpContext.Current.Response.ContentType = "text/css";
					processed = true;
					break;

				default:
					WebAuthentication auth = WebAuthentication.Instance;
					HttpResponse Response = HttpContext.Current.Response;
					HttpServerUtility Server = HttpContext.Current.Server;
					switch (SprocketPath.Value)
					{
						case "admin/login":
							ShowLoginScreen();
							processed = true;
							break;

						case "admin/logout":
							auth.ClearAuthenticationCookie();
							Response.Redirect(WebUtility.MakeFullPath("admin/login"));
							processed = true;
							break;

						case "admin/login/process":
							if (auth.ProcessLoginForm("SprocketUsername", "SprocketPassword", "SprocketPreserveLogin"))
								Response.Redirect(WebUtility.MakeFullPath("admin"));
							else
								ShowLoginScreen("Invalid Username and/or Password.");
							processed = true;
							break;

						default:
							if (!auth.IsLoggedIn)
							{
								GotoLoginScreen();
								processed = true;
							}
							else if (OnCMSAdminAuthenticationSuccess != null)
							{
								Result result = new Result();
								OnCMSAdminAuthenticationSuccess(auth.CurrentUsername, result);
								if (!result.Succeeded)
								{
									ShowLoginScreen(result.Message);
									processed = true;
								}
							}
							break;
					}
					break;
			}
			if (processed)
			{
				handled.Set();
				return;
			}

			if (OnAdminRequest != null)
			{
				AdminInterface admin = new AdminInterface();
				OnAdminRequest(admin, handled);
				if (handled.Handled)
				{
					WebClientScripts scripts = WebClientScripts.Instance;
					admin.AddMainMenuLink(new AdminMenuLink("Administrative Tasks", WebUtility.MakeFullPath("admin"), -100));
					admin.AddMainMenuLink(new AdminMenuLink("Log Out", WebUtility.MakeFullPath("admin/logout"), 100));
					admin.AddFooterLink(new AdminMenuLink("&copy; 2005-" + SprocketDate.Now.Year + " " + SprocketSettings.GetValue("WebsiteName"), "", 100));
					string powered = SprocketSettings.GetValue("ShowPoweredBySprocket");
					if(powered != null)
						if(StringUtilities.MatchesAny(powered.ToLower(), "true", "yes"))
							admin.AddFooterLink(new AdminMenuLink("Powered by Sprocket", "http://www.sprocketcms.com", 1000));
					admin.AddHeadSection(new RankedString(scripts.BuildStandardScriptsBlock(), 1));
					HttpContext.Current.Response.Write(admin.Render());
				}
			}
		}
示例#4
0
        void WebEvents_OnLoadRequestedPath(HandleFlag handled)
        {
            if (handled.Handled) return;
            if (!IsAdminRequest) return;

            PageEntry page = pages.FromPath(SprocketPath.Value);
            if (page == null)
                return;

            KeyValuePair<string, object>[] vars;
            if (!SprocketPath.StartsWith("admin", "login"))
            {
                if (!WebAuthentication.VerifyAccess(PermissionType.AccessAdminArea))
                {
                    WebUtility.Redirect("admin/login");
                    return;
                }

                AdminInterface admin = new AdminInterface();
                WebClientScripts scripts = WebClientScripts.Instance;
                admin.AddMainMenuLink(new AdminMenuLink("Website Home", WebUtility.MakeFullPath(""), ObjectRank.Last, "website_home"));
                admin.AddMainMenuLink(new AdminMenuLink("Overview", WebUtility.MakeFullPath("admin"), ObjectRank.First, "website_overview"));
                admin.AddMainMenuLink(new AdminMenuLink("Log Out", WebUtility.MakeFullPath("admin/logout"), ObjectRank.Last, "log_out"));

                admin.AddFooterLink(new AdminMenuLink("Log Out", WebUtility.MakeFullPath("admin/logout"), ObjectRank.Early));
                admin.AddFooterLink(new AdminMenuLink("&copy; 2005-" + DateTime.UtcNow.Year + " " + SprocketSettings.GetValue("WebsiteName"), "", ObjectRank.Late));
                admin.AddFooterLink(new AdminMenuLink("Powered by Sprocket", "http://www.sprocketcms.com", ObjectRank.Last));
                admin.AddHeadSection(new AdminSection(scripts.BuildStandardScriptsBlock(), ObjectRank.Late));
                admin.WebsiteName = GetWebsiteName();

                if (OnLoadAdminPage != null)
                {
                    OnLoadAdminPage(admin, page, handled);
                    if (handled.Handled)
                        return;
                }

                vars = admin.GetScriptVariables();
            }
            else
            {
                vars = new KeyValuePair<string, object>[1];
                vars[0] = new KeyValuePair<string, object>("_admin_websitename", GetWebsiteName());
            }

            ContentManager.RequestedPage = page;
            if (pagePreProcessors.ContainsKey(page.PageCode))
                foreach (PagePreprocessorHandler method in pagePreProcessors[page.PageCode])
                    method(page);
            string txt = page.Render(vars);
            Response.ContentType = page.ContentType;
            Response.Write(txt);
            handled.Set();
        }