Added Domain Status update/add

This commit is contained in:
Pinga 2023-12-19 12:18:43 +02:00
parent 34257ba7eb
commit 72e5607264
3 changed files with 227 additions and 17 deletions

View file

@ -436,6 +436,53 @@ class DomainsController extends Controller
] ]
); );
if ($_SESSION["auth_roles"] != 0) {
$clientStatuses = $data['clientStatuses'] ?? [];
foreach ($clientStatuses as $status => $value) {
if ($value === 'on') {
// Insert or update the status in the database
$db->exec(
'INSERT INTO domain_status (domain_id, status) VALUES (?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)',
[
$domain_id,
$status
]
);
}
}
} else {
$clientStatuses = $data['clientStatuses'] ?? [];
$serverStatuses = $data['serverStatuses'] ?? [];
foreach ($clientStatuses as $status => $value) {
if ($value === 'on') {
// Insert or update the status in the database
$db->exec(
'INSERT INTO domain_status (domain_id, status) VALUES (?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)',
[
$domain_id,
$status
]
);
}
}
foreach ($serverStatuses as $status => $value) {
if ($value === 'on') {
// Insert or update the status in the database
$db->exec(
'INSERT INTO domain_status (domain_id, status) VALUES (?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)',
[
$domain_id,
$status
]
);
}
}
}
// Data sanity checks // Data sanity checks
// Validate keyTag // Validate keyTag
if (!empty($dsKeyTag)) { if (!empty($dsKeyTag)) {
@ -483,14 +530,6 @@ class DomainsController extends Controller
2 => 64, // SHA-256 2 => 64, // SHA-256
4 => 96 // SHA-384 4 => 96 // SHA-384
]; ];
if (empty($validDigests[$dsDigestType])) {
return view($response, 'admin/domains/createDomain.twig', [
'domainName' => $domainName,
'error' => 'Unsupported digest type',
'registrars' => $registrars,
'registrar' => $registrar,
]);
}
if (!empty($dsDigest)) { if (!empty($dsDigest)) {
if (strlen($dsDigest) != $validDigests[$dsDigestType] || !ctype_xdigit($dsDigest)) { if (strlen($dsDigest) != $validDigests[$dsDigestType] || !ctype_xdigit($dsDigest)) {
return view($response, 'admin/domains/createDomain.twig', [ return view($response, 'admin/domains/createDomain.twig', [
@ -985,7 +1024,6 @@ class DomainsController extends Controller
$csrfTokenName = $this->container->get('csrf')->getTokenName(); $csrfTokenName = $this->container->get('csrf')->getTokenName();
$csrfTokenValue = $this->container->get('csrf')->getTokenValue(); $csrfTokenValue = $this->container->get('csrf')->getTokenValue();
return view($response,'admin/domains/updateDomain.twig', [ return view($response,'admin/domains/updateDomain.twig', [
'domain' => $domain, 'domain' => $domain,
'domainStatus' => $domainStatus, 'domainStatus' => $domainStatus,
@ -1185,6 +1223,67 @@ class DomainsController extends Controller
] ]
); );
if ($_SESSION["auth_roles"] != 0) {
$clientStatuses = $data['clientStatuses'] ?? [];
$db->delete(
'domain_status',
[
'domain_id' => $domain_id
]
);
foreach ($clientStatuses as $status => $value) {
if ($value === 'on') {
// Insert or update the status in the database
$db->exec(
'INSERT INTO domain_status (domain_id, status) VALUES (?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)',
[
$domain_id,
$status
]
);
}
}
} else {
$clientStatuses = $data['clientStatuses'] ?? [];
$serverStatuses = $data['serverStatuses'] ?? [];
$db->delete(
'domain_status',
[
'domain_id' => $domain_id
]
);
foreach ($clientStatuses as $status => $value) {
if ($value === 'on') {
// Insert or update the status in the database
$db->exec(
'INSERT INTO domain_status (domain_id, status) VALUES (?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)',
[
$domain_id,
$status
]
);
}
}
foreach ($serverStatuses as $status => $value) {
if ($value === 'on') {
// Insert or update the status in the database
$db->exec(
'INSERT INTO domain_status (domain_id, status) VALUES (?, ?) ON DUPLICATE KEY UPDATE status = VALUES(status)',
[
$domain_id,
$status
]
);
}
}
}
// Data sanity checks // Data sanity checks
// Validate keyTag // Validate keyTag
if (!empty($dsKeyTag)) { if (!empty($dsKeyTag)) {
@ -1216,10 +1315,6 @@ class DomainsController extends Controller
2 => 64, // SHA-256 2 => 64, // SHA-256
4 => 96 // SHA-384 4 => 96 // SHA-384
]; ];
if (empty($validDigests[$dsDigestType])) {
$this->container->get('flash')->addMessage('error', 'Unsupported digest type');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
if (!empty($dsDigest)) { if (!empty($dsDigest)) {
if (strlen($dsDigest) != $validDigests[$dsDigestType] || !ctype_xdigit($dsDigest)) { if (strlen($dsDigest) != $validDigests[$dsDigestType] || !ctype_xdigit($dsDigest)) {
$this->container->get('flash')->addMessage('error', 'Invalid digest length or format'); $this->container->get('flash')->addMessage('error', 'Invalid digest length or format');

View file

@ -177,6 +177,61 @@
<label for="authInfo" class="form-label required">{{ __('Auth Info') }}</label> <label for="authInfo" class="form-label required">{{ __('Auth Info') }}</label>
<input type="text" class="form-control" id="authInfo" name="authInfo" required> <input type="text" class="form-control" id="authInfo" name="authInfo" required>
</div> </div>
<div class="mb-3 mt-3">
<div class="form-label">{{ __('Statuses') }}</div>
<div>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientHold]">
<span class="form-check-label">clientHold</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientRenewProhibited]">
<span class="form-check-label">clientRenewProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientTransferProhibited]">
<span class="form-check-label">clientTransferProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientDeleteProhibited]">
<span class="form-check-label">clientDeleteProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientUpdateProhibited]">
<span class="form-check-label">clientUpdateProhibited</span>
</label>
</div>
</div>
{% if roles == 0 %}
<div class="mb-3 mt-3">
<div class="form-label">{{ __('Server Statuses') }}</div>
<div>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverHold]">
<span class="form-check-label">serverHold</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverRenewProhibited]">
<span class="form-check-label">serverRenewProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverTransferProhibited]">
<span class="form-check-label">serverTransferProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverDeleteProhibited]">
<span class="form-check-label">serverDeleteProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverUpdateProhibited]">
<span class="form-check-label">serverUpdateProhibited</span>
</label>
</div>
</div>
{% endif %}
</div> </div>
<div class="card-footer"> <div class="card-footer">
<div class="row align-items-center"> <div class="row align-items-center">

View file

@ -102,6 +102,17 @@
<label for="contactBilling" class="form-label required">{{ __('Billing Contact') }}</label> <label for="contactBilling" class="form-label required">{{ __('Billing Contact') }}</label>
<input type="text" class="form-control mb-2" placeholder="{{ __('Billing Contact') }}" name="contactBilling" id="contactBilling" value="{{ contactBilling }}" required> <input type="text" class="form-control mb-2" placeholder="{{ __('Billing Contact') }}" name="contactBilling" id="contactBilling" value="{{ contactBilling }}" required>
</div> </div>
<div class="hr-text">
<span>{{ __('Domain Security') }}</span>
</div>
<!-- AuthInfo -->
<div class="mb-3 mt-3">
<label for="authInfo" class="form-label required">{{ __('Auth Info') }}</label>
<input type="text" class="form-control" id="authInfo" name="authInfo" value="{{ domainAuth.authinfo }}" required>
</div>
</div> </div>
<!-- Fields for nameservers --> <!-- Fields for nameservers -->
@ -118,11 +129,60 @@
{% endfor %} {% endfor %}
</div> </div>
<!-- AuthInfo --> {% set statuses = domainStatus|map(status => status.status) %}
<div class="mb-3 mt-3"> <div class="mb-3 mt-3">
<label for="authInfo" class="form-label required">{{ __('Auth Info') }}</label> <div class="form-label">{{ __('Statuses') }}</div>
<input type="text" class="form-control" id="authInfo" name="authInfo" value="{{ domainAuth.authinfo }}" required> <div>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientHold]" {% if 'clientHold' in statuses %}checked{% endif %}>
<span class="form-check-label">clientHold</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientRenewProhibited]" {% if 'clientRenewProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">clientRenewProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientTransferProhibited]" {% if 'clientTransferProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">clientTransferProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientDeleteProhibited]" {% if 'clientDeleteProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">clientDeleteProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="clientStatuses[clientUpdateProhibited]" {% if 'clientUpdateProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">clientUpdateProhibited</span>
</label>
</div>
</div> </div>
<div class="mb-3 mt-3">
<div class="form-label">{{ __('Server Statuses') }}</div>
<div>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverHold]"{% if roles != 0 %}disabled{% endif %} {% if 'serverHold' in statuses %}checked{% endif %}>
<span class="form-check-label">serverHold</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverRenewProhibited]"{% if roles != 0 %}disabled{% endif %} {% if 'serverRenewProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">serverRenewProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverTransferProhibited]"{% if roles != 0 %}disabled{% endif %} {% if 'serverTransferProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">serverTransferProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverDeleteProhibited]"{% if roles != 0 %}disabled{% endif %} {% if 'serverDeleteProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">serverDeleteProhibited</span>
</label>
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="serverStatuses[serverUpdateProhibited]"{% if roles != 0 %}disabled{% endif %} {% if 'serverUpdateProhibited' in statuses %}checked{% endif %}>
<span class="form-check-label">serverUpdateProhibited</span>
</label>
</div>
</div>
</div> </div>
</div> </div>