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