Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions PeachPied.WordPress.AspNet/PeachPied.WordPress.AspNet.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Peachpie.RequestHandler" Version="$(PeachpieVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PeachPied.WordPress.Standard\PeachPied.WordPress.Standard.csproj" />
</ItemGroup>

</Project>
68 changes: 68 additions & 0 deletions PeachPied.WordPress.AspNet/RequestHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Web;
using Pchp.Core;
using Pchp.Core.Utilities;
using PeachPied.WordPress.Standard;

namespace PeachPied.WordPress.AspNet
{
/// <summary>
/// Request handling for wordpress scripts.
/// </summary>
public class RequestHandler : Peachpie.RequestHandler.RequestHandler
{
/// <summary>
/// Creates request context for a WordPress application.
/// </summary>
protected override Context InitializeRequestContext(HttpContext context)
{
var ctx = base.InitializeRequestContext(context);

ctx.RootPath = ctx.WorkingDirectory =
// where the nuget package resolves the contentFiles,
// this should be placed outside the bin folder tho:
Path.Combine(context.Request.PhysicalApplicationPath, "bin/wordpress");

ApplySettings(ctx, context.GetSection("wordpress") as NameValueCollection);

return ctx;
}

void ApplySettings(Context ctx, NameValueCollection configuration)
{
WpStandard.WP_DEBUG = Debugger.IsAttached;

var table_prefix = "wp_";

if (configuration != null)
{
for (int i = 0; i < configuration.Count; i++)
{
var key = configuration.GetKey(i);
var value = configuration.Get(i);

switch (key.ToUpperInvariant())
{
case "TABLE_PREFIX": table_prefix = value; break;
case "DB_HOST": WpStandard.DB_HOST = value; break;
case "DB_NAME": WpStandard.DB_NAME = value; break;
case "DB_USER": WpStandard.DB_USER = value; break;
case "DB_PASSWORD": WpStandard.DB_PASSWORD = value; break;
case "WP_DEBUG": WpStandard.WP_DEBUG = bool.Parse(value); break;
//case "DISABLE_WP_CRON": WpStandard.DISABLE_WP_CRON = bool.Parse(value); break;
// TODO: WP_CONTENT_DIR: resolve absolute path relatively to app root
default:
ctx.DefineConstant(key, value);
break;
}
}
}

// required global variables:
ctx.Globals["table_prefix"] = table_prefix;
}
}
}
35 changes: 35 additions & 0 deletions app-aspnet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("app_aspnet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("app_aspnet")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("87ea2cb3-1513-4a5d-b223-895dc26be8f1")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
30 changes: 30 additions & 0 deletions app-aspnet/Web.Debug.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
31 changes: 31 additions & 0 deletions app-aspnet/Web.Release.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
176 changes: 176 additions & 0 deletions app-aspnet/Web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="wordpress" type="System.Configuration.NameValueSectionHandler" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- Allow all folders with 'bin', 'App_code', 'App_Data', etc names. -->
<hiddenSegments>
<clear />
</hiddenSegments>
</requestFiltering>
</security>
<handlers>
<add name="WordPressHandler" path="*.php" verb="*" type="PeachPied.WordPress.AspNet.RequestHandler, PeachPied.WordPress.AspNet" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
<rewrite>
<rules>
<rule name="WordPress Admin" stopProcessing="true">
<match url="^wp-admin/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" negate="true" pattern="\.php$" />
<add input="{REQUEST_FILENAME}" negate="true" pattern="wp-admin/.*" />
<!--add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /-->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" logRewrittenUrl="true" url="wp-admin/index.php" />
</rule>
<rule name="WordPress" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" negate="true" pattern="\.php$" />
<add input="{PATH_INFO}" negate="true" pattern="(wp-include|wp-admin|wp-content)" />
<!--add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /-->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" logRewrittenUrl="true" url="index.php/{R:1}" />
</rule>
<rule name="WordPressContentFiles">
<match url="^(wp-.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" negate="true" pattern="\.php$" />
<!--add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /-->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="bin/wordpress/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
</compilers>
</system.codedom>

<wordpress>
<add key="DB_PASSWORD" value="password" />
<add key="WP_SITEURL" value="http://localhost:52312" />
<add key="WP_HOME" value="http://localhost:52312" />
</wordpress>

<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<dependentAssembly>

<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />



</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Security.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="Devsense.PHP.Parser" publicKeyToken="840d8b321fee7061" culture="neutral" />


</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="FluentFTP" publicKeyToken="f4af092b1d8df44f" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-33.0.0.0" newVersion="33.0.0.0" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="BCrypt.Net-Next" publicKeyToken="1e11be04b6288443" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />

<bindingRedirect oldVersion="0.0.0.0-1.11.25.0" newVersion="1.11.25.0" />

</dependentAssembly>

</assemblyBinding>

</runtime>
</configuration>
15 changes: 15 additions & 0 deletions app-aspnet/WebForm1.aspx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="app_aspnet.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
17 changes: 17 additions & 0 deletions app-aspnet/WebForm1.aspx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace app_aspnet
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}
Loading