Exemplo n.º 1
0
        private static PHPConfigIssue ValidateUploadTmpDir(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;
            // Check if Upload dir is set to an absolute path and that path exists
            var setting = file.GetSetting("upload_tmp_dir");
            var expectedValue = Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\");
            if (setting == null || String.IsNullOrEmpty(setting.GetTrimmedValue()))
            {
                configIssue = new PHPConfigIssue("upload_tmp_dir",
                                                                String.Empty,
                                                                expectedValue,
                                                                "ConfigIssueUploadDirNotSet",
                                                                "ConfigIssueUploadDirRecommend",
                                                                PHPConfigIssueIndex.UploadDir);
            }
            else if (!IsAbsoluteFilePath(setting.GetTrimmedValue(), false /* this is supposed to be a directory */))
            {
                configIssue = new PHPConfigIssue("upload_tmp_dir",
                                                                setting.GetTrimmedValue(),
                                                                expectedValue,
                                                                "ConfigIssueUploadDirNotCorrect",
                                                                "ConfigIssueUploadDirRecommend",
                                                                PHPConfigIssueIndex.UploadDir);
            }

            return configIssue;
        }
Exemplo n.º 2
0
        private PHPConfigIssue ValidatePHPRC()
        {
            PHPConfigIssue configIssue = null;
            // Check if PHPRC is set and points to a directory that has php.ini file
            var envVariableElement = _currentFastCgiApplication.EnvironmentVariables["PHPRC"];
            var expectedValue = EnsureTrailingBackslash(Path.GetDirectoryName(PHPIniFilePath));
            if (envVariableElement == null)
            {
                configIssue = new PHPConfigIssue("PHPRC", 
                                                                String.Empty,
                                                                expectedValue,
                                                                "ConfigIssuePHPRCNotSet",
                                                                "ConfigIssuePHPRCRecommend",
                                                                PHPConfigIssueIndex.Phprc);
            }
            else
            {
                if (!IsValidPhpDirectory(envVariableElement.Value))
                {
                    configIssue = new PHPConfigIssue("PHPRC",
                                                                    envVariableElement.Value,
                                                                    expectedValue,
                                                                    "ConfigIssuePHPRCFileNotExists",
                                                                    "ConfigIssuePHPRCRecommend",
                                                                    PHPConfigIssueIndex.Phprc);
                }
            }

            return configIssue;
        }
Exemplo n.º 3
0
        private PHPConfigIssue ValidateResourceType()
        {
            PHPConfigIssue configIssue = null;
            // Check if handler mapping is configured for "File or Folder"
            if (_currentPhpHandler.ResourceType != ResourceType.Either)
            {
                configIssue = new PHPConfigIssue("resourceType",
                                                                _currentPhpHandler.ResourceType.ToString(),
                                                                ResourceType.Either.ToString(),
                                                                "ConfigIssueResourceTypeIncorrect",
                                                                "ConfigIssueResourceTypeRecommend",
                                                                PHPConfigIssueIndex.ResourceType);
            }

            return configIssue;
        }
Exemplo n.º 4
0
        private PHPConfigIssue ValidateMonitorChanges()
        {
            PHPConfigIssue configIssue = null;
            // Check if monitorChangesTo setting is supported and is set correctly
            if (_currentFastCgiApplication.MonitorChangesToExists())
            {
                var path = _currentFastCgiApplication.MonitorChangesTo;
                if (String.IsNullOrEmpty(path))
                {
                    configIssue = new PHPConfigIssue("monitorChangesTo",
                                                                    String.Empty,
                                                                    PHPIniFilePath,
                                                                    "ConfigIssueMonitorChangesNotSet",
                                                                    "ConfigIssueMonitorChangesRecommend",
                                                                    PHPConfigIssueIndex.MonitorChangesTo);
                }
                else if (!String.Equals(PHPIniFilePath, path, StringComparison.OrdinalIgnoreCase))
                {
                    configIssue = new PHPConfigIssue("monitorChangesTo",
                                                                    path,
                                                                    PHPIniFilePath,
                                                                    "ConfigIssueMonitorChangesIncorrect",
                                                                    "ConfigIssueMonitorChangesRecommend",
                                                                    PHPConfigIssueIndex.MonitorChangesTo);
                }
            }

            return configIssue;
        }
