Redirect() public static method

Redirects the current response to the specified URL, properly appending the current namespace if any.
public static Redirect ( string target ) : void
target string The target URL.
return void
Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            currentWiki = DetectWiki();

            string currentUser = SessionFacade.GetCurrentUsername();

            string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki);

            if (!AdminMaster.CanManageGroups(currentUser, currentGroups))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }
            aclActionsSelector.Visible = AdminMaster.CanManagePermissions(currentUser, currentGroups);

            revName.ValidationExpression = GlobalSettings.UsernameRegex;

            if (!Page.IsPostBack)
            {
                rptGroups.DataBind();
                providerSelector.Reload();
                btnNewGroup.Enabled = providerSelector.HasProviders;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Redirects to the login page if needed.
 /// </summary>
 public static void RedirectToLoginIfNeeded()
 {
     if (SessionFacade.LoginKey == null)
     {
         UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(HttpContext.Current.Request.Url.ToString()));
     }
 }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            page = Pages.FindPage(Request["Page"]);
            if (page == null)
            {
                UrlTools.RedirectHome();
            }

            // Check permissions
            bool canView = false;

            if (Request["Discuss"] == null)
            {
                canView = AuthChecker.CheckActionForPage(page, Actions.ForPages.ReadPage,
                                                         SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames());
            }
            else
            {
                canView = AuthChecker.CheckActionForPage(page, Actions.ForPages.ReadDiscussion,
                                                         SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames());
            }
            if (!canView)
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            content = Content.GetPageContent(page, true);

            Page.Title = FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, page) + " - " + Settings.WikiTitle;

            PrintContent();
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <PageInfo> pages = Pages.GetPages(Tools.DetectCurrentNamespaceInfo());
            Random          r     = new Random();

            UrlTools.Redirect(pages[r.Next(0, pages.Count)].FullName + Settings.PageExtension);
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            if (!AdminMaster.CanManageConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            PrintSystemStatus();

            if (!Page.IsPostBack)
            {
                rptPages.DataBind();
                rptIndex.DataBind();

                DisplayOrphansCount();

                string anon = Settings.AnonymousGroup;
                foreach (UserGroup group in Users.GetUserGroups())
                {
                    if (group.Name != anon)
                    {
                        ListItem item = new ListItem(group.Name, group.Name);
                        item.Selected = true;
                        lstGroups.Items.Add(item);
                    }
                }
            }
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            currentWiki = DetectWiki();

            SetProvider();
            SetInputData();

            string currentUser = SessionFacade.GetCurrentUsername();

            string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki);
            string   dir           = Tools.GetDirectoryName(file);

            // Verify permissions
            AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));
            bool        canUpload   = authChecker.CheckActionForDirectory(provider, dir,
                                                                          Actions.ForDirectories.UploadFiles, currentUser, currentGroups);
            bool canDeleteFiles = authChecker.CheckActionForDirectory(provider, dir,
                                                                      Actions.ForDirectories.DeleteFiles, currentUser, currentGroups);

            if (!canUpload || !canDeleteFiles)
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            // Inject the proper stylesheet in page head
            Literal l = new Literal();

            l.Text = Tools.GetIncludes(currentWiki, DetectNamespace());
            Page.Header.Controls.Add(l);

            ResizeImage();
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            if (!AdminMaster.CanManageConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            StringBuilder sb = new StringBuilder(200);

            sb.Append("<script type=\"text/javascript\">\r\n<!--\r\n");
            sb.AppendFormat("\tvar __DateTimeFormatTextBox = '{0}';\r\n", txtDateTimeFormat.ClientID);
            sb.Append("// -->\r\n</script>");
            lblStrings.Text = sb.ToString();

            if (!Page.IsPostBack)
            {
                // Setup validation regular expressions
                revMainUrl.ValidationExpression      = Settings.MainUrlRegex;
                revWikiTitle.ValidationExpression    = Settings.WikiTitleRegex;
                revContactEmail.ValidationExpression = Settings.EmailRegex;
                revSenderEmail.ValidationExpression  = Settings.EmailRegex;
                revSmtpServer.ValidationExpression   = Settings.SmtpServerRegex;

                // Load current values
                LoadGeneralConfig();
                LoadContentConfig();
                LoadSecurityConfig();
                LoadAdvancedConfig();
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = Properties.Messages.ProfileTitle + " - " + Settings.WikiTitle;

            if (SessionFacade.LoginKey == null)
            {
                UrlTools.Redirect(UrlTools.BuildUrl("Login.aspx?Redirect=Profile.aspx"));
            }

            currentUser   = SessionFacade.GetCurrentUser();
            currentGroups = SessionFacade.GetCurrentGroupNames();

            if (currentUser.Username == "admin")
            {
                // Admin only has language preferences, stored in a cookie
                UrlTools.Redirect("Language.aspx");
                return;
            }

            if (!Page.IsPostBack)
            {
                bool usersDataSupported      = !currentUser.Provider.UsersDataReadOnly;
                bool accountDetailsSupported = !currentUser.Provider.UserAccountsReadOnly;

                pnlUserData.Visible  = usersDataSupported;
                pnlAccount.Visible   = accountDetailsSupported;
                pnlNoChanges.Visible = !usersDataSupported && !accountDetailsSupported;

                languageSelector.LoadLanguages();

                string name = string.IsNullOrEmpty(currentUser.DisplayName) ? currentUser.Username : currentUser.DisplayName;
                lblUsername.Text    = name;
                txtDisplayName.Text = currentUser.DisplayName;
                txtEmail1.Text      = currentUser.Email;
                var groups = SessionFacade.GetCurrentGroups().ToList();
                lblGroupsList.Text = string.Join(", ", groups.Select(g => g.Name));

                //if (groups.Count == 1 && groups[0].Name == "Anonymous")
                {
                    // bug groupes
                    var user       = SessionFacade.GetCurrentUser();
                    var userName   = SessionFacade.GetCurrentUsername();
                    var firstGroup = user?.Groups?.FirstOrDefault();
                    var findUser   = Users.FindUser(userName);

                    lblGroupsList.Text += " - DEBUG - " +
                                          $"Session ID : {Session.SessionID} - userName = {userName} - user.Username = {user.Username} - " +
                                          $"user.Groups.Count = {user.Groups?.Count()} - user.Groups[0] = {firstGroup} - " +
                                          $"findUser.Groups.Count = {findUser?.Groups?.Count()} - findUser.Groups[0] = {findUser?.Groups?.FirstOrDefault()} - ";
                }


                LoadNotificationsStatus();
                LoadLanguageAndTimezoneSettings();

                rxvDisplayName.ValidationExpression = Settings.DisplayNameRegex;
                rxvEmail1.ValidationExpression      = Settings.EmailRegex;
                rxvPassword1.ValidationExpression   = Settings.PasswordRegex;
            }
        }
Exemplo n.º 9
0
        protected void Application_Error(object sender, EventArgs e)
        {
            // Retrieve last error and log it, redirecting to Error.aspx (avoiding infinite loops)

            Exception ex = Server.GetLastError( );

            HttpException httpEx = ex as HttpException;

            if (httpEx != null)
            {
                // Try to redirect an inexistent .aspx page to a probably existing .ashx page
                if (httpEx.GetHttpCode( ) == 404)
                {
                    string page = Path.GetFileNameWithoutExtension(Request.PhysicalPath);
                    UrlTools.Redirect(page + Settings.PageExtension);
                    return;
                }
            }

            LogError(ex);
            string url = "";

            try
            {
                url = Tools.GetCurrentUrlFixed( );
            }
            catch { }
            EmailTools.NotifyError(ex, url);
            Session["LastError"] = Server.GetLastError( );
            if (!Request.PhysicalPath.ToLowerInvariant( ).Contains("error.aspx"))
            {
                UrlTools.Redirect("Error.aspx");
            }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string currentWiki = DetectWiki();

            AdminMaster.RedirectToLoginIfNeeded();

            if (!AdminMaster.CanManagePages(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki)))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                // Load namespaces

                // Add root namespace
                lstNamespace.Items.Add(new ListItem("<root>", ""));

                List <NamespaceInfo> namespaces = Pages.GetNamespaces(currentWiki);

                foreach (NamespaceInfo ns in namespaces)
                {
                    lstNamespace.Items.Add(new ListItem(ns.Name, ns.Name));
                }

                // Load navigation paths
                rptNavPaths.DataBind();
            }

            btnNewNavPath.Enabled = CanManagePagesInCurrentNamespace();
        }
