diff --git a/umbraco/businesslogic/Log.cs b/umbraco/businesslogic/Log.cs
index 75ccd52fe0..051d96fe9d 100644
--- a/umbraco/businesslogic/Log.cs
+++ b/umbraco/businesslogic/Log.cs
@@ -370,6 +370,22 @@ namespace umbraco.BusinessLogic
#endregion
+ public static void CleanLogs(int maximumAgeOfLogsInMinutes)
+ {
+ try
+ {
+ DateTime oldestPermittedLogEntry = DateTime.Now.Subtract(new TimeSpan(0, maximumAgeOfLogsInMinutes, 0));
+ SqlHelper.ExecuteNonQuery("delete from umbracoLog where datestamp < @oldestPermittedLogEntry",
+ SqlHelper.CreateParameter("@oldestPermittedLogEntry", oldestPermittedLogEntry));
+ Add(LogTypes.System, -1, "Log scrubbed. Removed all items older than " + oldestPermittedLogEntry);
+ }
+ catch (Exception e)
+ {
+ Debug.WriteLine(e.ToString(), "Error");
+ Trace.WriteLine(e.ToString());
+ }
+ }
+
#endregion
}
diff --git a/umbraco/businesslogic/UmbracoSettings.cs b/umbraco/businesslogic/UmbracoSettings.cs
index ea190d376f..08f584baeb 100644
--- a/umbraco/businesslogic/UmbracoSettings.cs
+++ b/umbraco/businesslogic/UmbracoSettings.cs
@@ -134,6 +134,49 @@ namespace umbraco
}
}
+ ///
+ /// Gets a value indicating whether the logs will be auto cleaned
+ ///
+ /// true if logs are to be automatically cleaned; otherwise, false
+ public static bool AutoCleanLogs
+ {
+ get
+ {
+ string value = GetKey("/settings/logging/autoCleanLogs");
+ bool result;
+ if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result))
+ return result;
+ return false;
+ }
+ }
+
+ ///
+ /// Gets the value indicating the log cleaning frequency (in miliseconds)
+ ///
+ public static int CleaningMiliseconds
+ {
+ get
+ {
+ string value = GetKey("/settings/logging/cleaningMiliseconds");
+ int result;
+ if (!string.IsNullOrEmpty(value) && int.TryParse(value, out result))
+ return result;
+ return -1;
+ }
+ }
+
+ public static int MaxLogAge
+ {
+ get
+ {
+ string value = GetKey("/settings/logging/maxLogAge");
+ int result;
+ if (!string.IsNullOrEmpty(value) && int.TryParse(value, out result))
+ return result;
+ return -1;
+ }
+ }
+
///
/// Gets the disabled log types.
///
diff --git a/umbraco/businesslogic/umbraco.businesslogic.csproj b/umbraco/businesslogic/umbraco.businesslogic.csproj
index 89cf99af67..33b81f8560 100644
--- a/umbraco/businesslogic/umbraco.businesslogic.csproj
+++ b/umbraco/businesslogic/umbraco.businesslogic.csproj
@@ -107,7 +107,9 @@
System.Web
-
+
+ 3.5
+
System.XML
diff --git a/umbraco/cms/umbraco.cms.csproj b/umbraco/cms/umbraco.cms.csproj
index c0e8bd0bc9..5ffdea2b25 100644
--- a/umbraco/cms/umbraco.cms.csproj
+++ b/umbraco/cms/umbraco.cms.csproj
@@ -1,7 +1,7 @@
Local
- 9.0.21022
+ 9.0.30729
2.0
{CCD75EC3-63DB-4184-B49D-51C1DD337230}
Debug
@@ -107,7 +107,9 @@
System.Web
-
+
+ 3.5
+
System.XML
diff --git a/umbraco/presentation/Global.asax.cs b/umbraco/presentation/Global.asax.cs
index aaf41228df..77b94b8d3b 100644
--- a/umbraco/presentation/Global.asax.cs
+++ b/umbraco/presentation/Global.asax.cs
@@ -16,7 +16,6 @@ namespace umbraco
{
protected void Application_Start(Object sender, EventArgs e)
{
-
}
protected void Session_Start(Object sender, EventArgs e)
@@ -59,7 +58,7 @@ namespace umbraco
protected void Application_End(Object sender, EventArgs e)
{
- Log.Add(LogTypes.System, BusinessLogic.User.GetUser(0), -1, "Application shutted down at " + DateTime.Now);
+ Log.Add(LogTypes.System, BusinessLogic.User.GetUser(0), -1, "Application shut down at " + DateTime.Now);
}
}
}
diff --git a/umbraco/presentation/config/umbracoSettings.config b/umbraco/presentation/config/umbracoSettings.config
index 3e983911e9..a29e98918b 100644
--- a/umbraco/presentation/config/umbracoSettings.config
+++ b/umbraco/presentation/config/umbracoSettings.config
@@ -85,6 +85,9 @@
+ true
+ 86400
+ 1440
diff --git a/umbraco/presentation/requestModule.cs b/umbraco/presentation/requestModule.cs
index 6b8b64bdf3..8a9e3d059e 100644
--- a/umbraco/presentation/requestModule.cs
+++ b/umbraco/presentation/requestModule.cs
@@ -6,6 +6,8 @@ using System.Web;
using umbraco.BusinessLogic;
using System.Collections.Generic;
+using umbraco.cms.businesslogic.cache;
+using System.Web.Caching;
namespace umbraco.presentation
@@ -28,6 +30,9 @@ namespace umbraco.presentation
public const string ORIGINAL_URL_CXT_KEY = "umbOriginalUrl";
+ private static string LOG_SCRUBBER_TASK_NAME = "ScrubLogs";
+ private static CacheItemRemovedCallback OnCacheRemove = null;
+
protected void ApplicationStart(HttpApplication HttpApp)
{
//starting the application. Application doesn't support HttpContext in integrated mode (standard mode on IIS7)
@@ -79,18 +84,20 @@ namespace umbraco.presentation
// adding endswith and contains checks to ensure support for custom 404 messages (only 404 parse directory and aspx requests)
if (querystring.StartsWith("?404") && (!querystring.Contains(".") || querystring.EndsWith(".aspx") || querystring.Contains(".aspx&")))
{
- Uri u = new Uri(querystring.Substring(5, querystring.Length-5));
+ Uri u = new Uri(querystring.Substring(5, querystring.Length - 5));
string path = u.AbsolutePath;
if (returnQuery)
{
return u.Query;
}
- else {
+ else
+ {
return path;
}
}
- if (returnQuery) {
+ if (returnQuery)
+ {
return querystring;
}
else
@@ -301,6 +308,10 @@ namespace umbraco.presentation
try
{
Log.Add(LogTypes.System, User.GetUser(0), -1, "Application started at " + DateTime.Now);
+ if (UmbracoSettings.AutoCleanLogs)
+ {
+ AddTask(LOG_SCRUBBER_TASK_NAME, GetLogScrubbingInterval());
+ }
}
catch
{
@@ -331,7 +342,7 @@ namespace umbraco.presentation
//Find Applications and event handlers and hook-up the events
//BusinessLogic.Application.RegisterIApplications();
- //define the base settings for the dependency loader to use the global path settings
+ //define the base settings for the dependency loader to use the global path settings
//if (!CompositeDependencyHandler.HandlerFileName.StartsWith(GlobalSettings.Path))
// CompositeDependencyHandler.HandlerFileName = GlobalSettings.Path + "/" + CompositeDependencyHandler.HandlerFileName;
@@ -343,6 +354,62 @@ namespace umbraco.presentation
}
#endregion
+
+ #region Inteval tasks
+ private static int GetLogScrubbingInterval()
+ {
+ int interval = 24 * 60 * 60; //24 hours
+ try
+ {
+ if (UmbracoSettings.CleaningMiliseconds > -1)
+ interval = UmbracoSettings.CleaningMiliseconds;
+ }
+ catch (Exception)
+ {
+ Log.Add(LogTypes.System, -1, "Unable to locate a log scrubbing interval. Defaulting to 24 horus");
+ }
+ return interval;
+ }
+
+ private static int GetLogScrubbingMaximumAge()
+ {
+ int maximumAge = 24 * 60 * 60;
+ try
+ {
+ if (UmbracoSettings.MaxLogAge > -1)
+ maximumAge = UmbracoSettings.MaxLogAge;
+ }
+ catch (Exception)
+ {
+ Log.Add(LogTypes.System, -1, "Unable to locate a log scrubbing maximum age. Defaulting to 24 horus");
+ }
+ return maximumAge;
+
+ }
+
+ private void AddTask(string name, int seconds)
+ {
+ OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
+ HttpRuntime.Cache.Insert(name, seconds, null,
+ DateTime.Now.AddSeconds(seconds), System.Web.Caching.Cache.NoSlidingExpiration,
+ CacheItemPriority.NotRemovable, OnCacheRemove);
+ }
+
+ public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
+ {
+ if (k.Equals(LOG_SCRUBBER_TASK_NAME))
+ {
+ ScrubLogs();
+ }
+ AddTask(k, Convert.ToInt32(v));
+ }
+
+ private static void ScrubLogs()
+ {
+ Log.CleanLogs(GetLogScrubbingMaximumAge());
+ }
+
+ #endregion
}
diff --git a/umbraco/providers/members/MembersMembershipProvider.cs b/umbraco/providers/members/MembersMembershipProvider.cs
index 38bebc0b56..1fff1e8af7 100644
--- a/umbraco/providers/members/MembersMembershipProvider.cs
+++ b/umbraco/providers/members/MembersMembershipProvider.cs
@@ -660,7 +660,7 @@ namespace umbraco.providers.members
}
}
string newPassword = Membership.GeneratePassword(MinRequiredPasswordLength, MinRequiredNonAlphanumericCharacters);
- m.Password = EncodePassword(newPassword);
+ m.Password = newPassword;
return newPassword;
}
}