Calling a CGI script from phpWCMS with arguments...

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
fnord
Posts: 17
Joined: Sat 20. Nov 2004, 06:39

Calling a CGI script from phpWCMS with arguments...

Post by fnord »

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:

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]
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
Karla
Posts: 223
Joined: Tue 26. Oct 2004, 11:56

Post by Karla »

fnord
Posts: 17
Joined: Sat 20. Nov 2004, 06:39

Isn't that the opposite?

Post by fnord »

Oliver Georgi said wrote:Vars you want to use anywhere has to be brought to the $GLOBALS array first.
I think that thread is actually the opposite if what I'm trying to do. Isn't that for making my local variables in my function global so that any PHP function can use them?

What I'm looking for is a way to access the global predefined variables that PHP usually gets in my function.

I could totally be wrong but that's my understanding.

Fnord
Post Reply