function decryptmsg($emailmsg, $password) { global $pref, $atmail; if (strpos($emailmsg, '-----BEGIN PGP MESSAGE-----') === false) { return; } require_once 'PGP.php'; $userWrkDir = $this->mail->MailDir ? $this->mail->MailDir : $atmail->tmpdir; $ownFile = $atmail->tmpdir . ".ht.{$this->SessionID}"; $pgp = new PGP(array('wrkDir' => "{$userWrkDir}/pgp", 'ownFile' => $ownFile)); if (empty($pgp->ErrorMsg)) { if (!$pgp->Word) { //if not cached $pgp->Word = $password; } //take it from user if (empty($pgp->Word)) { return $emailmsg; } //try to decrypt with the password $emailmsg = $pgp->decrypt($emailmsg); if ($pgp->is_error()) { return $pgp->ErrorMsg . $emailmsg; } } else { $emailmsg = $pgp->ErrorMsg . $emailmsg; } return $emailmsg; }