<commit_before>#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// Subtext WebLog
// 
// Subtext is an open source weblog system that is a fork of the .TEXT
// weblog system.
//
// For updated news and information please visit http://subtextproject.com/
// Subtext is hosted at SourceForge at http://sourceforge.net/projects/subtext
// The development mailing list is at <EMAIL> 
//
// This project is licensed under the BSD license.  See the License.txt file for more information.
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion

using System;
using System.Data.SqlClient;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Web;
using log4net;
using log4net.Appender;
using log4net.Repository.Hierarchy;
using Subtext.Framework;
using Subtext.Framework.Configuration;
using Subtext.Framework.Data;
using Subtext.Framework.Exceptions;
using Subtext.Framework.Logging;

namespace Subtext 
{
	public class Global : System.Web.HttpApplication
	{
		//This call is to kickstart log4net.
		//log4net Configuration Attribute is in AssemblyInfo
		private readonly static ILog log = LogManager.GetLogger(typeof(Global));

		static Global()
		{
			//Wrap the logger with our own.
			log = new Subtext.Framework.Logging.Log(log);
		}
		
		/// <summary>
		/// <para>
		/// This is used to vary partial caching of ASCX controls and ASPX pages on a per blog basis.  
		/// You can see this in action via the [PartialCaching] attribute.
		/// </para>
		/// <para>
		/// Provides an application-wide implementation of the <see cref="P:System.Web.UI.PartialCachingAttribute.VaryByCustom"/> property.
		/// </para>
		/// </summary>
		/// <param name="context">An <see cref="T:System.Web.HttpContext"/> that contains information about the current Web request</param>
		/// <param name="custom"></param>
		/// <returns>
		/// If the value of the <paramref name="custom"/> parameter is "browser", the browser's
		/// <see cref="System.Web.HttpBrowserCapabilities.Type"/> ; otherwise,
		/// <see langword="null"/> .
		/// </returns>
		public override string GetVaryByCustomString(HttpContext context, string custom)
		{
			if(custom == "Blogger" && !Security.IsAdmin && !Security.IsHostAdmin) // Do not cache admin.
			{
				return Config.CurrentBlog.Id.ToString(CultureInfo.InvariantCulture);
			}

			return base.GetVaryByCustomString(context, custom);
		}

		private const string ERROR_PAGE_LOCATION = "~/SystemMessages/error.aspx";
		private const string BAD_CONNECTION_STRING_PAGE = "~/SystemMessages/CheckYourConnectionString.aspx";

		public Global()
		{
			InitializeComponent();
		}	
		
		/// <summary>
		/// Method called by the application on startup.  
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Application_Start(Object sender, EventArgs e)
		{
			//This line will trigger the configuration.
			log.Info("Application_Start - This is not a malfunction.");
#if DEBUG
			log4net.Repository.Hierarchy.Hierarchy h = LogManager.GetRepository() as log4net.Repository.Hierarchy.Hierarchy;
			EnsureLog4NetConnectionString(h);
#endif
		}

#if DEBUG
		private static void EnsureLog4NetConnectionString(Hierarchy h)
		{
			if (h.Root.Appenders.Count == 0)
				throw new InvalidOperationException("No appenders configured!");

			foreach(IAppender appender in h.Root.Appenders)
			{
				AdoNetAppender adoAppender = appender as AdoNetAppender;
				if(adoAppender != null)
				{
					adoAppender.ActivateOptions();
					//Normalize appender connection string.
					if (!String.IsNullOrEmpty(adoAppender.ConnectionString) && !adoAppender.ConnectionString.EndsWith(";"))
						adoAppender.ConnectionString += ";";
					
					if(adoAppender.ConnectionString != Config.Settings.ConnectionString.ToString())
					{
						throw new InvalidOperationException("Log4Net is not picking up our connection string.");
					}					
				}
			}
		}
#endif

