protected void Page_Init(object sender, EventArgs e)
    {
        if (Session["ActiveUser"] == null)
        {
            FormsAuthentication.SignOut();
            FormsAuthentication.RedirectToLoginPage();
        }

        if (Page.User.IsInRole("editor"))
        {
            string        strRequestPage = Request.Url.Segments[Request.Url.Segments.Length - 1];
            List <string> lstEditorPages = new List <string>();
            lstEditorPages.Add("add.aspx");
            lstEditorPages.Add("autosaves.aspx");
            lstEditorPages.Add("editor.aspx");
            lstEditorPages.Add("mediabrowser.aspx");
            lstEditorPages.Add("posts.aspx");
            lstEditorPages.Add("users.aspx");
            if (!lstEditorPages.Contains(strRequestPage.ToLower()))
            {
                Response.Redirect("Editor.aspx");
            }
        }

        if (Blogsa.Settings["language"] != null)
        {
            Blogsa.RefreshBlogAdminLanguage(Blogsa.Settings["language"].ToString());
        }
        else
        {
            Response.Redirect(Request.Url.ToString());
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string error = String.Empty;

        try
        {
            string strPage = Request["p"];
            if (string.IsNullOrEmpty(strPage))
            {
                strPage = "main";
            }

            if (strPage.Equals("perma"))
            {
                if (!rblpermalink.SelectedValue.Equals("{custom}"))
                {
                    txtpermaexpression.Text = rblpermalink.SelectedValue;
                }
            }

            HtmlGenericControl htmlDiv = null;
            switch (strPage)
            {
            case "main": htmlDiv = divMainSettings; break;

            case "perma": htmlDiv = divPermaLinkSettings; break;

            case "postcomment": htmlDiv = divPostCommentSettings; break;

            case "paging": htmlDiv = divPagingSettings; break;

            case "mail": htmlDiv = divMailSettings; break;

            case "library": htmlDiv = divLibrarySettings; break;

            default: htmlDiv = null; break;
            }

            if (htmlDiv != null)
            {
                foreach (Control wC in htmlDiv.Controls)
                {
                    if (wC is TextBox)
                    {
                        TextBox txtBox = (TextBox)wC;
                        if (txtBox.ID.Equals("txtsmtp_pass") && string.IsNullOrEmpty(txtBox.Text))
                        {
                            txtBox.Text = Blogsa.Settings["smtp_pass"].ToString();
                        }
                        string strName = txtBox.ID.ToString().Substring(3, txtBox.ID.ToString().Length - 3);

                        SaveValue(strName, txtBox.Text);
                    }
                    else if (wC is DropDownList)
                    {
                        DropDownList ddList  = (DropDownList)wC;
                        string       strName = ddList.ID.ToString().Substring(3, ddList.ID.ToString().Length - 3);

                        SaveValue(strName, ddList.SelectedValue);
                    }
                    else if (wC is RadioButtonList)
                    {
                        RadioButtonList rblList = (RadioButtonList)wC;
                        string          strName = rblList.ID.ToString().Substring(3, rblList.ID.ToString().Length - 3);

                        SaveValue(strName, rblList.SelectedValue);
                    }
                }
            }
        }
        catch (System.Exception ex)
        {
            error = ex.Message;
        }

        if (!String.IsNullOrEmpty(error))
        {
            MessageBox1.Message = Language.Admin["SettingError"] + error;
            MessageBox1.Type    = MessageBox.ShowType.Error;
        }
        else
        {
            Blogsa.RefreshBlogLanguage(Blogsa.DefaultBlogLanguage);
            Blogsa.RefreshBlogAdminLanguage(Blogsa.DefaultBlogAdminLanguage);
            Response.Redirect(String.Format("Settings.aspx?p={0}&Message=1", Request["p"]), true);
        }
    }