/// <summary> /// Creates a new Snippet. /// </summary> /// <param name="name">The name of the Snippet.</param> /// <param name="content">The content of the Snippet.</param> /// <param name="provider">The Provider to use to store the Snippet (<c>null</c> for the default provider).</param> /// <returns>True if the Snippets has been addedd successfully.</returns> public static bool AddSnippet(string name, string content, IPagesStorageProviderV30 provider) { if (Find(name) != null) { return(false); } if (provider == null) { provider = Collectors.PagesProviderCollector.GetProvider(Settings.DefaultPagesProvider); } Snippet newSnippet = provider.AddSnippet(name, content); if (newSnippet != null) { Log.LogEntry("Snippet " + name + " created", EntryType.General, Log.SystemUsername); Content.ClearPseudoCache(); Content.InvalidateAllPages(); } else { Log.LogEntry("Creation failed for Snippet " + name, EntryType.Error, Log.SystemUsername); } return(newSnippet != null); }
protected void btnClearCache_Click(object sender, EventArgs e) { Redirections.Clear(); Content.ClearPseudoCache(); Content.InvalidateAllPages(); PrintSystemStatus(); }
/// <summary> /// Removes a Snippet. /// </summary> /// <param name="snippet">The Snippet to remove.</param> /// <returns>True if the Snippet has been removed successfully.</returns> public static bool RemoveSnippet(Snippet snippet) { var done = snippet.Provider.RemoveSnippet(snippet.Name); if (done) { Log.LogEntry("Snippet " + snippet.Name + " deleted", EntryType.General, Log.SystemUsername); Content.ClearPseudoCache(); Content.InvalidateAllPages(); } else { Log.LogEntry("Deletion failed for Snippet " + snippet.Name, EntryType.Error, Log.SystemUsername); } return(done); }
/// <summary> /// Modifies the Content of a Snippet. /// </summary> /// <param name="snippet">The Snippet to update.</param> /// <param name="content">The new Content.</param> /// <returns>True if the Snippet has been updated successfully.</returns> public static bool ModifySnippet(Snippet snippet, string content) { Snippet newSnippet = snippet.Provider.ModifySnippet(snippet.Name, content); if (newSnippet != null) { Log.LogEntry("Snippet " + snippet.Name + " updated", EntryType.General, Log.SystemUsername); Content.ClearPseudoCache(); Content.InvalidateAllPages(); } else { Log.LogEntry("Modification failed for Snippet " + snippet.Name, EntryType.Error, Log.SystemUsername); } return(newSnippet != null); }
/// <summary> /// Performs all the actions that are needed after a provider status is changed. /// </summary> private void PerformPostProviderChangeActions() { Content.InvalidateAllPages(); Content.ClearPseudoCache(); }
protected void btnSave_Click(object sender, EventArgs e) { lblResult.CssClass = ""; lblResult.Text = ""; Page.Validate(); if (!Page.IsValid) { return; } Log.LogEntry("Wiki Configuration change requested", EntryType.General, SessionFacade.CurrentUsername); Settings.BeginBulkUpdate(); // Save general configuration Settings.WikiTitle = txtWikiTitle.Text; Settings.MainUrl = txtMainUrl.Text; Settings.ContactEmail = txtContactEmail.Text; Settings.SenderEmail = txtSenderEmail.Text; Settings.ErrorsEmails = GetErrorsEmails(); Settings.SmtpServer = txtSmtpServer.Text; txtSmtpPort.Text = txtSmtpPort.Text.Trim(); if (txtSmtpPort.Text.Length > 0) { Settings.SmtpPort = int.Parse(txtSmtpPort.Text); } else { Settings.SmtpPort = -1; } if (txtUsername.Text.Length > 0) { Settings.SmtpUsername = txtUsername.Text; Settings.SmtpPassword = txtPassword.Text; } else { Settings.SmtpUsername = ""; Settings.SmtpPassword = ""; } Settings.SmtpSsl = chkEnableSslForSmtp.Checked; // Save content configuration Settings.SetTheme(null, lstRootTheme.SelectedValue); Settings.DefaultPage = lstMainPage.SelectedValue; Settings.DateTimeFormat = txtDateTimeFormat.Text; Settings.DefaultLanguage = lstDefaultLanguage.SelectedValue; Settings.DefaultTimezone = int.Parse(lstDefaultTimeZone.SelectedValue); Settings.MaxRecentChangesToDisplay = int.Parse(txtMaxRecentChangesToDisplay.Text); Settings.RssFeedsMode = (RssFeedsMode)Enum.Parse(typeof(RssFeedsMode), lstRssFeedsMode.SelectedValue); Settings.EnableDoubleClickEditing = chkEnableDoubleClickEditing.Checked; Settings.EnableSectionEditing = chkEnableSectionEditing.Checked; Settings.EnableSectionAnchors = chkEnableSectionAnchors.Checked; Settings.EnablePageToolbar = chkEnablePageToolbar.Checked; Settings.EnableViewPageCodeFeature = chkEnableViewPageCode.Checked; Settings.EnablePageInfoDiv = chkEnablePageInfoDiv.Checked; Settings.DisableBreadcrumbsTrail = !chkEnableBreadcrumbsTrail.Checked; Settings.AutoGeneratePageNames = chkAutoGeneratePageNames.Checked; Settings.ProcessSingleLineBreaks = chkProcessSingleLineBreaks.Checked; Settings.UseVisualEditorAsDefault = chkUseVisualEditorAsDefault.Checked; if (txtKeptBackupNumber.Text == "") { Settings.KeptBackupNumber = -1; } else { Settings.KeptBackupNumber = int.Parse(txtKeptBackupNumber.Text); } Settings.DisplayGravatars = chkDisplayGravatars.Checked; Settings.ListSize = int.Parse(txtListSize.Text); // Save security configuration Settings.UsersCanRegister = chkAllowUsersToRegister.Checked; Settings.UsernameRegex = txtUsernameRegEx.Text; Settings.PasswordRegex = txtPasswordRegEx.Text; AccountActivationMode mode = AccountActivationMode.Email; switch (lstAccountActivationMode.SelectedValue.ToLowerInvariant()) { case "email": mode = AccountActivationMode.Email; break; case "admin": mode = AccountActivationMode.Administrator; break; case "auto": mode = AccountActivationMode.Auto; break; } Settings.AccountActivationMode = mode; Settings.UsersGroup = lstDefaultUsersGroup.SelectedValue; Settings.AdministratorsGroup = lstDefaultAdministratorsGroup.SelectedValue; Settings.AnonymousGroup = lstDefaultAnonymousGroup.SelectedValue; Settings.DisableCaptchaControl = !chkEnableCaptchaControl.Checked; Settings.DisableConcurrentEditing = chkPreventConcurrentEditing.Checked; if (rdoNoModeration.Checked) { Settings.ChangeModerationMode = ChangeModerationMode.None; } else if (rdoRequirePageViewingPermissions.Checked) { Settings.ChangeModerationMode = ChangeModerationMode.RequirePageViewingPermissions; } else if (rdoRequirePageEditingPermissions.Checked) { Settings.ChangeModerationMode = ChangeModerationMode.RequirePageEditingPermissions; } Settings.AllowedFileTypes = GetAllowedFileExtensions(); Settings.FileDownloadCountFilterMode = (FileDownloadCountFilterMode)Enum.Parse(typeof(FileDownloadCountFilterMode), lstFileDownloadCountFilterMode.SelectedValue); Settings.FileDownloadCountFilter = txtFileDownloadCountFilter.Text.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); Settings.MaxFileSize = int.Parse(txtMaxFileSize.Text); Settings.ScriptTagsAllowed = chkAllowScriptTags.Checked; LoggingLevel level = LoggingLevel.AllMessages; if (rdoAllMessages.Checked) { level = LoggingLevel.AllMessages; } else if (rdoWarningsAndErrors.Checked) { level = LoggingLevel.WarningsAndErrors; } else if (rdoErrorsOnly.Checked) { level = LoggingLevel.ErrorsOnly; } else { level = LoggingLevel.DisableLog; } Settings.LoggingLevel = level; Settings.MaxLogSize = int.Parse(txtMaxLogSize.Text); Settings.IpHostFilter = txtIpHostFilter.Text; // Save advanced configuration Settings.DisableAutomaticVersionCheck = !chkEnableAutomaticUpdateChecks.Checked; Settings.DisableCache = chkDisableCache.Checked; Settings.CacheSize = int.Parse(txtCacheSize.Text); Settings.CacheCutSize = int.Parse(txtCacheCutSize.Text); Settings.EnableViewStateCompression = chkEnableViewStateCompression.Checked; Settings.EnableHttpCompression = chkEnableHttpCompression.Checked; Settings.EndBulkUpdate(); Content.InvalidateAllPages(); Content.ClearPseudoCache(); lblResult.CssClass = "resultok"; lblResult.Text = Properties.Messages.ConfigSaved; }
public void ProcessRequest(HttpContext context) { string targetFolder = HttpContext.Current.Server.MapPath("uploadfiles"); if (!Directory.Exists(targetFolder)) { Directory.CreateDirectory(targetFolder); } HttpRequest request = context.Request; HttpFileCollection uploadedFiles = context.Request.Files; if (uploadedFiles != null && uploadedFiles.Count > 0) { for (int i = 0; i < uploadedFiles.Count; i++) { string fileName = uploadedFiles[i].FileName; int indx = fileName.LastIndexOf("\\"); if (indx > -1) { fileName = fileName.Substring(indx + 1); } uploadedFiles[i].SaveAs(targetFolder + "\\" + fileName); //string file = upDll.FileName; string ext = System.IO.Path.GetExtension(fileName); if (ext != null) { ext = ext.ToLowerInvariant(); } if (ext != ".dll") { //lblUploadResult.CssClass = "resulterror"; //lblUploadResult.Text = Properties.Messages.VoidOrInvalidFile; return; } Log.LogEntry("Provider DLL upload requested " + fileName, EntryType.General, SessionFacade.CurrentUsername); string[] asms = Settings.Provider.ListPluginAssemblies(); if (Array.Find <string>(asms, delegate(string v) { if (v.Equals(fileName)) { return(true); } else { return(false); } }) != null) { // DLL already exists //lblUploadResult.CssClass = "resulterror"; //lblUploadResult.Text = Properties.Messages.DllAlreadyExists; return; } else { BinaryReader b = new BinaryReader(uploadedFiles[i].InputStream); byte[] binData = b.ReadBytes(uploadedFiles[i].ContentLength); Stream stream = uploadedFiles[i].InputStream; stream.Position = 0; byte[] fileData = null; using (var binaryReader = new BinaryReader(uploadedFiles[i].InputStream)) { fileData = binaryReader.ReadBytes(uploadedFiles[i].ContentLength); Settings.Provider.StorePluginAssembly(fileName, fileData); } int count = ProviderLoader.LoadFromAuto(fileName); //lblUploadResult.CssClass = "resultok"; //lblUploadResult.Text = Properties.Messages.LoadedProviders.Replace("###", count.ToString()); //upDll.Attributes.Add("value", ""); //PerformPostProviderChangeActions(); Content.InvalidateAllPages(); Content.ClearPseudoCache(); //LoadDlls(); //populate the dropdownlist //ResetEditor(); // reset the upload control //rptProviders.DataBind(); //LoadSourceProviders(); } } } }