		/// <summary>
		/// Method called when a session starts.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Session_Start(Object sender, EventArgs e)<commit_msg>When ensuring that the log4net connection string is there, we were comparing against a normalized connection string. Now we compare against the one in web.config.<commit_after>#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// Subtext WebLog
// 
// Subtext is an open source weblog system that is a fork of the .TEXT
// weblog system.
//
// For updated news and information please visit http://subtextproject.com/
// Subtext is hosted at SourceForge at http://sourceforge.net/projects/subtext
// The development mailing list is at <EMAIL> 
//
// This project is licensed under the BSD license.  See the License.txt file for more information.
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion

using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Web;
using log4net;
using log4net.Appender;
using log4net.Repository.Hierarchy;
using Subtext.Framework;
using Subtext.Framework.Configuration;
using Subtext.Framework.Data;
using Subtext.Framework.Exceptions;
using Subtext.Framework.Logging;

namespace Subtext 
{
	public class Global : System.Web.HttpApplication
	{
		//This call is to kickstart log4net.
		//log4net Configuration Attribute is in AssemblyInfo
		private readonly static ILog log = LogManager.GetLogger(typeof(Global));

		static Global()
		{
			//Wrap the logger with our own.
			log = new Subtext.Framework.Logging.Log(log);
		}
		
		/// <summary>
		/// <para>
		/// This is used to vary partial caching of ASCX controls and ASPX pages on a per blog basis.  
		/// You can see this in action via the [PartialCaching] attribute.
		/// </para>
		/// <para>
		/// Provides an application-wide implementation of the <see cref="P:System.Web.UI.PartialCachingAttribute.VaryByCustom"/> property.
		/// </para>
		/// </summary>
		/// <param name="context">An <see cref="T:System.Web.HttpContext"/> that contains information about the current Web request</param>
		/// <param name="custom"></param>
		/// <returns>
		/// If the value of the <paramref name="custom"/> parameter is "browser", the browser's
		/// <see cref="System.Web.HttpBrowserCapabilities.Type"/> ; otherwise,
		/// <see langword="null"/> .
		/// </returns>
		public override string GetVaryByCustomString(HttpContext context, string custom)
		{
			if(custom == "Blogger" && !Security.IsAdmin && !Security.IsHostAdmin) // Do not cache admin.
			{
				return Config.CurrentBlog.Id.ToString(CultureInfo.InvariantCulture);
			}

			return base.GetVaryByCustomString(context, custom);
		}

		private const string ERROR_PAGE_LOCATION = "~/SystemMessages/error.aspx";
		private const string BAD_CONNECTION_STRING_PAGE = "~/SystemMessages/CheckYourConnectionString.aspx";

		public Global()
		{
			InitializeComponent();
		}	
		
		/// <summary>
		/// Method called by the application on startup.  
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Application_Start(Object sender, EventArgs e)
		{
			//This line will trigger the configuration.
			log.Info("Application_Start - This is not a malfunction.");
#if DEBUG
			log4net.Repository.Hierarchy.Hierarchy h = LogManager.GetRepository() as log4net.Repository.Hierarchy.Hierarchy;
			EnsureLog4NetConnectionString(h);
#endif
		}

#if DEBUG
		private static void EnsureLog4NetConnectionString(Hierarchy h)
		{
			if (h.Root.Appenders.Count == 0)
				throw new InvalidOperationException("No appenders configured!");

			foreach(IAppender appender in h.Root.Appenders)
			{
				AdoNetAppender adoAppender = appender as AdoNetAppender;
				if(adoAppender != null)
				{
					adoAppender.ActivateOptions();
					//Normalize appender connection string, since Log4Net seems to truncate that last semicolon.
					if (!String.IsNullOrEmpty(adoAppender.ConnectionString) && !adoAppender.ConnectionString.EndsWith(";"))
						adoAppender.ConnectionString += ";";
					
					if(adoAppender.ConnectionString != ConfigurationManager.ConnectionStrings["subtextData"].ConnectionString)
					{
						throw new InvalidOperationException("Log4Net is not picking up our connection string.");
					}					
				}
			}
		}
#endif

		/// <summary>
		/// Method called when a session starts.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Session_Start(Object sender, EventArgs e)
{'fraction_non_alphanumeric': 0.15877723280483633, 'fraction_numerical': 0.0027375384966351088, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7379918', 'n_tokens_mistral': 2727, 'n_tokens_neox': 2409, 'n_words': 701}