Initial commit

This commit is contained in:
2022-05-15 21:39:39 +02:00
commit 81a6b562b6
50 changed files with 3837 additions and 0 deletions

22
www/openpgpkey_wkd.php Normal file
View File

@ -0,0 +1,22 @@
<?php
require_once '../common_config.php';
header( 'Access-Control-Allow-Origin: *' );
$db = get_db_instance();
$stmt = $db->prepare( 'SELECT pgp_key FROM mailbox WHERE openpgpkey_wkd = ? AND domain = ?;' );
$stmt->execute( [ explode( '?', basename( $_SERVER[ 'REQUEST_URI' ] ) )[ 0 ], $_GET[ 'domain' ] ?? $_SERVER[ 'HTTP_HOST' ] ] );
$res = $stmt->fetch( PDO::FETCH_ASSOC );
if ( ! empty( $res[ 'pgp_key' ] ) ) {
$gpg = gnupg_init();
gnupg_seterrormode( $gpg, GNUPG_ERROR_WARNING );
gnupg_setarmor( $gpg, 0 );
$imported_key = gnupg_import( $gpg, $res[ 'pgp_key' ] );
if ( ! $imported_key ) {
http_response_code( 500 );
} else {
http_response_code( 200 );
header( 'Content-Type: application/octet-stream' );
echo gnupg_export( $gpg, $imported_key[ 'fingerprint' ] );
}
} else {
http_response_code( 404 );
}