check.php: use null coalescing operator ("??") more

This commit is contained in:
Miraty 2023-08-14 18:20:47 +02:00
parent c40f52a21e
commit bb937526a7
3 changed files with 7 additions and 7 deletions

View file

@ -141,10 +141,10 @@ function authDeleteUser(string $user_id): void {
} }
function rateLimit(): void { function rateLimit(): void {
if (PAGE_METADATA['tokens_account_cost'] ?? 0 > 0) if ((PAGE_METADATA['tokens_account_cost'] ?? 0) > 0)
rateLimitAccount(PAGE_METADATA['tokens_account_cost']); rateLimitAccount(PAGE_METADATA['tokens_account_cost']);
if (PAGE_METADATA['tokens_instance_cost'] ?? 0 > 0) if ((PAGE_METADATA['tokens_instance_cost'] ?? 0) > 0)
rateLimitInstance(PAGE_METADATA['tokens_instance_cost']); rateLimitInstance(PAGE_METADATA['tokens_instance_cost']);
} }

View file

@ -108,7 +108,7 @@ function testReg(): string {
'ns' => 'ns1.servnest.invalid.', 'ns' => 'ns1.servnest.invalid.',
]); ]);
$results = kdig(name: $domain, type: 'NS', server: CONF['reg']['address']); $results = kdig(name: $domain, type: 'NS', server: CONF['reg']['address']);
if ($results['authorityRRs'][0]['rdataNS'] !== 'ns1.servnest.invalid.') if (($results['authorityRRs'][0]['rdataNS'] ?? NULL) !== 'ns1.servnest.invalid.')
exit('Error: /reg/ns: NS record not set' . LF); exit('Error: /reg/ns: NS record not set' . LF);
curlTest('/reg/ns', [ curlTest('/reg/ns', [
@ -189,9 +189,9 @@ function testNs(string $domain): void {
'value' => 'letsencrypt.org', 'value' => 'letsencrypt.org',
]); ]);
$results = kdig(name: $domain, type: 'CAA', server: CONF['reg']['address']); $results = kdig(name: $domain, type: 'CAA', server: CONF['reg']['address']);
if ($results['answerRRs'][0]['TTL'] !== 7200) if (($results['answerRRs'][0]['TTL'] ?? NULL) !== 7200)
exit('Error: /ns/caa: wrong TTL' . LF); exit('Error: /ns/caa: wrong TTL' . LF);
if ($results['answerRRs'][0]['rdataCAA'] !== '0 issue "letsencrypt.org" ') if (($results['answerRRs'][0]['rdataCAA'] ?? NULL) !== '0 issue "letsencrypt.org" ')
exit('Error: /ns/caa: CAA record not set' . LF); exit('Error: /ns/caa: CAA record not set' . LF);
curlTest('/ns/edit', [ curlTest('/ns/edit', [
@ -200,7 +200,7 @@ function testNs(string $domain): void {
. '@ 86400 NS ' . CONF['ns']['servers'][0] . "\r\n", . '@ 86400 NS ' . CONF['ns']['servers'][0] . "\r\n",
]); ]);
$results = kdig(name: 'aaaa.' . $domain, type: 'AAAA', server: CONF['reg']['address']); $results = kdig(name: 'aaaa.' . $domain, type: 'AAAA', server: CONF['reg']['address']);
if ($results['answerRRs'][0]['rdataAAAA'] !== CONF['ht']['ipv6_address']) if (($results['answerRRs'][0]['rdataAAAA'] ?? NULL) !== CONF['ht']['ipv6_address'])
exit('Error: /ns/edit: AAAA record not set' . LF); exit('Error: /ns/edit: AAAA record not set' . LF);
} }

View file

@ -41,7 +41,7 @@ if (CONF['common']['services']['auth'] === 'error' OR (in_array(SERVICE, SERVICE
require ROOT_PATH . '/pg-view/' . PAGE_ADDRESS . '.php'; require ROOT_PATH . '/pg-view/' . PAGE_ADDRESS . '.php';
if ($_POST === [] AND PAGE_METADATA['require-login'] ?? true !== false AND !isset($_SESSION['id']) AND PAGE_TERMINAL) if ($_POST === [] AND (PAGE_METADATA['require-login'] ?? true) !== false AND !isset($_SESSION['id']) AND PAGE_TERMINAL)
echo '<p>' . sprintf(_('This form won\'t be accepted because you need to %slog in%s first.'), '<a class="auth" href="' . redirUrl('auth/login') . '">', '</a>') . '</p>'; echo '<p>' . sprintf(_('This form won\'t be accepted because you need to %slog in%s first.'), '<a class="auth" href="' . redirUrl('auth/login') . '">', '</a>') . '</p>';
displayFinalMessage($data); displayFinalMessage($data);