Browse Source

separate view and controller logic

pull/63/head
Nicolas Roman 1 year ago
parent
commit
320a229d4f
2 changed files with 46 additions and 35 deletions
  1. +8
    -23
      inc/webadmin-letsencrypt.php
  2. +38
    -12
      tpl/webadmin-letsencrypt.tpl.php

+ 8
- 23
inc/webadmin-letsencrypt.php 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';

+ 38
- 12
tpl/webadmin-letsencrypt.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>';
}
?>
</ul>
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>';
<?php
foreach ($failed_domains_dns as $failed_domain) {
echo $failed_domain . "<br>";
}
} else {
echo "all checks succeeded";
}
} 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
}
}

Loading…
Cancel
Save