Fixed #58; also other minor bugs removed

This commit is contained in:
Pinga 2023-12-31 14:46:18 +02:00
parent 0a4afa6c98
commit dd17c0b873
8 changed files with 61 additions and 14 deletions

View file

@ -57,8 +57,20 @@ class DomainsController extends Controller
$domain_already_reserved = $this->container->get('db')->selectRow('SELECT id,type FROM reserved_domain_names WHERE name = ? LIMIT 1',[$parts['domain']]); $domain_already_reserved = $this->container->get('db')->selectRow('SELECT id,type FROM reserved_domain_names WHERE name = ? LIMIT 1',[$parts['domain']]);
if ($domain_already_reserved) { if ($domain_already_reserved) {
$this->container->get('flash')->addMessage('info', 'Domain ' . $domainName . ' is not available, as it is ' . $domain_already_reserved['type'] . '!'); if ($token !== null && $token !== '') {
return $response->withHeader('Location', '/domain/check')->withStatus(302); $allocation_token = $this->container->get('db')->selectValue('SELECT token FROM allocation_tokens WHERE domain_name = ? AND token = ?',[$domainName,$token]);
if ($allocation_token) {
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' is available!<br />Allocation token valid');
return $response->withHeader('Location', '/domain/check')->withStatus(302);
} else {
$this->container->get('flash')->addMessage('error', 'Domain ' . $domainName . ' is not available: Allocation Token mismatch');
return $response->withHeader('Location', '/domain/check')->withStatus(302);
}
} else {
$this->container->get('flash')->addMessage('info', 'Domain ' . $domainName . ' is not available, as it is ' . $domain_already_reserved['type'] . '!');
return $response->withHeader('Location', '/domain/check')->withStatus(302);
}
} else { } else {
if ($claim == 1) { if ($claim == 1) {
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' is available!<br />Claim exists.<br />Claim key is: ' . $claim_key); $this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' is available!<br />Claim exists.<br />Claim key is: ' . $claim_key);
@ -109,6 +121,8 @@ class DomainsController extends Controller
$phaseType = $data['phaseType'] ?? 'none'; $phaseType = $data['phaseType'] ?? 'none';
$smd = $data['smd'] ?? null; $smd = $data['smd'] ?? null;
$token = $data['token'] ?? null;
$nameservers = !empty($data['nameserver']) ? $data['nameserver'] : null; $nameservers = !empty($data['nameserver']) ? $data['nameserver'] : null;
$nameserver_ipv4 = !empty($data['nameserver_ipv4']) ? $data['nameserver_ipv4'] : null; $nameserver_ipv4 = !empty($data['nameserver_ipv4']) ? $data['nameserver_ipv4'] : null;
$nameserver_ipv6 = !empty($data['nameserver_ipv6']) ? $data['nameserver_ipv6'] : null; $nameserver_ipv6 = !empty($data['nameserver_ipv6']) ? $data['nameserver_ipv6'] : null;
@ -259,13 +273,22 @@ class DomainsController extends Controller
); );
if ($domain_already_reserved) { if ($domain_already_reserved) {
return view($response, 'admin/domains/createDomain.twig', [ if ($token !== null && $token !== '') {
'domainName' => $domainName, $allocation_token = $db->selectValue('SELECT token FROM allocation_tokens WHERE domain_name = ? AND token = ?',[$domainName,$token]);
'error' => 'Domain name is reserved or restricted',
'registrars' => $registrars, if (!$allocation_token) {
'registrar' => $registrar, $this->container->get('flash')->addMessage('error', 'Domain ' . $domainName . ' is not available: Allocation Token mismatch');
'launch_phases' => $launch_phases return $response->withHeader('Location', '/domain/create')->withStatus(302);
]); }
} else {
return view($response, 'admin/domains/createDomain.twig', [
'domainName' => $domainName,
'error' => 'Domain name is reserved or restricted',
'registrars' => $registrars,
'registrar' => $registrar,
'launch_phases' => $launch_phases
]);
}
} }
if ($registrationYears && (($registrationYears < 1) || ($registrationYears > 10))) { if ($registrationYears && (($registrationYears < 1) || ($registrationYears > 10))) {
@ -2347,6 +2370,7 @@ class DomainsController extends Controller
$domain_id = $domain['id']; $domain_id = $domain['id'];
$tldid = $domain['tldid']; $tldid = $domain['tldid'];
$registrar_id_domain = $domain['clid']; $registrar_id_domain = $domain['clid'];
$token = $data['token'] ?? null;
if (!$domain_id) { if (!$domain_id) {
$this->container->get('flash')->addMessage('error', 'Domain does not exist in registry'); $this->container->get('flash')->addMessage('error', 'Domain does not exist in registry');
@ -2428,6 +2452,15 @@ class DomainsController extends Controller
return $response->withHeader('Location', '/transfer/request')->withStatus(302); return $response->withHeader('Location', '/transfer/request')->withStatus(302);
} }
if ($token !== null && $token !== '') {
$allocation_token = $db->selectValue('SELECT token FROM allocation_tokens WHERE domain_name = ? AND token = ?',[$domainName,$token]);
if (!$allocation_token) {
$this->container->get('flash')->addMessage('error', 'Domain ' . $domainName . ' can not be transferred: Allocation Token mismatch');
return $response->withHeader('Location', '/transfer/request')->withStatus(302);
}
}
$domain = $db->selectRow('SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate FROM domain WHERE name = ? LIMIT 1', $domain = $db->selectRow('SELECT id, registrant, crdate, exdate, lastupdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate FROM domain WHERE name = ? LIMIT 1',
[ $domainName ]); [ $domainName ]);

View file

@ -300,7 +300,7 @@ function extractDomainAndTLD($urlString) {
foreach ($testTlds as $testTld) { foreach ($testTlds as $testTld) {
if (str_ends_with($host, "$testTld")) { if (str_ends_with($host, "$testTld")) {
// Handle the test TLD case // Handle the test TLD case
$tldLength = strlen($testTld) + 1; // +1 for the dot $tldLength = strlen($testTld); // No +1 for the dot
$hostWithoutTld = substr($host, 0, -$tldLength); $hostWithoutTld = substr($host, 0, -$tldLength);
$hostParts = explode('.', $hostWithoutTld); $hostParts = explode('.', $hostWithoutTld);
$sld = array_pop($hostParts); $sld = array_pop($hostParts);

View file

@ -24,6 +24,7 @@
<div class="page-body"> <div class="page-body">
<div class="container-xl"> <div class="container-xl">
<div class="col-12"> <div class="col-12">
{% include 'partials/flash.twig' %}
{% if domainName is defined and crdate is defined %} {% if domainName is defined and crdate is defined %}
<div class="alert alert-important alert-success alert-dismissible" role="alert"> <div class="alert alert-important alert-success alert-dismissible" role="alert">
<div class="d-flex"> <div class="d-flex">
@ -253,6 +254,11 @@
</div> </div>
{% endif %} {% endif %}
<div class="mb-3">
<label for="token" class="form-label">{{ __('Allocation Token') }}</label>
<input type="text" class="form-control" placeholder="Allocation token" name="token" autocapitalize="none">
</div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<div class="row align-items-center"> <div class="row align-items-center">

View file

@ -63,6 +63,11 @@
<strong>{{ __('Estimated Price') }}: </strong><span id="domainPrice">$0.00</span> <strong>{{ __('Estimated Price') }}: </strong><span id="domainPrice">$0.00</span>
</div> </div>
<div class="mb-3">
<label for="token" class="form-label">{{ __('Allocation Token') }}</label>
<input type="text" class="form-control" placeholder="Allocation token" name="token" autocapitalize="none">
</div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<div class="row align-items-center"> <div class="row align-items-center">

View file

@ -266,8 +266,9 @@ function processDomainCheck($conn, $db, $xml, $trans) {
if ($allocation_token !== null) { if ($allocation_token !== null) {
$allocationTokenValue = (string)$allocation_token; $allocationTokenValue = (string)$allocation_token;
$stmt = $db->prepare("SELECT token FROM allocation_tokens WHERE domain_name = :domainName LIMIT 1"); $stmt = $db->prepare("SELECT token FROM allocation_tokens WHERE domain_name = :domainName AND token = :token LIMIT 1");
$stmt->bindParam(':domainName', $label, PDO::PARAM_STR); $stmt->bindParam(':domainName', $label, PDO::PARAM_STR);
$stmt->bindParam(':token', $allocationTokenValue, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$token = $stmt->fetchColumn(); $token = $stmt->fetchColumn();

View file

@ -625,8 +625,9 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans) {
if ($allocation_token !== null) { if ($allocation_token !== null) {
$allocationTokenValue = (string)$allocation_token; $allocationTokenValue = (string)$allocation_token;
$stmt = $db->prepare("SELECT token FROM allocation_tokens WHERE domain_name = :domainName LIMIT 1"); $stmt = $db->prepare("SELECT token FROM allocation_tokens WHERE domain_name = :domainName AND token = :token LIMIT 1");
$stmt->bindParam(':domainName', $label, PDO::PARAM_STR); $stmt->bindParam(':domainName', $label, PDO::PARAM_STR);
$stmt->bindParam(':token', $allocationTokenValue, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$token = $stmt->fetchColumn(); $token = $stmt->fetchColumn();

View file

@ -756,8 +756,9 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
if ($allocation_token !== null) { if ($allocation_token !== null) {
$allocationTokenValue = (string)$allocation_token; $allocationTokenValue = (string)$allocation_token;
$stmt = $db->prepare("SELECT token FROM allocation_tokens WHERE domain_name = :domainName LIMIT 1"); $stmt = $db->prepare("SELECT token FROM allocation_tokens WHERE domain_name = :domainName AND token = :token LIMIT 1");
$stmt->bindParam(':domainName', $domainName, PDO::PARAM_STR); $stmt->bindParam(':domainName', $domainName, PDO::PARAM_STR);
$stmt->bindParam(':token', $allocationTokenValue, PDO::PARAM_STR);
$stmt->execute(); $stmt->execute();
$token = $stmt->fetchColumn(); $token = $stmt->fetchColumn();

View file

@ -257,7 +257,7 @@ function extractDomainAndTLD($urlString) {
foreach ($testTlds as $testTld) { foreach ($testTlds as $testTld) {
if (str_ends_with($host, "$testTld")) { if (str_ends_with($host, "$testTld")) {
// Handle the test TLD case // Handle the test TLD case
$tldLength = strlen($testTld) + 1; // +1 for the dot $tldLength = strlen($testTld); // No +1 for the dot
$hostWithoutTld = substr($host, 0, -$tldLength); $hostWithoutTld = substr($host, 0, -$tldLength);
$hostParts = explode('.', $hostWithoutTld); $hostParts = explode('.', $hostWithoutTld);
$sld = array_pop($hostParts); $sld = array_pop($hostParts);