/// <summary> /// The update log. /// </summary> /// <param name="comment"> /// The comment. /// </param> public void UpdateLog(Comment comment) { if (!this.RecaptchaLoggingEnabled || this.skipRecaptcha) { return; } var log = RecaptchaLogger.ReadLogItems(); var logItem = new RecaptchaLogItem { Response = this.RecaptchaResponseValue, Challenge = this.RecaptchaChallengeValue, CommentId = comment.Id, Enabled = this.RecaptchaEnabled, Necessary = this.RecaptchaNecessary, NumberOfAttempts = this.RecaptchaAttempts, TimeToComment = DateTime.Now.Subtract(this.PageLoadTime).TotalSeconds, TimeToSolveCapcha = DateTime.Now.Subtract(this.RecaptchaRenderTime).TotalSeconds }; log.Add(logItem); if (log.Count > this.MaxLogEntries) { log.RemoveRange(0, log.Count - this.MaxLogEntries); } RecaptchaLogger.SaveLogItems(log); this.RecaptchaAttempts = 0; this.PageLoadTime = DateTime.Now; Blog.CurrentInstance.Cache.Remove(string.Format("{0}RecaptchaChallengeValue", this.UserUniqueIdentifier)); Blog.CurrentInstance.Cache.Remove(string.Format("{0}RecaptchaResponseValue", this.UserUniqueIdentifier)); }
public void UpdateLog(Comment comment) { if (RecaptchaLoggingEnabled && !skipRecaptcha) { RecaptchaLogItem logItem = new RecaptchaLogItem(); logItem.Response = RecaptchaResponseValue; logItem.Challenge = RecaptchaChallengeValue; logItem.CommentID = comment.Id; logItem.Enabled = RecaptchaEnabled; logItem.Necessary = RecaptchaNecessary; logItem.NumberOfAttempts = RecaptchaAttempts; logItem.TimeToComment = DateTime.Now.Subtract(PageLoadTime).TotalSeconds; logItem.TimeToSolveCapcha = DateTime.Now.Subtract(RecaptchaRenderTime).TotalSeconds; Stream s = (Stream)BlogService.LoadFromDataStore(BlogEngine.Core.DataStore.ExtensionType.Extension, "RecaptchaLog"); List<RecaptchaLogItem> log = new List<RecaptchaLogItem>(); if (s != null) { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List<RecaptchaLogItem>)); log = (List<RecaptchaLogItem>)serializer.Deserialize(s); s.Close(); } log.Add(logItem); if (log.Count > MaxLogEntries) { log.RemoveRange(0, log.Count - MaxLogEntries); } BlogService.SaveToDataStore(BlogEngine.Core.DataStore.ExtensionType.Extension, "RecaptchaLog", log); RecaptchaAttempts = 0; PageLoadTime = DateTime.Now; HttpContext.Current.Cache.Remove(UserUniqueIdentifier + "RecaptchaChallengeValue"); HttpContext.Current.Cache.Remove(UserUniqueIdentifier + "RecaptchaResponseValue"); } }