* * Licensed under the GNU General Public License. * * check the README for necessary prerequisites * */ //! OpenPGP client command $PGP_COMMAND = "gpg"; //! A dir where the PHP script has write access $PGP_HOME = "/var/gpg/.phkp"; //! The maximum size (in characters) of a submitted key. //! Set to '0' to disable receiving of keys, and '-1' for no limit. $MAX_KEYSIZE = 102400; if (ereg("/pks\\/add", $_SERVER['REQUEST_URI'])) { if ($MAX_KEYSIZE == -1 || strlen($_POST['keytext']) <= $MAX_KEYSIZE) { //write key into temporary file file_put_contents("{$PGP_HOME}/tmp", $_POST['keytext']); //run gpg --with-fingerprint to retreive information about the key from the keyfile $result = shell_exec("{$PGP_COMMAND} --homedir {$PGP_HOME} --with-fingerprint {$PGP_HOME}/tmp"); //extract email addresses from the information $pattern = '/[a-z0-9_\\-\\+]+@[a-z0-9\\-]+\\.([a-z]{2,3})(?:\\.[a-z]{2})?/i'; preg_match_all($pattern, $result, $matches); //for each email address assigned to the key, put intformation into the DB and send confirmation emails foreach ($matches[0] as $match) { //echo $match.': '.$_POST['keytext']; requestPGP($match, $_POST['keytext']); } } else { header("HTTP/1.0 403 Forbidden"); } }
<?php /* gpg-mailgate This file is part of the gpg-mailgate source code. gpg-mailgate is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. gpg-mailgate source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>. */ require_once "include/config.php"; require_once "include/language.php"; require_once "include/common.php"; require_once "include/dbconnect.php"; require_once "include/pgp.php"; if (isset($_POST['email']) && isset($_POST['key'])) { $result = requestPGP($_POST['email'], $_POST['key']); if ($result === true) { get_page("home", array('message' => $lang['submit_success'])); } else { get_page("home", array('message' => $result)); } } else { get_page("home"); }