I had this working a few days ago, and now it doesnt - very puzzling - can anyone help?
OK, here goes with the code, and some explanations.
putenv("PGPPATH=/home/ambitire/.pgp");
//generate token for unique filenames
$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);
so far, so good
Now this next line is necessary to avoid errors later on
$fp = fopen($crypted, "w+");
If I don't do that it will say later on that it can't open the file to read it (see line marked ***)
//invoke PGP to encrypt file contents
system("/usr/local/bin/pgpe -r 'RESNET <info@reservationsnetwork.ie>' -o $crypted -t $plainTxt");
The above pgp command works in telnet, I've done an echo and copied that into telnet and it works.
//open file and read encrypted contents into var
$fd = fopen($crypted, "r"); ****
this line won't work without opening the file earlier (see above)
$mail_cont = fread($fd, filesize($crypted));
fclose($fd);
//delete files!
unlink($plainTxt);
unlink($crypted);
echo "Encrypted value = ".$mail_cont;
But the encrypted value is blank! I think because I'd already opened the output file.
So, basically, the PGP works, but the output file isn't getting generated (I think that's what's happening). In telnet the output file seems to be OK.
Can anyone help please?
Regards
Elizabeth Alderton