I need to run the following function in CGI (it won't work in ordinary php3)
What I basically want to do is put this function in a seperate cgi file, then call it from a php3 file, passing the variable $msg (which is the bit to be encrypted) and then returning the value of $mail_cont, which is the encrypted value.
The call would be something like:
$msg="this is it";
exec("http://www.etc/path/encrypt.cgi",$codedvalue);
echo $codedvalue;
echo $codedvalue[0];
But all I get is
$codedvalue=array
or
nothing when I ask for codedvalue[0];
I'm probably doing something fundamentally wrong. Here is the function, should it just be on it's own in the cgi file? Or does it need something else like headers and so on?
function encryptccdetails($msg)
{
//set the environment variable for PGPPATH
putenv("PGPPATH=/home/ambitire/.pgp");
//generate token for unique filenames
echo "New file";
$tmpToken = md5(uniqid(rand()));
//create vars to hold paths and filenames
$plainTxt = "/home/ambitire/reservationsnetwork_html/respix/" . "$tmpToken" . "data";
$crypted = "/home/ambitire/reservationsnetwork_html/respix/" . "$tmpToken" . "pgp";
//open file and dump in plaintext contents
$fp = fopen($plainTxt, "w+");
fputs($fp, $msg);
fclose($fp);
//invoke PGP to encrypt file contents
//system("/usr/local/bin/pgpe -r 'Julie Meloni <julie@thickbook.com>' -o $crypted -a $plainTxt");
system("/usr/local/bin/pgpe -r 'Reservations Network <info@reservationsnetwork.ie>' -o $crypted -a $plainTxt");
//open file and read encrypted contents into var
$fd = fopen($crypted, "r");
$mail_cont = fread($fd, filesize($crypted));
fclose($fd);
//delete files!
unlink($plainTxt);
unlink($crypted);
echo $mail_cont;
return $mail_cont;
}
?>
any help would be very much appreciated.
I've searched the forum but I can't see anything that helps on this.
Regards
Elizabeth