blob: e13d4a3290dc2ab02f9c607fe0d190b87d1a59df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<?php
require_once "init.php";
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
shell_exec(
'echo "' .
base64_encode(file_get_contents('php://input')) .
'"' .
' | base64 -d' .
' | gpg --import'
);
print 'done' . "\n";
die();
}
if (!array_key_exists('k', $_GET)) {
print
'There are ' .
trim(shell_exec('gpg --list-keys --with-colons | grep "^fpr:" | cut -d: -f10 | wc -l')) .
' keys on this server.<br>' .
"\n";
print
'You can <a href="?k=' .
trim(shell_exec('gpg --list-keys --with-colons deep42thought@archlinux32.org | grep -m1 "^fpr:" | cut -d: -f10')) .
'">download</a> them.' . "\n";
die();
}
if (substr($_GET['k'], 0, 2)=='0x')
$_GET['k'] = substr($_GET['k'], 2);
if (preg_match('/^[0-9A-Fa-f]{16,40}$/', $_GET['k']) !== 1)
die();
header('Content-Type: text/plain');
$output = shell_exec('gpg -a --export ' . $_GET['k']);
print $output;
if (! empty($output))
die();
$fh = fopen('key-wishlist', 'a');
if ($fh !== false) {
fwrite($fh, $_GET['k'] . "\n");
fclose($fh);
}
|