servnest/ht/le.php

35 lines
1.0 KiB
PHP
Raw Normal View History

2021-01-22 21:58:46 +01:00
<?php require "../top.inc.php"; ?>
2021-02-17 22:48:49 +01:00
<p>
Installer un certificat Let's Encrypt
</p>
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
<form method="post">
<label for="domain">Domaine sur lequel installer le certificat</label><br>
<input required="" placeholder="site.<?= DOMAIN_EXAMPLE ?>" id="domain" name="domain" type="text"><br>
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
<input value="Valider" type="submit">
</form>
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
<?php
2021-01-22 21:58:46 +01:00
2021-08-05 14:04:33 +02:00
if (isset($_POST['domaine']) AND isset($_SESSION['username'])) {
antiCSRF();
2021-01-22 21:58:46 +01:00
exec(SUDO_PATH . " " . MANIVER_PATH . " le-install " . $_POST['domain'], $output);
2021-03-04 01:02:38 +01:00
addNiverLog($_SESSION['username'] . " installed a Let's Encrypt certificate on their site", $output);
$conf = file_get_contents(NGINX_CONFIG_PATH . "/" . $_POST['domain'] . ".conf");
2021-02-17 22:48:49 +01:00
$conf = preg_replace("#host\.atope\.art#", $_POST['domain'], $conf);
2021-03-04 01:02:38 +01:00
file_put_contents(NGINX_CONFIG_PATH . "/" . $_POST['domain'] . ".conf", $conf);
2021-01-22 21:58:46 +01:00
exec(SUDO_PATH . " " . MANIVER_PATH . " reload-nginx");
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
echo "Formulaire traité !!";
} else {
echo "Rien n'a été reçu lors du dernier chargement";
}
2021-01-22 21:58:46 +01:00
2021-02-17 22:48:49 +01:00
?>
2021-01-22 21:58:46 +01:00
<?php require "../bottom.inc.php"; ?>