Some refactoring and small changes:
- Use webObjectsSvc.GetServerManager() - Do not make any changes if the PHP5 handler is not changed in the UI - Added text on IIS70_Settings page to inform that the PHP5 Executable Path can be ignored
This commit is contained in:
parent
d7ac9fa36f
commit
170b4da51d
5 changed files with 62 additions and 45 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,7 +256,10 @@
|
|||
<data name="txtPublicSharedIP.Text" xml:space="preserve">
|
||||
<value>Web Sites Public Shared Address:</value>
|
||||
</data>
|
||||
<data name="chkHeliconApeGlobalRegistration.Text">
|
||||
<value xml:space="preserve">Register Helicon Ape module globally:</value>
|
||||
<data name="chkHeliconApeGlobalRegistration.Text" xml:space="preserve">
|
||||
<value>Register Helicon Ape module globally:</value>
|
||||
</data>
|
||||
<data name="litPHP5Info.Text" xml:space="preserve">
|
||||
<value>If any PHP5 FastCGI handlers are present on the server, the PHP 5.x Executable Path given above will be ignored and not used.</value>
|
||||
</data>
|
||||
</root>
|
|
@ -291,6 +291,11 @@
|
|||
</asp:DropDownList>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="Normal">
|
||||
<asp:Literal ID="litPHP5Info" runat="server" meta:resourcekey="litPHP5Info" Text="If any PHP5 FastCGI handlers are present on the server, the PHP 5.x Executable Path given above will be ignored and not used."></asp:Literal>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="Normal" valign="top">
|
||||
<asp:Label runat="server" meta:resourcekey="perlPathLabel" Text="Perl Executable Path:"></asp:Label>
|
||||
|
|
|
@ -490,6 +490,15 @@ namespace WebsitePanel.Portal.ProviderControls {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList ddlPhpMode;
|
||||
|
||||
/// <summary>
|
||||
/// litPHP5Info control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Literal litPHP5Info;
|
||||
|
||||
/// <summary>
|
||||
/// perlPath control.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue