void ContentManager_OnBeforeRenderPage(PageEntry page) { if (SprocketPath.Sections[SprocketPath.Sections.Length - 1] == "$forum_submit") { switch (Request.Form["action"]) { case "save_forum_settings": SaveForumSettings(); break; case "post_topic": PostTopic(); break; default: Response.Write("<p>Nope, sorry.</p><p>Click <a href=\"" + HttpUtility.HtmlEncode(Request.UrlReferrer.ToString()) + "\">here</a> to go back to where you were.</p>"); Response.End(); return; } Response.Redirect(Request.UrlReferrer.ToString()); } }
private PageEntry LoadEntry(XmlElement xml, PageEntry parent) { PageEntry pageEntry = new PageEntry(templates); pageEntry.Parent = parent; pageEntry.TemplateName = xml.GetAttribute("Template"); if (xml.HasAttribute("ContentType")) pageEntry.ContentType = xml.GetAttribute("ContentType"); if (xml.HasAttribute("Path")) { pageEntry.Path = xml.GetAttribute("Path").ToLower(); if (prefixAllPathsWith != null && prefixAllPathsWith != String.Empty) { if (pageEntry.Path.Length > 0) pageEntry.Path = prefixAllPathsWith + "/" + pageEntry.Path; else pageEntry.Path = prefixAllPathsWith; } requestPaths[pageEntry.Path] = pageEntry; if (xml.HasAttribute("HandleSubPaths")) { pageEntry.HandleSubPaths = StringUtilities.BoolFromString(xml.GetAttribute("HandleSubPaths")); flexiblePaths.Add(pageEntry); } } if (xml.HasAttribute("Code")) { pageEntry.PageCode = xml.GetAttribute("Code"); pageCodes[pageEntry.PageCode] = pageEntry; } foreach (XmlElement node in xml.ChildNodes) pageEntry.Pages.Add(LoadEntry(node, pageEntry)); pages.Add(pageEntry); return pageEntry; }
void OnAdminRequest(AdminInterface admin, PageEntry page, HandleFlag handled) { // build the "current user" block User user = User.Select(SecurityProvider.ClientSpaceID, WebAuthentication.Instance.CurrentUsername); string block = "<div id=\"currentuser-block\">" + "You are currently logged in as <b>{0}</b>." + "</div>"; admin.AddLeftColumnSection(new AdminSection( string.Format(block, (user.FirstName + " " + user.Surname).Trim()), ObjectRank.First)); if (!WebAuthentication.VerifyAccess(PermissionType.UserAdministrator)) return; admin.AddMainMenuLink(new AdminMenuLink("Users and Roles", WebUtility.MakeFullPath("admin/security"), ObjectRank.Normal)); // build the security interface if it has been requested if (SprocketPath.Value.StartsWith("admin/security")) { //handled.Set(); int defaultMaxFilterMatches; try { defaultMaxFilterMatches = int.Parse(SprocketSettings.GetValue("WebSecurityDefaultUserFilterMatches")); } catch { defaultMaxFilterMatches = 50; } admin.AddInterfaceScript(WebControlScript.TabStrip); admin.AddInterfaceScript(WebControlScript.Fader); admin.AddInterfaceScript(WebControlScript.AjaxForm); string scr = ResourceLoader.LoadTextResource("Sprocket.Security.CMS.security.js") .Replace("50,//{defaultMaxFilterMatches}", defaultMaxFilterMatches.ToString() + ",") .Replace("if(true)//{ifUserCanAccessRoleManagement}", WebAuthentication.VerifyAccess(PermissionType.RoleAdministrator) ? "" : "if(false)"); admin.AddInterfaceScript(new AdminSection(scr, 0)); admin.AddBodyOnLoadScript(new AdminSection("SecurityInterface.Run()", 0)); string html = "<div id=\"user-admin-container\"></div>"; admin.AddPreContentSection(new AdminSection(html, 0)); admin.AddHeadSection(new AdminSection("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WebUtility.MakeFullPath("resources/admin/security.css") + "\" />", 0)); } }
void WebEvents_OnEndHttpRequest() { PageStack.Clear(); requestedPage = null; }
void WebEvents_OnLoadRequestedPath(HandleFlag handled) { requestedPage = null; if (handled.Handled) return; PageEntry page = Pages.FromPath(SprocketPath.Value); if (page == null) return; requestedPage = page; if (OnBeforeRenderPage != null) OnBeforeRenderPage(page); string txt = page.Render(); Response.ContentType = page.ContentType; Response.Write(txt); handled.Set(); }
private PageEntry LoadEntry(XmlElement xml, PageEntry parent) { PageEntry pageEntry = new PageEntry(); pageEntry.Parent = parent; pageEntry.TemplateName = xml.GetAttribute("Template"); pageEntry.ContentFile = xml.GetAttribute("ContentFile"); if (xml.HasAttribute("ContentType")) pageEntry.ContentType = xml.GetAttribute("ContentType"); if (xml.HasAttribute("Path")) { pageEntry.Path = xml.GetAttribute("Path").ToLower(); requestPaths[pageEntry.Path] = pageEntry; if (xml.HasAttribute("HandleSubPaths")) { pageEntry.HandleSubPaths = StringUtilities.BoolFromString(xml.GetAttribute("HandleSubPaths")); flexiblePaths.Add(pageEntry); } } if (xml.HasAttribute("Code")) { pageEntry.PageCode = xml.GetAttribute("Code"); pageCodes[pageEntry.PageCode] = pageEntry; } if (xml.HasAttribute("ContentFile")) { pageEntry.ContentFile = xml.GetAttribute("ContentFile"); contentFiles[pageEntry.ContentFile] = pageEntry; } foreach (XmlElement node in xml.ChildNodes) pageEntry.Pages.Add(LoadEntry(node, pageEntry)); pages.Add(pageEntry); return pageEntry; }
void WebEvents_OnEndHttpRequest() { PageStack.Clear(); requestedPage = null; }
void WebEvents_OnLoadRequestedPath(HandleFlag handled) { requestedPage = null; if (handled.Handled) return; PageEntry page = Pages.FromPath(SprocketPath.Value); if (page == null) return; requestedPage = page; if (Values.PagePreProcessors.ContainsKey(page.PageCode)) foreach (PagePreprocessorHandler method in Values.PagePreProcessors[page.PageCode]) method(page); if (OnBeforeRenderPage != null) OnBeforeRenderPage(page); string txt = page.Render(); Response.ContentType = page.ContentType; Response.Write(txt); handled.Set(); }
public void PreProcessLogout(PageEntry page) { WebAuthentication.Instance.ClearAuthenticationCookie(); WebUtility.Redirect("admin/logout"); }
public void PreProcessLoginPage(PageEntry page) { if(WebAuthentication.VerifyAccess(PermissionType.AccessAdminArea)) WebUtility.Redirect("admin"); }