Exemplo n.º 11
0
		protected void Page_Load(object sender, EventArgs e) {
			Page.Title = "Language/Time Zone - " + Settings.WikiTitle;

			if(SessionFacade.LoginKey != null && SessionFacade.GetCurrentUsername() != "admin") UrlTools.Redirect("Profile.aspx");

			if(!Page.IsPostBack) {
				// Load values stored in cookie
				HttpCookie cookie = Request.Cookies[Settings.CultureCookieName];

				languageSelector.LoadLanguages();

				string culture = null;
				if(cookie != null) culture = cookie["C"];
				else culture = Settings.DefaultLanguage;
				languageSelector.SelectedLanguage = culture;

				string timezone = null;
				if(cookie != null) timezone = cookie["T"];
				else timezone = Settings.DefaultTimezone.ToString();
				languageSelector.SelectedTimezone = timezone;

				if(!string.IsNullOrEmpty(Request["Language"])) {
					string lang = Request["Language"];

					SavePreferences(lang, languageSelector.SelectedTimezone);
					languageSelector.SelectedLanguage = lang;

					if(Request["Redirect"] != null) UrlTools.Redirect(UrlTools.BuildUrl(Request["Redirect"]));
					else if(Request.UrlReferrer != null && !string.IsNullOrEmpty(Request.UrlReferrer.ToString())) UrlTools.Redirect(UrlTools.BuildUrl(Request.UrlReferrer.FixHost().ToString()));
				}
			}

		}
