reg/register: add "Check availability" feature
This commit is contained in:
parent
15ddd77bc4
commit
ed05d4aab9
6 changed files with 86 additions and 52 deletions
|
@ -4,7 +4,7 @@ form {
|
|||
margin-bottom: 0.6rem;
|
||||
}
|
||||
|
||||
input, select, textarea {
|
||||
input, button, select, textarea {
|
||||
border-radius: 0.5rem;
|
||||
font-size: 1rem;
|
||||
margin: 0.3rem;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
function output($code, $msg = '', $logs = ['']) {
|
||||
function output($code, $msg = '', $logs = [''], $data = []) {
|
||||
http_response_code($code);
|
||||
$shortCode = intval($code / 100);
|
||||
if ($shortCode === 5)
|
||||
|
@ -10,7 +10,7 @@ function output($code, $msg = '', $logs = ['']) {
|
|||
4 => '<p><output>' . _('<strong>User error</strong>: ') . '<em>' . $msg . '</em></output></p>' . LF,
|
||||
5 => '<p><output>' . _('<strong>Server error</strong>: ') . '<em>' . $msg . '</em></output></p>' . LF,
|
||||
};
|
||||
displayPage(['final_message' => $final_message]);
|
||||
displayPage(array_merge(['final_message' => $final_message], $data));
|
||||
}
|
||||
|
||||
function insert($table, $values) {
|
||||
|
|
|
@ -218,7 +218,7 @@ msgstr "Définir un domaine comme étant l'alias d'un autre"
|
|||
|
||||
#: pages.php:140
|
||||
msgid "Define all subdomains of a domain as aliases of subdomains of another domain"
|
||||
msgstr "Définir la descendance d'un domain comme alias de la descendance d'un autre domaine"
|
||||
msgstr "Définir la descendance d'un domaine comme alias de la descendance d'un autre domaine"
|
||||
|
||||
#: pages.php:144
|
||||
msgid "Store geographic coordinates"
|
||||
|
@ -272,15 +272,15 @@ msgstr "Supprimer un accès"
|
|||
msgid "Delete an existing HTTP access from a subdirectory of the SFTP space"
|
||||
msgstr "Retirer un accès HTTP existant d'un sous-dossier de l'espace SFTP"
|
||||
|
||||
#: router.php:137 view.php:39
|
||||
#: router.php:133 view.php:39
|
||||
msgid "This service is currently under maintenance. No action can be taken on it until an administrator finishes repairing it."
|
||||
msgstr "Ce service est en cours de maintenance. Aucune action ne peut être effectuée avant qu'ane administrataire termine de le réparer."
|
||||
|
||||
#: router.php:147
|
||||
#: router.php:144
|
||||
msgid "You need to be logged in to do this."
|
||||
msgstr "Vous devez être connecté·e à un compte pour faire cela."
|
||||
|
||||
#: router.php:149
|
||||
#: router.php:146
|
||||
msgid "This account doesn't exist anymore. Log out to end this ghost session."
|
||||
msgstr "Ce compte n'existe plus. Déconnectez-vous pour terminer cette session fantôme."
|
||||
|
||||
|
@ -360,7 +360,8 @@ msgstr "Ce compte n'existe pas."
|
|||
msgid "Wrong password."
|
||||
msgstr "Clé de passe incorrecte."
|
||||
|
||||
#: pg-act/auth/password.php:6
|
||||
#: pg-act/auth/password.php:6 pg-act/auth/unregister.php:4
|
||||
#: pg-act/auth/username.php:6
|
||||
msgid "Wrong current password."
|
||||
msgstr "Clé de passe actuelle incorrecte."
|
||||
|
||||
|
@ -368,24 +369,24 @@ msgstr "Clé de passe actuelle incorrecte."
|
|||
msgid "Password updated."
|
||||
msgstr "Clé de passe mise à jour."
|
||||
|
||||
#: pg-act/auth/register.php:10 pg-act/auth/username.php:8
|
||||
#: pg-act/auth/register.php:10 pg-act/auth/username.php:11
|
||||
msgid "This username is already taken."
|
||||
msgstr "Cet identifiant est déjà pris."
|
||||
|
||||
#: pg-act/auth/unregister.php:4
|
||||
#: pg-act/auth/unregister.php:7
|
||||
msgid "Account deletion must be confirmed."
|
||||
msgstr "La suppression du compte doit être confirmée."
|
||||
|
||||
#: pg-act/auth/unregister.php:10
|
||||
#: pg-act/auth/unregister.php:13
|
||||
#, php-format
|
||||
msgid "Your account can't be deleted because the %s service is currently unavailable."
|
||||
msgstr "Votre compte ne peut pas être supprimé car le service %s est actuellement indisponible."
|
||||
|
||||
#: pg-act/auth/unregister.php:39
|
||||
#: pg-act/auth/unregister.php:42
|
||||
msgid "Account deleted."
|
||||
msgstr "Compte supprimé."
|
||||
|
||||
#: pg-act/auth/username.php:17
|
||||
#: pg-act/auth/username.php:20
|
||||
msgid "Username updated."
|
||||
msgstr "Identifiant mis à jour."
|
||||
|
||||
|
@ -401,7 +402,7 @@ msgstr "Impossible de récupérer l'enregistrement %s."
|
|||
#: pg-act/ht/add-dns.php:15 pg-act/ht/add-dns.php:21
|
||||
#, php-format
|
||||
msgid "This domain must have %2$s as its only %1$s record."
|
||||
msgstr "Ce domain doit avoir %2$s pour unique enregistrement %1$s."
|
||||
msgstr "Ce domaine doit avoir %2$s pour unique enregistrement %1$s."
|
||||
|
||||
#: pg-act/ht/add-dns.php:27
|
||||
msgid "No TXT record with the expected format has been found."
|
||||
|
@ -484,15 +485,19 @@ msgstr "Zone supprimée."
|
|||
msgid "This format of subdomain is not allowed."
|
||||
msgstr "Ce format de sous-domaine n'est pas autorisé."
|
||||
|
||||
#: pg-act/reg/register.php:21
|
||||
msgid "This domain is already registered."
|
||||
msgstr "Ce domain est déjà enregistré."
|
||||
#: pg-act/reg/register.php:27
|
||||
msgid "This domain is open to registration!"
|
||||
msgstr "Ce domaine est disponible à l'enregistrement."
|
||||
|
||||
#: pg-act/reg/register.php:24
|
||||
#: pg-act/reg/register.php:29
|
||||
msgid "This domain is reserved."
|
||||
msgstr "Ce domain est réservé."
|
||||
msgstr "Ce domaine est réservé."
|
||||
|
||||
#: pg-act/reg/register.php:34
|
||||
#: pg-act/reg/register.php:31
|
||||
msgid "This domain is already registered."
|
||||
msgstr "Ce domaine est déjà enregistré."
|
||||
|
||||
#: pg-act/reg/register.php:47
|
||||
msgid "Domain registered."
|
||||
msgstr "Domaine enregistré."
|
||||
|
||||
|
@ -598,7 +603,8 @@ msgstr "Identifiant"
|
|||
msgid "Password"
|
||||
msgstr "Clé de passe"
|
||||
|
||||
#: pg-view/auth/password.php:2
|
||||
#: pg-view/auth/password.php:2 pg-view/auth/unregister.php:6
|
||||
#: pg-view/auth/username.php:2
|
||||
msgid "Current password"
|
||||
msgstr "Clé de passe actuelle"
|
||||
|
||||
|
@ -623,20 +629,20 @@ msgstr "Minimum %1$s caractères, ou %2$s caractères si elle contient minuscule
|
|||
msgid "This will delete every resource managed by the current account, including registered domains, hosted DNS records, websites files and cryptographic keys for Onion services and DNSSEC."
|
||||
msgstr "Ceci supprimera toutes les ressources gérées par le compte actuel, y compris les domaines enregistrés, les enregistrements DNS hébergés, les fichiers des sites et les clés cryptographiques des services Onion et de DNSSEC."
|
||||
|
||||
#: pg-view/auth/unregister.php:7
|
||||
#: pg-view/auth/unregister.php:10
|
||||
msgid "Delete the current account and everything related (required)"
|
||||
msgstr "Supprimer le compte actuel et tout ce qui y est lié (requis)"
|
||||
|
||||
#: pg-view/auth/unregister.php:9 pg-view/ns/form.ns.php:4 pg-view/reg/ds.php:5
|
||||
#: pg-view/auth/unregister.php:12 pg-view/ns/form.ns.php:4 pg-view/reg/ds.php:5
|
||||
#: pg-view/reg/glue.php:5 pg-view/reg/ns.php:5
|
||||
msgid "Delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
#: pg-view/auth/username.php:2
|
||||
#: pg-view/auth/username.php:5
|
||||
msgid "New username"
|
||||
msgstr "Nouvel identifiant"
|
||||
|
||||
#: pg-view/auth/username.php:5
|
||||
#: pg-view/auth/username.php:8
|
||||
msgid "Update username"
|
||||
msgstr "Mettre à jour l'identifiant"
|
||||
|
||||
|
@ -1088,7 +1094,11 @@ msgstr "Enregistrer un nouveau domaine sur son compte. Il doit être composé d'
|
|||
msgid "Suffix"
|
||||
msgstr "Suffixe"
|
||||
|
||||
#: pg-view/reg/register.php:28
|
||||
#: pg-view/reg/register.php:27
|
||||
msgid "Check availability"
|
||||
msgstr "Vérifier sa disponibilité"
|
||||
|
||||
#: pg-view/reg/register.php:29
|
||||
msgid "Register"
|
||||
msgstr "Enregistrer"
|
||||
|
||||
|
|
|
@ -271,15 +271,15 @@ msgstr ""
|
|||
msgid "Delete an existing HTTP access from a subdirectory of the SFTP space"
|
||||
msgstr ""
|
||||
|
||||
#: router.php:137 view.php:39
|
||||
#: router.php:133 view.php:39
|
||||
msgid "This service is currently under maintenance. No action can be taken on it until an administrator finishes repairing it."
|
||||
msgstr ""
|
||||
|
||||
#: router.php:147
|
||||
#: router.php:144
|
||||
msgid "You need to be logged in to do this."
|
||||
msgstr ""
|
||||
|
||||
#: router.php:149
|
||||
#: router.php:146
|
||||
msgid "This account doesn't exist anymore. Log out to end this ghost session."
|
||||
msgstr ""
|
||||
|
||||
|
@ -359,7 +359,8 @@ msgstr ""
|
|||
msgid "Wrong password."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/auth/password.php:6
|
||||
#: pg-act/auth/password.php:6 pg-act/auth/unregister.php:4
|
||||
#: pg-act/auth/username.php:6
|
||||
msgid "Wrong current password."
|
||||
msgstr ""
|
||||
|
||||
|
@ -367,24 +368,24 @@ msgstr ""
|
|||
msgid "Password updated."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/auth/register.php:10 pg-act/auth/username.php:8
|
||||
#: pg-act/auth/register.php:10 pg-act/auth/username.php:11
|
||||
msgid "This username is already taken."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/auth/unregister.php:4
|
||||
#: pg-act/auth/unregister.php:7
|
||||
msgid "Account deletion must be confirmed."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/auth/unregister.php:10
|
||||
#: pg-act/auth/unregister.php:13
|
||||
#, php-format
|
||||
msgid "Your account can't be deleted because the %s service is currently unavailable."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/auth/unregister.php:39
|
||||
#: pg-act/auth/unregister.php:42
|
||||
msgid "Account deleted."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/auth/username.php:17
|
||||
#: pg-act/auth/username.php:20
|
||||
msgid "Username updated."
|
||||
msgstr ""
|
||||
|
||||
|
@ -483,15 +484,19 @@ msgstr ""
|
|||
msgid "This format of subdomain is not allowed."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/reg/register.php:21
|
||||
msgid "This domain is already registered."
|
||||
#: pg-act/reg/register.php:27
|
||||
msgid "This domain is open to registration!"
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/reg/register.php:24
|
||||
#: pg-act/reg/register.php:29
|
||||
msgid "This domain is reserved."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/reg/register.php:34
|
||||
#: pg-act/reg/register.php:31
|
||||
msgid "This domain is already registered."
|
||||
msgstr ""
|
||||
|
||||
#: pg-act/reg/register.php:47
|
||||
msgid "Domain registered."
|
||||
msgstr ""
|
||||
|
||||
|
@ -597,7 +602,8 @@ msgstr ""
|
|||
msgid "Password"
|
||||
msgstr ""
|
||||
|
||||
#: pg-view/auth/password.php:2
|
||||
#: pg-view/auth/password.php:2 pg-view/auth/unregister.php:6
|
||||
#: pg-view/auth/username.php:2
|
||||
msgid "Current password"
|
||||
msgstr ""
|
||||
|
||||
|
@ -622,20 +628,20 @@ msgstr ""
|
|||
msgid "This will delete every resource managed by the current account, including registered domains, hosted DNS records, websites files and cryptographic keys for Onion services and DNSSEC."
|
||||
msgstr ""
|
||||
|
||||
#: pg-view/auth/unregister.php:7
|
||||
#: pg-view/auth/unregister.php:10
|
||||
msgid "Delete the current account and everything related (required)"
|
||||
msgstr ""
|
||||
|
||||
#: pg-view/auth/unregister.php:9 pg-view/ns/form.ns.php:4 pg-view/reg/ds.php:5
|
||||
#: pg-view/auth/unregister.php:12 pg-view/ns/form.ns.php:4 pg-view/reg/ds.php:5
|
||||
#: pg-view/reg/glue.php:5 pg-view/reg/ns.php:5
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: pg-view/auth/username.php:2
|
||||
#: pg-view/auth/username.php:5
|
||||
msgid "New username"
|
||||
msgstr ""
|
||||
|
||||
#: pg-view/auth/username.php:5
|
||||
#: pg-view/auth/username.php:8
|
||||
msgid "Update username"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1087,7 +1093,11 @@ msgstr ""
|
|||
msgid "Suffix"
|
||||
msgstr ""
|
||||
|
||||
#: pg-view/reg/register.php:28
|
||||
#: pg-view/reg/register.php:27
|
||||
msgid "Check availability"
|
||||
msgstr ""
|
||||
|
||||
#: pg-view/reg/register.php:29
|
||||
msgid "Register"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -17,11 +17,24 @@ match (CONF['reg']['suffixes'][$_POST['suffix']]) {
|
|||
|
||||
$domain = formatAbsoluteDomain($_POST['subdomain'] . '.' . $_POST['suffix']);
|
||||
|
||||
if (query('select', 'registry', ['domain' => $domain], 'domain') !== [])
|
||||
output(403, _('This domain is already registered.'));
|
||||
$registered = query('select', 'registry', ['domain' => $domain], 'domain') !== [];
|
||||
$reserved = in_array($_POST['subdomain'], explode(LF, file_get_contents(ROOT_PATH . '/pg-act/reg/reserved.txt')));
|
||||
|
||||
if (in_array($_POST['subdomain'], explode(LF, file_get_contents(ROOT_PATH . '/pg-act/reg/reserved.txt'))))
|
||||
output(403, _('This domain is reserved.'));
|
||||
$message = match ($registered) {
|
||||
false => match ($reserved) {
|
||||
false => match ($_POST['action']) {
|
||||
'register' => NULL,
|
||||
default => '✔️ ' . _('This domain is open to registration!'),
|
||||
},
|
||||
default => '❌ ' . _('This domain is reserved.'),
|
||||
},
|
||||
default => '❌ ' . _('This domain is already registered.'),
|
||||
};
|
||||
if ($message !== NULL)
|
||||
output(200, data: [
|
||||
'message' => '<p>' . $message . '</p>',
|
||||
'domain' => htmlspecialchars($_POST['subdomain']),
|
||||
]);
|
||||
|
||||
rateLimit();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div>
|
||||
<label for="subdomain"><?= _('Subdomain') ?></label>
|
||||
<br>
|
||||
<input id="subdomain" pattern="<?= SUBDOMAIN_REGEX ?>" required="" placeholder="servnest" name="subdomain" type="text">
|
||||
<input id="subdomain" pattern="<?= SUBDOMAIN_REGEX ?>" required="" placeholder="servnest" name="subdomain" type="text" value="<?= $data['domain'] ?? '' ?>">
|
||||
</div>
|
||||
<div>
|
||||
<label for="suffix"><?= _('Suffix') ?></label>
|
||||
|
@ -24,6 +24,7 @@ foreach (CONF['reg']['suffixes'] as $suffix => $availability) {
|
|||
</select>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<input type="submit" value="<?= _('Register') ?>">
|
||||
<button type="submit" name="action" value="check">👁️ <?= _('Check availability') ?></button>
|
||||
<?= $data['message'] ?? '<br>' ?>
|
||||
<button type="submit" name="action" value="register">🔗 <?= _('Register') ?></button>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue