mirror of
https://github.com/getnamingo/registry.git
synced 2025-06-29 15:43:23 +02:00
Added TMCH claims check in panel
This commit is contained in:
parent
783c3b4e2b
commit
2b6164a0f1
2 changed files with 39 additions and 41 deletions
|
@ -20,8 +20,11 @@ class DomainsController extends Controller
|
||||||
// Retrieve POST data
|
// Retrieve POST data
|
||||||
$data = $request->getParsedBody();
|
$data = $request->getParsedBody();
|
||||||
$domainName = $data['domain_name'] ?? null;
|
$domainName = $data['domain_name'] ?? null;
|
||||||
|
$token = $data['token'] ?? null;
|
||||||
|
$claims = $data['claims'] ?? null;
|
||||||
|
|
||||||
if ($domainName) {
|
if ($domainName) {
|
||||||
|
$domainName = preg_replace('/[^\p{L}0-9-.]/u', '', $domainName);
|
||||||
$parts = extractDomainAndTLD($domainName);
|
$parts = extractDomainAndTLD($domainName);
|
||||||
|
|
||||||
$domainModel = new Domain($this->container->get('db'));
|
$domainModel = new Domain($this->container->get('db'));
|
||||||
|
@ -32,33 +35,47 @@ class DomainsController extends Controller
|
||||||
|
|
||||||
$invalid_label = validate_label($domainName, $this->container->get('db'));
|
$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']]);
|
||||||
|
|
||||||
|
if ($claim_key) {
|
||||||
|
$claim = 1;
|
||||||
|
} else {
|
||||||
|
$claim = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$claim = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the domain is Invalid
|
// Check if the domain is Invalid
|
||||||
if ($invalid_label) {
|
if ($invalid_label) {
|
||||||
$status = $invalid_label;
|
$this->container->get('flash')->addMessage('error', 'Domain ' . $domainName . ' is not available: ' . $invalid_label);
|
||||||
$isAvailable = 0;
|
return $response->withHeader('Location', '/domain/check')->withStatus(302);
|
||||||
} else {
|
} else {
|
||||||
// If the domain is not taken, check if it's reserved
|
// If the domain is not taken, check if it's reserved
|
||||||
if ($availability === '1') {
|
if ($availability === '1') {
|
||||||
$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) {
|
||||||
$isAvailable = 0;
|
$this->container->get('flash')->addMessage('info', 'Domain ' . $domainName . ' is not available, as it is ' . $domain_already_reserved['type'] . '!');
|
||||||
$status = ucfirst($domain_already_reserved['type']);
|
return $response->withHeader('Location', '/domain/check')->withStatus(302);
|
||||||
} else {
|
} else {
|
||||||
$isAvailable = $availability;
|
if ($claim == 1) {
|
||||||
$status = $availability === '0' ? 'In use' : null;
|
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' is available!<br />Claim exists.<br />Claim key is: ' . $claim_key);
|
||||||
|
return $response->withHeader('Location', '/domain/check')->withStatus(302);
|
||||||
|
} elseif ($claim == 2) {
|
||||||
|
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' is available!');
|
||||||
|
return $response->withHeader('Location', '/domain/check')->withStatus(302);
|
||||||
|
} elseif ($claim == 0) {
|
||||||
|
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' is available!<br />Claim does not exist');
|
||||||
|
return $response->withHeader('Location', '/domain/check')->withStatus(302);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$isAvailable = $availability;
|
$this->container->get('flash')->addMessage('error', 'Domain ' . $domainName . ' is not available: In use');
|
||||||
$status = 'In use';
|
return $response->withHeader('Location', '/domain/check')->withStatus(302);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view($response, 'admin/domains/checkDomain.twig', [
|
|
||||||
'isAvailable' => $isAvailable,
|
|
||||||
'domainName' => $domainName,
|
|
||||||
'status' => $status,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,33 +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">
|
||||||
{% if isAvailable is defined and domainName is defined %}
|
{% include 'partials/flash.twig' %}
|
||||||
{% if isAvailable %}
|
|
||||||
<div class="alert alert-important alert-success alert-dismissible" role="alert">
|
|
||||||
<div class="d-flex">
|
|
||||||
<div>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" /></svg>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<strong>{{ domainName }}</strong> {{ __('is available') }}!
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="alert alert-important alert-danger alert-dismissible" role="alert">
|
|
||||||
<div class="d-flex">
|
|
||||||
<div>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" /><path d="M12 8v4" /><path d="M12 16h.01" /></svg>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<strong>{{ domainName }}</strong> {{ __('is not available') }}: <strong>{{ status }}</strong>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body border-bottom py-3">
|
<div class="card-body border-bottom py-3">
|
||||||
<p class="mb-4">{{ __('Enter the domain name you want to check:') }}</p>
|
<p class="mb-4">{{ __('Enter the domain name you want to check:') }}</p>
|
||||||
|
@ -58,8 +32,15 @@
|
||||||
{{ csrf.field | raw }}
|
{{ csrf.field | raw }}
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
<input type="text" class="form-control" placeholder="yourdomain.com" name="domain_name" required="required" autocapitalize="none">
|
<input type="text" class="form-control" placeholder="yourdomain.com" name="domain_name" required="required" autocapitalize="none">
|
||||||
|
<input type="text" class="form-control" placeholder="Allocation token" name="token" autocapitalize="none">
|
||||||
<button type="submit" class="btn btn-primary">{{ __('Check Availability') }}</button>
|
<button type="submit" class="btn btn-primary">{{ __('Check Availability') }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="claims">
|
||||||
|
<span class="form-check-label">Check claims</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue