Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP content handler
#1
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


Attached Files
.zip   PhpHandler.zip (Size: 11.27 KB / Downloads: 3)
Reply
#2
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;
Reply
#3
Thumbs Up 
Ok, it works.
Thanks a lot.
Reply
#4
Great! :-)

You're welcome
Reply
#5
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
Reply
#6
$_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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)