liam-linux-account-manager/views/serveraccount_pubkeys.php

25 lines
838 B
PHP
Raw Permalink Normal View History

2021-11-16 15:11:32 +01:00
<?php
try {
$server = $server_dir->get_server_by_hostname($router->vars['hostname']);
$account = $server->get_account_by_name($router->vars['account']);
} catch(ServerAccountNotFoundException $e) {
require('views/error404.php');
die;
} catch(ServerNotFoundException $e) {
require('views/error404.php');
die;
}
$pubkeys = $account->list_public_keys();
if(isset($router->vars['format']) && $router->vars['format'] == 'txt') {
$page = new PageSection('entity_pubkeys_txt');
$page->set('pubkeys', $pubkeys);
header('Content-type: text/plain; charset=utf-8');
echo $page->generate();
} elseif(isset($router->vars['format']) && $router->vars['format'] == 'json') {
$page = new PageSection('entity_pubkeys_json');
$page->set('pubkeys', $pubkeys);
header('Content-type: application/json; charset=utf-8');
echo $page->generate();
}