<?php
/*
This file belongs to the Webinterface of schokokeks.org Hosting
Written by schokokeks.org Hosting, namely
Bernd Wurst <bernd@schokokeks.org>
Hanno Böck <hanno@schokokeks.org>
This code is published under a 0BSD license.
Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
*/
require_once('inc/base.php');
require_once('inc/security.php');
define("CERT_OK", 0);
define("CERT_INVALID", 1);
define("CERT_NOCHAIN", 2);
function user_certs()
{
$uid = (int) $_SESSION['userinfo']['uid'];
$result = db_query("SELECT id, valid_from, valid_until, subject, cn FROM vhosts.certs WHERE uid=? ORDER BY cn", [$uid]);
$ret = [];
while ($i = $result->fetch()) {
$ret[] = $i;
}
#DEBUG($ret);
return $ret;
}
function user_csr()
{
$uid = (int) $_SESSION['userinfo']['uid'];
$result = db_query("SELECT id, created, hostname, bits FROM vhosts.csr WHERE uid=? ORDER BY hostname", [$uid]);
$ret = [];
while ($i = $result->fetch()) {
$ret[] = $i;
}
#DEBUG($ret);
return $ret;
}
function user_has_manual_certs()
{
foreach (user_certs() as $c) {
if (!cert_is_letsencrypt($c['id'])) {
return true;
}
}