Calling a CGI script from phpWCMS with arguments...
Posted: Wed 29. Dec 2004, 00:23
After trying the "virtual" method suggested in this topic and coming across the same issue that the results of the CGI scripts are placed at top of the screen instead of in the content area where they "should" go I set out to find a better way.
I thought I had come across a smooth way of calling a cgi script (perl in my case) from within the contents of phpWCMS. I'm using this PHP code to take all of the posted arguments and pass them along to the cgi script:
Unfortunately, it appears that the post variables that would normally be available to a php script are not available inside the [PHP] ... [/PHP] context.
Am I doing something wrong or has phpwcms not made those variables available?
Thanks in advance for any help.
fnord
I thought I had come across a smooth way of calling a cgi script (perl in my case) from within the contents of phpWCMS. I'm using this PHP code to take all of the posted arguments and pass them along to the cgi script:
Code: Select all
[PHP]
$CGISCRIPT="./cgi-bin/pregtest.cgi";
// preparing the arguments passed to this PHP page
$QSTRING = $QUERY_STRING;
foreach ($HTTP_POST_VARS as $header=> $value ){
if($QSTRING==""){
$QSTRING = $header.'='.urlencode($value);
}else{
$QSTRING = $QSTRING.'&'.$header.'='.urlencode($value);
}
}
putenv('REQUEST_METHOD=POST');
putenv('CONTENT_TYPE=application/x-www-form-urlencoded');
putenv('CONTENT_LENGTH='.strlen($QSTRING));
putenv('QUERY_STRING='.$QSTRING);
unset($return_array);
exec('echo "'.$QSTRING.'"| '.$CGISCRIPT, $return_array, $return_val);
$onestring = implode('',$return_array);
echo "$onestring";
[/PHP]
Am I doing something wrong or has phpwcms not made those variables available?
Thanks in advance for any help.
fnord