2022-05-22 14:59:45 +02:00
|
|
|
<?php require "../../common/html.php"; ?>
|
2021-03-02 22:56:38 +01:00
|
|
|
|
2021-02-16 19:20:19 +01:00
|
|
|
<p>
|
2022-04-18 16:05:00 +02:00
|
|
|
Ajouter un domaine sur un dossier de site<br>
|
|
|
|
Le domaine doit pointer vers ces adresses IP :
|
2022-05-20 00:15:13 +02:00
|
|
|
<br>IPv4 : <code><?= CONF['ht']['ipv4_address'] ?></code>
|
|
|
|
<br>IPv6 : <code><?= CONF['ht']['ipv6_address'] ?></code>
|
2021-02-16 19:20:19 +01:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<form method="post">
|
2022-04-18 16:05:00 +02:00
|
|
|
<label for="domain">Domaine sur lequel répondre</label><br>
|
2022-05-20 00:15:13 +02:00
|
|
|
<input required="" placeholder="site.<?= CONF['common']['domain_example'] ?>" id="domain" name="domain" type="text"><br>
|
2022-04-18 16:05:00 +02:00
|
|
|
<label for="dir">Dossier ciblé</label><br>
|
|
|
|
<select required="" name="dir" id="dir">
|
|
|
|
<option value="" disabled="" selected="">---</option>
|
|
|
|
|
2022-05-21 02:15:36 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (isset($_SESSION['username'])) {
|
|
|
|
$dirsStatuses = dirsStatuses($_SESSION['username'], "dns", "http");
|
|
|
|
|
|
|
|
foreach ($dirsStatuses as $dir => $alreadyEnabled) {
|
|
|
|
$disabled = $alreadyEnabled ? " disabled=''" : "";
|
|
|
|
echo " <option" . $disabled . " value='" . $dir . "'>" . $dir . "</option>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
</select>
|
|
|
|
<br>
|
|
|
|
<input value="Valider" type="submit">
|
2021-02-16 19:20:19 +01:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['username'])) {
|
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
checkDomainFormat($_POST['domain']);
|
2021-02-16 19:20:19 +01:00
|
|
|
|
2022-05-21 02:15:36 +02:00
|
|
|
if ($dirsStatuses[$_POST['dir']] !== false)
|
2022-05-20 02:19:45 +02:00
|
|
|
userError("Wrong value for <code>dir</code>.");
|
2021-02-16 19:20:19 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
|
2021-02-16 19:20:19 +01:00
|
|
|
|
2022-05-03 15:27:46 +02:00
|
|
|
$nginxConf = 'server {
|
2022-05-20 00:15:13 +02:00
|
|
|
listen [::1]:' . CONF['ht']['https_port'] . ' ssl http2;
|
|
|
|
listen 127.0.0.1:' . CONF['ht']['https_port'] . ' ssl http2;
|
2022-05-03 15:27:46 +02:00
|
|
|
server_name ' . $_POST['domain'] . ';
|
2022-05-20 00:15:13 +02:00
|
|
|
root ' . CONF['ht']['ht_path'] . '/' . $_SESSION['username'] . '/' . $_POST['dir'] . ';
|
2022-05-03 15:27:46 +02:00
|
|
|
|
|
|
|
ssl_certificate /etc/ssl/certs/niver.crt;
|
|
|
|
ssl_certificate_key /etc/ssl/private/niver.key;
|
|
|
|
|
2022-05-21 02:15:36 +02:00
|
|
|
include inc/ht-tls.conf;
|
2022-05-03 15:27:46 +02:00
|
|
|
}
|
|
|
|
';
|
2022-05-20 00:15:13 +02:00
|
|
|
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $nginxConf);
|
2021-03-04 01:02:38 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
// Reload Nginx
|
2022-05-20 00:15:13 +02:00
|
|
|
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx");
|
2021-03-04 01:02:38 +01:00
|
|
|
|
2022-04-18 16:05:00 +02:00
|
|
|
echo "Accès HTTP par domaine ajouté sur ce dossier !";
|
2021-02-16 19:20:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2022-05-22 14:59:45 +02:00
|
|
|
<?php closeHTML(); ?>
|