Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnAccept()
        {
            try
            {
                var setting = new PHPIniSetting
                {
                    Name    = _nameTextBox.Text.Trim(),
                    Value   = _valueTextBox.Text.Trim(),
                    Section = _sectionTextBox.Text.Trim()
                };

                var settings = new RemoteObjectCollection <PHPIniSetting> {
                    setting
                };
                _module.Proxy.AddOrUpdateSettings(settings);

                DialogResult = DialogResult.OK;
                SettingName  = setting.Name;
                Close();
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
        }
Ejemplo n.º 3
0
        public string AddExtension(string extensionPath)
        {
            if (String.IsNullOrEmpty(extensionPath))
            {
                throw new ArgumentException("The extension path is not specified.");
            }

            EnsurePHPIsRegistered();

            var filename = Path.GetFileName(extensionPath);
            if (String.IsNullOrEmpty(filename))
            {
                throw new ArgumentException(String.Format("Cannot extract file name from the extention path {0}.", extensionPath));   
            }
            var targetPath = Path.Combine(PHPDirectory, "ext");
            targetPath = Path.Combine(targetPath, filename);

            File.Copy(extensionPath, targetPath, false);
            var extension = new PHPIniExtension(filename, true);

            var extensions = new RemoteObjectCollection<PHPIniExtension> { extension };
            UpdateExtensions(extensions);
            
            return extension.Name;
        }
Ejemplo n.º 4
0
        protected override void DoProcessing()
        {
            using (var serverManager = new ServerManager())
            {
                var serverManagerWrapper = new ServerManagerWrapper(serverManager, SiteName, VirtualPath);
                var configHelper = new PHPConfigHelper(serverManagerWrapper);
                var phpIniFile = configHelper.GetPHPIniFile();

                var setting = Helper.FindSetting(phpIniFile.Settings, Name);
                if (setting != null)
                {
                    if (ShouldProcess(Name))
                    {
                        var settings = new RemoteObjectCollection<PHPIniSetting>
                            {
                                new PHPIniSetting(Name, Value, setting.Section)
                            };
                        configHelper.AddOrUpdatePHPIniSettings(settings);
                    }
                }
                else
                {
                    var ex = new ArgumentException(String.Format(Resources.SettingDoesNotExistError, Name));
                    ReportNonTerminatingError(ex, "InvalidArgument", ErrorCategory.ObjectNotFound);
                }
            }
        }
Ejemplo n.º 5
0
        private void OnGetVersionsDoWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _versionComboBox.BeginUpdate();
            _versionComboBox.SuspendLayout();

            try
            {
                RemoteObjectCollection <PHPVersion> phpVersions = e.Result as RemoteObjectCollection <PHPVersion>;
                foreach (PHPVersion phpVersion in phpVersions)
                {
                    phpVersion.Version = String.Format("{0} ({1})", phpVersion.Version, phpVersion.ScriptProcessor);
                    _versionComboBox.Items.Add(phpVersion);
                }
                _versionComboBox.DisplayMember = "Version";
                _versionComboBox.SelectedIndex = 0;
                if (_versionComboBox.Items.Count > 0)
                {
                    UpdateTaskForm();
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                _versionComboBox.ResumeLayout();
                _versionComboBox.EndUpdate();
            }
        }
Ejemplo n.º 6
0
        protected override void DoProcessing()
        {
            using (var serverManager = new ServerManager())
            {
                var serverManagerWrapper = new ServerManagerWrapper(serverManager, SiteName, VirtualPath);
                var configHelper         = new PHPConfigHelper(serverManagerWrapper);
                var phpIniFile           = configHelper.GetPHPIniFile();

                var setting = Helper.FindSetting(phpIniFile.Settings, Name);
                if (setting != null)
                {
                    if (ShouldProcess(Name))
                    {
                        var settings = new RemoteObjectCollection <PHPIniSetting>
                        {
                            new PHPIniSetting(Name, Value, setting.Section)
                        };
                        configHelper.AddOrUpdatePHPIniSettings(settings);
                    }
                }
                else
                {
                    var ex = new ArgumentException(String.Format(Resources.SettingDoesNotExistError, Name));
                    ReportNonTerminatingError(ex, "InvalidArgument", ErrorCategory.ObjectNotFound);
                }
            }
        }
Ejemplo n.º 7
0
        protected override void DoProcessing()
        {
            using (ServerManager serverManager = new ServerManager())
            {
                ServerManagerWrapper serverManagerWrapper       = new ServerManagerWrapper(serverManager, this.SiteName, this.VirtualPath);
                PHPConfigHelper      configHelper               = new PHPConfigHelper(serverManagerWrapper);
                RemoteObjectCollection <PHPVersion> phpVersions = configHelper.GetAllPHPVersions();

                WildcardPattern nameWildcard    = PrepareWildcardPattern(HandlerName);
                WildcardPattern versionWildcard = PrepareWildcardPattern(Version);

                bool isActive = true;
                foreach (PHPVersion phpVersion in phpVersions)
                {
                    if (!nameWildcard.IsMatch(phpVersion.HandlerName))
                    {
                        isActive = false;
                        continue;
                    }
                    if (!versionWildcard.IsMatch(phpVersion.Version))
                    {
                        isActive = false;
                        continue;
                    }

                    PHPVersionItem versionItem = new PHPVersionItem(phpVersion, isActive);
                    WriteObject(versionItem);
                    isActive = false;
                }
            }
        }
Ejemplo n.º 8
0
        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);
                }
            }
        }
