PHP Script
Cochran, Jason L
JCochran at hearstnp.com
Sat Oct 3 00:21:13 CEST 2009
I need help getting a scrip working. I am hosted with Hostgator. My key
is in the cpanel. Yet I can't get php to work with it.
PHP_INFO: http://gator1028.hostgator.com/~mwtadmin/php_info.php
SCRIPT: http://gator1028.hostgator.com/~mwtadmin/pgp_test.php
Thanks!
===== pgp_test.php =====
<?php
// replace this with the user name or e-mail address that you used
for your PGP key pair
$pgpuser = "webmaster at mywesttexas.com" ; // The email used to
generate your public key
// Recipient of the email
$testemail = "jcochran at mrt.com";
// Replace with your subject
$emailsubject = "Encrypted Email Subject";
// The from field
$emailfrom = "From: webmaster at mywesttexas.com";
// Feed your text in here
$body = "To test if your decryption work, put some text here or feed
in the variables from your submitted forms";
// Tell gnupg where the public key is that is should use to encode
your message
// This is usually in your home directory, below the public_html
(mine is .gnupg)
// change this to the correct path of your web space. On hostgator:
home/username/.gnupg
putenv("GNUPGHOME=/home/mwtadmin/.gnupg");
// create a temporary, unique file name to work from
$infile = tempnam("/tmp", "PGP.asc");
$outfile = $infile.".asc";
// we write the various bits and bobs into the temp file
$fp = fopen($infile, "w");
fwrite($fp, $body);
fclose($fp);
// Call the other directory of gnuGP (this will work on hostgator)
and run the command
// When you call this line, it will set off the actuall encoding
process
$command = "/usr/bin/gpg -a -always-trust -batch -no-secmem-warning
-e -r $pgpuser -o $outfile $infile";
// Call the line that will encrypt your temporary file
system($command, $result);
// The encryption is now loaded in the system, so delete the temp
file
//unlink($infile);
if ($result == 0) {
$fp = fopen($outfile, "r");
if (!$fp || filesize($outfile) == 0) {
$result = -1;
} else {
// read the encrypted file
$contents = fread ($fp, filesize ($outfile));
// delete the encrypted file
unlink($outfile);
// send the email and write something nice if it was a success
// otherwise moan bitterly and wonder what went wrong
// Errors are usually either your username, or more like the paths
to your gnuGP
// contact your Tech Support for your paths - the ones shown here
works for hostgator.
mail ($testemail, $emailsubject, $contents, $emailfrom);
print "Thank you!! Your encrypted booking information has been
sent.";
}
}
if ( $result != 0) {
print "There was a problem processing the information.";
}
?>
~ Jason
Midland Reporter Telegram
Direct: (432) 687-9011 (x 3111)
www.mywesttexas.com
========================================================
This e-mail message is intended only for the personal
use of the recipient(s) named above. If you are not
an intended recipient, you may not review, copy or
distribute this message.
If you have received this communication in error, please
notify the sender immediately by e-mail and delete the original message.
========================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20091002/eb9ede14/attachment.htm>
More information about the Gnupg-users
mailing list