Parse() private method

private Parse ( ) : void
return void
Ejemplo n.º 1
0
        public PHPConfigInfo GetPHPConfigInfo()
        {
            var configInfo = new PHPConfigInfo();

            // If PHP is not registered properly then just return information about
            // how it registered.
            if (!IsPHPRegistered())
            {
                configInfo.RegistrationType = _registrationType;
                return configInfo;
            }

            configInfo.RegistrationType = _registrationType;
            configInfo.HandlerName = _currentPhpHandler.Name;
            configInfo.HandlerIsLocal = _currentPhpHandler.IsLocallyStored;
            configInfo.Executable = _currentPhpHandler.Executable;
            configInfo.Version = GetPHPExecutableVersion(_currentPhpHandler.Executable);
            configInfo.PHPIniFilePath = PHPIniFilePath;

            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            var setting = file.GetSetting("error_log");
            configInfo.ErrorLog = setting != null ? setting.GetTrimmedValue() : String.Empty;

            configInfo.EnabledExtCount = file.GetEnabledExtensionsCount();
            configInfo.InstalledExtCount = file.Extensions.Count;

            ICollection issues = ValidateConfiguration(file);
            configInfo.IsConfigOptimal = (issues.Count == 0);

            return configInfo;
        }
Ejemplo n.º 2
0
        public PHPIniFile GetPHPIniFile()
        {
            EnsurePHPIsRegistered();

            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            return file;
        }
Ejemplo n.º 3
0
        public RemoteObjectCollection<PHPConfigIssue> ValidateConfiguration()
        {
            EnsurePHPIsRegistered();

            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            return ValidateConfiguration(file);
        }
Ejemplo n.º 4
0
        private void ApplyRecommendedPHPIniSettings(ArrayList configIssueIndexes)
        {
            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            var settings = new List<PHPIniSetting>();

            foreach (int configIssueIndex in configIssueIndexes)
            {
                switch (configIssueIndex)
                {
                    case PHPConfigIssueIndex.ExtensionDir:
                        {
                            settings.Add(GetToApplyExtensionDir());
                            break;
                        }
                    case PHPConfigIssueIndex.LogErrors:
                        {
                            settings.Add(GetToApplyLogErrors());
                            break;
                        }
                    case PHPConfigIssueIndex.ErrorLog:
                        {
                            settings.Add(GetToApplyErrorLog(file));
                            break;
                        }
                    case PHPConfigIssueIndex.SessionPath:
                        {
                            settings.Add(GetToApplySessionPath(file));
                            break;
                        }
                    case PHPConfigIssueIndex.UploadDir:
                        {
                            settings.Add(GetToApplyUploadTmpDir(file));
                            break;
                        }
                    case PHPConfigIssueIndex.CgiForceRedirect:
                        {
                            settings.Add(GetToApplyCgiForceRedirect());
                            break;
                        }
                    case PHPConfigIssueIndex.CgiPathInfo:
                        {
                            settings.Add(GetToApplyCgiPathInfo());
                            break;
                        }
                    case PHPConfigIssueIndex.FastCgiImpersonation:
                        {
                            settings.Add(GetToApplyFastCgiImpersonate());
                            break;
                        }
                    case PHPConfigIssueIndex.DateTimeZone:
                        {
                            settings.Add(GetToApplyDateTimeZone(file));
                            break;
                        }
                }
            }

            if (settings.Count > 0)
            {
                file.AddOrUpdateSettings(settings);
                file.Save(PHPIniFilePath);
            }
        }
Ejemplo n.º 5
0
        public void RemovePHPIniSetting(PHPIniSetting setting)
        {
            EnsurePHPIsRegistered();

            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            if (file.Remove(setting))
            {
                file.Save(file.FileName);
            }
        }
Ejemplo n.º 6
0
        public void UpdateExtensions(IEnumerable<PHPIniExtension> extensions)
        {
            EnsurePHPIsRegistered();

            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            file.UpdateExtensions(extensions);
            file.Save(file.FileName);
        }
