private static Label PreparePHPRegistrationWarning(PHPRegistrationType registrationType) { Label result = null; if (registrationType == PHPRegistrationType.Cgi) { result = new Label(); result.Text = Resources.WarningPHPConfigCgi; } else if (registrationType == PHPRegistrationType.Isapi) { result = new Label(); result.Text = Resources.WarningPHPConfigIsapi; } else if (registrationType == PHPRegistrationType.None) { result = new Label(); result.Text = Resources.WarningPHPConfigNotRegistered; } else if (registrationType == PHPRegistrationType.NoneNoFastCgi) { result = PrepareNoFastCgiWarning(); } else { // Just in case result = new Label(); result.Text = String.Empty; } return(result); }
private static Label PreparePHPRegistrationWarning(PHPRegistrationType registrationType) { Label result = null; if (registrationType == PHPRegistrationType.Cgi) { result = new Label(); result.Text = Resources.WarningPHPConfigCgi; } else if (registrationType == PHPRegistrationType.Isapi) { result = new Label(); result.Text = Resources.WarningPHPConfigIsapi; } else if (registrationType == PHPRegistrationType.None) { result = new Label(); result.Text = Resources.WarningPHPConfigNotRegistered; } else if (registrationType == PHPRegistrationType.NoneNoFastCgi) { result = PrepareNoFastCgiWarning(); } else { // Just in case result = new Label(); result.Text = String.Empty; } return result; }
private void Initialize() { if (!IsFastCgiInstalled()) { // If FastCGI is not installed on IIS then bail out as there is no point to continue _registrationType = PHPRegistrationType.NoneNoFastCgi; return; } // Get the handlers collection var handlersSection = _configurationWrapper.GetHandlersSection(); _handlersCollection = handlersSection.Handlers; // Get the Default document collection var defaultDocumentSection = _configurationWrapper.GetDefaultDocumentSection(); _defaultDocumentCollection = defaultDocumentSection.Files; // Get the FastCgi application collection var appHostConfig = _configurationWrapper.GetAppHostConfiguration(); var fastCgiSection = (FastCgiSection)appHostConfig.GetSection("system.webServer/fastCgi", typeof(FastCgiSection)); _fastCgiApplicationCollection = fastCgiSection.Applications; // Assume by default that PHP is not registered _registrationType = PHPRegistrationType.None; // Find the currently active PHP handler and FastCGI application var handler = _handlersCollection.GetActiveHandler("*.php"); if (handler != null) { if (String.Equals(handler.Modules, "FastCgiModule", StringComparison.OrdinalIgnoreCase)) { _registrationType = PHPRegistrationType.FastCgi; } else if (String.Equals(handler.Modules, "CgiModule", StringComparison.OrdinalIgnoreCase)) { _registrationType = PHPRegistrationType.Cgi; } else if (String.Equals(handler.Modules, "IsapiModule", StringComparison.OrdinalIgnoreCase)) { _registrationType = PHPRegistrationType.Isapi; } if (_registrationType == PHPRegistrationType.FastCgi) { ApplicationElement fastCgiApplication = _fastCgiApplicationCollection.GetApplication(handler.Executable, handler.Arguments); if (fastCgiApplication != null) { _currentPhpHandler = handler; _currentFastCgiApplication = fastCgiApplication; _phpIniFilePath = GetPHPIniFilePath(); if (String.IsNullOrEmpty(_phpIniFilePath)) { throw new FileNotFoundException(String.Format(Resources.CannotFindPhpIniForExecutableError, handler.Executable)); } _phpDirectory = GetPHPDirectory(); } else { _registrationType = PHPRegistrationType.None; } } } }
private static Label PreparePHPRegistrationWarning(PHPRegistrationType registrationType) { Label result = new Label(); if (registrationType == PHPRegistrationType.Cgi) { result.Text = Resources.WarningPHPConfigCgi; } else if (registrationType == PHPRegistrationType.Isapi) { result.Text = Resources.WarningPHPConfigIsapi; } else if (registrationType == PHPRegistrationType.None) { result.Text = Resources.WarningPHPConfigNotRegistered; } return result; }
private void Initialize() { // Get the handlers collection ManagementConfiguration config = _managementUnit.Configuration; HandlersSection handlersSection = (HandlersSection)config.GetSection("system.webServer/handlers", typeof(HandlersSection)); _handlersCollection = handlersSection.Handlers; // Get the Default document collection DefaultDocumentSection defaultDocumentSection = (DefaultDocumentSection)config.GetSection("system.webServer/defaultDocument", typeof(DefaultDocumentSection)); _defaultDocumentCollection = defaultDocumentSection.Files; // Get the FastCgi application collection Configuration appHostConfig = _managementUnit.ServerManager.GetApplicationHostConfiguration(); FastCgiSection fastCgiSection = (FastCgiSection)appHostConfig.GetSection("system.webServer/fastCgi", typeof(FastCgiSection)); _fastCgiApplicationCollection = fastCgiSection.Applications; // Assume by default that PHP is not registered _registrationType = PHPRegistrationType.None; // Find the currently active PHP handler and FastCGI application HandlerElement handler = _handlersCollection.GetActiveHandler("*.php"); if (handler != null) { if (String.Equals(handler.Modules, "FastCgiModule", StringComparison.OrdinalIgnoreCase)) { _registrationType = PHPRegistrationType.FastCgi; } else if (String.Equals(handler.Modules, "CgiModule", StringComparison.OrdinalIgnoreCase)) { _registrationType = PHPRegistrationType.Cgi; } else if (String.Equals(handler.Modules, "IsapiModule", StringComparison.OrdinalIgnoreCase)) { _registrationType = PHPRegistrationType.Isapi; } if (_registrationType == PHPRegistrationType.FastCgi) { ApplicationElement fastCgiApplication = _fastCgiApplicationCollection.GetApplication(handler.Executable, handler.Arguments); if (fastCgiApplication != null) { _currentPHPHandler = handler; _currentFastCgiApplication = fastCgiApplication; _phpIniFilePath = GetPHPIniFilePath(); _phpDirectory = GetPHPDirectory(); } else { _registrationType = PHPRegistrationType.None; } } } }