diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/Handlers/HandlersModuleService.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/Handlers/HandlersModuleService.cs index d2a7c783..bf283e54 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/Handlers/HandlersModuleService.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/Handlers/HandlersModuleService.cs @@ -278,34 +278,5 @@ namespace WebsitePanel.Providers.Web.Handlers srvman.CommitChanges(); } } - - internal void MoveHandlerToTop(string handlerName, string siteName, string vDirPath) - { - if (string.IsNullOrEmpty(siteName)) - { - return; - } - - if (string.IsNullOrEmpty(vDirPath)) - { - vDirPath = "/"; - } - - using (var srvman = GetServerManager()) - { - var config = srvman.GetWebConfiguration(siteName, vDirPath); - - var handlersSection = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection)); - - var handlersCollection = handlersSection.Handlers; - - var handlerElement = handlersCollection[handlerName]; - - handlersCollection.Remove(handlerElement); - handlersCollection.AddCopyAt(0, handlerElement); - - srvman.CommitChanges(); - } - } } } diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/IIs70.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/IIs70.cs index bb0376a4..cdfbcf8c 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/IIs70.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Web.IIS70/IIs70.cs @@ -882,22 +882,19 @@ namespace WebsitePanel.Providers.Web { if (PhpMode == Constants.PhpMode.FastCGI && virtualDir.PhpInstalled.Contains('|')) { - var path = PhpExecutablePath; var args = virtualDir.PhpInstalled.Split('|'); + if (args.Count() > 1) { - // Handler name is present, let us try to find the corresponding path to executable - var phpVersion = GetPhpVersions(virtualDir).SingleOrDefault(p => p.HandlerName == args[1]); - if (phpVersion != null) - { - path = phpVersion.ExecutionPath; - } - } + // Handler name is present, use it to set choosen version + var handlerName = args[1]; - if (!String.IsNullOrEmpty(path) && File.Exists(path)) - { - handlersSvc.CopyInheritedHandlers(((WebSite)virtualDir).SiteId, virtualDir.VirtualPath); - handlersSvc.MoveHandlerToTop(args[1], ((WebSite) virtualDir).SiteId, virtualDir.VirtualPath); + if (handlerName != GetActivePhpHandlerName(virtualDir)) + { + // Only change handler if it is different from the current one + handlersSvc.CopyInheritedHandlers(((WebSite)virtualDir).SiteId, virtualDir.VirtualPath); + MakeHandlerActive(handlerName, virtualDir); + } } } else @@ -4511,12 +4508,21 @@ namespace WebsitePanel.Providers.Web protected PhpVersion[] GetPhpVersions(WebVirtualDirectory virtualDir) { - using (var srvman = new ServerManager()) + using (var srvman = webObjectsSvc.GetServerManager()) { return GetPhpVersions(srvman, virtualDir); } } + protected string GetActivePhpHandlerName(WebVirtualDirectory virtualDir) + { + using (var srvman = webObjectsSvc.GetServerManager()) + { + return GetActivePhpHandlerName(srvman, virtualDir); + } + } + + protected string GetActivePhpHandlerName(ServerManager srvman, WebVirtualDirectory virtualDir) { var config = srvman.GetWebConfiguration(((WebSite)virtualDir).SiteId, virtualDir.VirtualPath); @@ -4529,11 +4535,34 @@ namespace WebsitePanel.Providers.Web ).FirstOrDefault(); } - private static string GetPhpExecutableVersion(string phpexePath) + protected static string GetPhpExecutableVersion(string phpexePath) { return FileVersionInfo.GetVersionInfo(phpexePath).ProductVersion; } + protected void MakeHandlerActive(string handlerName, WebVirtualDirectory virtualDir) + { + using (var srvman = webObjectsSvc.GetServerManager()) + { + var config = srvman.GetWebConfiguration(((WebSite)virtualDir).SiteId, virtualDir.VirtualPath); + + var handlersSection = (HandlersSection)config.GetSection(Constants.HandlersSection, typeof(HandlersSection)); + + var handlersCollection = handlersSection.Handlers; + + var handlerElement = handlersCollection[handlerName]; + var activeHandlerElement = handlersCollection[GetActivePhpHandlerName(srvman, virtualDir)]; + + var activeHandlerIndex = handlersCollection.IndexOf(activeHandlerElement); + + handlersCollection.Remove(handlerElement); + + handlersCollection.AddCopyAt(activeHandlerIndex, handlerElement); + + srvman.CommitChanges(); + } + } + #endregion } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/IIS70_Settings.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/IIS70_Settings.ascx.resx index 8c517294..377a2135 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/IIS70_Settings.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/App_LocalResources/IIS70_Settings.ascx.resx @@ -256,7 +256,10 @@ Web Sites Public Shared Address: - - Register Helicon Ape module globally: + + Register Helicon Ape module globally: + + + If any PHP5 FastCGI handlers are present on the server, the PHP 5.x Executable Path given above will be ignored and not used. \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx index 3c44ec57..d3942659 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx @@ -291,6 +291,11 @@ + + + + + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx.designer.cs index 5bba0914..b2bd278a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ProviderControls/IIS70_Settings.ascx.designer.cs @@ -490,6 +490,15 @@ namespace WebsitePanel.Portal.ProviderControls { /// protected global::System.Web.UI.WebControls.DropDownList ddlPhpMode; + /// + /// litPHP5Info control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal litPHP5Info; + /// /// perlPath control. ///