separate view and controller logic

This commit is contained in:
Nicolas Roman 2019-06-07 11:49:11 +02:00
parent 58dda79c6a
commit 320a229d4f
2 changed files with 47 additions and 36 deletions

View File

@ -29,38 +29,23 @@ if (!isset($_SESSION['lestencrypt-domains']) || empty($_SESSION['letsencrypt-dom
$_SESSION['letsencrypt-domains'] = $domains;
}
if (isset($params[2]) && $params[2] == "check") {
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
if (isset($_POST['submit'])) {
$letsencrypt = new letsencryt();
// check HTTP
$checked_domains = $letsencrypt->checkRemoteResourceAvailability($_SESSION['letsencrypt-domains']);
$failed_domains_http = array_diff($_SESSION['letsencrypt-domains'], $checked_domains);
# debug à améliorer
echo '<h2>The following domain(s) failed the HTTP challenge</h2>';
foreach ($failed_domains_http as $failed_domain) {
echo $failed_domain . '<br>';
}
// check DNS
if (!empty($checked_domains)) {
if (empty($failed_domains_http) && !empty($checked_domains)) {
// check DNS
$valid_domains = $letsencrypt->checkDNSValidity($checked_domains);
$failed_domains_dns = array_diff($checked_domains, $valid_domains);
# debug à améliorer
echo '<h2>The following domain(s) failed the DNS check</h2>';
foreach ($failed_domains_dns as $failed_domain) {
echo $failed_domain . '<br>';
}
}
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
} else {
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/webadmin-letsencrypt.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
// page de base
}
include_once EVOADMIN_BASE . '../tpl/webadmin-letsencrypt.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';

View File

@ -1,20 +1,46 @@
<h2>Gestion Let's Encrypt</h2>
<?php
if (count($_SESSION['letsencrypt-domains']) > 0) {
?>
if (isset($_POST['submit'])) {
if (count($failed_domains_http) > 0) {
echo '<h3 class="form-error">Erreur HTTP</h3>';
<p>Liste des domaines à intégrer dans le certificat : </p>
<ul>
<?php
foreach ($_SESSION['letsencrypt-domains'] as $domain) {
echo '<li>' . $domain . '</li>';
echo '<p>';
echo 'Le challenge HTTP a échoué pour le(s) domaine(s) ci-dessous.
Merci de vérifier que le dossier <code>/.well-known/acme-challenge/</code> est accessible.';
echo '</p>';
echo '<p>';
foreach ($failed_domains_http as $failed_domain) {
echo $failed_domain . "<br>";
}
echo '</p>';
} elseif (count($failed_domains_dns) > 0) {
echo '<h3 class="form-error">Erreur DNS</h3>';
echo '<p>';
echo 'La vérification DNS a échoué pour les domaines ci-dessous.
Merci de vérifier les enregistrements de type A et AAAA.';
echo '</p>';
foreach ($failed_domains_dns as $failed_domain) {
echo $failed_domain . "<br>";
}
} else {
echo "all checks succeeded";
}
?>
</ul>
<?php
} else {
print "<p>Aucun domaine.</p>";
echo "<p>Les domaines suivants seront intégrés au certificat : </p>";
if (count($_SESSION['letsencrypt-domains']) > 0) {
echo '<p>';
foreach ($_SESSION['letsencrypt-domains'] as $domain) {
echo $domain . '<br>';
}
echo '</p>';
?>
<form name="form-confirm-delete-alias" id="form-confirm-delete-alias" action="" method="POST">
<p><input type="submit" name="submit" value="Poursuivre l'installation du certificat" style="margin-left:0px;"></p>
</form>
<?php
}
}