protected override void DoProcessing() { using (ServerManager serverManager = new ServerManager()) { ServerManagerWrapper serverManagerWrapper = new ServerManagerWrapper(serverManager, this.SiteName, this.VirtualPath); PHPConfigHelper configHelper = new PHPConfigHelper(serverManagerWrapper); PHPIniFile phpIniFile = configHelper.GetPHPIniFile(); PHPIniSetting setting = Helper.FindSetting(phpIniFile.Settings, Name); if (setting != null) { if (ShouldProcess(Name)) { string warningMessage = String.Format(Resources.DeleteSettingWarningMessage, setting.Name, setting.Value); if (Force || ShouldContinue(warningMessage, Resources.DeleteSettingWarningCaption)) { configHelper.RemovePHPIniSetting(setting); } } } else { ArgumentException ex = new ArgumentException(String.Format(Resources.SettingDoesNotExistError, Name)); ReportNonTerminatingError(ex, "InvalidArgument", ErrorCategory.ObjectNotFound); } } }
protected override void DoProcessing() { using (ServerManager serverManager = new ServerManager()) { ServerManagerWrapper serverManagerWrapper = new ServerManagerWrapper(serverManager, this.SiteName, this.VirtualPath); PHPConfigHelper configHelper = new PHPConfigHelper(serverManagerWrapper); PHPIniFile phpIniFile = configHelper.GetPHPIniFile(); PHPIniSetting setting = Helper.FindSetting(phpIniFile.Settings, Name); if (setting == null) { if (ShouldProcess(Name)) { RemoteObjectCollection <PHPIniSetting> settings = new RemoteObjectCollection <PHPIniSetting>(); settings.Add(new PHPIniSetting(Name, Value, Section)); configHelper.AddOrUpdatePHPIniSettings(settings); } } else { ArgumentException ex = new ArgumentException(String.Format(Resources.SettingAlreadyExistsError, Name)); ReportNonTerminatingError(ex, "InvalidArgument", ErrorCategory.InvalidArgument); } } }
private void LoadExtensions(PHPIniFile file) { try { ListView.SuspendLayout(); ListView.Items.Clear(); foreach (PHPIniExtension extension in file.Extensions) { if (_filterBy != null && _filterValue != null) { if (_filterBy == NameString && extension.Name.IndexOf(_filterValue, StringComparison.OrdinalIgnoreCase) == -1) { continue; } } ListView.Items.Add(new PHPExtensionItem(extension)); } if (SelectedGrouping != null) { Group(SelectedGrouping); } } finally { ListView.ResumeLayout(); } }
protected override void DoProcessing() { using (ServerManager serverManager = new ServerManager()) { ServerManagerWrapper serverManagerWrapper = new ServerManagerWrapper(serverManager, this.SiteName, this.VirtualPath); PHPConfigHelper configHelper = new PHPConfigHelper(serverManagerWrapper); PHPIniFile phpIniFile = configHelper.GetPHPIniFile(); WildcardPattern nameWildcard = PrepareWildcardPattern(Name); WildcardPattern sectionWildcard = PrepareWildcardPattern(Section); foreach (PHPIniSetting setting in phpIniFile.Settings) { if (!nameWildcard.IsMatch(setting.Name)) { continue; } if (!sectionWildcard.IsMatch(setting.Section)) { continue; } PHPSettingItem settingItem = new PHPSettingItem(setting); WriteObject(settingItem); } } }
protected override void DoProcessing() { using (ServerManager serverManager = new ServerManager()) { ServerManagerWrapper serverManagerWrapper = new ServerManagerWrapper(serverManager, this.SiteName, this.VirtualPath); PHPConfigHelper configHelper = new PHPConfigHelper(serverManagerWrapper); PHPIniFile phpIniFile = configHelper.GetPHPIniFile(); WildcardPattern wildcard = PrepareWildcardPattern(Name); foreach (PHPIniExtension extension in phpIniFile.Extensions) { if (!wildcard.IsMatch(extension.Name)) { continue; } if (Status == PHPExtensionStatus.Disabled && extension.Enabled) { continue; } if (Status == PHPExtensionStatus.Enabled && !extension.Enabled) { continue; } PHPExtensionItem extensionItem = new PHPExtensionItem(extension); WriteObject(extensionItem); } } }
private void UpdateUI(PHPIniFile file) { PHPIniSetting setting = file.GetSetting(_settingNames[0]); string[] settingValues = null; if (setting != null) { if (String.Equals(setting.GetTrimmedValue(), _settingsDevValues[0])) { _errorReportingPreset = ErrorReportingPreset.Development; settingValues = _settingsDevValues; } else if (String.Equals(setting.GetTrimmedValue(), _settingsProdValues[0])) { _errorReportingPreset = ErrorReportingPreset.Production; settingValues = _settingsProdValues; } int i = 1; var php7 = new Version(Module.Proxy.GetPHPConfigInfo().Version) >= new Version("7.2"); while (_errorReportingPreset != ErrorReportingPreset.Undefined && i < _settingNames.Length) { if (php7 && _settingNames[i] == "track_errors") { // IMPORTANT: skip obsolete setting. i++; continue; } setting = file.GetSetting(_settingNames[i]); if (setting == null || !String.Equals(setting.GetTrimmedValue(), settingValues[i])) { _errorReportingPreset = ErrorReportingPreset.Undefined; } i++; } } if (_errorReportingPreset == ErrorReportingPreset.Development) { _devMachineRadioButton.Checked = true; } else if (_errorReportingPreset == ErrorReportingPreset.Production) { _prodMachineRadioButton.Checked = true; } setting = file.GetSetting("error_log"); if (setting != null) { _errorLogFile = setting.GetTrimmedValue(); _errorLogFileTextBox.Text = setting.GetTrimmedValue(); } }
private static PHPIniFile LoadPhpFile(string phpFilePath) { if (phpFilePath == null) { throw new InvalidOperationException(); } var phpFile = new PHPIniFile(phpFilePath); return(phpFile); }
private void OnGetSettingsCompleted(object sender, RunWorkerCompletedEventArgs e) { try { object o = e.Result; var file = new PHPIniFile(); file.SetData(o); UpdateUI(file); } catch (Exception ex) { DisplayErrorMessage(ex, Resources.ResourceManager); } }
private void UpdateUI(PHPIniFile file) { PHPIniSetting setting = file.GetSetting(SettingNames[0]); string[] settingValues = null; if (setting != null) { if (String.Equals(setting.GetTrimmedValue(), SettingsDevValues[0])) { _errorReportingPreset = ErrorReportingPreset.Development; settingValues = SettingsDevValues; } else if (String.Equals(setting.GetTrimmedValue(), SettingsProdValues[0])) { _errorReportingPreset = ErrorReportingPreset.Production; settingValues = SettingsProdValues; } int i = 1; while (_errorReportingPreset != ErrorReportingPreset.Undefined && i < SettingNames.Length) { setting = file.GetSetting(SettingNames[i]); if (setting == null || !String.Equals(setting.GetTrimmedValue(), settingValues[i])) { _errorReportingPreset = ErrorReportingPreset.Undefined; } i = i + 1; } } if (_errorReportingPreset == ErrorReportingPreset.Development) { _devMachineRadioButton.Checked = true; } else if (_errorReportingPreset == ErrorReportingPreset.Production) { _prodMachineRadioButton.Checked = true; } setting = file.GetSetting("error_log"); if (setting != null) { _errorLogFile = setting.GetTrimmedValue(); _errorLogFileTextBox.Text = setting.GetTrimmedValue(); } }
protected override PropertyBag GetProperties() { var result = new PropertyBag(); var o = Module.Proxy.GetPHPIniSettings(); var file = new PHPIniFile(); file.SetData(o); for (var i = 0; i < _settingNames.Length; i++) { var setting = file.GetSetting(_settingNames[i]); if (setting != null) { result[i] = setting.Value; } } return(result); }
private void LoadPHPIni(PHPIniFile file) { try { ListView.SuspendLayout(); ListView.Items.Clear(); foreach (var setting in file.Settings) { if (_filterBy != null && _filterValue != null) { if (_filterBy == NameString && setting.Name.IndexOf(_filterValue, StringComparison.OrdinalIgnoreCase) == -1) { continue; } if (_filterBy == ValueString && setting.Value.IndexOf(_filterValue, StringComparison.OrdinalIgnoreCase) == -1) { continue; } if (_filterBy == SectionString && setting.Section.IndexOf(_filterValue, StringComparison.OrdinalIgnoreCase) == -1) { continue; } } ListView.Items.Add(new PHPSettingItem(setting)); } if (SelectedGrouping != null) { Group(SelectedGrouping); } } finally { ListView.ResumeLayout(); } }
private void OnGetSettingsCompleted(object sender, RunWorkerCompletedEventArgs e) { try { object o = e.Result; _file = new PHPIniFile(); _file.SetData(o); LoadPHPIni(_file); // If updated setting name was saved then use it to re-select it after refresh if (!String.IsNullOrEmpty(_updatedSettingName)) { SelectSettingByName(_updatedSettingName); _updatedSettingName = null; } } catch (Exception ex) { DisplayErrorMessage(ex, Resources.ResourceManager); } }
protected override void BeginProcessing() { EnsureAdminUser(); try { _serverManager = new ServerManager(); ServerManagerWrapper serverManagerWrapper = new ServerManagerWrapper(_serverManager, this.SiteName, this.VirtualPath); _configHelper = new PHPConfigHelper(serverManagerWrapper); _phpIniFile = _configHelper.GetPHPIniFile(); _extensions = new RemoteObjectCollection <PHPIniExtension>(); } catch (FileNotFoundException ex) { DisposeServerManager(); ReportTerminatingError(ex, "FileNotFound", ErrorCategory.ObjectNotFound); } catch (InvalidOperationException ex) { DisposeServerManager(); ReportTerminatingError(ex, "InvalidOperation", ErrorCategory.InvalidOperation); } }
private void OnGetExtensionsCompleted(object sender, RunWorkerCompletedEventArgs e) { try { object o = e.Result; _file = new PHPIniFile(); _file.SetData(o); LoadExtensions(_file); // If name of the updated extension was saved then use it to re-select it. if (!String.IsNullOrEmpty(_updatedExtensionName)) { SelectExtensionByName(_updatedExtensionName); _updatedExtensionName = null; } } catch (Exception ex) { DisplayErrorMessage(ex, Resources.ResourceManager); } }
public object GetPHPIniSettings() { EnsureServerOrSiteConnection(); PHPIniFile file = null; try { var mgmtUnitWrapper = new ManagementUnitWrapper(ManagementUnit); var configHelper = new PHPConfigHelper(mgmtUnitWrapper); file = configHelper.GetPHPIniFile(); } catch (FileNotFoundException) { RaiseException("ErrorPHPIniNotFound"); } catch (InvalidOperationException) { RaiseException("ErrorPHPIsNotRegistered"); } Debug.Assert(file != null); return(file.GetData()); }