using System; using System.Configuration; using System.Collections.Generic; using System.IO; using System.Security.Cryptography; using System.Threading; using System.Web; using System.Web.Security; using System.Web.Configuration; using System.Text; using ScrewTurn.Wiki.PluginFramework; namespace ScrewTurn.Wiki { /// /// Allows access to all the ScrewTurn Wiki settings and configuration options. /// [System.Security.Permissions.FileIOPermission(System.Security.Permissions.SecurityAction.Assert, AllLocalFiles = System.Security.Permissions.FileIOPermissionAccess.PathDiscovery)] public static class Settings { private static string version = null; /// /// Gets the settings storage provider. /// public static ISettingsStorageProviderV30 Provider { get { return Collectors.SettingsProvider; } } /// /// Gets the version of the Wiki. /// public static string WikiVersion { get { if(version == null) { version = typeof(Settings).Assembly.GetName().Version.ToString(); } return version; } } /// /// Gets the name of the Login Cookie. /// public static string LoginCookieName { get { return "ScrewTurnWikiLogin3"; } } /// /// Gets the name of the Culture Cookie. /// public static string CultureCookieName { get { return "ScrewTurnWikiCulture3"; } } /// /// Gets the Master Password, used to encrypt the Users data. /// public static string MasterPassword { get { string pass = WebConfigurationManager.AppSettings["MasterPassword"]; if(pass == null || pass.Length == 0) throw new Exception("Configuration: MasterPassword cannot be null."); return pass; } } /// /// Gets the bytes of the MasterPassword. /// public static byte[] MasterPasswordBytes { get { MD5 md5 = MD5CryptoServiceProvider.Create(); return md5.ComputeHash(System.Text.UTF8Encoding.UTF8.GetBytes(MasterPassword)); } } /// /// Gets the extension used for Pages, including the dot. /// public static string PageExtension { get { return ".ashx"; } } /// /// Gets the display name validation regex. /// public static string DisplayNameRegex { get { return "^[^\\|\\r\\n]*$"; } } /// /// Gets the Email validation Regex. /// public static string EmailRegex { get { return @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})$"; } } /// /// Gets the WikiTitle validation Regex. /// public static string WikiTitleRegex { get { return ".+"; } } /// /// Gets the MainUrl validation Regex. /// public static string MainUrlRegex { get { return @"^https?\://{1}\S+/$"; } } /// /// Gets the SMTP Server validation Regex. /// public static string SmtpServerRegex { //get { return @"^(?:[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})|(?=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[0-2]*[0-9]*[0-9]+\.[0-2]*[0-9]*[0-9]+\.[0-2]*[0-9]*[0-9]+\.[0-2]*[0-9]*[0-9]+$"; } get { return @"^[A-Za-z0-9\.\-_]+$"; } } /// /// Begins a bulk update session. /// public static void BeginBulkUpdate() { Provider.BeginBulkUpdate(); } /// /// Ends a bulk update session. /// public static void EndBulkUpdate() { Provider.EndBulkUpdate(); } #region Directories and Files /// /// Gets the Root Directory of the Wiki. /// public static string RootDirectory { get { return System.Web.HttpRuntime.AppDomainAppPath; } } /// /// Gets the Public Directory of the Wiki. /// public static string PublicDirectory { get { return RootDirectory + PublicDirectoryName + Path.DirectorySeparatorChar; } } /// /// Gets the Public Directory Name (without the full Path) of the Wiki. /// public static string PublicDirectoryName { get { string dir = WebConfigurationManager.AppSettings["PublicDirectory"]; if(string.IsNullOrEmpty(dir)) throw new InvalidConfigurationException("PublicDirectory cannot be empty or null"); dir = dir.Trim('\\', '/'); // Remove '/' and '\' from head and tail if(string.IsNullOrEmpty(dir)) throw new InvalidConfigurationException("PublicDirectory cannot be empty or null"); else return dir; } } /// /// Gets the Name of the Themes directory. /// public static string ThemesDirectoryName { get { return "Themes"; } } /// /// Gets the Themes directory. /// public static string ThemesDirectory { get { return RootDirectory + ThemesDirectoryName + Path.DirectorySeparatorChar; } } /// /// Gets the Name of the JavaScript Directory. /// public static string JsDirectoryName { get { return "JS"; } } /// /// Gets the JavaScript Directory. /// public static string JsDirectory { get { return RootDirectory + JsDirectoryName + Path.DirectorySeparatorChar; } } #endregion #region Basic Settings and Associated Data /// /// Gets an integer. /// /// The string value. /// The default value, returned when string parsing fails. /// The result. private static int GetInt(string value, int def) { if(value == null) return def; int i = def; int.TryParse(value, out i); return i; } /// /// Gets a boolean. /// /// The string value. /// The default value, returned when parsing fails. /// The result. private static bool GetBool(string value, bool def) { if(value == null) return def; else { if(value.ToLowerInvariant() == "yes") return true; bool b = def; bool.TryParse(value, out b); return b; } } /// /// Prints a boolean. /// /// The value. /// The string result. private static string PrintBool(bool value) { return value ? "yes" : "no"; } /// /// Gets a string. /// /// The raw string. /// The default value, returned when the raw string is null. /// The result. private static string GetString(string value, string def) { if(string.IsNullOrEmpty(value)) return def; else return value; } /// /// Gets or sets the Title of the Wiki. /// public static string WikiTitle { get { return GetString(Provider.GetSetting("WikiTitle"), "ScrewTurn Wiki"); } set { Provider.SetSetting("WikiTitle", value); } } /// /// Gets or sets the SMTP Server. /// public static string SmtpServer { get { return GetString(Provider.GetSetting("SmtpServer"), "smtp.server.com"); } set { Provider.SetSetting("SmtpServer", value); } } /// /// Gets or sets the SMTP Server Username. /// public static string SmtpUsername { get { return GetString(Provider.GetSetting("SmtpUsername"), ""); } set { Provider.SetSetting("SmtpUsername", value); } } /// /// Gets or sets the SMTP Server Password. /// public static string SmtpPassword { get { return GetString(Provider.GetSetting("SmtpPassword"), ""); } set { Provider.SetSetting("SmtpPassword", value); } } /// /// Gets or sets the SMTP Server Port. /// public static int SmtpPort { get { return GetInt(Provider.GetSetting("SmtpPort"), -1); } set { Provider.SetSetting("SmtpPort", value.ToString()); } } /// /// Gets or sets a value specifying whether to enable SSL in SMTP. /// public static bool SmtpSsl { get { return GetBool(Provider.GetSetting("SmtpSsl"), false); } set { Provider.SetSetting("SmtpSsl", PrintBool(value)); } } /// /// Gets or sets a value specifying whether the access to the Wiki is public or not (in this case users won't need to login in order to edit pagesCache). /// /// Deprecated in version 3.0. public static bool PublicAccess { get { return GetBool(Provider.GetSetting("PublicAccess"), false); } set { Provider.SetSetting("PublicAccess", PrintBool(value)); } } /// /// Gets or sets a value specifying whether the access to the Wiki is private or not (in this case users won't be able to view pagesCache unless they are logged in). /// /// Deprecated in version 3.0. public static bool PrivateAccess { get { return GetBool(Provider.GetSetting("PrivateAccess"), false); } set { Provider.SetSetting("PrivateAccess", PrintBool(value)); } } /// /// Gets or sets a value specifying whether, in Public Access mode, anonymous file management is allowed. /// /// Deprecated in version 3.0. public static bool FileManagementInPublicAccessAllowed { get { return GetBool(Provider.GetSetting("FileManagementInPublicAccessAllowed"), false); } set { Provider.SetSetting("FileManagementInPublicAccessAllowed", PrintBool(value)); } } /// /// Gets or sets a value specifying whether Users can create new accounts or not (in this case Register.aspx won't be available). /// public static bool UsersCanRegister { get { return GetBool(Provider.GetSetting("UsersCanRegister"), true); } set { Provider.SetSetting("UsersCanRegister", PrintBool(value)); } } /// /// Gets or sets a value specifying whether to disable the Captcha control in the Registration Page. /// public static bool DisableCaptchaControl { get { return GetBool(Provider.GetSetting("DisableCaptchaControl"), false); } set { Provider.SetSetting("DisableCaptchaControl", PrintBool(value)); } } /// /// Gets or sets a value indicating whether to enable the "View Page Code" feature. /// public static bool EnableViewPageCodeFeature { get { return GetBool(Provider.GetSetting("EnableViewPageCode"), true); } set { Provider.SetSetting("EnableViewPageCode", PrintBool(value)); } } /// /// Gets or sets a value indicating whether to enable the Page Information DIV. /// public static bool EnablePageInfoDiv { get { return GetBool(Provider.GetSetting("EnablePageInfoDiv"), true); } set { Provider.SetSetting("EnablePageInfoDiv", PrintBool(value)); } } /// /// Gets or sets a value indicating whether to enable the Page Toolbar. /// public static bool EnablePageToolbar { get { return GetBool(Provider.GetSetting("EnablePageToolbar"), true); } set { Provider.SetSetting("EnablePageToolbar", PrintBool(value)); } } /// /// Gets or sets the Account Activation Mode. /// public static AccountActivationMode AccountActivationMode { get { string value = GetString(Provider.GetSetting("AccountActivationMode"), "EMAIL"); switch(value.ToLowerInvariant()) { case "email": return AccountActivationMode.Email; case "admin": return AccountActivationMode.Administrator; case "auto": return AccountActivationMode.Auto; default: return AccountActivationMode.Email; } } set { string aa = ""; switch(value) { case AccountActivationMode.Email: aa = "EMAIL"; break; case AccountActivationMode.Administrator: aa = "ADMIN"; break; case AccountActivationMode.Auto: aa = "AUTO"; break; default: throw new ArgumentException("Invalid Account Activation Mode."); } Provider.SetSetting("AccountActivationMode", aa); } } /// /// Gets or sets the page change moderation mode. /// public static ChangeModerationMode ChangeModerationMode { get { string value = GetString(Provider.GetSetting("ChangeModerationMode"), ChangeModerationMode.None.ToString()); return (ChangeModerationMode)Enum.Parse(typeof(ChangeModerationMode), value, true); } set { Provider.SetSetting("ChangeModerationMode", value.ToString()); } } /// /// Gets or sets a value specifying whether or not Users can create new Page. /// /// Deprecated in version 3.0. public static bool UsersCanCreateNewPages { get { return GetBool(Provider.GetSetting("UsersCanCreateNewPages"), true); } set { Provider.SetSetting("UsersCanCreateNewPages", PrintBool(value)); } } /// /// Gets or sets a value specifying whether or not users can view uploaded Files. /// /// Deprecated in version 3.0. public static bool UsersCanViewFiles { get { return GetBool(Provider.GetSetting("UsersCanViewFiles"), true); } set { Provider.SetSetting("UsersCanViewFiles", PrintBool(value)); } } /// /// Gets or sets a value specifying whether or not users can upload Files. /// /// Deprecated in version 3.0. public static bool UsersCanUploadFiles { get { return GetBool(Provider.GetSetting("UsersCanUploadFiles"), false); } set { Provider.SetSetting("UsersCanUploadFiles", PrintBool(value)); } } /// /// Gets or sets a value specifying whether or not users can delete Files. /// /// Deprecated in version 3.0. public static bool UsersCanDeleteFiles { get { return GetBool(Provider.GetSetting("UsersCanDeleteFiles"), false); } set { Provider.SetSetting("UsersCanDeleteFiles", PrintBool(value)); } } /// /// Gets or sets a value specifying whether or not users can create new Categories. /// /// Deprecated in version 3.0. public static bool UsersCanCreateNewCategories { get { return GetBool(Provider.GetSetting("UsersCanCreateNewCategories"), false); } set { Provider.SetSetting("UsersCanCreateNewCategories", PrintBool(value)); } } /// /// Gets or sets a value specifying whether or not users can manage Page Categories. /// /// Deprecated in version 3.0. public static bool UsersCanManagePageCategories { get { return GetBool(Provider.GetSetting("UsersCanManagePageCategories"), false); } set { Provider.SetSetting("UsersCanManagePageCategories", PrintBool(value)); } } /// /// Gets or sets the Default Language. /// public static string DefaultLanguage { get { return GetString(Provider.GetSetting("DefaultLanguage"), "en-US"); } set { Provider.SetSetting("DefaultLanguage", value); } } /// /// Gets or sets the Default Timezone (time delta in minutes). /// public static int DefaultTimezone { get { string value = GetString(Provider.GetSetting("DefaultTimezone"), "0"); return int.Parse(value); } set { Provider.SetSetting("DefaultTimezone", value.ToString()); } } /// /// Gets or sets the DateTime format. /// public static string DateTimeFormat { get { return GetString(Provider.GetSetting("DateTimeFormat"), "yyyy'/'MM'/'dd' 'HH':'mm"); } set { Provider.SetSetting("DateTimeFormat", value); } } /// /// Gets or sets the main URL of the Wiki. /// public static string MainUrl { get { string s = GetString(Provider.GetSetting("MainUrl"), "http://www.server.com/"); if(!s.EndsWith("/")) s += "/"; return s; } set { Provider.SetSetting("MainUrl", value); } } /// /// Gets the correct path to use with Cookies. /// public static string CookiePath { get { string requestUrl = HttpContext.Current.Request.RawUrl; string virtualDirectory = HttpContext.Current.Request.ApplicationPath; // We need to convert the case of the virtual directory to that used in the url // Return the virtual directory as is if we can't find it in the URL if (requestUrl.ToLower().Contains(virtualDirectory.ToLower())) { return requestUrl.Substring(requestUrl.ToLower().IndexOf(virtualDirectory.ToLower()),virtualDirectory.Length); } return virtualDirectory; } } /// /// Gets or sets the Contact Email. /// public static string ContactEmail { get { return GetString(Provider.GetSetting("ContactEmail"), "info@server.com"); } set { Provider.SetSetting("ContactEmail", value); } } /// /// Gets or sets the Sender Email. /// public static string SenderEmail { get { return GetString(Provider.GetSetting("SenderEmail"), "no-reply@server.com"); } set { Provider.SetSetting("SenderEmail", value); } } /// /// Gets or sets the email addresses to send a message to when an error occurs. /// public static string[] ErrorsEmails { get { return GetString(Provider.GetSetting("ErrorsEmails"), "").Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } set { Provider.SetSetting("ErrorsEmails", string.Join("|", value)); } } /// /// Gets or sets the Defaul Page of the Wiki. /// public static string DefaultPage { get { return GetString(Provider.GetSetting("DefaultPage"), "MainPage"); } set { Provider.SetSetting("DefaultPage", value); } } /// /// Gets or sets the maximum number of recent changes to display with {RecentChanges} special tag. /// public static int MaxRecentChangesToDisplay { get { return GetInt(Provider.GetSetting("MaxRecentChangesToDisplay"), 10); } set { Provider.SetSetting("MaxRecentChangesToDisplay", value.ToString()); } } /// /// Gets or sets a value specifying whether to enable double-click Page editing. /// public static bool EnableDoubleClickEditing { get { return GetBool(Provider.GetSetting("EnableDoubleClickEditing"), false); } set { Provider.SetSetting("EnableDoubleClickEditing", PrintBool(value)); } } /// /// Gets or sets a value indicating whether to enable section editing. /// public static bool EnableSectionEditing { get { return GetBool(Provider.GetSetting("EnableSectionEditing"), true); } set { Provider.SetSetting("EnableSectionEditing", PrintBool(value)); } } /// /// Gets or sets a value indicating whether to display section anchors. /// public static bool EnableSectionAnchors { get { return GetBool(Provider.GetSetting("EnableSectionAnchors"), true); } set { Provider.SetSetting("EnableSectionAnchors", PrintBool(value)); } } /// /// Gets or sets a value indicating whether to disable the Breadcrumbs Trail. /// public static bool DisableBreadcrumbsTrail { get { return GetBool(Provider.GetSetting("DisableBreadcrumbsTrail"), false); } set { Provider.SetSetting("DisableBreadcrumbsTrail", PrintBool(value)); } } /// /// Gets or sets a value indicating whether the editor should auto-generate page names from the title. /// public static bool AutoGeneratePageNames { get { return GetBool(Provider.GetSetting("AutoGeneratePageNames"), true); } set { Provider.SetSetting("AutoGeneratePageNames", PrintBool(value)); } } /// /// Gets or sets a value indicating whether or not to process single line breaks in WikiMarkup. /// public static bool ProcessSingleLineBreaks { get { return GetBool(Provider.GetSetting("ProcessSingleLineBreaks"), false); } set { Provider.SetSetting("ProcessSingleLineBreaks", PrintBool(value)); } } /// /// Gets or sets the # of Backups that are kept. Older backups are deleted after Page editing. /// /// -1 indicates that no backups are deleted. public static int KeptBackupNumber { get { return GetInt(Provider.GetSetting("KeptBackupNumber"), -1); } set { Provider.SetSetting("KeptBackupNumber", value.ToString()); } } /// /// Gets the theme name for a namespace. /// /// The namespace (null for the root). /// The theme name. public static string GetTheme(string nspace) { if(!string.IsNullOrEmpty(nspace)) nspace = Pages.FindNamespace(nspace).Name; string propertyName = "Theme" + (!string.IsNullOrEmpty(nspace) ? "-" + nspace : ""); return GetString(Provider.GetSetting(propertyName), "Default"); } /// /// Sets the theme for a namespace. /// /// The namespace (null for the root). /// The theme name. public static void SetTheme(string nspace, string theme) { if(!string.IsNullOrEmpty(nspace)) nspace = Pages.FindNamespace(nspace).Name; string propertyName = "Theme" + (!string.IsNullOrEmpty(nspace) ? "-" + nspace : ""); Provider.SetSetting(propertyName, theme); } /// /// Gets the Theme Path for a namespace. /// /// The namespace (null for the root). /// The path of the theme. public static string GetThemePath(string nspace) { return ThemesDirectoryName + "/" + GetTheme(nspace) + "/"; } /// /// Gets or sets the list of allowed file types. /// public static string[] AllowedFileTypes { get { string raw = GetString(Provider.GetSetting("AllowedFileTypes"), "jpg|jpeg|gif|png|tif|tiff|bmp|svg|htm|html|zip|rar|pdf|txt|doc|xls|ppt|docx|xlsx|pptx"); return raw.ToLowerInvariant().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } set { string res = string.Join("|", value); Provider.SetSetting("AllowedFileTypes", res); } } /// /// Gets or sets the file download count filter mode. /// public static FileDownloadCountFilterMode FileDownloadCountFilterMode { get { string raw = GetString(Provider.GetSetting("FileDownloadCountFilterMode"), FileDownloadCountFilterMode.CountAll.ToString()); return (FileDownloadCountFilterMode)Enum.Parse(typeof(FileDownloadCountFilterMode), raw); } set { Provider.SetSetting("FileDownloadCountFilterMode", value.ToString()); } } /// /// Gets or sets the file download count extension filter. /// public static string[] FileDownloadCountFilter { get { string raw = GetString(Provider.GetSetting("FileDownloadCountFilter"), ""); return raw.ToLowerInvariant().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } set { string res = string.Join("|", value); Provider.SetSetting("FileDownloadCountFilter", res); } } /// /// Gets or sets a value specifying whether script tags are allowed. /// public static bool ScriptTagsAllowed { get { return GetBool(Provider.GetSetting("ScriptTagsAllowed"), false); } set { Provider.SetSetting("ScriptTagsAllowed", PrintBool(value)); } } /// /// Gets or sets the Logging Level. /// public static LoggingLevel LoggingLevel { get { int value = GetInt(Provider.GetSetting("LoggingLevel"), 3); return (LoggingLevel)value; } set { Provider.SetSetting("LoggingLevel", ((int)value).ToString()); } } /// /// Gets or sets the Max size of the Log file (KB). /// public static int MaxLogSize { get { return GetInt(Provider.GetSetting("MaxLogSize"), 256); } set { Provider.SetSetting("MaxLogSize", value.ToString()); } } /// /// Gets or sets the IP/Host filter for page editing. /// public static string IpHostFilter { get{ return Provider.GetSetting("IpHostFilter"); } set { Provider.SetSetting("IpHostFilter", value); } } /// /// Gets or sets the max number of recent changes to log. /// public static int MaxRecentChanges { get { return GetInt(Provider.GetSetting("MaxRecentChanges"), 100); } set { Provider.SetSetting("MaxRecentChanges", value.ToString()); } } /// /// Gets or sets a valus specifying whether or not Administrators cannot access the Configuration section in the Administration page. /// /// Deprecated in version 3.0. [Obsolete] public static bool ConfigVisibleToAdmins { get { return GetBool(Provider.GetSetting("ConfigVisibleToAdmins"), false); } set { Provider.SetSetting("ConfigVisibleToAdmins", PrintBool(value)); } } /// /// Gets or sets the Type name of the Default Users Provider. /// public static string DefaultUsersProvider { get { return GetString(Provider.GetSetting("DefaultUsersProvider"), typeof(UsersStorageProvider).ToString()); } set { Provider.SetSetting("DefaultUsersProvider", value); } } /// /// Gets or sets the Type name of the Default Pages Provider. /// public static string DefaultPagesProvider { get { return GetString(Provider.GetSetting("DefaultPagesProvider"), typeof(PagesStorageProvider).ToString()); } set { Provider.SetSetting("DefaultPagesProvider", value); } } /// /// Gets or sets the Type name of the Default Files Provider. /// public static string DefaultFilesProvider { get { return GetString(Provider.GetSetting("DefaultFilesProvider"), typeof(FilesStorageProvider).ToString()); } set { Provider.SetSetting("DefaultFilesProvider", value); } } /// /// Gets or sets the Default Cache Provider. /// public static string DefaultCacheProvider { get { return GetString(Provider.GetSetting("DefaultCacheProvider"), typeof(CacheProvider).ToString()); } set { Provider.SetSetting("DefaultCacheProvider", value); } } /// /// Gets or sets the Discussion Permissions. /// public static string DiscussionPermissions { get { return GetString(Provider.GetSetting("DiscussionPermissions"), "PAGE"); } set { Provider.SetSetting("DiscussionPermissions", value); } } /// /// Gets or sets a value specifying whether or not to disable concurrent editing of Pages. /// public static bool DisableConcurrentEditing { get { return GetBool(Provider.GetSetting("DisableConcurrentEditing"), false); } set { Provider.SetSetting("DisableConcurrentEditing", PrintBool(value)); } } /// /// Gets or sets a value indicating whether to use the Visual editor as default. /// public static bool UseVisualEditorAsDefault { get { return GetBool(Provider.GetSetting("UseVisualEditorAsDefault"), false); } set { Provider.SetSetting("UseVisualEditorAsDefault", PrintBool(value)); } } /// /// Gets or sets the name of the default Administrators group. /// public static string AdministratorsGroup { get { return GetString(Provider.GetSetting("AdministratorsGroup"), "Administrators"); } set { Provider.SetSetting("AdministratorsGroup", value); } } /// /// Gets or sets the name of the default Users group. /// public static string UsersGroup { get { return GetString(Provider.GetSetting("UsersGroup"), "Users"); } set { Provider.SetSetting("UsersGroup", value); } } /// /// Gets or sets the name of the default Anonymous users group. /// public static string AnonymousGroup { get { return GetString(Provider.GetSetting("AnonymousGroup"), "Anonymous"); } set { Provider.SetSetting("AnonymousGroup", value); } } /// /// Gets or sets a value indicating whether to display gravatars. /// public static bool DisplayGravatars { get { return GetBool(Provider.GetSetting("DisplayGravatars"), true); } set { Provider.SetSetting("DisplayGravatars", PrintBool(value)); } } /// /// Gets or sets the functioning mode of RSS feeds. /// public static RssFeedsMode RssFeedsMode { get { string value = GetString(Provider.GetSetting("RssFeedsMode"), RssFeedsMode.Summary.ToString()); return (RssFeedsMode)Enum.Parse(typeof(RssFeedsMode), value); } set { Provider.SetSetting("RssFeedsMode", value.ToString()); } } #endregion #region Advanced Settings and Associated Data /// /// Gets or sets a value indicating whether to disable the Automatic Version Check. /// public static bool DisableAutomaticVersionCheck { get { return GetBool(Provider.GetSetting("DisableAutomaticVersionCheck"), false); } set { Provider.SetSetting("DisableAutomaticVersionCheck", PrintBool(value)); } } /// /// Gets or sets the Max file size for upload (in KB). /// public static int MaxFileSize { get { return GetInt(Provider.GetSetting("MaxFileSize"), 10240); } set { Provider.SetSetting("MaxFileSize", value.ToString()); } } /// /// Gets or sets a value specifying whether to disable the cache. /// public static bool DisableCache { get { return GetBool(Provider.GetSetting("DisableCache"), false); } set { Provider.SetSetting("DisableCache", PrintBool(value)); } } /// /// Gets or sets the Cache Size. /// public static int CacheSize { get { return GetInt(Provider.GetSetting("CacheSize"), 100); } set { Provider.SetSetting("CacheSize", value.ToString()); } } /// /// Gets or sets the Cache Cut Size. /// public static int CacheCutSize { get { return GetInt(Provider.GetSetting("CacheCutSize"), 20); } set { Provider.SetSetting("CacheCutSize", value.ToString()); } } /// /// Gets or sets a value specifying whether ViewState compression is enabled or not. /// public static bool EnableViewStateCompression { get { return GetBool(Provider.GetSetting("EnableViewStateCompression"), false); } set { Provider.SetSetting("EnableViewStateCompression", PrintBool(value)); } } /// /// Gets or sets a value specifying whether HTTP compression is enabled or not. /// public static bool EnableHttpCompression { get { return GetBool(Provider.GetSetting("EnableHttpCompression"), false); } set { Provider.SetSetting("EnableHttpCompression", PrintBool(value)); } } /// /// Gets or sets the Username validation Regex. /// public static string UsernameRegex { get { return GetString(Provider.GetSetting("UsernameRegex"), @"^\w[\w\ !$@%^\.\(\)]{3,25}$"); } set { Provider.SetSetting("UsernameRegex", value); } } /// /// Gets or sets the Password validation Regex. /// public static string PasswordRegex { get { return GetString(Provider.GetSetting("PasswordRegex"), @"^\w[\w~!@#$%^\(\)\[\]\{\}\.,=\-_\ ]{6,25}$"); } set { Provider.SetSetting("PasswordRegex", value); } } #endregion /// /// Determines whether a meta-data item is global or namespace-specific. /// /// The item to test. /// true if the meta-data item is global, false otherwise. public static bool IsMetaDataItemGlobal(MetaDataItem item) { int value = (int)item; return value < 100; // See MetaDataItem } } /// /// Lists legal RSS feeds function modes. /// public enum RssFeedsMode { /// /// RSS feeds serve full-text content. /// FullText, /// /// RSS feeds serve summary content. /// Summary, /// /// RSS feeds are disabled. /// Disabled } /// /// Lists legal file download filter modes. /// public enum FileDownloadCountFilterMode { /// /// Counts all downloads. /// CountAll, /// /// Counts only the specified extensions. /// CountSpecifiedExtensions, /// /// Excludes the specified extensions. /// ExcludeSpecifiedExtensions } /// /// Lists legal page change moderation mode values. /// public enum ChangeModerationMode { /// /// Page change moderation is disabled. /// None, /// /// Anyone who has page editing permissoins but not page management permissions /// can edit pages, but the changes are held in moderation. /// RequirePageEditingPermissions, /// /// Anyone who has page viewing permissions can edit pages, but the changes are /// held in moderation. /// RequirePageViewingPermissions } /// /// Lists legal account activation mode values. /// public enum AccountActivationMode { /// /// Users must activate their account via email. /// Email, /// /// Accounts must be activated by administrators. /// Administrator, /// /// Accounts are active by default. /// Auto } }