Exemplo n.º 12
0
 /// <summary>
 /// Redirects to the login page if needed.
 /// </summary>
 public static void RedirectToLoginIfNeeded()
 {
     if (SessionFacade.LoginKey == null)
     {
         UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
     }
 }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Page.Title = Properties.Messages.PageIncomingLinks + " - " + Settings.WikiTitle;

            var page = Pages.FindPage(Request["Page"]);

            PageContent content;

            if (page != null)
            {
                content = Content.GetPageContent(page, true);

                lblTitle.Text = Properties.Messages.PageIncomingLinks + ": " + FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, page);

                if (!AuthChecker.CheckActionForPage(page, Actions.ForPages.ReadPage, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
                {
                    UrlTools.Redirect("AccessDenied.aspx");
                    return;
                }
            }

            var incomingLinks = Pages.GetPageIncomingLinks(page);

            foreach (var link in incomingLinks)
            {
                var linkPage        = Pages.FindPage(link);
                var linkPageContent = linkPage.Provider.GetContent(linkPage);
                ulItems.InnerHtml += string.Format("<li><a href=\"{0}\">{1}</a></li>", UrlTools.BuildUrl(Tools.UrlEncode(link), Settings.PageExtension), linkPageContent.Title);
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            bool canManageCategories = AdminMaster.CanManageCategories(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames());

            if (!canManageCategories)
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                // Load namespaces

                // Add root namespace
                lstNamespace.Items.Add(new ListItem("<root>", ""));

                List <NamespaceInfo> namespaces = Pages.GetNamespaces();

                foreach (NamespaceInfo ns in namespaces)
                {
                    lstNamespace.Items.Add(new ListItem(ns.Name, ns.Name));
                }

                // Load pages
                rptCategories.DataBind();
            }

            btnNewCategory.Enabled = CanManageCategoriesInCurrentNamespace();
            btnBulkManage.Enabled  = btnNewCategory.Enabled;
        }
Exemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = Properties.Messages.HistoryTitle + " - " + Settings.WikiTitle;

            page = Pages.FindPage(Request["Page"]);

            if (page != null)
            {
                canRollback = AuthChecker.CheckActionForPage(page, Actions.ForPages.ManagePage,
                                                             SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames());

                content       = Content.GetPageContent(page, true);
                lblTitle.Text = Properties.Messages.PageHistory + ": " + FormattingPipeline.PrepareTitle(content.Title, false, FormattingContext.PageContent, page);

                bool canView = AuthChecker.CheckActionForPage(page, Actions.ForPages.ReadPage,
                                                              SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames());
                if (!canView)
                {
                    UrlTools.Redirect("AccessDenied.aspx");
                }
            }
            else
            {
                lblTitle.Text = Properties.Messages.PageNotFound;
                return;
            }

            if (!Page.IsPostBack && page != null)
            {
                List <int> revisions = Pages.GetBackups(page);
                revisions.Reverse();
                // Populate dropdown lists
                lstRev1.Items.Clear();
                lstRev2.Items.Clear();
                lstRev2.Items.Add(new ListItem(Properties.Messages.Current, "Current"));
                if (Request["Rev2"] != null && Request["Rev2"].Equals(lstRev2.Items[0].Value))
                {
                    lstRev2.SelectedIndex = 0;
                }
                for (int i = 0; i < revisions.Count; i++)
                {
                    lstRev1.Items.Add(new ListItem(revisions[i].ToString(), revisions[i].ToString()));
                    lstRev2.Items.Add(new ListItem(revisions[i].ToString(), revisions[i].ToString()));
                    if (Request["Rev1"] != null && Request["Rev1"].Equals(lstRev1.Items[i].Value))
                    {
                        lstRev1.SelectedIndex = i;
                    }
                    if (Request["Rev2"] != null && Request["Rev2"].Equals(lstRev2.Items[i + 1].Value))
                    {
                        lstRev2.SelectedIndex = i + 1;
                    }
                }
                if (revisions.Count == 0)
                {
                    btnCompare.Enabled = false;
                }
            }

            PrintHistory();
        }
