Hi, me again.
I'm trying to encrypt a string using PHP - can anyone tell me why:
<?php
function encryptccdetails($msg)
{
//set the environment variable for PGPPATH
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" . "pgpdata";
//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;
}
?>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<?php
//$plainTxt = "/home/ambitire/reservationsnetwork_html/respix/" . "$tmpToken" . "data";
//$crypted = "/home/ambitire/reservationsnetwork_html/respix/" . "$tmpToken" . "pgpdata";
$message=encryptccdetails('trythis');
?>
<table width="100%" border="0">
<tr>
<td>did this work?</td>
<td><?php echo $message?></td>
</tr>
</table>
</body>
gives the errors:
Warning: fopen("/home/ambitire/reservationsnetwork_html/respix/pgpdata","r") - No such file or directory in /usr/local/apache/secure/ambitire/public_html/resnet/enc.php3 on line 25
Warning: Supplied argument is not a valid File-Handle resource in /usr/local/apache/secure/ambitire/public_html/resnet/enc.php3 on line 26
Warning: Supplied argument is not a valid File-Handle resource in /usr/local/apache/secure/ambitire/public_html/resnet/enc.php3 on line 27
Warning: Unlink failed (No such file or directory) in /usr/local/apache/secure/ambitire/public_html/resnet/enc.php3 on line 31
I think it's the path. The path I give is on the non-secure server and the script is runnign on a secure server. However the ISP doesn't think it is - so I'm stuck!
Regards and thanx!
Elizabeth