Switch PHP views to Twig and add 2FA/UI enhancements

Migrate many view templates from raw PHP to Twig and modernize UI/UX for 2FA and settings. Controllers updated to provide avatar data and two-factor info (ProfileController, UserController) and SettingsController now includes timezone lists, notification preset selection, cron path, cached update state and rollback availability. ErrorHandler now attempts to render error pages via a new Core\TwigService with a safe fallback to raw PHP views. TwoFactorService generation silences deprecated warnings during QR code creation. Numerous .php view files were removed and replaced with .twig equivalents (2fa setup/verify/backup-codes and many auth, dashboard, domains, errors, layout, users, tags, tld-registry, etc.), and core/TwigService was added. These changes move the app toward a Twig-based templating system, improve 2FA flows, surface avatar images in lists/profiles, and make error rendering more robust.
This commit is contained in:
Hosteroid
2026-03-03 18:21:32 +02:00
parent cd4e3e6bcc
commit 4818172bc6
73 changed files with 9948 additions and 10686 deletions

307
app/Views/debug/whois.twig Normal file
View File

@@ -0,0 +1,307 @@
{% extends "layout/base.twig" %}
{% set title = 'WHOIS Debug Tool' %}
{% set pageTitle = 'WHOIS Debug Tool' %}
{% set pageDescription = 'Test and debug WHOIS data extraction' %}
{% set pageIcon = 'fas fa-search' %}
{% block content %}
{% if domain is empty %}
<!-- Search Form -->
<div class="max-w-2xl mx-auto">
<div class="bg-white dark:bg-slate-800 rounded-lg border border-gray-200 dark:border-slate-700 p-6">
<form method="GET" action="/debug/whois" class="space-y-4">
<div>
<label for="domain" class="block text-sm font-medium text-gray-700 dark:text-slate-300 mb-1.5">
Domain Name
</label>
<input type="text"
id="domain"
name="domain"
class="w-full px-3 py-2.5 border border-gray-300 dark:border-slate-600 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm bg-white dark:bg-slate-700 text-gray-900 dark:text-white"
placeholder="Enter domain (e.g., google.com)"
required
autofocus>
<p class="mt-1.5 text-xs text-gray-500 dark:text-slate-400">
Enter a domain name without http:// or www.
</p>
</div>
<button type="submit"
class="w-full inline-flex items-center justify-center px-5 py-2.5 bg-primary hover:bg-primary-dark text-white rounded-lg font-medium transition-colors text-sm">
<i class="fas fa-search mr-2"></i>
Check WHOIS
</button>
</form>
</div>
<!-- Info Card -->
<div class="mt-4 bg-blue-50 dark:bg-blue-500/10 border border-blue-200 dark:border-blue-500/30 rounded-lg p-4">
<div class="flex items-start">
<div class="flex-shrink-0">
<i class="fas fa-info-circle text-blue-500 text-lg"></i>
</div>
<div class="ml-3">
<h3 class="text-sm font-semibold text-gray-900 dark:text-white mb-1">What is this tool?</h3>
<p class="text-xs text-gray-600 dark:text-slate-400 leading-relaxed">
This debug tool shows you the raw WHOIS data for any domain and how our system parses it.
Use it to troubleshoot issues with domain information extraction.
</p>
</div>
</div>
</div>
</div>
{% else %}
<!-- Back Button & Copy Report -->
<div class="mb-4 flex justify-between items-center">
<a href="/debug/whois" class="inline-flex items-center px-4 py-2 border border-gray-300 dark:border-slate-600 text-gray-700 dark:text-slate-300 text-sm rounded-lg hover:bg-gray-50 dark:hover:bg-slate-700 transition-colors font-medium">
<i class="fas fa-arrow-left mr-2"></i>
Check Another Domain
</a>
<button onclick="copyDebugReport(this)" class="inline-flex items-center px-4 py-2 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 transition-colors font-medium">
<i class="fas fa-copy mr-2"></i>
Copy Debug Report
</button>
</div>
<!-- Domain Info Card -->
<div class="bg-white dark:bg-slate-800 rounded-lg border border-gray-200 dark:border-slate-700 p-5 mb-4">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<p class="text-xs font-medium text-gray-500 dark:text-slate-400 uppercase tracking-wide">Domain</p>
<p class="text-sm font-semibold text-gray-900 dark:text-white mt-1">{{ domain }}</p>
</div>
<div>
<p class="text-xs font-medium text-gray-500 dark:text-slate-400 uppercase tracking-wide">WHOIS Server</p>
<p class="text-sm font-semibold text-gray-900 dark:text-white mt-1">{{ server }}</p>
</div>
<div>
<p class="text-xs font-medium text-gray-500 dark:text-slate-400 uppercase tracking-wide">TLD</p>
<p class="text-sm font-semibold text-gray-900 dark:text-white mt-1">{{ tld }}</p>
</div>
</div>
</div>
<!-- Main Content Grid -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
<!-- Parsed Data -->
<div class="bg-white dark:bg-slate-800 rounded-lg border border-gray-200 dark:border-slate-700 overflow-hidden">
<div class="px-5 py-3 border-b border-gray-200 dark:border-slate-700 bg-green-50 dark:bg-green-500/10">
<h2 class="text-sm font-semibold text-gray-900 dark:text-white flex items-center">
<i class="fas fa-check-circle text-green-600 dark:text-green-400 mr-2 text-sm"></i>
Extracted Data (What We Save)
</h2>
</div>
<div class="p-5">
<div class="space-y-3">
<div class="flex justify-between py-2 border-b border-gray-100 dark:border-slate-700">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400">Domain</span>
<span class="text-xs text-gray-900 dark:text-white font-mono">{{ info.domain ?? 'N/A' }}</span>
</div>
<div class="flex justify-between py-2 border-b border-gray-100 dark:border-slate-700">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400">Registrar</span>
<span class="text-xs text-gray-900 dark:text-white font-mono">{{ info.registrar ?? 'N/A' }}</span>
</div>
<div class="flex justify-between py-2 border-b border-gray-100 dark:border-slate-700">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400">Expiration Date</span>
<span class="text-xs text-gray-900 dark:text-white font-mono">{{ info.expiration_date ?? 'N/A' }}</span>
</div>
<div class="flex justify-between py-2 border-b border-gray-100 dark:border-slate-700">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400">Creation Date</span>
<span class="text-xs text-gray-900 dark:text-white font-mono">{{ info.creation_date ?? 'N/A' }}</span>
</div>
<div class="flex justify-between py-2 border-b border-gray-100 dark:border-slate-700">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400">Updated Date</span>
<span class="text-xs text-gray-900 dark:text-white font-mono">{{ info.updated_date ?? 'N/A' }}</span>
</div>
<div class="flex justify-between py-2 border-b border-gray-100 dark:border-slate-700">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400">Registrar URL</span>
<span class="text-xs text-gray-900 dark:text-white font-mono">{{ info.registrar_url ?? 'N/A' }}</span>
</div>
<div class="flex justify-between py-2 border-b border-gray-100 dark:border-slate-700">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400">Abuse Email</span>
<span class="text-xs text-gray-900 dark:text-white font-mono">{{ info.abuse_email ?? 'N/A' }}</span>
</div>
<div class="py-2">
<span class="text-xs font-medium text-gray-600 dark:text-slate-400 block mb-2">Nameservers</span>
<div class="space-y-1">
{% if info.nameservers is not empty %}
{% for ns in info.nameservers %}
<div class="text-xs text-gray-900 dark:text-white font-mono bg-gray-50 dark:bg-slate-700 px-2 py-1 rounded">{{ ns }}</div>
{% endfor %}
{% else %}
<span class="text-xs text-gray-400 dark:text-slate-500">N/A</span>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<!-- Key-Value Pairs -->
<div class="bg-white dark:bg-slate-800 rounded-lg border border-gray-200 dark:border-slate-700 overflow-hidden">
<div class="px-5 py-3 border-b border-gray-200 dark:border-slate-700 bg-blue-50 dark:bg-blue-500/10">
<h2 class="text-sm font-semibold text-gray-900 dark:text-white flex items-center">
<i class="fas fa-table text-blue-600 dark:text-blue-400 mr-2 text-sm"></i>
All Key-Value Pairs
</h2>
</div>
<div class="overflow-y-auto" style="max-height: 500px;">
<table class="min-w-full divide-y divide-gray-200 dark:divide-slate-700">
<thead class="bg-gray-50 dark:bg-slate-700 sticky top-0">
<tr>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-600 dark:text-slate-400 uppercase">Key</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-600 dark:text-slate-400 uppercase">Value</th>
</tr>
</thead>
<tbody class="bg-white dark:bg-slate-800 divide-y divide-gray-100 dark:divide-slate-700">
{% for item in parsedData %}
{% if item.value is not empty %}
<tr class="hover:bg-gray-50 dark:hover:bg-slate-700">
<td class="px-4 py-2 text-xs font-medium text-gray-700 dark:text-slate-300">{{ item.key }}</td>
<td class="px-4 py-2 text-xs text-gray-900 dark:text-white font-mono">{{ item.value }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<!-- Raw Response -->
<div class="mt-4 bg-white dark:bg-slate-800 rounded-lg border border-gray-200 dark:border-slate-700 overflow-hidden">
<div class="px-5 py-3 border-b border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-700">
<h2 class="text-sm font-semibold text-gray-900 dark:text-white flex items-center">
<i class="fas fa-file-code text-gray-600 dark:text-slate-400 mr-2 text-sm"></i>
Raw WHOIS Response
</h2>
</div>
<div class="p-5">
<pre class="text-xs font-mono bg-gray-50 dark:bg-slate-900 p-4 rounded border border-gray-200 dark:border-slate-700 overflow-x-auto text-gray-900 dark:text-slate-300">{{ response }}</pre>
</div>
</div>
<!-- Hidden data for JS -->
<script id="debug-data" type="application/json">
{
"domain": {{ domain|json_encode|raw }},
"tld": {{ tld|json_encode|raw }},
"server": {{ server|json_encode|raw }},
"extractedData": {{ info|json_encode|raw }},
"rawResponse": {{ response|json_encode|raw }},
"parsedKeyValuePairs": {{ parsedData|json_encode|raw }}
}
</script>
<script>
function copyDebugReport(button) {
const data = JSON.parse(document.getElementById('debug-data').textContent);
let report = `=== WHOIS DEBUG REPORT ===\n\n`;
report += `Domain: ${data.domain}\n`;
report += `TLD: ${data.tld}\n`;
report += `WHOIS Server: ${data.server}\n`;
report += `Date: ${new Date().toISOString()}\n\n`;
report += `--- EXTRACTED DATA (What We Save) ---\n`;
report += `Domain: ${data.extractedData.domain || 'N/A'}\n`;
report += `Registrar: ${data.extractedData.registrar || 'N/A'}\n`;
report += `Registrar URL: ${data.extractedData.registrar_url || 'N/A'}\n`;
report += `Expiration Date: ${data.extractedData.expiration_date || 'N/A'}\n`;
report += `Creation Date: ${data.extractedData.creation_date || 'N/A'}\n`;
report += `Updated Date: ${data.extractedData.updated_date || 'N/A'}\n`;
report += `Abuse Email: ${data.extractedData.abuse_email || 'N/A'}\n`;
report += `Nameservers: ${data.extractedData.nameservers && data.extractedData.nameservers.length > 0 ? data.extractedData.nameservers.join(', ') : 'N/A'}\n`;
report += `Status: ${data.extractedData.status && data.extractedData.status.length > 0 ? data.extractedData.status.join(', ') : 'N/A'}\n\n`;
report += `--- ALL KEY-VALUE PAIRS ---\n`;
if (data.parsedKeyValuePairs && data.parsedKeyValuePairs.length > 0) {
data.parsedKeyValuePairs.forEach(item => {
if (item.value) {
report += `${item.key}: ${item.value}\n`;
}
});
} else {
report += 'No key-value pairs found\n';
}
report += `\n--- RAW WHOIS RESPONSE ---\n`;
report += data.rawResponse;
report += `\n\n=== END OF REPORT ===`;
copyToClipboard(report, button);
}
function copyToClipboard(text, button) {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(text).then(() => {
showCopySuccess(button);
}).catch(err => {
console.error('Modern clipboard API failed:', err);
fallbackCopyTextToClipboard(text, button);
});
} else {
fallbackCopyTextToClipboard(text, button);
}
}
function fallbackCopyTextToClipboard(text, button) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.top = '0';
textArea.style.left = '0';
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = '0';
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
const successful = document.execCommand('copy');
if (successful) {
showCopySuccess(button);
} else {
showCopyError(button);
}
} catch (err) {
console.error('Fallback copy failed:', err);
showCopyError(button);
}
document.body.removeChild(textArea);
}
function showCopySuccess(button) {
if (!button) return;
const originalHTML = button.innerHTML;
button.innerHTML = '<i class="fas fa-check mr-2"></i>Copied!';
button.classList.remove('bg-blue-600', 'hover:bg-blue-700');
button.classList.add('bg-green-600', 'hover:bg-green-700');
setTimeout(() => {
button.innerHTML = originalHTML;
button.classList.remove('bg-green-600', 'hover:bg-green-700');
button.classList.add('bg-blue-600', 'hover:bg-blue-700');
}, 2000);
}
function showCopyError(button) {
alert('Failed to copy to clipboard.\n\nYour browser may not support this feature, or the site needs HTTPS.\n\nPlease manually select and copy the text from the Raw WHOIS Response section below.');
}
</script>
{% endif %}
{% endblock %}