private GetSetting ( string name ) : |
||
name | string | |
return |
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; }
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; }
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; }
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; }
private static PHPIniSetting GetToApplyDateTimeZone(PHPIniFile file) { PHPIniSetting setting = file.GetSetting("date.timezone"); if (setting == null) { setting = new PHPIniSetting("date.timezone", DoubleQuotesWrap(GetPHPTimeZone()), "Date"); } return setting; }
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; }
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; }
private static PHPIniSetting GetToApplySessionPath(PHPIniFile file) { PHPIniSetting setting = file.GetSetting("session.save_path"); if (setting == null || !IsAbsoluteFilePath(setting.GetTrimmedValue(), false)) { string value = Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\"); setting = new PHPIniSetting("session.save_path", DoubleQuotesWrap(value), "Session"); } return setting; }
private void UpdateUI(PHPIniFile file) { PHPIniSetting setting = file.GetSetting(SettingNames[0]); string[] settingValues = null; if (setting != null) { if (String.Equals(setting.TrimmedValue, SettingsDevValues[0])) { _errorReportingPreset = ErrorReportingPreset.Development; settingValues = SettingsDevValues; } else if (String.Equals(setting.TrimmedValue, 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.TrimmedValue, 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.TrimmedValue; _errorLogFileTextBox.Text = setting.TrimmedValue; } }
protected override PropertyBag GetProperties() { PropertyBag result = new PropertyBag(); object o = Module.Proxy.GetPHPIniSettings(); PHPIniFile file = new PHPIniFile(); file.SetData(o); for (int i = 0; i < _settingNames.Length; i++) { PHPIniSetting setting = file.GetSetting(_settingNames[i]); if (setting != null) { result[i] = setting.Value; } } return result; }
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; }
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; }
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; }
private static PHPIniSetting GetToApplyDateTimeZone(PHPIniFile file) { var setting = file.GetSetting("date.timezone") ?? new PHPIniSetting("date.timezone", DoubleQuotesWrap(GetPHPTimeZone()), "Date"); return setting; }
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; }
private PHPIniSetting GetToApplyErrorLog(PHPIniFile file) { var handlerName = _currentPhpHandler.Name; var setting = file.GetSetting("error_log"); if (setting == null || !IsAbsoluteFilePath(setting.GetTrimmedValue(), true)) { var value = Path.Combine(Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\"), handlerName + "_errors.log"); setting = new PHPIniSetting("error_log", DoubleQuotesWrap(value), "PHP"); } return setting; }
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; }
private static PHPIniSetting GetToApplyUploadTmpDir(PHPIniFile file) { PHPIniSetting setting = file.GetSetting("upload_tmp_dir"); if (setting == null || !IsAbsoluteFilePath(setting.GetTrimmedValue(), false)) { string value = Environment.ExpandEnvironmentVariables(@"%WINDIR%\Temp\"); setting = new PHPIniSetting("upload_tmp_dir", DoubleQuotesWrap(value), "PHP"); } return setting; }
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; }