Browse Source

first draft webadmin-letsencrypt.php

pull/63/head
Nicolas Roman 1 year ago
parent
commit
2193307e14
1 changed files with 66 additions and 0 deletions
  1. +66
    -0
      inc/webadmin-letsencrypt.php

+ 66
- 0
inc/webadmin-letsencrypt.php View File

@ -0,0 +1,66 @@
<?php
require_once EVOADMIN_BASE . '../lib/letsencrypt.php';
use lib\LetsEncrypt as letsencryt;
// store domain and aliases in session
if (!isset($_SESSION['lestencrypt-domains']) || empty($_SESSION['letsencrypt-domains'])) {
$domain = $params[1];
$cmd = 'web-add.sh list-vhost';
if (!is_superadmin()) {
$cmd = sprintf('%s %s', $cmd, $domain);
}
sudoexec($cmd, $data_output, $exec_return);
$data_split = explode(':', $data_output[0]);
$aliases = explode(',', $data_split[3]);
$domains = array();
// store domain and aliases
array_push($domains, $data_split[2]);
foreach ($aliases as $alias) {
array_push($domains, $alias);
}
$_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';
$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)) {
$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';
}

Loading…
Cancel
Save