Exemplo n.º 5
0
        private PHPConfigIssue ValidatePHPMaxRequests()
        {
            PHPConfigIssue configIssue = null;
            // Check if PHP_FCGI_MAX_REQUESTS is set and is bigger than instanceMaxRequests
            var envVariableElement = _currentFastCgiApplication.EnvironmentVariables["PHP_FCGI_MAX_REQUESTS"];
            if (envVariableElement == null)
            {
                configIssue = new PHPConfigIssue("PHP_FCGI_MAX_REQUESTS",
                                                                String.Empty,
                                                                _currentFastCgiApplication.InstanceMaxRequests.ToString(CultureInfo.InvariantCulture),
                                                                "ConfigIssuePHPMaxRequestsNotSet",
                                                                "ConfigIssuePHPMaxRequestsRecommend",
                                                                PHPConfigIssueIndex.PhpMaxRequests);
            }
            else
            {
                long maxRequests;
                if (!Int64.TryParse(envVariableElement.Value, out maxRequests) ||
                    (maxRequests < _currentFastCgiApplication.InstanceMaxRequests))
                {
                    configIssue = new PHPConfigIssue("PHP_FCGI_MAX_REQUESTS",
                                                                    envVariableElement.Value,
                                                                    _currentFastCgiApplication.InstanceMaxRequests.ToString(CultureInfo.InvariantCulture),
                                                                    "ConfigIssuePHPMaxRequestsIncorrect",
                                                                    "ConfigIssuePHPMaxRequestsRecommend",
                                                                    PHPConfigIssueIndex.PhpMaxRequests);
                }
            }

            return configIssue;
        }
Exemplo n.º 6
0
        private static PHPConfigIssue ValidateFastCgiImpersonate(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;
            
            // Check if fastcgi impersonation is turned on
            var setting = file.GetSetting("fastcgi.impersonate");
            if (setting == null || String.IsNullOrEmpty(setting.GetTrimmedValue()))
            {
                configIssue = new PHPConfigIssue("fastcgi.impersonate",
                                                                String.Empty,
                                                                "1",
                                                                "ConfigIssueFastCgiImpersonateNotSet",
                                                                "ConfigIssueFastCgiImpersonateRecommend",
                                                                PHPConfigIssueIndex.FastCgiImpersonation);
            }
            else if (!String.Equals(setting.GetTrimmedValue(), "1", StringComparison.OrdinalIgnoreCase))
            {
                configIssue = new PHPConfigIssue("fastcgi.impersonate",
                                                                setting.GetTrimmedValue(),
                                                                "1",
                                                                "ConfigIssueFastCgiImpersonateNotCorrect",
                                                                "ConfigIssueFastCgiImpersonateRecommend",
                                                                PHPConfigIssueIndex.FastCgiImpersonation);
            }

            return configIssue;
        }
Exemplo n.º 7
0
        private static PHPConfigIssue ValidateLogErrors(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;

            // Check if log_errors is set to On
            var setting = file.GetSetting("log_errors");
            if (setting == null || String.IsNullOrEmpty(setting.GetTrimmedValue()))
            {
                configIssue = new PHPConfigIssue("log_errors",
                                                                String.Empty,
                                                                "On",
                                                                "ConfigIssueLogErrorsNotSet",
                                                                "ConfigIssueLogErrorsRecommend",
                                                                PHPConfigIssueIndex.LogErrors);
            }
            else if (!String.Equals(setting.GetTrimmedValue(), "On", StringComparison.OrdinalIgnoreCase))
            {
                configIssue = new PHPConfigIssue("log_errors",
                                                                setting.GetTrimmedValue(),
                                                                "On",
                                                                "ConfigIssueLogErrorsNotCorrect",
                                                                "ConfigIssueLogErrorsRecommend",
                                                                PHPConfigIssueIndex.LogErrors);
            }

            return configIssue;
        }
