Skip to content

Commit

Permalink
Unix support
Browse files Browse the repository at this point in the history
- Added PHP_OS (necessary for other commited patches)
- Fixed absolute-path-includes
  • Loading branch information
J. Christopher Pereira committed Feb 10, 2014
1 parent c170280 commit 4cb8a0c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Source/Core/ScriptContext.CLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,23 @@ private void InitConstants(DualDictionary<string, object> _constants)
_constants.Add("PHP_RELEASE_VERSION", PhpVersion.Release, false);
_constants.Add("PHP_VERSION_ID", PhpVersion.Major * 10000 + PhpVersion.Minor * 100 + PhpVersion.Release, false);
_constants.Add("PHP_EXTRA_VERSION", PhpVersion.Extra, false);
_constants.Add("PHP_OS", Environment.OSVersion.Platform == PlatformID.Win32NT ? "WINNT" : "WIN32", false); // TODO: GENERICS (Unix)

string php_os = "Unknown";
switch (Environment.OSVersion.Platform)
{
case PlatformID.Win32NT:
php_os = "WINNT";
break;
case PlatformID.Win32S:
case PlatformID.Win32Windows:
case PlatformID.WinCE:
php_os = "WIN32";
break;
case PlatformID.Unix:
php_os = "Linux";
break;
}
_constants.Add("PHP_OS", php_os, false);
_constants.Add("PHP_SAPI", (System.Web.HttpContext.Current == null) ? "cli" : "isapi", false);
_constants.Add("DIRECTORY_SEPARATOR", FullPath.DirectorySeparatorString, false);
_constants.Add("PATH_SEPARATOR", Path.PathSeparator.ToString(), false);
Expand Down Expand Up @@ -574,6 +590,14 @@ public object DynamicInclude(
DTypeDesc includer,
InclusionTypes inclusionType)
{
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
// Fix for absolute-path-includes on Unix filesystems.
// Example: include_once('/path/app\libs\include.php')
// HACK: Translate "\" to "/"
includerFileRelPath = includerFileRelPath.Replace('\\', '/');
}

ApplicationConfiguration app_config = Configuration.Application;

// determines inclusion behavior:
Expand Down

0 comments on commit 4cb8a0c

Please sign in to comment.