Ejemplo n.º 7
0
        public PHPConfigInfo GetPHPConfigInfo()
        {
            PHPConfigInfo configInfo = new PHPConfigInfo();

            // If PHP is not registered properly then just return information about
            // how it registered.
            if (!IsPHPRegistered())
            {
                configInfo.RegistrationType = _registrationType;
                return configInfo;
            }

            configInfo.RegistrationType = _registrationType;
            configInfo.HandlerName = _currentPHPHandler.Name;
            configInfo.Executable = _currentPHPHandler.Executable;
            configInfo.Version = GetPHPExecutableVersion(_currentPHPHandler.Executable);

            if (String.IsNullOrEmpty(PHPIniFilePath))
            {
                throw new FileNotFoundException("php.ini file does not exist");
            }

            configInfo.PHPIniFilePath = PHPIniFilePath;

            PHPIniFile file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            PHPIniSetting setting = file.GetSetting("error_log");
            if (setting != null)
            {
                configInfo.ErrorLog = setting.TrimmedValue;
            }
            else
            {
                configInfo.ErrorLog = String.Empty;
            }

            configInfo.EnabledExtCount = file.GetEnabledExtensionsCount();
            configInfo.InstalledExtCount = file.Extensions.Count;

            ICollection issues = ValidateConfiguration(file);
            configInfo.IsConfigOptimal = (issues.Count == 0);

            return configInfo;
        }
Ejemplo n.º 8
0
        private void ApplyRecommendedPHPIniSettings()
        {
            string phpDirectory = Path.GetDirectoryName(_currentPHPHandler.ScriptProcessor);
            string handlerName = _currentPHPHandler.Name;
            string phpIniPath = GetPHPIniPath();

            PHPIniFile file = new PHPIniFile(phpIniPath);
            file.Parse();

            // Set the recommended php.ini settings
            List<PHPIniSetting> settings = new List<PHPIniSetting>();

            // Set extension directory path
            string value = Path.Combine(phpDirectory, "ext");
            settings.Add(new PHPIniSetting("extension_dir", value, "PHP"));

            // Set log_errors
            settings.Add(new PHPIniSetting("log_errors", "On", "PHP"));

            // Set error_log path
            value = Path.Combine(Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\"), handlerName + "_errors.log");
            settings.Add(new PHPIniSetting("error_log", value, "PHP"));

            // Set session path
            value = Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\");
            settings.Add(new PHPIniSetting("session.save_path", value, "Session"));

            // Set cgi.force_redirect
            settings.Add(new PHPIniSetting("cgi.force_redirect", "0", "PHP"));
            
            // Set cgi.fix_pathinfo
            settings.Add(new PHPIniSetting("cgi.fix_pathinfo", "1", "PHP"));

            // Enable fastcgi impersonation
            settings.Add(new PHPIniSetting("fastcgi.impersonate", "1", "PHP"));
            
            // Disable fastcgi logging
            settings.Add(new PHPIniSetting("fastcgi.logging", "0", "PHP"));

            // Set maximum script execution time
            settings.Add(new PHPIniSetting("max_execution_time", "300", "PHP"));

            // Turn off display errors
            settings.Add(new PHPIniSetting("display_errors", "Off", "PHP"));
            file.AddOrUpdateSettings(settings);

            // Enable the most common PHP extensions
            List<PHPIniExtension> extensions = new List<PHPIniExtension>();
            extensions.Add(new PHPIniExtension("php_curl.dll", true));
            extensions.Add(new PHPIniExtension("php_gd2.dll", true));
            extensions.Add(new PHPIniExtension("php_gettext.dll", true));
            extensions.Add(new PHPIniExtension("php_mysql.dll", true));
            extensions.Add(new PHPIniExtension("php_mysqli.dll", true));
            extensions.Add(new PHPIniExtension("php_mbstring.dll", true));
            extensions.Add(new PHPIniExtension("php_openssl.dll", true));
            extensions.Add(new PHPIniExtension("php_soap.dll", true));
            extensions.Add(new PHPIniExtension("php_xmlrpc.dll", true));
            file.UpdateExtensions(extensions);

            file.Save(phpIniPath);
        }
Ejemplo n.º 9
0
        public PHPIniFile GetPHPIniFile()
        {
            Debug.Assert(IsPHPRegistered());

            PHPIniFile file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            return file;
        }
Ejemplo n.º 10
0
        public void AddOrUpdatePHPIniSettings(IEnumerable<PHPIniSetting> settings)
        {
            Debug.Assert(IsPHPRegistered());

            PHPIniFile file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            file.AddOrUpdateSettings(settings);
            file.Save(file.FileName);
        }
Ejemplo n.º 11
0
        public void UpdateExtensions(IEnumerable<PHPIniExtension> extensions)
        {
            Debug.Assert(IsPHPRegistered());

            PHPIniFile file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            file.UpdateExtensions(extensions);
            file.Save(file.FileName);
        }
Ejemplo n.º 12
0
        public void RemovePHPIniSetting(PHPIniSetting setting)
        {
            Debug.Assert(IsPHPRegistered());

            PHPIniFile file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            if (file.Remove(setting))
            {
                file.Save(file.FileName);
            }
        }
Ejemplo n.º 13
0
        private PHPIniFile GetPHPIniFile()
        {
            PHPConfigHelper phpConfig = new PHPConfigHelper(ManagementUnit);
            string phpiniPath = phpConfig.PHPIniFilePath;

            if (String.IsNullOrEmpty(phpiniPath))
            {
                RaiseException("ErrorPHPIniNotFound");
            }

            PHPIniFile file = new PHPIniFile(phpiniPath);
            file.Parse();

            return file;
        }
Ejemplo n.º 14
0
        private void MakeRecommendedPHPIniChanges()
        {
            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            // Set the recommended php.ini settings
            var settings = new List<PHPIniSetting>
                {
                    GetToApplyExtensionDir(),
                    GetToApplyLogErrors(),
                    GetToApplyErrorLog(file),
                    GetToApplySessionPath(file),
                    GetToApplyUploadTmpDir(file),
                    GetToApplyDateTimeZone(file),
                    GetToApplyCgiForceRedirect(),
                    GetToApplyCgiPathInfo(),
                    GetToApplyFastCgiImpersonate(),
                    new PHPIniSetting("fastcgi.logging", "0", "PHP"),
                    new PHPIniSetting("max_execution_time", "300", "PHP"),
                    new PHPIniSetting("display_errors", "Off", "PHP")
                };

            // Enable the most common PHP extensions
            var extensions = new List<PHPIniExtension>
                {
                    new PHPIniExtension("php_curl.dll", true),
                    new PHPIniExtension("php_gd2.dll", true),
                    new PHPIniExtension("php_gettext.dll", true),
                    new PHPIniExtension("php_mysql.dll", true),
                    new PHPIniExtension("php_mysqli.dll", true),
                    new PHPIniExtension("php_mbstring.dll", true),
                    new PHPIniExtension("php_openssl.dll", true),
                    new PHPIniExtension("php_soap.dll", true),
                    new PHPIniExtension("php_xmlrpc.dll", true)
                };

            file.UpdateExtensions(extensions);
            file.AddOrUpdateSettings(settings);
            file.Save(PHPIniFilePath);
        }
Ejemplo n.º 15
0
        public RemoteObjectCollection<PHPConfigIssue> ValidateConfiguration()
        {
            // Check if PHP is not registered
            if (!IsPHPRegistered())
            {
                return null;
            }

            PHPIniFile file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            return ValidateConfiguration(file);
        }
Ejemplo n.º 16
0
        public void AddOrUpdatePHPIniSettings(IEnumerable<PHPIniSetting> settings)
        {
            EnsurePHPIsRegistered();

            var file = new PHPIniFile(PHPIniFilePath);
            file.Parse();

            file.AddOrUpdateSettings(settings);
            file.Save(file.FileName);
        }
Ejemplo n.º 17
0
        public PHPConfigInfo GetPHPConfigInfo()
        {
            // Check if PHP is not registered
            if (_currentFastCgiApplication == null || _currentPHPHandler == null)
            {
                return null;
            }

            PHPConfigInfo configInfo = new PHPConfigInfo();
            configInfo.HandlerName = _currentPHPHandler.Name;
            configInfo.ScriptProcessor = _currentPHPHandler.ScriptProcessor;
            configInfo.Version = GetPHPExecutableVersion(_currentPHPHandler.ScriptProcessor);
            string phpIniPath = GetPHPIniPath();

            if (String.IsNullOrEmpty(phpIniPath))
            {
                throw new FileNotFoundException("php.ini file does not exist");
            }

            configInfo.PHPIniFilePath = phpIniPath;

            PHPIniFile file = new PHPIniFile(phpIniPath);
            file.Parse();

            PHPIniSetting setting = file.GetSetting("error_log");
            if (setting != null)
            {
                configInfo.ErrorLog = setting.Value;
            }
            else
            {
                configInfo.ErrorLog = String.Empty;
            }

            configInfo.EnabledExtCount = file.GetEnabledExtensionsCount();
            configInfo.InstalledExtCount = file.Extensions.Count;

            return configInfo;
        }