Exemplo n.º 16
0
 private void EndPageRequest(IAsyncResult ar)
 {
     try {
         HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(ar);
         StreamReader    reader   = new StreamReader(response.GetResponseStream());
         if (lstWiki.SelectedValue.ToUpperInvariant() == "MEDIA")
         {
             Regex textarea = new Regex(@"(?<=(\<textarea([^>])*?)\>)(.|\s)+?(?=(\<\/textarea\>))");
             Match match    = textarea.Match(reader.ReadToEnd());
             if (match.Success)
             {
                 Translator translator = new Translator();
                 string     text       = translator.Translate(match.Value.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&quot;", @""""));
                 savePage(text);
             }
         }
         if (lstWiki.SelectedValue.ToUpperInvariant() == "FLEX")
         {
             Regex textarea = new Regex(@"(?<=(\<textarea class=\'EditBox\'([^>])*?)\>)(.|\s)+?(?=(\<\/textarea\>))");
             Match match    = textarea.Match(reader.ReadToEnd());
             if (match.Success)
             {
                 Translator translator = new Translator();
                 string     text       = translator.Translate(match.Value.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&quot;", @""""));
                 savePage(text);
             }
         }
         UrlTools.Redirect(UrlTools.BuildUrl(txtPageName.Text.Replace(":", "_").Replace("/", "_").Replace(@"\", "_").Replace('?', '_'), ".ashx"));
     }
     catch (WebException) {
         lblResult.Text = "Web exception";
     }
 }
Exemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();
            PageSize = Settings.ListSize;
            rangeEnd = PageSize - 1;

            if (!AdminMaster.CanManageUsers(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }
            aclActionsSelector.Visible = AdminMaster.CanManagePermissions(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames());

            revUsername.ValidationExpression    = Settings.UsernameRegex;
            revDisplayName.ValidationExpression = Settings.DisplayNameRegex;
            revPassword1.ValidationExpression   = Settings.PasswordRegex;
            revEmail.ValidationExpression       = Settings.EmailRegex;

            if (!Page.IsPostBack)
            {
                ResetUserList();

                RefreshList();

                providerSelector.Reload();
                btnNewUser.Enabled = providerSelector.HasProviders;
            }

            if (Page.IsPostBack)
            {
                // Preserve password value (a bit insecure but much more usable)
                txtPassword1.Attributes.Add("value", txtPassword1.Text);
                txtPassword2.Attributes.Add("value", txtPassword2.Text);
            }
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Array.Find(SessionFacade.GetCurrentGroupNames(), delegate(string g) { return(g == Settings.AdministratorsGroup); }) == null)
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            Page.Title = "Import - " + Settings.WikiTitle;
        }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!SessionFacade.GetCurrentGroupNames().Any(g => g == Settings.AdministratorsGroup))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            Page.Title = "Import - " + Settings.WikiTitle;
        }
Exemplo n.º 20
0
        protected void btnDeleteMessage_Click(object sender, EventArgs e)
        {
            int      id   = int.Parse(Request["Message"]);
            PageInfo page = Pages.FindPage(Request["Page"]);

            Log.LogEntry("Message deletion requested for " + page.FullName + "." + id.ToString(), EntryType.General, SessionFacade.GetCurrentUsername());
            bool done = Pages.RemoveMessage(page, id, chkDeleteMessageReplies.Checked);

            UrlTools.Redirect(UrlTools.BuildUrl(Request["Page"], Settings.PageExtension + "?Discuss=1"));
        }
Exemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            currentWiki = DetectWiki();

            Page.Title = Properties.Messages.UserTitle + " - " + Settings.GetWikiTitle(currentWiki);

            currentUsername = Request["User"];
            if (string.IsNullOrEmpty(currentUsername))
            {
                currentUsername = Request["Username"];
            }
            if (string.IsNullOrEmpty(currentUsername))
            {
                UrlTools.Redirect("Default.aspx");
            }

            if (currentUsername == "admin")
            {
                currentUser = Users.GetGlobalAdministratorAccount();
            }
            else
            {
                currentUser = Users.FindUser(currentWiki, currentUsername);
            }

            if (currentUser == null)
            {
                UrlTools.Redirect("Default.aspx");
            }

            if (!Page.IsPostBack)
            {
                lblTitle.Text = lblTitle.Text.Replace("##NAME##", Users.GetDisplayName(currentUser));

                txtSubject.Text = Request["Subject"];
                if (txtSubject.Text != "" && SessionFacade.LoginKey == null)
                {
                    UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed()));
                }
            }

            if (SessionFacade.LoginKey == null)
            {
                pnlMessage.Visible = false;
            }
            else
            {
                pnlMessage.Visible = true;
            }

            DisplayGravatar();

            DisplayRecentActivity();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Verifies the need for a page redirection, and performs it when appropriate.
        /// </summary>
        private void VerifyAndPerformPageRedirection()
        {
            if (currentPage == null)
            {
                return;
            }

            // Force formatting so that the destination can be detected
            Content.GetFormattedPageContent(currentPage, true);

            PageInfo dest = Redirections.GetDestination(currentPage, out var fragment);

            if (dest == null)
            {
                return;
            }

            if (dest != null)
            {
                if (Request["NoRedirect"] != "1")
                {
                    var fullUrl = dest.FullName + Settings.PageExtension + "?From=" + currentPage.FullName;
                    if (!string.IsNullOrEmpty(fragment))
                    {
                        fullUrl += "#" + fragment;
                    }

                    UrlTools.Redirect(fullUrl, false);
                }
                else
                {
                    // Write redirection hint
                    var sb = new StringBuilder();
                    sb.Append(@"<div id=""RedirectionDiv"">");
                    sb.Append(Properties.Messages.ThisPageRedirectsTo);
                    sb.Append(": ");
                    sb.Append(@"<a href=""");

                    var fullUrl = UrlTools.BuildUrl("++", Tools.UrlEncode(dest.FullName), Settings.PageExtension, "?From=", Tools.UrlEncode(currentPage.FullName));
                    if (!string.IsNullOrEmpty(fragment))
                    {
                        fullUrl += "#" + fragment;
                    }
                    sb.Append(fullUrl);
                    sb.Append(@""">");
                    PageContent k = Content.GetPageContent(dest, true);
                    sb.Append(FormattingPipeline.PrepareTitle(k.Title, false, FormattingContext.PageContent, currentPage));
                    sb.Append("</a></div>");
                    var literal = new Literal();
                    literal.Text = sb.ToString();
                    plhContent.Controls.Add(literal);
                }
            }
        }
Exemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            string currentWiki = DetectWiki();

            if (!AdminMaster.CanManageGlobalConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki)))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            PrintSystemStatus();
        }
Exemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            if (!AdminMaster.CanManageNamespaces(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(DetectWiki())))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                rptNamespaces.DataBind();
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// Verifies the need for a redirect and performs it.
 /// </summary>
 private void VerifyAndPerformRedirects()
 {
     if (currentPage == null)
     {
         UrlTools.Redirect(UrlTools.BuildUrl("PageNotFound.aspx?Page=", Tools.UrlEncode(DetectFullName())));
     }
     if (Request["Edit"] == "1")
     {
         UrlTools.Redirect(UrlTools.BuildUrl("Edit.aspx?Page=", Tools.UrlEncode(currentPage.FullName)));
     }
     if (Request["History"] == "1")
     {
         UrlTools.Redirect(UrlTools.BuildUrl("History.aspx?Page=", Tools.UrlEncode(currentPage.FullName)));
     }
 }
Exemplo n.º 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            if (!AdminMaster.CanManageConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                // Load log entries
                rptLog.DataBind();
            }
        }
Exemplo n.º 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            if (!AdminMaster.CanManageSnippetsAndTemplates(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                // Load snippets
                rptSnippetsTemplates.DataBind();
            }
        }
Exemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = Properties.Messages.PageNotFoundTitle + " - " + Settings.WikiTitle;

            if (Request["Page"] != null)
            {
                lblDescription.Text = lblDescription.Text.Replace("##PAGENAME##", Request["Page"]);
            }
            else
            {
                UrlTools.Redirect(UrlTools.BuildUrl("Default.aspx"));
            }

            PrintSearchResults();
        }
Exemplo n.º 29
0
        /// <summary>
        /// Rolls back the externally selected page to the previous version.
        /// </summary>
        private void AutoRollback()
        {
            List <int> backups = Pages.GetBackups(externallySelectedPage);

            if (backups.Count > 0)
            {
                int targetRevision = backups[backups.Count - 1];

                Log.LogEntry("Page rollback requested for " + txtCurrentPage.Value + " to rev. " + targetRevision.ToString(), EntryType.General, SessionFacade.GetCurrentUsername());

                Pages.Rollback(externallySelectedPage, targetRevision);

                UrlTools.Redirect(externallySelectedPage.FullName + Settings.PageExtension);
            }
        }
Exemplo n.º 30
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            string content = editor.GetContent();

            Page.Validate();

            if (!Page.IsValid || content.Replace(" ", "").Length == 0 || txtSubject.Text.Replace(" ", "").Length == 0)
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = Properties.Messages.SubjectAndBodyNeeded;
                return;
            }

            Regex r = new Regex(@"\<script.*?\>", RegexOptions.Compiled | RegexOptions.IgnoreCase);

            if (r.Match(editor.GetContent()).Success)
            {
                lblResult.CssClass = "resulterror";
                lblResult.Text     = @"<span style=""color: #FF0000;"">" + Properties.Messages.ScriptDetected + "</span>";
                return;
            }

            string username = Request.UserHostAddress;

            if (SessionFacade.LoginKey != null)
            {
                username = SessionFacade.CurrentUsername;
            }

            if (Request["Edit"] == null)
            {
                int parent = -1;
                try
                {
                    parent = int.Parse(Request["Parent"]);
                }
                catch { }

                Pages.AddMessage(page, username, txtSubject.Text, DateTime.Now, content, parent);
            }
            else
            {
                var     messages = Pages.GetPageMessages(page);
                Message msg      = Pages.FindMessage(messages, int.Parse(Request["Edit"]));
                Pages.ModifyMessage(page, int.Parse(Request["Edit"]), msg.Username, txtSubject.Text, DateTime.Now, content);
            }
            UrlTools.Redirect(page.FullName + Settings.PageExtension + "?Discuss=1&NoRedirect=1");
        }