35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
if (preg_match('/' . SUBDOMAIN_REGEX . '/D', $_POST['subdomain']) !== 1)
|
|
output(403, _('This format of subdomain is not allowed.'));
|
|
|
|
if (array_key_exists($_POST['suffix'], CONF['reg']['suffixes']) !== true)
|
|
output(403, 'This suffix doesn\'t exist.');
|
|
|
|
match (CONF['reg']['suffixes'][$_POST['suffix']]) {
|
|
'all' => NULL,
|
|
'approved' => match ($_SESSION['type']) {
|
|
'approved' => NULL,
|
|
default => output(403, 'The current account type is not allowed to register in this suffix.'),
|
|
},
|
|
default => output(403, 'This suffix is not open to registration.'),
|
|
};
|
|
|
|
$domain = formatAbsoluteDomain($_POST['subdomain'] . '.' . $_POST['suffix']);
|
|
|
|
if (query('select', 'registry', ['domain' => $domain], 'domain') !== [])
|
|
output(403, _('This domain is already registered.'));
|
|
|
|
if (in_array($_POST['subdomain'], explode(LF, file_get_contents(ROOT_PATH . '/pg-act/reg/reserved.txt'))))
|
|
output(403, _('This domain is reserved.'));
|
|
|
|
rateLimit();
|
|
|
|
insert('registry', [
|
|
'domain' => $domain,
|
|
'username' => $_SESSION['id'],
|
|
'last_renewal' => date('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
output(200, _('Domain registered.'));
|