summaryrefslogtreecommitdiff
path: root/keys.php
blob: 42d9c012b19f6effca4b76d075e8a03ecdf962a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

require_once "init.php";

if (!array_key_exists('k', $_GET)) {
  print 'There are ' . shell_exec('gpg --list-keys --with-colons | grep "^fpr:" | cut -d: -f10 | wc -l') . ' keys on this server.';
  die();
}
if (preg_match('/^[0-9A-Fa-f]{16,40}$/', $_GET['k']) !== 1)
  die();

$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);
}