Hi,
I'm getting an error when using fopen, and GPG. I let uses fill in a form, then when they press submit, this is put in a temp file, then GPG opens the file, encrypts the file, and saves it as an encrypted file, then emails it off. I had it working fine, until I deleted the public key, and created a new 1. Now I receive the error..
Warning: fopen("/users/site/tmpdata/17hshf9gpgdata", "r") - No such file or directory in /users/site/www/include/booking.php on line 49.
My code is...
putenv("/users/site/.gnupg");
$tmpToken = md5(uniqid(rand()));
$crypted = ("/users/site/tmpdata/" . "$tmpToken" . "gpgdata");
$plainTxt = ("/users/site/tmpdata/" . "$tmpToken" . "data");
$fp = fopen($plainTxt, "w+");
fputs($fp, $message);
fclose($fp);
system("export HOME=/users/site ; /usr/bin/gpg --encrypt --no-secmem-warning -ao $crypted -r MyKey $plainTxt");
$fd = fopen($crypted, "r");
$mail_cont = fread($fd, filesize($crypted));
fclose($fd);
unlink($plainTxt);
unlink($crypted);
I know that the 1st file is being created, because if I remove the unlink command, and list the contents of the directory, the file is there. Its just not being encrypted and the new file created. So it must be the gpg command, however if I run just
gpg --encrypt --no-secmem-warning -ao $crypted -r MyKey $plainTxt
via telnet, it works fine, both files are created. And I can't understand why it would change, it used to work until I deleted the old key, but the new key I created used the same username & email, just different password.
If anyone can help I'd be very greatful
Ben