示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SharedBasePage requestPage = this.Page as SharedBasePage;

            if (!SiteSecurity.IsValidContributor())
            {
                Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html");
            }

            this.ID = "EditUserBox";

            editControl.Text   = GetProfileContent();
            editControl.Width  = Unit.Percentage(99d);
            editControl.Height = Unit.Pixel(400);
            editControl.SetLanguage(CultureInfo.CurrentUICulture.Name);
            editControl.SetTextDirection(requestPage.ReadingDirection);

            if (!IsPostBack)
            {
                SiteConfig siteConfig  = requestPage.SiteConfig;
                User       currentUser = SiteSecurity.GetUser(requestPage.User.Identity.Name);

                textEMail.Text             = currentUser.EmailAddress;
                textDisplayName.Text       = currentUser.DisplayName;
                checkboxNewPost.Checked    = currentUser.NotifyOnNewPost;
                checkboxAllComment.Checked = currentUser.NotifyOnAllComment;
                checkboxOwnComment.Checked = currentUser.NotifyOnOwnComment;
                textPassword.Text          = passwordPlaceHolder;
                textConfirmPassword.Text   = passwordPlaceHolder;
                textOpenIdIdentifier.Text  = currentUser.OpenIDUrl;

                DataBind();
            }
        }
示例#2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            requestPage = Page as SharedBasePage;

            // if you are commenting on your own blog, no need for Captha
            if (SiteSecurity.IsValidContributor())
            {
                CaptchaControl1.Enabled = CaptchaControl1.Visible = false;
            }
            else
            {
                CaptchaControl1.Enabled = CaptchaControl1.Visible = requestPage.SiteConfig.EnableCaptcha;
            }

            resmgr = ApplicationResourceTable.Get();

            if (!IsPostBack)
            {
                if (Request.Cookies["name"] != null)
                {
                    string nameStr = HttpUtility.UrlDecode(Request.Cookies["name"].Value, Encoding.UTF8);
                    //truncate at 32 chars to avoid abuse...
                    name.Text = nameStr.Substring(0, Math.Min(32, nameStr.Length));
                }

                if (Request.Cookies["email"] != null)
                {
                    email.Text = HttpUtility.UrlDecode(Request.Cookies["email"].Value, Encoding.UTF8);
                }
            }

            DataBind();
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            SharedBasePage requestPage = Page as SharedBasePage;

            // only allow users to login using openid when we actually allow it
            if (requestPage.SiteConfig.AllowOpenIdComments == true)
            {
                OpenIdRelyingParty      openid   = new OpenIdRelyingParty();
                IAuthenticationResponse response = openid.GetResponse();
                if (response != null)
                {
                    // Stage 3: OpenID Provider sending assertion response
                    switch (response.Status)
                    {
                    case AuthenticationStatus.Authenticated:
                        ClaimsResponse sregResponse = response.GetExtension <ClaimsResponse>();
                        FetchResponse  axResponse   = response.GetExtension <FetchResponse>();
                        string         nick         = response.FriendlyIdentifierForDisplay;
                        string         homepage     = response.ClaimedIdentifier;
                        string         email        = "*****@*****.**";
                        if (sregResponse != null)
                        {
                            nick  = string.IsNullOrEmpty(sregResponse.Nickname) ? sregResponse.FullName : sregResponse.Nickname;
                            email = sregResponse.Email;
                        }

                        if (String.IsNullOrEmpty(nick) && axResponse != null && axResponse.Attributes.Contains(WellKnownAttributes.Name.First) && axResponse.Attributes.Contains(WellKnownAttributes.Name.Last))
                        {
                            nick = axResponse.GetAttributeValue(WellKnownAttributes.Name.First) + " " +
                                   axResponse.GetAttributeValue(WellKnownAttributes.Name.Last);
                        }

                        string comment = Session["pendingComment"] as string;
                        string entryId = Session["pendingEntryId"] as string;
                        if (String.IsNullOrEmpty(comment) == false && String.IsNullOrEmpty(entryId) == false)
                        {
                            AddNewComment(nick, email, homepage, comment, entryId, /* openid */ true);
                        }

                        break;
                    }
                }
            }

            // if you are commenting on your own blog, no need for Captha
            if (SiteSecurity.IsValidContributor())
            {
                CaptchaControl1.Enabled = CaptchaControl1.Visible = false;
            }
            else
            {
                CaptchaControl1.Enabled = CaptchaControl1.Visible = requestPage.SiteConfig.EnableCaptcha;
            }

            resmgr = ApplicationResourceTable.Get();

            if (!IsPostBack)
            {
                if (requestPage.WeblogEntryId.Length == 0)
                {
                    requestPage.Redirect(SiteUtilities.GetStartPageUrl(requestPage.SiteConfig));
                }
                ViewState["entryId"] = requestPage.WeblogEntryId;

                if (Request.Cookies["name"] != null)
                {
                    string nameStr = HttpUtility.UrlDecode(Request.Cookies["name"].Value, Encoding.UTF8);
                    //truncate at 32 chars to avoid abuse...
                    name.Text = nameStr.Substring(0, Math.Min(32, nameStr.Length));
                }

                if (Request.Cookies["email"] != null)
                {
                    email.Text = HttpUtility.UrlDecode(Request.Cookies["email"].Value, Encoding.UTF8);
                }

                if (Request.Cookies["homepage"] != null)
                {
                    homepage.Text = HttpUtility.UrlDecode(Request.Cookies["homepage"].Value, Encoding.UTF8);
                }

                if (Request.Cookies["openid"] != null)
                {
                    openid_identifier.Text = HttpUtility.UrlDecode(Request.Cookies["openid"].Value, Encoding.UTF8);
                }
            }

            DataBind();
        }
        public void AddNewComment(string name, string email, string homepage, string comment, string entryId, bool openid)
        {
            SharedBasePage requestPage = Page as SharedBasePage;

            // if we allow tags, use the allowed tags, otherwise use an empty array
            ValidTagCollection allowedTags = (requestPage.SiteConfig.CommentsAllowHtml ? requestPage.SiteConfig.AllowedTags : new ValidTagCollection(null));

            Entry entry = requestPage.DataService.GetEntry(entryId);

            if ((entry != null) && SiteUtilities.AreCommentsAllowed(entry, requestPage.SiteConfig))
            {
                Comment c = new Comment();
                c.Initialize();
                c.OpenId          = openid;
                c.Author          = HttpUtility.HtmlEncode(name);
                c.AuthorEmail     = HttpUtility.HtmlEncode(email);
                c.AuthorHomepage  = FixUrl(homepage);
                c.AuthorIPAddress = Request.UserHostAddress;
                c.AuthorUserAgent = Request.UserAgent;
                c.Referer         = Request.UrlReferrer != null?Request.UrlReferrer.ToString() : String.Empty;

                // clean the code from html tags


                c.TargetEntryId = entryId;
                c.TargetTitle   = entry.Title;

                if (requestPage.SiteConfig.CommentsRequireApproval == true &&
                    (requestPage.SiteConfig.SmtpServer == null || requestPage.SiteConfig.SmtpServer.Length == 0))
                {
                    requestPage.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, "ERROR: Comment Moderation is turned on, but you haven't configured an SMTP Server for sending mail!", ""));
                }

                // if comments require moderation, they are not public.
                // except when the commenter is a contributor
                if (SiteSecurity.IsValidContributor())
                {
                    c.IsPublic = true;
                }
                else
                {
                    // bypass spam when the comment is authenticated by openid en openid doesn't require approval
                    if (requestPage.SiteConfig.EnableSpamBlockingService && (requestPage.SiteConfig.BypassSpamOpenIdComment && openid) == false)
                    {
                        // make sure to send the unfiltered comment for analysis by external service
                        c.Content = comment;
                        bool externalServiceSucceeded = false;
                        try
                        {
                            if (requestPage.SiteConfig.SpamBlockingService.IsSpam(c))
                            {
                                potentialSpamSubmitted = true;
                                if (!requestPage.SiteConfig.EnableSpamModeration)
                                {
                                    // abort saving the comment
                                    requestPage.LoggingService.AddEvent(new EventDataItem(EventCodes.CommentBlocked, String.Format("Blocking suspected spam from {0} {1} [{2}].", c.Author, c.AuthorEmail, c.AuthorIPAddress), SiteUtilities.GetPermaLinkUrl(entryId)));
                                    clearCommentInput();
                                    return;
                                }
                                c.SpamState = SpamState.Spam;
                                c.IsPublic  = false;
                            }
                            else
                            {
                                c.SpamState = SpamState.NotSpam;
                                c.IsPublic  = true;
                            }
                            externalServiceSucceeded = true;
                        }
                        catch (Exception ex)
                        {
                            requestPage.LoggingService.AddEvent(new EventDataItem(EventCodes.Error, String.Format("The external spam blocking service failed for comment {0}. Original exception: {1}", c.EntryId, ex), SiteUtilities.GetPermaLinkUrl(entryId)));
                        }
                        if (!externalServiceSucceeded)
                        {
                            // If the external service fails, we will hide the comment, but not delete it,
                            // even if moderation is disabled.
                            c.SpamState = SpamState.NotChecked;
                            if (doesFeedbackHaveSpamPotential(c))
                            {
                                potentialSpamSubmitted = true;
                                c.IsPublic             = false;
                            }
                            else
                            {
                                c.IsPublic = true;
                            }
                        }
                    }
                    else
                    {
                        c.IsPublic = true;
                    }
                    // If comment moderation enabled, hide all comments regardless of the what the external spam service says
                    if (requestPage.SiteConfig.CommentsRequireApproval)
                    {
                        c.IsPublic = false;
                    }
                }

                // FilterHtml html encodes anything we don't like
                string filteredText = SiteUtilities.FilterHtml(comment, allowedTags);
                c.Content = filteredText;


                if (requestPage.SiteConfig.SendCommentsByEmail &&
                    requestPage.SiteConfig.SmtpServer != null &&
                    requestPage.SiteConfig.SmtpServer.Length > 0)
                {
                    SendMailInfo defaultMailInfo = ComposeMail(c);
                    requestPage.DataService.AddComment(c, defaultMailInfo);
                    requestPage.DataService.RunActions(ComposeMailForUsers(entry, c));

                    string commentShort = c.Content.Replace("\n", "");
                    if (commentShort.Length > 50)
                    {
                        commentShort = commentShort.Substring(0, 50) + "...";
                    }
                    requestPage.LoggingService.AddEvent(
                        new EventDataItem(
                            EventCodes.CommentAdded, commentShort, SiteUtilities.GetCommentViewUrl(entryId)));
                }
                else
                {
                    requestPage.DataService.AddComment(c);
                }

                clearCommentInput();

                // break the caching
                requestPage.DataCache.Remove("BlogCoreData");
                Session.Remove("pendingComment");
                Session.Remove("pendingEntryId");

                //Send the user to the comment they JUST posted.
                if (!potentialSpamSubmitted)
                {
                    Response.Redirect(SiteUtilities.GetCommentViewUrl(c.TargetEntryId) + "#" + c.EntryId);
                }
            }
        }
        protected void CommentView_PreRender(object sender, System.EventArgs e)
        {
            SharedBasePage requestPage    = Page as SharedBasePage;
            string         entryId        = (string)ViewState["entryId"];
            bool           obfuscateEmail = requestPage.SiteConfig.ObfuscateEmail;

            Entry entry = requestPage.DataService.GetEntry(entryId);

            if (entry != null)
            {
                //Modified 10-3-03 HPierson
                //Render the day template with just the single entry, rather than the item template
                //Modified 12-8-03 HPierson
                //Using entry.CreatedLocalTime causes a bug when dasBlog is not configured to be in
                //the same time zone as the server. Instead, we use the configured WindowsTimeZone
                //to calculate the dasBlog configured local time for the entry
                requestPage.WeblogEntries.Add(entry);
                if (requestPage.SiteConfig.AdjustDisplayTimeZone)
                {
                    newtelligence.DasBlog.Util.WindowsTimeZone wtz = requestPage.SiteConfig.GetConfiguredTimeZone();
                    requestPage.ProcessDayTemplate(wtz.ToLocalTime(entry.CreatedUtc), commentViewContent);
                }
                else
                {
                    requestPage.ProcessDayTemplate(entry.CreatedUtc, commentViewContent);
                }

                HtmlAnchor commentStart = new HtmlAnchor();
                commentStart.Name = "commentstart";
                commentViewContent.Controls.Add(commentStart);

                // Show all public comments, or all contents if you can approve them
                // This way all non-public comments remain hidden, when you no longer require approval.
                bool allComments = SiteSecurity.IsValidContributor();

                foreach (Comment c in requestPage.DataService.GetCommentsFor(entryId, allComments))
                {
                    SingleCommentView view = (SingleCommentView)LoadControl("SingleCommentView.ascx");
                    view.Comment        = c;
                    view.ObfuscateEmail = obfuscateEmail;
                    commentViewContent.Controls.Add(view);
                }

                commentsClosed.Visible   = false;
                commentViewTable.Visible = true;
                // only show the openid option when allowed in the config
                openIdTable.Visible = requestPage.SiteConfig.AllowOpenIdComments;

                commentsGravatarEnabled.Visible = requestPage.SiteConfig.CommentsAllowGravatar;

                // show the comments require approval warning when moderating, or suspected spam,
                // maybe users won't post multiple comments when their comment won't show immediately
                commentsModerated.Visible = (requestPage.SiteConfig.CommentsRequireApproval || potentialSpamSubmitted);
                if (potentialSpamSubmitted)
                {
                    labelCommentsModerated.Text = resmgr.GetString("text_comment_potential_spam");
                }
                // display no/some html
                labelCommentHtml.Visible = requestPage.SiteConfig.CommentsAllowHtml && (requestPage.SiteConfig.AllowedTags.AllowedTagsCount > 0);
                labelComment.Visible     = !labelCommentHtml.Visible;
                labelCommentHtml.Text    = String.Format(resmgr.GetString("text_comment_content_html"), requestPage.SiteConfig.AllowedTags.ToString());

                if (SiteUtilities.AreCommentsAllowed(entry, requestPage.SiteConfig) == false)
                {
                    commentsClosed.Visible   = true;
                    commentViewTable.Visible = false;
                    openIdTable.Visible      = false;
                    // if comments are not allow, there is no need to show the approval warning
                    commentsModerated.Visible = false;
                }

                if (Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "coCommentScript") == false && requestPage.SiteConfig.EnableCoComment == true)
                {
                    string coCommentScript = String.Format(@"

					<script type=""text/javascript"">
// this ensures coComment gets the correct values
coco =
{{
     tool          : ""dasBlog"",
     siteurl       : ""{0}"",
     sitetitle     : ""{1}"",
     pageurl       : ""{2}"",
     pagetitle     : ""{3}"",
     author        : ""{4}"",
     formID        : ""{5}"",
     textareaID    : ""{6}"",
     buttonID      : ""{7}""
}}
</script>
<script id=""cocomment-fetchlet"" src=""http://www.cocomment.com/js/enabler.js"" type=""text/javascript"">
// this activates coComment
</script>
  ",
                                                           requestPage.SiteConfig.Root,
                                                           Server.HtmlEncode(requestPage.SiteConfig.Title),
                                                           Request.Url.ToString(),
                                                           Server.HtmlEncode(entry.Title),
                                                           Server.HtmlEncode(entry.Author),
                                                           this.Page.Form.ClientID,
                                                           this.comment.ClientID,
                                                           this.add.ClientID
                                                           );
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "coComment", coCommentScript);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SharedBasePage requestPage = this.Page as SharedBasePage;

            siteConfig = SiteConfig.GetSiteConfig();

            resmgr = ApplicationResourceTable.Get();

            imageUpload.Accept = "image/jpeg,image/gif,image/png";
            editControl.Width  = Unit.Percentage(99d);
            editControl.Height = Unit.Pixel(400);
            editControl.Text   = "<p></p>";

            // TODO: OmarS need to get rid of this
            isDHTMLEdit = true;

            editControl.SetLanguage(CultureInfo.CurrentUICulture.Name);
            editControl.SetTextDirection(requestPage.ReadingDirection);

            if (!requestPage.SiteConfig.EnableCrossposts)
            {
                gridCrossposts.Visible = false;
                labelCrosspost.Visible = false;
            }

            if (!SiteSecurity.IsValidContributor())
            {
                Response.Redirect("~/FormatPage.aspx?path=SiteConfig/accessdenied.format.html");
            }

            CrosspostInfoCollection crosspostSiteInfo = new CrosspostInfoCollection();

            if (!IsPostBack)
            {
                foreach (CrosspostSite site in requestPage.SiteConfig.CrosspostSites)
                {
                    CrosspostInfo ci = new CrosspostInfo(site);
                    ci.TrackingUrlBase = SiteUtilities.GetCrosspostTrackingUrlBase(requestPage.SiteConfig);
                    crosspostSiteInfo.Add(ci);
                }

                // set up categories
                foreach (CategoryCacheEntry category in requestPage.DataService.GetCategories())
                {
                    this.categoryList.Items.Add(category.Name);
                }


                // get the cultures
                CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);

                // setup temp store for listitem items, for sorting
                List <ListItem> cultureList = new List <ListItem>(cultures.Length);

                foreach (CultureInfo ci in cultures)
                {
                    string langName = (ci.NativeName != ci.EnglishName) ? ci.NativeName + " / " + ci.EnglishName : ci.NativeName;

                    if (langName.Length > 55)
                    {
                        langName = langName.Substring(0, 55) + "...";
                    }

                    cultureList.Add(new ListItem(langName, ci.Name));
                }

                // setup the sort culture
                string rssCulture = requestPage.SiteConfig.RssLanguage;

                CultureInfo sortCulture;

                try
                {
                    sortCulture = (rssCulture != null && rssCulture.Length > 0 ? new CultureInfo(rssCulture) : CultureInfo.CurrentCulture);
                }
                catch (ArgumentException)
                {
                    // default to the culture of the server
                    sortCulture = CultureInfo.CurrentCulture;
                }

                // sort the list
                cultureList.Sort(delegate(ListItem x, ListItem y)
                {
                    // actual comparison
                    return(String.Compare(x.Text, y.Text, true, sortCulture));
                });

                // add to the languages listbox
                ListItem[] cultureListItems = cultureList.ToArray();

                listLanguages.Items.AddRange(cultureListItems);

                listLanguages.SelectedValue = "";

                if (requestPage != null && requestPage.WeblogEntryId != "")
                {
                    Session["newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer"] = Request.UrlReferrer;
                    Entry entry = requestPage.DataService.GetEntryForEdit(requestPage.WeblogEntryId);

                    if (entry != null)
                    {
                        CurrentEntry       = entry;
                        entryTitle.Text    = entry.Title;
                        entryAbstract.Text = entry.Description;

                        textDate.SelectedDate = entry.CreatedLocalTime;

                        if (isDHTMLEdit)
                        {
                            editControl.Text = entry.Content;
                        }

                        foreach (string s in entry.GetSplitCategories())
                        {
                            categoryList.Items.FindByText(s).Selected = true;
                        }

                        this.checkBoxAllowComments.Checked = entry.AllowComments;
                        this.checkBoxPublish.Checked       = entry.IsPublic;
                        this.checkBoxSyndicated.Checked    = entry.Syndicated;

                        // GeoRSS.
                        this.txtLat.Text  = String.Format(CultureInfo.InvariantCulture, "{0}", entry.Latitude);
                        this.txtLong.Text = String.Format(CultureInfo.InvariantCulture, "{0}", entry.Longitude);

                        if (entry.Attachments.Count > 0)
                        {
                            foreach (Attachment enclosure in entry.Attachments)
                            {
                                enclosure.Url = SiteUtilities.GetEnclosureLinkUrl(requestPage.SiteConfig, entry.EntryId, enclosure);
                            }

                            this.enclosureUpload.Visible    = false;
                            this.buttonRemove.Visible       = true;
                            this.labelEnclosureName.Visible = true;
                            this.labelEnclosureName.Text    = entry.Attachments[0].Name;
                        }

                        listLanguages.SelectedValue = entry.Language == null ? "" : entry.Language;

                        // merge the crosspost config with the crosspost data
                        foreach (CrosspostInfo cpi in crosspostSiteInfo)
                        {
                            foreach (Crosspost cp in entry.Crossposts)
                            {
                                if (cp.ProfileName == cpi.Site.ProfileName)
                                {
                                    cpi.IsAlreadyPosted = true;
                                    cpi.TargetEntryId   = cp.TargetEntryId;
                                    cpi.Categories      = cp.Categories;
                                    break;
                                }
                            }
                        }
                        // if the entry is not public yet but opened for editing, then we can setup autosave.
                        // (If the entry was already published publically and then autosave was used, the
                        // entry's status would change to non-public and then no longer be accessible!)
                        if (requestPage.SiteConfig.EnableAutoSave && !entry.IsPublic)
                        {
                            SetupAutoSave();
                        }

                        if (requestPage.SiteConfig.EnableGoogleMaps)
                        {
                            AddGoogleMapsApi();
                        }
                    }
                }
                else // This is a brand new entry, so setup the AutoSave script if it's enabled.
                {
                    if (requestPage.SiteConfig.EnableAutoSave)
                    {
                        SetupAutoSave();
                    }

                    if (requestPage.SiteConfig.EnableGoogleMaps)
                    {
                        AddGoogleMapsApi();
                    }

                    txtLat.Text  = String.Format(CultureInfo.InvariantCulture, "{0}", siteConfig.DefaultLatitude);
                    txtLong.Text = String.Format(CultureInfo.InvariantCulture, "{0}", siteConfig.DefaultLongitude);
                }

                gridCrossposts.DataSource = crosspostSiteInfo;
                DataBind();
            }
        }
        protected void save_Click(object sender, EventArgs e)
        {
            SharedBasePage requestPage = this.Page as SharedBasePage;

            if (SiteSecurity.IsValidContributor())
            {
                //Catch empty posts!
                if (!editControl.HasText())
                {
                    return;
                }

                CrosspostInfoCollection crosspostList = new CrosspostInfoCollection();
                Entry entry;

                if (CurrentEntry == null)
                {
                    entry = new Entry();
                    entry.Initialize();
                }
                else
                {
                    entry = CurrentEntry;
                }

                //Try a culture specific parse...
                // TODO: Come up with a shiny javascript datetime picker

                if (textDate.SelectedDateFormatted.Length > 0)
                {
                    try
                    {
                        DateTime createdLocalTime = new DateTime(textDate.SelectedDate.Year,
                                                                 textDate.SelectedDate.Month,
                                                                 textDate.SelectedDate.Day,
                                                                 entry.CreatedLocalTime.Hour,
                                                                 entry.CreatedLocalTime.Minute,
                                                                 entry.CreatedLocalTime.Second,
                                                                 entry.CreatedLocalTime.Millisecond);

                        entry.CreatedLocalTime = createdLocalTime;
                    }
                    catch (FormatException fex)
                    {
                        Trace.Write("Bad DateTime string creating new Entry: " + fex.ToString());
                    }
                }

                // see if we need to delete any old Enclosures
                if (entry.Enclosure != null)
                {
                    if (this.enclosureUpload.Visible == true && this.buttonRemove.Visible == false)
                    {
                        DeleteEnclosures();
                    }
                }

                // upload the attachment
                if (enclosureUpload.Value != null && enclosureUpload.Value != String.Empty)
                {
                    try
                    {
                        long   numBytes;
                        string type;

                        string baseFileName;
                        string fileUrl = HandleUpload(enclosureUpload, entry.EntryId, out type, out numBytes, out baseFileName);

                        entry.Attachments.Add(new Attachment(baseFileName, type, numBytes, AttachmentType.Enclosure));
                    }
                    catch (Exception exc)
                    {
                        ErrorTrace.Trace(TraceLevel.Error, exc);
                    }
                }

                entry.Language      = listLanguages.SelectedValue == "" ? null : listLanguages.SelectedValue;
                entry.Title         = entryTitle.Text;
                entry.Description   = entryAbstract.Text;
                entry.Author        = requestPage.User.Identity.Name;
                entry.AllowComments = checkBoxAllowComments.Checked;
                entry.IsPublic      = checkBoxPublish.Checked;
                entry.Syndicated    = checkBoxSyndicated.Checked;

                // GeoRSS.
                if (siteConfig.EnableGeoRss)
                {
                    double latitude, longitude;
                    if (double.TryParse(txtLat.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out latitude))
                    {
                        entry.Latitude = latitude;
                    }
                    else
                    {
                        entry.Latitude = null;
                    }

                    if (double.TryParse(txtLong.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out longitude))
                    {
                        entry.Longitude = longitude;
                    }
                    else
                    {
                        entry.Longitude = null;
                    }
                }

                if (isDHTMLEdit)
                {
                    entry.Content = editControl.Text;
                }

                // handle categories
                string categories = "";

                StringBuilder sb       = new StringBuilder();
                bool          needSemi = false;

                foreach (ListItem listItem in categoryList.Items)
                {
                    if (listItem.Selected)
                    {
                        if (needSemi)
                        {
                            sb.Append(";");
                        }
                        sb.Append(listItem.Text);
                        needSemi = true;
                    }
                }

                categories       = sb.ToString();
                entry.Categories = categories;

                // handle crosspostSiteInfo
                CrosspostInfoCollection crosspostSiteInfo = new CrosspostInfoCollection();

                // we need to reload the crosspostinfo as it contains sensitive data like password
                foreach (CrosspostSite site in requestPage.SiteConfig.CrosspostSites)
                {
                    CrosspostInfo ci = new CrosspostInfo(site);
                    ci.TrackingUrlBase = SiteUtilities.GetCrosspostTrackingUrlBase(requestPage.SiteConfig);
                    crosspostSiteInfo.Add(ci);
                }

                // merge the crosspost config with the crosspost data
                foreach (CrosspostInfo cpi in crosspostSiteInfo)
                {
                    foreach (Crosspost cp in entry.Crossposts)
                    {
                        if (cp.ProfileName == cpi.Site.ProfileName)
                        {
                            cpi.IsAlreadyPosted = true;
                            cpi.TargetEntryId   = cp.TargetEntryId;
                            cpi.Categories      = cp.Categories;
                            break;
                        }
                    }
                }

                foreach (DataGridItem item in gridCrossposts.Items)
                {
                    CheckBox checkSite = item.FindControl("checkSite") as CheckBox;
                    if (checkSite.Checked)
                    {
                        TextBox textSiteCategory = item.FindControl("textSiteCategory") as TextBox;
                        foreach (CrosspostInfo cpi in crosspostSiteInfo)
                        {
                            if (cpi.Site.ProfileName == checkSite.Text)
                            {
                                cpi.Categories = textSiteCategory.Text;
                                crosspostList.Add(cpi);
                                break;
                            }
                        }
                    }
                }

                try
                {
                    // prevent SaveEntry from happenning twice
                    if (crosspostList.Count == 0)
                    {
                        crosspostList = null;
                    }

                    if (CurrentEntry == null) // new entry
                    {
                        SiteUtilities.SaveEntry(entry, this.textTrackback.Text, crosspostList, requestPage.SiteConfig, requestPage.LoggingService, requestPage.DataService);
                    }
                    else // existing entry
                    {
                        SiteUtilities.UpdateEntry(entry, this.textTrackback.Text, crosspostList, requestPage.SiteConfig, requestPage.LoggingService, requestPage.DataService);
                    }
                }
                catch (Exception ex)
                {
                    //SDH: Changed to ex.ToString as the InnerException is often null, which causes another error in this catch!
                    StackTrace st = new StackTrace();
                    requestPage.LoggingService.AddEvent(
                        new EventDataItem(EventCodes.Error, ex.ToString() + Environment.NewLine + st.ToString(), SiteUtilities.GetPermaLinkUrl(entry)));

                    // if we created a new entry, and there was an error, delete the enclosure folder
                    DeleteEnclosures();

                    requestPage.Redirect("FormatPage.aspx?path=SiteConfig/pageerror.format.html");
                }


                entryTitle.Text    = "";
                entryAbstract.Text = "";
                categoryList.Items.Clear();

                if (Session["newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer"] != null)
                {
                    Uri originalReferrer = Session["newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer"] as Uri;
                    Session.Remove("newtelligence.DasBlog.Web.EditEntryBox.OriginalReferrer");
                    Redirect(originalReferrer.AbsoluteUri);
                }
                else
                {
                    Redirect(SiteUtilities.GetAdminPageUrl(requestPage.SiteConfig));
                }
            }
        }