<?php

declare(strict_types=1);

$id = trim((string) ($_GET['ne_id'] ?? ''));
$token = trim((string) ($_GET['token'] ?? ''));
$verified = $id !== '' && $token !== '' && myronNotificationEmailsService()->verify($id, $token);

if ($verified) {
    myronRedirectWithFlash(myronBuildAdminUrl('administration.notificationEmails'), 'Notification email verified.', 'success');
}

http_response_code(400);
header('Content-Type: text/html; charset=UTF-8');
echo '<!DOCTYPE html><html lang="' . myronEscape(myronSiteLanguage()) . '"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>' . myronEscape(myronComposeDocumentTitle('Notification Email Verification')) . '</title><link rel="stylesheet" href="' . myronEscape(myronBuildAssetUrl('runtime/css/style-guide.css')) . '"></head><body><main class="mc-page-canvas mc-page-canvas--site"><section class="sg-section"><h1 class="sg-section__title">Verification link expired</h1><p class="sg-section__subtitle">Return to Notification Emails and resend verification.</p><a class="sg-button sg-button--primary" href="' . myronEscape(myronBuildAdminUrl('administration.notificationEmails')) . '">Open Notification Emails</a></section></main></body></html>';
