Add pages to display domains contents
This commit is contained in:
parent
9bcf3a57a2
commit
aef17741e6
9 changed files with 204 additions and 102 deletions
|
@ -20,7 +20,8 @@ if (SERVICE === "reg" OR SERVICE === "ns")
|
|||
if (SERVICE !== "")
|
||||
require CONF['common']['root_path'] . "/fn/" . SERVICE . ".php";
|
||||
|
||||
function success($msg) {
|
||||
echo "<p><strong>Succès</strong> : <em>" . $msg . "</em></p>";
|
||||
function success($msg = '') {
|
||||
if ($msg !== '')
|
||||
echo "<p><strong>Succès</strong> : <em>" . $msg . "</em></p>";
|
||||
closeHTML();
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ define('TITLES', [
|
|||
'index' => '<span aria-hidden="true">🏷️ </span>Registre <code>' . CONF['reg']['registry'] . '</code>',
|
||||
'register' => 'Enregistrer un nouveau domaine',
|
||||
'unregister' => 'Effacer un domaine',
|
||||
'print' => 'Afficher les données',
|
||||
'ns' => 'Ajouter un enregistrement <abbr title="Name Server">NS</abbr>',
|
||||
'ds' => 'Ajouter un enregistrement <abbr title="Delegation Signer">DS</abbr>',
|
||||
'glue' => 'Créer un Glue Record',
|
||||
|
@ -21,7 +22,7 @@ define('TITLES', [
|
|||
'index' => '<span aria-hidden="true">📖 </span>Serveurs de noms',
|
||||
'zone-add' => 'Ajouter une zone',
|
||||
'zone-del' => 'Effacer une zone',
|
||||
'dnssec' => 'Afficher les enregistrements <abbr title="Delegation Signer">DS</abbr>',
|
||||
'print' => 'Afficher les données',
|
||||
'ip' => 'Enregistrements A et AAAA',
|
||||
'ns' => 'Enregistrement <abbr title="Name Server">NS</abbr>',
|
||||
'txt' => 'Enregistrement TXT',
|
||||
|
@ -54,6 +55,7 @@ define('DESCRIPTIONS', [
|
|||
'index' => 'Demander l\'attribution d\'un sous-domaine',
|
||||
'register' => 'Prendre possession d\'un sous-domaine de <code>' . CONF['reg']['registry'] . '</code>',
|
||||
'unregister' => 'Effacer toutes les données d\'un domaine',
|
||||
'print' => 'Afficher les enregistrements relatifs à un domaine',
|
||||
'ns' => 'Indiquer les serveurs de noms de son sous-domaine de <code>' . CONF['reg']['registry'] . '</code>',
|
||||
'ds' => 'Déléguer la confiance <abbr title="Domain Name System Security Extensions">DNSSEC</abbr>',
|
||||
'glue' => 'Indiquer les IP de ses serveurs de noms de son sous-domaine de <code>' . CONF['reg']['registry'] . '</code> dont les adresses se trouvent sur ce même sous-domaine',
|
||||
|
@ -62,7 +64,7 @@ define('DESCRIPTIONS', [
|
|||
'index' => 'Gérer les données enregistrées dans ses domaines',
|
||||
'zone-add' => 'Pour qu\'elle soit gérée par le serveur de noms de Niver',
|
||||
'zone-del' => 'Effacer toutes les données d\'une zone',
|
||||
'dnssec' => 'À indiquer à la zone parente pour activer <abbr title="Domain Name System Security Extensions">DNSSEC</abbr>',
|
||||
'print' => 'Afficher le contenu de la zone',
|
||||
'ip' => 'Indiquer l\'adresse IP d\'un domaine',
|
||||
'ns' => 'Indiquer le serveur de noms d\'une zone',
|
||||
'txt' => 'Associer du texte à un domaine',
|
||||
|
|
|
@ -33,8 +33,11 @@ h2 {
|
|||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
header, main, footer {
|
||||
header, main > *:not(table, pre), footer {
|
||||
max-width: 40rem;
|
||||
}
|
||||
|
||||
header, main > *, footer {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php require "../../common/html.php"; ?>
|
||||
|
||||
<?php displayIndex(); ?>
|
||||
|
||||
<p>
|
||||
Vous avez accès à un espace <abbr title="SSH File Transfert Protocol">SFTP</abbr>. Vous pouvez téléverser vos sites dans <code>/<nom du site>/*</code>. Indiquez les données ci-dessous à votre client <abbr title="SSH File Transfert Protocol">SFTP</abbr> pour y accéder.
|
||||
</p>
|
||||
|
||||
<section>
|
||||
<h2>Authentifier le serveur</h2>
|
||||
|
||||
<details>
|
||||
<summary>Clé publique</summary>
|
||||
|
@ -23,35 +26,33 @@
|
|||
|
||||
</section>
|
||||
|
||||
<a href="sftp://<?= isset($_SESSION['username']) ? $_SESSION['username'] : '<username>'; ?>@<?= CONF['ht']['sftp_domain'] ?>:<?= CONF['ht']['public_sftp_port'] ?>/">sftp://<?= isset($_SESSION['username']) ? $_SESSION['username'] : '<username>'; ?>@<?= CONF['ht']['sftp_domain'] ?>:<?= CONF['ht']['public_sftp_port'] ?>/</a>
|
||||
<section>
|
||||
<h2>Se connecter au serveur</h2>
|
||||
|
||||
<dl>
|
||||
<dt>Serveur</dt>
|
||||
<dd>
|
||||
<code><?= CONF['ht']['sftp_domain'] ?></code>
|
||||
</dd>
|
||||
<a href="sftp://<?= isset($_SESSION['username']) ? $_SESSION['username'] : '<username>'; ?>@<?= CONF['ht']['sftp_domain'] ?>:<?= CONF['ht']['public_sftp_port'] ?>/">sftp://<?= isset($_SESSION['username']) ? $_SESSION['username'] : '<username>'; ?>@<?= CONF['ht']['sftp_domain'] ?>:<?= CONF['ht']['public_sftp_port'] ?>/</a>
|
||||
|
||||
<dt>Port</dt>
|
||||
<dd>
|
||||
<code><?= CONF['ht']['public_sftp_port'] ?></code><?php if (CONF['ht']['public_sftp_port'] === 22) echo " (par défaut)"; ?>
|
||||
</dd>
|
||||
|
||||
<dt>Dossier</dt>
|
||||
<dd>
|
||||
<code>/</code>
|
||||
</dd>
|
||||
|
||||
<dt>Utilisataire</dt>
|
||||
<dd>
|
||||
<code><?= isset($_SESSION['username']) ? $_SESSION['username'] : '<username>'; ?></code>
|
||||
</dd>
|
||||
|
||||
<dt>Clé de passe</dt>
|
||||
<dd>
|
||||
celle que vous avez définit lors de l'activation de l'accès <abbr title="SSH File Transfert Protocol">SFTP</abbr>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<?php displayIndex(); ?>
|
||||
<dl>
|
||||
<dt>Serveur</dt>
|
||||
<dd>
|
||||
<code><?= CONF['ht']['sftp_domain'] ?></code>
|
||||
</dd>
|
||||
<dt>Port</dt>
|
||||
<dd>
|
||||
<code><?= CONF['ht']['public_sftp_port'] ?></code><?php if (CONF['ht']['public_sftp_port'] === 22) echo " (par défaut)"; ?>
|
||||
</dd>
|
||||
<dt>Dossier</dt>
|
||||
<dd>
|
||||
<code>/</code>
|
||||
</dd>
|
||||
<dt>Utilisataire</dt>
|
||||
<dd>
|
||||
<code><?= isset($_SESSION['username']) ? $_SESSION['username'] : '<username>'; ?></code>
|
||||
</dd>
|
||||
<dt>Clé de passe</dt>
|
||||
<dd>
|
||||
celle que vous avez définit lors de l'activation de l'accès <abbr title="SSH File Transfert Protocol">SFTP</abbr>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
<?php require "../../common/html.php"; ?>
|
||||
|
||||
Afin d'activer DNSSEC, vous devez indiquer un enregistrement DS à la zone parente.
|
||||
|
||||
<form method="post">
|
||||
<select required="" name="zone" id="zone">
|
||||
<option value="" disabled="" selected="">---</option>
|
||||
<?php
|
||||
if (isset($_SESSION['username']))
|
||||
foreach(nsListUserZones($_SESSION['username']) as $zone)
|
||||
echo " <option value='" . $zone . "'>" . $zone . "</option>\n";
|
||||
?>
|
||||
</select>
|
||||
<br>
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
switchToFormProcess();
|
||||
|
||||
nsCheckZonePossession($_POST['zone']);
|
||||
|
||||
$zoneContent = file_get_contents(CONF['ns']['knot_zones_path'] . "/" . $_POST['zone'] . "zone");
|
||||
|
||||
$found = preg_match("#\n" . preg_quote($_POST['zone']) . "\s+0\s+CDS\s+([0-9]{1,5})\s+([0-9]{1,2})\s+([0-9])\s+([0-9A-F]{64})\n#", $zoneContent, $matches);
|
||||
if ($found !== 1)
|
||||
serverError("Unable to get public key record from zone file.");
|
||||
|
||||
$tag = $matches[1];
|
||||
$algo = $matches[2];
|
||||
$digestType = $matches[3];
|
||||
$digest = $matches[4];
|
||||
|
||||
?>
|
||||
|
||||
<dl>
|
||||
<dt>Zone</dt>
|
||||
<dd>
|
||||
<code><?= $_POST['zone'] ?></code>
|
||||
</dd>
|
||||
<dt>Tag</dt>
|
||||
<dd>
|
||||
<code><?= $tag ?></code>
|
||||
</dd>
|
||||
<dt>Algorithme</dt>
|
||||
<dd>
|
||||
<code><?= $algo ?></code><?php if ($algo === "15") echo " (Ed25519)"; ?>
|
||||
</dd>
|
||||
<dt>Type de condensat</dt>
|
||||
<dd>
|
||||
<code><?= $digestType ?></code><?php if ($digestType === "2") echo " (SHA-256)"; ?>
|
||||
</dd>
|
||||
<dt>Condensat</dt>
|
||||
<dd>
|
||||
<code><?= $digest ?></code>
|
||||
</dd>
|
||||
</dl>
|
103
public/ns/print.php
Normal file
103
public/ns/print.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php require "../../common/html.php"; ?>
|
||||
|
||||
<form method="post">
|
||||
<input type="radio" name="print" id="table" value="table" checked="">
|
||||
<label for="table">Tableau de mes enregistrements</label>
|
||||
<br>
|
||||
<input type="radio" name="print" id="ds" value="ds">
|
||||
<label for="ds">Enregistrement DS</label>
|
||||
<br>
|
||||
<input type="radio" name="print" id="raw" value="raw">
|
||||
<label for="raw">Fichier de zone brut</label>
|
||||
<br>
|
||||
<label for="zone">Zone</label>
|
||||
<select required="" name="zone" id="zone">
|
||||
<option value="" disabled="" selected="">-</option>
|
||||
<?php
|
||||
if (isset($_SESSION['username']))
|
||||
foreach (nsListUserZones($_SESSION['username']) as $zone)
|
||||
echo " <option value='" . $zone . "'>" . $zone . "</option>\n";
|
||||
?>
|
||||
</select>
|
||||
<br>
|
||||
<input value="Afficher" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
switchToFormProcess();
|
||||
|
||||
nsCheckZonePossession($_POST['zone']);
|
||||
|
||||
$zoneContent = file_get_contents(CONF['ns']['knot_zones_path'] . '/' . $_POST['zone'] . 'zone');
|
||||
if ($zoneContent === false)
|
||||
serverError("Unable to read zone file.");
|
||||
|
||||
if ($_POST['print'] === 'raw') {
|
||||
echo '<pre>' . htmlspecialchars($zoneContent) . '</pre>';
|
||||
success();
|
||||
}
|
||||
|
||||
if ($_POST['print'] === 'table') { ?>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Domaine</th>
|
||||
<th>TTL</th>
|
||||
<th>Type</th>
|
||||
<th>Contenu</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach(explode("\n", $zoneContent) as $zoneLine) {
|
||||
if (str_starts_with($zoneLine, ';')) continue; // Ignore comments
|
||||
if (empty($zoneLine)) continue;
|
||||
$elements = preg_split("#[\t ]+#", $zoneLine, 4);
|
||||
if (!in_array($elements[2], ['CAA', 'A', 'AAAA', 'MX', 'NS', 'SRV', 'SSHFP', 'TLSA', 'TXT'], true)) continue; // Ignore records generated by Knot
|
||||
echo ' <tr>';
|
||||
foreach ($elements as $element)
|
||||
echo ' <td>' . htmlspecialchars($element) . '</td>';
|
||||
echo ' </tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
if ($_POST['print'] === 'ds') {
|
||||
|
||||
$found = preg_match("#\n" . preg_quote($_POST['zone']) . "\s+0\s+CDS\s+([0-9]{1,5})\s+([0-9]{1,2})\s+([0-9])\s+([0-9A-F]{64})\n#", $zoneContent, $matches);
|
||||
if ($found !== 1)
|
||||
serverError("Unable to get public key record from zone file.");
|
||||
|
||||
$tag = $matches[1];
|
||||
$algo = $matches[2];
|
||||
$digestType = $matches[3];
|
||||
$digest = $matches[4];
|
||||
|
||||
?>
|
||||
|
||||
<dl>
|
||||
<dt>Zone</dt>
|
||||
<dd>
|
||||
<code><?= $_POST['zone'] ?></code>
|
||||
</dd>
|
||||
<dt>Tag</dt>
|
||||
<dd>
|
||||
<code><?= $tag ?></code>
|
||||
</dd>
|
||||
<dt>Algorithme</dt>
|
||||
<dd>
|
||||
<code><?= $algo ?></code><?php if ($algo === "15") echo " (Ed25519)"; ?>
|
||||
</dd>
|
||||
<dt>Type de condensat</dt>
|
||||
<dd>
|
||||
<code><?= $digestType ?></code><?php if ($digestType === "2") echo " (SHA-256)"; ?>
|
||||
</dd>
|
||||
<dt>Condensat</dt>
|
||||
<dd>
|
||||
<code><?= $digest ?></code>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<?php
|
||||
success();
|
||||
}
|
||||
?>
|
|
@ -41,7 +41,7 @@ switchToFormProcess();
|
|||
|
||||
regCheckDomainPossession($_POST['suffix']);
|
||||
|
||||
$domain = formatAbsoluteDomain(formatEndWithDot($_POST['subdomain']) . CONF['reg']['registry']);
|
||||
$domain = formatAbsoluteDomain(formatEndWithDot($_POST['subdomain']) . $_POST['suffix']);
|
||||
|
||||
$record = checkIpFormat($_POST['ip']);
|
||||
|
||||
|
|
51
public/reg/print.php
Normal file
51
public/reg/print.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php require "../../common/html.php"; ?>
|
||||
|
||||
<form method="post">
|
||||
<label for="domain">Domaine</label>
|
||||
<select required="" name="domain" id="domain">
|
||||
<option value="" disabled="" selected="">-</option>
|
||||
<?php
|
||||
if (isset($_SESSION['username']))
|
||||
foreach (regListUserDomains($_SESSION['username']) as $domain)
|
||||
echo " <option value='" . $domain . "'>" . $domain . "</option>\n";
|
||||
?>
|
||||
</select>
|
||||
<br>
|
||||
<input value="Afficher" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
switchToFormProcess();
|
||||
|
||||
regCheckDomainPossession($_POST['domain']);
|
||||
|
||||
$zoneContent = file_get_contents(CONF['reg']['registry_file']);
|
||||
if ($zoneContent === false)
|
||||
serverError("Unable to read registry file.");
|
||||
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Domaine</th>
|
||||
<th>TTL</th>
|
||||
<th>Type</th>
|
||||
<th>Contenu</th>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach(explode("\n", $zoneContent) as $zoneLine) {
|
||||
if (str_starts_with($zoneLine, ';')) continue; // Ignore comments
|
||||
if (empty($zoneLine)) continue;
|
||||
$elements = preg_split("#[\t ]+#", $zoneLine, 4);
|
||||
if (!str_ends_with($elements[0], $_POST['domain'])) continue; // Ignore records for other domains
|
||||
if (!in_array($elements[2], ['A', 'AAAA', 'NS', 'DS'], true)) continue; // Ignore records generated by Knot
|
||||
echo " <tr>\n";
|
||||
foreach ($elements as $element)
|
||||
echo " <td>" . htmlspecialchars($element) . "</td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
|
||||
success();
|
|
@ -1,15 +1,14 @@
|
|||
<?php require "../../common/html.php"; ?>
|
||||
|
||||
Enregistrer la possession d'un domaine sur son compte.<br>
|
||||
Ce domaine doit être composé uniquement d'au moins 4 lettres latines non accentuées.
|
||||
<br>
|
||||
<br>
|
||||
<p>
|
||||
Enregistrer un nouveau domaine sur son compte. Ce domaine doit être composé uniquement d'au moins 4 lettres latines non accentuées (a-z).
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
<div>
|
||||
<label for="subdomain">Sous-domaine</label>
|
||||
<br>
|
||||
<input id="subdomain" pattern="<?= CONF['reg']['subdomain_regex'] ?>" required="" placeholder="niver" name="subdomain" type="text">.<?= CONF['reg']['registry'] ?>
|
||||
</div>
|
||||
<label for="subdomain">Sous-domaine</label>
|
||||
<br>
|
||||
<input id="subdomain" pattern="<?= CONF['reg']['subdomain_regex'] ?>" required="" placeholder="niver" name="subdomain" type="text">.<?= CONF['reg']['registry'] ?>
|
||||
<br>
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
|
@ -20,7 +19,7 @@ switchToFormProcess();
|
|||
if (preg_match("/" . CONF['reg']['subdomain_regex'] . "/", $_POST['subdomain']) !== 1)
|
||||
userError("Erreur : Le nom de domaine doit être composé uniquement d'entre 4 et 63 lettres minuscules (a-z)");
|
||||
|
||||
$domain = formatAbsoluteDomain(formatEndWithDot($_POST['subdomain']) . CONF['reg']['registry']);
|
||||
$domain = formatAbsoluteDomain($_POST['subdomain'] . '.' . CONF['reg']['registry']);
|
||||
|
||||
if (regIsFree($domain) !== true)
|
||||
userError("Ce domaine n'est pas disponible à l'enregistrement. Il est réservé ou déjà enregistré.");
|
||||
|
|
Loading…
Reference in a new issue