Fix in CP domain:check

This commit is contained in:
Pinga 2024-11-28 19:12:19 +02:00
parent 23d7886a85
commit 9a86d52c7c

View file

@ -38,7 +38,12 @@ class DomainsController extends Controller
}
}
$domainName = preg_replace('/[^\p{L}0-9-.]/u', '', $domainName);
$invalid_domain = validate_label($domainName, $this->container->get('db'));
if ($invalid_domain) {
$this->container->get('flash')->addMessage('error', 'Domain ' . $domainName . ' is not available: ' . $invalid_domain);
return $response->withHeader('Location', '/domain/check')->withStatus(302);
}
try {
$parts = extractDomainAndTLD($domainName);
} catch (\Exception $e) {
@ -53,8 +58,6 @@ class DomainsController extends Controller
// Convert the DB result into a boolean '0' or '1'
$availability = $availability ? '0' : '1';
$invalid_label = validate_label($domainName, $this->container->get('db'));
if (isset($claims)) {
$claim_key = $this->container->get('db')->selectValue('SELECT claim_key FROM tmch_claims WHERE domain_label = ? LIMIT 1',[$parts['domain']]);
@ -67,11 +70,6 @@ class DomainsController extends Controller
$claim = 2;
}
// Check if the domain is Invalid
if ($invalid_label) {
$this->container->get('flash')->addMessage('error', 'Domain ' . $domainName . ' is not available: ' . $invalid_label);
return $response->withHeader('Location', '/domain/check')->withStatus(302);
} else {
// If the domain is not taken, check if it's reserved
if ($availability === '1') {
$domain_already_reserved = $this->container->get('db')->selectRow('SELECT id,type FROM reserved_domain_names WHERE name = ? LIMIT 1',[$parts['domain']]);
@ -109,7 +107,6 @@ class DomainsController extends Controller
}
}
}
}
// Default view for GET requests or if POST data is not set
return view($response,'admin/domains/checkDomain.twig');