Ejemplo n.º 9
0
        protected override bool ApplyChanges()
        {
            bool appliedChanges = false;

            string[] settingValues = null;

            Debug.Assert(_devMachineRadioButton.Checked || _prodMachineRadioButton.Checked);
            if (_devMachineRadioButton.Checked)
            {
                settingValues = SettingsDevValues;
            }
            else if (_prodMachineRadioButton.Checked)
            {
                settingValues = SettingsProdValues;
            }

            RemoteObjectCollection <PHPIniSetting> settings = new RemoteObjectCollection <PHPIniSetting>();

            for (int i = 0; i < settingValues.Length; i++)
            {
                settings.Add(new PHPIniSetting(SettingNames[i], settingValues[i], "PHP"));
            }

            string errorLogValue = '"' + _errorLogFileTextBox.Text.Trim(new char [] { ' ', '"' }) + '"';

            settings.Add(new PHPIniSetting("error_log", errorLogValue, "PHP"));

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                appliedChanges = true;

                // Update the values used for determining if changes have been made
                _errorLogFile = _errorLogFileTextBox.Text;
                if (_devMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                }
                else if (_prodMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                }
                _hasChanges = false;
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                Update();
            }

            return(appliedChanges);
        }
Ejemplo n.º 10
0
        public void AddOrUpdateSettings(object settingsData)
        {
            EnsureServerConnection();

            PHPIniFile file = GetPHPIniFile();

            RemoteObjectCollection<PHPIniSetting> settings = new RemoteObjectCollection<PHPIniSetting>();
            ((IRemoteObject)settings).SetData(settingsData);

            file.AddOrUpdateSettings(settings);
            file.Save(file.FileName);
        }
Ejemplo n.º 11
0
        internal RemoteObjectCollection<PHPVersion> GetAllPHPVersions()
        {
            object o = Invoke("GetAllPHPVersions");

            if (o != null)
            {
                RemoteObjectCollection<PHPVersion> versions = new RemoteObjectCollection<PHPVersion>();
                versions.SetData(o);
                return versions;
            }

            return null;
        }
Ejemplo n.º 12
0
        internal RemoteObjectCollection<PHPConfigIssue> GetConfigIssues()
        {
            object o = Invoke("GetConfigIssues");

            if (o != null)
            {
                RemoteObjectCollection<PHPConfigIssue> configIssues = new RemoteObjectCollection<PHPConfigIssue>();
                configIssues.SetData(o);
                return configIssues;
            }

            return null;
        }
Ejemplo n.º 13
0
        public static PHPIniSetting FindSetting(RemoteObjectCollection <PHPIniSetting> settings, string name)
        {
            PHPIniSetting result = null;

            foreach (PHPIniSetting setting in settings)
            {
                if (String.Equals(setting.Name, name, StringComparison.OrdinalIgnoreCase))
                {
                    result = setting;
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 14
0
        public static PHPIniExtension FindExtension(RemoteObjectCollection <PHPIniExtension> extensions, string name)
        {
            PHPIniExtension result = null;

            foreach (PHPIniExtension extension in extensions)
            {
                if (String.Equals(extension.Name, name, StringComparison.OrdinalIgnoreCase))
                {
                    result = extension;
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 15
0
        public static PHPIniExtension FindExtension(RemoteObjectCollection<PHPIniExtension> extensions, string name)
        {
            PHPIniExtension result = null;

            foreach (PHPIniExtension extension in extensions)
            {
                if (String.Equals(extension.Name, name, StringComparison.OrdinalIgnoreCase))
                {
                    result = extension;
                    break;
                }
            }

            return result;
        }
Ejemplo n.º 16
0
        public static PHPIniSetting FindSetting(RemoteObjectCollection<PHPIniSetting> settings, string name)
        {
            PHPIniSetting result = null;

            foreach (PHPIniSetting setting in settings)
            {
                if (String.Equals(setting.Name, name, StringComparison.OrdinalIgnoreCase))
                {
                    result = setting;
                    break;
                }
            }

            return result;
        }
Ejemplo n.º 17
0
        private void OnConfigIssuesDoWorkCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _configIssuesListView.BeginUpdate();
            _configIssuesListView.SuspendLayout();

            try
            {
                RemoteObjectCollection <PHPConfigIssue> configIssues = e.Result as RemoteObjectCollection <PHPConfigIssue>;
                if (configIssues != null)
                {
                    foreach (PHPConfigIssue configIssue in configIssues)
                    {
                        ListViewItem listViewItem = new ListViewItem(configIssue.SettingName);
                        if (String.IsNullOrEmpty(configIssue.CurrentValue))
                        {
                            listViewItem.SubItems.Add(Resources.ConfigIssueNone);
                        }
                        else
                        {
                            listViewItem.SubItems.Add(configIssue.CurrentValue);
                        }
                        listViewItem.SubItems.Add(configIssue.RecommendedValue);
                        listViewItem.Tag = new object[TagSize] {
                            GetResourceStringByName(configIssue.IssueDescription),
                            GetResourceStringByName(configIssue.Recommendation),
                            configIssue.IssueIndex
                        };
                        _configIssuesListView.Items.Add(listViewItem);
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                _configIssuesListView.ResumeLayout();
                _configIssuesListView.EndUpdate();
            }

            if (_configIssuesListView.Items.Count > 0)
            {
                _configIssuesListView.Focus();
                _configIssuesListView.Items[0].Selected = true;
                UpdateTaskForm();
            }
        }
Ejemplo n.º 18
0
        public string AddExtension(string extensionPath)
        {
            EnsurePHPIsRegistered();

            string filename = Path.GetFileName(extensionPath);
            string targetPath = Path.Combine(PHPDirectory, "ext");
            targetPath = Path.Combine(targetPath, filename);

            File.Copy(extensionPath, targetPath, false);
            PHPIniExtension extension = new PHPIniExtension(filename, true);

            RemoteObjectCollection<PHPIniExtension> extensions = new RemoteObjectCollection<PHPIniExtension>();
            extensions.Add(extension);
            UpdateExtensions(extensions);
            
            return extension.Name;
        }
Ejemplo n.º 19
0
        public void AddOrUpdateSettings(object settingsData)
        {
            EnsureServerConnection();

            RemoteObjectCollection<PHPIniSetting> settings = new RemoteObjectCollection<PHPIniSetting>();
            ((IRemoteObject)settings).SetData(settingsData);

            try
            {
                PHPConfigHelper configHelper = new PHPConfigHelper(ManagementUnit);
                configHelper.AddOrUpdatePHPIniSettings(settings);
            }
            catch (FileNotFoundException)
            {
                RaiseException("ErrorPHPIniNotFound");
            }
        }
Ejemplo n.º 20
0
        private void SetExtensionState(bool enabled)
        {
            PHPExtensionItem item = SelectedItem;

            Debug.Assert(item != null);
            item.Extension.Enabled = enabled;
            RemoteObjectCollection <PHPIniExtension> extensions = new RemoteObjectCollection <PHPIniExtension>();

            extensions.Add(item.Extension);
            try
            {
                Module.Proxy.UpdateExtensions(extensions);
                // Save the name of the updated extension so that we can select it after refresh
                _updatedExtensionName = item.Extension.Name;
                Refresh();
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
        }
Ejemplo n.º 21
0
        public string AddExtension(string extensionPath)
        {
            Debug.Assert(IsPHPRegistered());

            string filename = Path.GetFileName(extensionPath);
            string targetPath = PHPDirectory + "ext\\" + filename;

            if (File.Exists(targetPath))
            {
                throw new InvalidOperationException("The extension file " + filename + " already exists at the PHP ext directory");
            }

            File.Copy(extensionPath, targetPath, false);
            PHPIniExtension extension = new PHPIniExtension(filename, true);

            RemoteObjectCollection<PHPIniExtension> extensions = new RemoteObjectCollection<PHPIniExtension>();
            extensions.Add(extension);
            UpdateExtensions(extensions);
            
            return extension.Name;
        }
Ejemplo n.º 22
0
        public void AddOrUpdateSettings(object settingsData)
        {
            EnsureServerConnection();

            var settings = new RemoteObjectCollection<PHPIniSetting>();
            settings.SetData(settingsData);

            try
            {
                var mgmtUnitWrapper = new ManagementUnitWrapper(ManagementUnit);
                var configHelper = new PHPConfigHelper(mgmtUnitWrapper);
                configHelper.AddOrUpdatePHPIniSettings(settings);
            }
            catch (FileNotFoundException)
            {
                RaiseException("ErrorPHPIniNotFound");
            }
            catch (InvalidOperationException)
            {
                RaiseException("ErrorPHPIsNotRegistered");
            }
        }
Ejemplo n.º 23
0
        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);
            }
        }
Ejemplo n.º 24
0
        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);
            }
        }
Ejemplo n.º 25
0
        protected override PropertyBag UpdateProperties(out bool updateSuccessful)
        {
            updateSuccessful = false;

            var settings = new RemoteObjectCollection <PHPIniSetting>();

            for (var i = 0; i < _settingNames.Length; i++)
            {
                settings.Add(new PHPIniSetting(_settingNames[i], (string)_clone[i], "PHP"));
            }

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                _bag             = _clone;
                updateSuccessful = true;
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }

            return(_bag);
        }
Ejemplo n.º 26
0
 public static PHPIniSetting FindSetting(RemoteObjectCollection <PHPIniSetting> settings, string name)
 {
     return(settings.FirstOrDefault(setting => String.Equals(setting.Name, name, StringComparison.OrdinalIgnoreCase)));
 }
Ejemplo n.º 27
0
 public static PHPIniExtension FindExtension(RemoteObjectCollection<PHPIniExtension> extensions, string name)
 {
     return extensions.FirstOrDefault(extension => String.Equals(extension.Name, name, StringComparison.OrdinalIgnoreCase));
 }
Ejemplo n.º 28
0
 public static PHPIniSetting FindSetting(RemoteObjectCollection<PHPIniSetting> settings, string name)
 {
     return settings.FirstOrDefault(setting => String.Equals(setting.Name, name, StringComparison.OrdinalIgnoreCase));
 }
Ejemplo n.º 29
0
        public RemoteObjectCollection<PHPVersion> GetAllPHPVersions()
        {
            EnsurePHPIsRegistered();

            var result = new RemoteObjectCollection<PHPVersion>();
            
            foreach (var handler in _handlersCollection)
            {
                if (!String.Equals(handler.Path, "*.php", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                
                if (String.Equals(handler.Modules, "FastCgiModule", StringComparison.OrdinalIgnoreCase) &&
                    File.Exists(handler.Executable))
                {
                    result.Add(new PHPVersion(handler.Name, handler.Executable, GetPHPExecutableVersion(handler.Executable)));
                }
            }

            return result;
        }
Ejemplo n.º 30
0
        private RemoteObjectCollection<PHPConfigIssue> ValidateConfiguration(PHPIniFile file)
        {

            var configIssues = new RemoteObjectCollection<PHPConfigIssue>();
          
            // IIS and FastCGI settings
            var configIssue = ValidateDefaultDocument();
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }
            
            configIssue = ValidateResourceType();
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidatePHPMaxRequests();
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidatePHPRC();
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateMonitorChanges();
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            // PHP Settings
            configIssue = ValidateExtensionDir(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateLogErrors(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateErrorLog(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateSessionPath(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateUploadTmpDir(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateCgiForceRedirect(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateCgiPathInfo(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateFastCgiImpersonate(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            configIssue = ValidateDateTimeZone(file);
            if (configIssue != null)
            {
                configIssues.Add(configIssue);
            }

            return configIssues;
        }
Ejemplo n.º 31
0
        protected override bool ApplyChanges()
        {
            bool appliedChanges = false;

            string[] settingValues = null;

            Debug.Assert(_devMachineRadioButton.Checked || _prodMachineRadioButton.Checked);
            if (_devMachineRadioButton.Checked)
            {
                settingValues = SettingsDevValues;
            }
            else if (_prodMachineRadioButton.Checked)
            {
                settingValues = SettingsProdValues;
            }

            RemoteObjectCollection<PHPIniSetting> settings = new RemoteObjectCollection<PHPIniSetting>();
            for (int i = 0; i < settingValues.Length; i++)
            {
                settings.Add(new PHPIniSetting(SettingNames[i], settingValues[i], "PHP"));
            }

            string errorLogValue = '"' + _errorLogFileTextBox.Text.Trim(new char [] {' ', '"'}) + '"';
            settings.Add(new PHPIniSetting("error_log", errorLogValue, "PHP"));

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                appliedChanges = true;
                
                // Update the values used for determining if changes have been made
                _errorLogFile = _errorLogFileTextBox.Text;
                if (_devMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                }
                else if (_prodMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                }
                _hasChanges = false;
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                Update();
            }

            return appliedChanges;
        }
Ejemplo n.º 32
0
 public static PHPIniExtension FindExtension(RemoteObjectCollection <PHPIniExtension> extensions, string name)
 {
     return(extensions.FirstOrDefault(extension => String.Equals(extension.Name, name, StringComparison.OrdinalIgnoreCase)));
 }
Ejemplo n.º 33
0
        protected override PropertyBag UpdateProperties(out bool updateSuccessful)
        {
            updateSuccessful = false;

            RemoteObjectCollection<PHPIniSetting> settings = new RemoteObjectCollection<PHPIniSetting>();

            for (int i = 0; i < _settingNames.Length; i++)
            {
                settings.Add(new PHPIniSetting(_settingNames[i], (string)_clone[i], "PHP"));
            }

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                _bag = _clone;
                updateSuccessful = true;
            }
            catch(Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }

            return _bag;
        }
Ejemplo n.º 34
0
        public void UpdatePHPExtensions(object extensionsData)
        {
            EnsureServerConnection();

            PHPIniFile file = GetPHPIniFile();

            RemoteObjectCollection<PHPIniExtension> extensions = new RemoteObjectCollection<PHPIniExtension>();
            ((IRemoteObject)extensions).SetData(extensionsData);

            file.UpdateExtensions(extensions);
            file.Save(file.FileName);
        }
Ejemplo n.º 35
0
        public void UpdateExtensions(object extensionsData)
        {
            EnsureServerConnection();

            RemoteObjectCollection<PHPIniExtension> extensions = new RemoteObjectCollection<PHPIniExtension>();
            ((IRemoteObject)extensions).SetData(extensionsData);

            try
            {
                PHPConfigHelper configHelper = new PHPConfigHelper(ManagementUnit);
                configHelper.UpdateExtensions(extensions);
            }
            catch (FileNotFoundException)
            {
                RaiseException("ErrorPHPIniNotFound");
            }
        }
Ejemplo n.º 36
0
        protected override bool ApplyChanges()
        {
            var appliedChanges = false;

            string[] settingValues = null;

            Debug.Assert(_devMachineRadioButton.Checked || _prodMachineRadioButton.Checked);
            if (_devMachineRadioButton.Checked)
            {
                settingValues = _settingsDevValues;
            }
            else if (_prodMachineRadioButton.Checked)
            {
                settingValues = _settingsProdValues;
            }

            var php7     = new Version(Module.Proxy.GetPHPConfigInfo().Version) >= new Version("7.2");
            var settings = new RemoteObjectCollection <PHPIniSetting>();

            for (int i = 0; i < settingValues.Length; i++)
            {
                if (php7 && _settingNames[i] == "track_errors")
                {
                    // IMPORTANT: skip obsolete setting.
                    continue;
                }

                settings.Add(new PHPIniSetting(_settingNames[i], settingValues[i], "PHP"));
            }

            string errorLogValue = '"' + _errorLogFileTextBox.Text.Trim(new[] { ' ', '"' }) + '"';

            settings.Add(new PHPIniSetting("error_log", errorLogValue, "PHP"));

            try
            {
                Module.Proxy.AddOrUpdateSettings(settings);
                appliedChanges = true;

                // Update the values used for determining if changes have been made
                _errorLogFile = _errorLogFileTextBox.Text;
                if (_devMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Development;
                }
                else if (_prodMachineRadioButton.Checked)
                {
                    _errorReportingPreset = ErrorReportingPreset.Production;
                }
                _hasChanges = false;
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
            finally
            {
                Update();
            }

            return(appliedChanges);
        }
Ejemplo n.º 37
0
        private void SetExtensionState(bool enabled)
        {
            PHPExtensionItem item = SelectedItem;
            Debug.Assert(item != null);
            item.Extension.Enabled = enabled;
            RemoteObjectCollection<PHPIniExtension> extensions = new RemoteObjectCollection<PHPIniExtension>();
            extensions.Add(item.Extension);
            Module.Proxy.UpdatePHPExtensions(extensions);

            // Save the name of the updated extension so that we can select it after refresh
            _updatedExtensionName = item.Extension.Name;
            Refresh();
        }
Ejemplo n.º 38
0
 internal void UpdateExtensions(RemoteObjectCollection<PHPIniExtension> extensions)
 {
     Invoke("UpdateExtensions", extensions.GetData());
 }
Ejemplo n.º 39
0
 internal void AddOrUpdateSettings(RemoteObjectCollection<PHPIniSetting> settings)
 {
     Invoke("AddOrUpdateSettings", settings.GetData());
 }
Ejemplo n.º 40
0
        public void UpdateExtensions(object extensionsData)
        {
            EnsureServerConnection();

            var extensions = new RemoteObjectCollection<PHPIniExtension>();
            extensions.SetData(extensionsData);

            try
            {
                var mgmtUnitWrapper = new ManagementUnitWrapper(ManagementUnit);
                var configHelper = new PHPConfigHelper(mgmtUnitWrapper);
                configHelper.UpdateExtensions(extensions);
            }
            catch (FileNotFoundException)
            {
                RaiseException("ErrorPHPIniNotFound");
            }
            catch (InvalidOperationException)
            {
                RaiseException("ErrorPHPIsNotRegistered");
            }
        }
Ejemplo n.º 41
0
 private void SetExtensionState(bool enabled)
 {
     var item = SelectedItem;
     Debug.Assert(item != null);
     item.Extension.Enabled = enabled;
     var extensions = new RemoteObjectCollection<PHPIniExtension> {item.Extension};
     try
     {
         Module.Proxy.UpdateExtensions(extensions);
         // Save the name of the updated extension so that we can select it after refresh
         _updatedExtensionName = item.Extension.Name;
         Refresh();
     }
     catch (Exception ex)
     {
         DisplayErrorMessage(ex, Resources.ResourceManager);
     }
 }
Ejemplo n.º 42
0
        protected override void OnAccept()
        {
            try
            {
                PHPIniSetting setting = new PHPIniSetting();
                setting.Name = _nameTextBox.Text.Trim();
                setting.Value = _valueTextBox.Text.Trim();
                setting.Section = _sectionTextBox.Text.Trim();

                RemoteObjectCollection<PHPIniSetting> settings = new RemoteObjectCollection<PHPIniSetting>();
                settings.Add(setting);
                _module.Proxy.AddOrUpdateSettings(settings);

                DialogResult = DialogResult.OK;
                SettingName = setting.Name;
                Close();
            }
            catch (Exception ex)
            {
                DisplayErrorMessage(ex, Resources.ResourceManager);
            }
        }