Fw: PHP / GnuPG problem with Fopen
| From: | Clint Fern | Date: | Thu, 09 Jan 2003 13:58:24 +0000 |
| Subject: | Fw: PHP / GnuPG problem with Fopen | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-130942@lists.php.net to get a copy of this message | ||
Hi,
Many apologies if this has been covered before - but I haven't tracked it down in the archive
and it's been annoying me for weeks.
I'm using a script to send an order number & encrypted cc number by GnuPG. Unfortunately
the temporary files don't seem to be created causing error messages. Can anyone point me in the
right direction - many thanks.
Script lines are;
$message = 'Order #' . $insert_id . "\n\n" . 'Number: ' .
$GLOBALS['cc_toencrypt'] . "\n\n";
// I've tried this variable putenv ("GNUPGHOME=/home/www/.gnupg");
// I've tried this variable putenv ("GNUPGHOME=/home/.gnupg");
//set the environment variable for GPGPATH
putenv ("GNUPGHOME=/usr/local/psa/home/ahosts/ppppp.com/home/.gnupg");
//generate token for unique filenames
$tmpToken = md5(uniqid(rand()));
//create vars to hold paths and filenames
$plainTxt = "/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/tmp/" . "$tmpToken"
. "data";
$crypted = "/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/tmp/" . "$tmpToken" .
"gpgdata";
//open file and dump in plaintext contents
$fp = fopen($plainTxt, "w+");
fputs($fp, $message);
fclose($fp);
//invoke GPG to encrypt file contents
system("/usr/local/php_safe/bin --encrypt -ao $crypted -r 'Ralph Brookes
<sales@ppppp.com>' $plainTxt");
//open file and read encrypted contents into var
251 $fd = fopen($crypted, "a+");
252 $mail_cont = fread($fd, filesize($crypted));
253 fclose($fd);
//delete files!
unlink($plainTxt);
255 Unlink($crypted);
tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, 'Extra Order Info', $mail_cont,
STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');
Error messages are;
Warning:
fopen("/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/tmp/21fc09f4a3e129b04ae38984613ece46pgpdata",
"r+") - No such file or directory in
/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/catalog2/catalog/includes/modules/payment/ccgpg.php
on line 251
Warning: stat failed for
/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/tmp/21fc09f4a3e129b04ae38984613ece46pgpdata (errno=2
- No such file or directory) in
/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/catalog2/catalog/includes/modules/payment/ccgpg.php
on line 252
Warning: fread(): supplied argument is not a valid File-Handle resource in
/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/catalog2/catalog/includes/modules/payment/ccgpg.php
on line 252
Warning: fclose(): supplied argument is not a valid File-Handle resource in
/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/catalog2/catalog/includes/modules/payment/ccgpg.php
on line 253
Warning: unlink() failed (No such file or directory) in
/usr/local/psa/home/ahosts/ppppp.com/httpsdocs/catalog2/catalog/includes/modules/payment/ccgpg.php
on line 255
Cheers
Clint
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.438 / Virus Database: 246 - Release Date: 07/01/03