Atozed Forums
PHP content handler - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: PHP content handler (/thread-2817.html)



PHP content handler - JuergenS - 07-31-2022

I would like to install and use a content handler for PHP (.php) files.
The content handler can be registered, but unfortunately the execute function of the content handler is NOT called.

TIWMimeTypes::RegisterType(L".php", L"text/php; charset=UTF-8", false);
THandlers::Add(L"/", L"*.php", new TIWH_Php());

However, it works with the same PHP files but with a different file extension (.myPhp).

TIWMimeTypes::RegisterType(L".myphp", L"text/php; charset=UTF-8", false);
THandlers::Add(L"/", L"*.myphp", new TIWH_Php());


Regrads
JuergenS


RE: PHP content handler - Alexandre Machado - 07-31-2022

ServerController.BlockedDocExtensions property by default contains .php extension. The reason is that 99.9999999999% of all attack/exploit kits available out there - that are used by someone trying to gain access to your application and/or server - uses several requests all targeting some .php file. IntraWeb by default refuses to process those requests.

Use the ServerController.OnConfig event to remove .php extension from BlockedDocExtensions:

procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
begin
BlockedDocExtensions.Remove('.php');
end;


RE: PHP content handler - JuergenS - 08-01-2022

Ok, it works.
Thanks a lot.


RE: PHP content handler - Alexandre Machado - 08-02-2022

Great! :-)

You're welcome


RE: PHP content handler - JuergenS - 08-07-2022

I integrated PHP 8.1.8 for Windows (php-cgi.exe) into a web application via a PHP handler (Iw::Content::Base::TContentBase) using TIWCGIRunner.
It works very well, almost all PHP examples from w3cschools.com can be run without any problems.

However, no PHP forms can be executed with POST, the following message is always output: "Warning: Undefined array key".
The form parameters are obviously not stored in the superglobals $_POST or $_REQUEST during POST.
I couldn't find any problem in the PHP configuration file, so I suspect a problem with the data transfer from TIWCGIRunner to php-cgi.exe.

Here are the contents of the two PHP files

FormPost.php:

<!DOCTYPE HTML> 
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="application/x-www-form-urlencoded">
</head>
<body>
<form method="post" action="FormPostDisplay.php">
  <input type="text" name="name" value="Value POST">
  <input type="submit">
</form>
</body>
</html>

FormPostDisplay.php:

<!DOCTYPE HTML> 
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p>Name: <?php echo $_POST['name']; ?></p>
<p>Name: <?php echo $_REQUEST['name']; ?></p>
</body>
</html>


An example would be available too.

Regards Juergen


RE: PHP content handler - Alexandre Machado - 08-09-2022

$_REQUEST and $_POST are not set and TIWCGIRunner by default generates GET requests only.

I'll check if what you want can be achieved in any other way.