Exemplo n.º 8
0
        private PHPConfigIssue ValidateErrorLog(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;

            // Check if error_log is set to an absolute path and that path exists
            var setting = file.GetSetting("error_log");
            string expectedValue = Path.Combine(Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\"), _currentPhpHandler.Name + "_errors.log");
            if (setting == null || String.IsNullOrEmpty(setting.GetTrimmedValue()))
            {
                configIssue = new PHPConfigIssue("error_log",
                                                                String.Empty,
                                                                expectedValue,
                                                                "ConfigIssueErrorLogNotSet",
                                                                "ConfigIssueErrorLogRecommend",
                                                                PHPConfigIssueIndex.ErrorLog);
            }
            else if (!IsAbsoluteFilePath(setting.GetTrimmedValue(), true /* this is supposed to be a file */))
            {
                configIssue = new PHPConfigIssue("error_log",
                                                                setting.GetTrimmedValue(),
                                                                expectedValue,
                                                                "ConfigIssueErrorLogNotCorrect",
                                                                "ConfigIssueErrorLogRecommend",
                                                                PHPConfigIssueIndex.ErrorLog);
            }

            return configIssue;
        }
Exemplo n.º 9
0
        private PHPConfigIssue ValidateExtensionDir(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;
            
            var setting = file.GetSetting("extension_dir");
            string expectedValue = EnsureTrailingBackslash(Path.Combine(PHPDirectory, "ext"));
            if (setting == null || String.IsNullOrEmpty(setting.GetTrimmedValue()))
            {
                configIssue = new PHPConfigIssue("extension_dir",
                                                                String.Empty,
                                                                expectedValue,
                                                                "ConfigIssueExtensionDirNotSet",
                                                                "ConfigIssueExtensionDirRecommend",
                                                                PHPConfigIssueIndex.ExtensionDir);
            }
            else
            {
                string currentValue = EnsureTrailingBackslash(setting.GetTrimmedValue());
                currentValue = EnsureBackslashes(currentValue);
                if (!String.Equals(currentValue, expectedValue, StringComparison.OrdinalIgnoreCase))
                {
                    configIssue = new PHPConfigIssue("extension_dir",
                                                                    setting.GetTrimmedValue(),
                                                                    expectedValue,
                                                                    "ConfigIssueExtensionDirIncorrect",
                                                                    "ConfigIssueExtensionDirRecommend",
                                                                    PHPConfigIssueIndex.ExtensionDir);
                }
            }

            return configIssue;
        }
Exemplo n.º 10
0
        private static PHPConfigIssue ValidateDateTimeZone(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;

            var setting = file.GetSetting("date.timezone");
            if (setting == null)
            {
                configIssue = new PHPConfigIssue("date.timezone",
                                                               String.Empty,
                                                               GetPHPTimeZone(),
                                                               "ConfigIssueDateTimeZoneNotSet",
                                                               "ConfigIssueDateTimeZoneRecommend",
                                                               PHPConfigIssueIndex.DateTimeZone);
            }

            return configIssue;
        }
Exemplo n.º 11
0
 private PHPConfigIssue ValidateDefaultDocument()
 {
     PHPConfigIssue configIssue = null;
     // Check if index.php is set as a default document
     var fileElement = _defaultDocumentCollection["index.php"];
     if (fileElement == null)
     {
         configIssue = new PHPConfigIssue("Default document",
                                                         _defaultDocumentCollection[0].Value,
                                                         "index.php",
                                                         "ConfigIssueDefaultDocumentNotSet",
                                                         "ConfigIssueDefaultDocumentRecommend",
                                                         PHPConfigIssueIndex.DefaultDocument);
     }
     else if (_defaultDocumentCollection.IndexOf(fileElement) > 0)
     {
         configIssue = new PHPConfigIssue("Default document",
                                                         _defaultDocumentCollection[0].Value,
                                                         "index.php",
                                                         "ConfigIssueDefaultDocumentNotFirst",
                                                         "ConfigIssueDefaultDocumentRecommend",
                                                         PHPConfigIssueIndex.DefaultDocument);
     }
     
     return configIssue;
 }
Exemplo n.º 12
0
        private static PHPConfigIssue ValidateCgiPathInfo(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;
            
            // Check if cgi.fix_pathinfo is set correctly
            var setting = file.GetSetting("cgi.fix_pathinfo");
            if (setting == null || String.IsNullOrEmpty(setting.GetTrimmedValue()))
            {
                configIssue = new PHPConfigIssue("cgi.fix_pathinfo",
                                                                String.Empty,
                                                                "1",
                                                                "ConfigIssueCgiPathInfoNotSet",
                                                                "ConfigIssueCgiPathInfoRecommend",
                                                                PHPConfigIssueIndex.CgiPathInfo);
            }
            else if (!String.Equals(setting.GetTrimmedValue(), "1", StringComparison.OrdinalIgnoreCase))
            {
                configIssue = new PHPConfigIssue("cgi.fix_pathinfo",
                                                                setting.GetTrimmedValue(),
                                                                "1",
                                                                "ConfigIssueCgiPathInfoNotCorrect",
                                                                "ConfigIssueCgiPathInfoRecommend",
                                                                PHPConfigIssueIndex.CgiPathInfo);
            }

            return configIssue;
        }
Exemplo n.º 13
0
        private static PHPConfigIssue ValidateCgiForceRedirect(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;
            
            // Check if cgi.force_redirect is set correctly
            PHPIniSetting setting = file.GetSetting("cgi.force_redirect");
            if (setting == null || String.IsNullOrEmpty(setting.TrimmedValue))
            {
                configIssue = new PHPConfigIssue("cgi.force_redirect",
                                                                String.Empty,
                                                                "0",
                                                                "ConfigIssueCgiForceRedirectNotSet",
                                                                "ConfigIssueCgiForceRedirectRecommend",
                                                                PHPConfigIssueIndex.CgiForceRedirect);
            }
            else if (!String.Equals(setting.TrimmedValue, "0", StringComparison.OrdinalIgnoreCase))
            {
                configIssue = new PHPConfigIssue("cgi.force_redirect",
                                                                setting.TrimmedValue,
                                                                "0",
                                                                "ConfigIssueCgiForceRedirectNotCorrect",
                                                                "ConfigIssueCgiForceRedirectRecommend",
                                                                PHPConfigIssueIndex.CgiForceRedirect);
            }

            return configIssue;
        }
Exemplo n.º 14
0
        private static PHPConfigIssue ValidateSessionPath(PHPIniFile file)
        {
            PHPConfigIssue configIssue = null;
            // Check if session path is set to an absolute path and that path exists
            PHPIniSetting setting = file.GetSetting("session.save_path");
            string expectedValue = Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\");
            if (setting == null || String.IsNullOrEmpty(setting.TrimmedValue))
            {
                configIssue = new PHPConfigIssue("session.save_path",
                                                                String.Empty,
                                                                expectedValue,
                                                                "ConfigIssueSessionPathNotSet",
                                                                "ConfigIssueSessionPathRecommend",
                                                                PHPConfigIssueIndex.SessionPath);
            }
            else if (!IsAbsoluteFilePath(setting.TrimmedValue, false /* this is supposed to be a directory */))
            {
                configIssue = new PHPConfigIssue("session.save_path",
                                                                setting.TrimmedValue,
                                                                expectedValue,
                                                                "ConfigIssueSessionPathNotCorrect",
                                                                "ConfigIssueSessionPathRecommend",
                                                                PHPConfigIssueIndex.SessionPath);
            }

            return configIssue;
        }
Exemplo n.º 15
0
        private PHPConfigIssue ValidatePHPRC()
        {
            PHPConfigIssue configIssue = null;
            // Check if PHPRC is set and points to a directory that has php.ini file
            EnvironmentVariableElement envVariableElement = _currentFastCgiApplication.EnvironmentVariables["PHPRC"];
            if (envVariableElement == null)
            {
                configIssue = new PHPConfigIssue("PHPRC", 
                                                                String.Empty,
                                                                PHPDirectory,
                                                                "ConfigIssuePHPRCNotSet",
                                                                "ConfigIssuePHPRCRecommend",
                                                                PHPConfigIssueIndex.PHPRC);
            }
            else
            {
                string path = Path.Combine(envVariableElement.Value, "php.ini");
                if (!File.Exists(path))
                {
                    configIssue = new PHPConfigIssue("PHPRC",
                                                                    envVariableElement.Value,
                                                                    PHPDirectory,
                                                                    "ConfigIssuePHPRCFileNotExists",
                                                                    "ConfigIssuePHPRCRecommend",
                                                                    PHPConfigIssueIndex.PHPRC);
                }
            }

            return configIssue;
        }
Exemplo n.º 16
0
        private PHPConfigIssue ValidatePHPRC()
        {
            PHPConfigIssue configIssue = null;
            // Check if PHPRC is set and points to a directory that has php.ini file
            EnvironmentVariableElement envVariableElement = _currentFastCgiApplication.EnvironmentVariables["PHPRC"];
            string expectedValue = EnsureTrailingBackslash(Path.GetDirectoryName(PHPIniFilePath));
            if (envVariableElement == null)
            {
                configIssue = new PHPConfigIssue("PHPRC", 
                                                                String.Empty,
                                                                expectedValue,
                                                                "ConfigIssuePHPRCNotSet",
                                                                "ConfigIssuePHPRCRecommend",
                                                                PHPConfigIssueIndex.PHPRC);
            }
            else
            {
                string pathPhpIni = Path.Combine(envVariableElement.Value, "php.ini");
                string pathPhpSapiIni = Path.Combine(envVariableElement.Value, "php-cgi-fcgi.ini");
                if (!File.Exists(pathPhpIni) && !File.Exists(pathPhpSapiIni))
                {
                    configIssue = new PHPConfigIssue("PHPRC",
                                                                    envVariableElement.Value,
                                                                    expectedValue,
                                                                    "ConfigIssuePHPRCFileNotExists",
                                                                    "ConfigIssuePHPRCRecommend",
                                                                    PHPConfigIssueIndex.PHPRC);
                }
            }

            return configIssue;
        }