PDA

View Full Version : Embedded CGI script using PHP passthru command


iantresman
04-07-2007, 10:29 PM
For anyone else trying to embed CGI/Win32 version of search.cgi into a PHP script, and run it under Windows XP, the following may help (the PHP virtual() function is for Unix, and must be substituted for the passthru() which works in a different way):
<?php
//Windows Usage
$QSTRING = $_SERVER['QUERY_STRING'];
putenv('REQUEST_METHOD=GET');
putenv('QUERY_STRING='.$QSTRING);
$command="C:\\dir\\directory\\another-subdiectory\\search.cgi";
ob_start();
passthru ($command);
$results = ob_get_contents();
ob_end_clean();
echo $results;
?>By default, the output in $results include the HTML header (Content-type: text/html; charset=UTF-8); I think there is an option to disable this under Advanced tab, "Disable charset enforcing on search script".

And I found there is no need to truncate the directory path to DOS 8.3 notation.

Regards,
Ian Tresman

wrensoft
04-08-2007, 09:03 AM
Thanks for that. In addition, there is also an option, detailed in our FAQ, to use, shell_exec to call the CGI (http://www.wrensoft.com/zoom/support/faq_ssi.html) on Windows / IIS.