Add user avatar system and fix WHOIS parsing/cron synchronization
- Add avatar upload with Gravatar fallback and initials - Fix false "available" detection for registered domains - Clean up WHOIS status parsing and server display - Update cron job to sync all WHOIS fields - Fix TLD cache and .me domain parsing issues
This commit is contained in:
@@ -124,30 +124,59 @@
|
||||
<!-- User Dropdown -->
|
||||
<div class="relative">
|
||||
<button onclick="toggleDropdown()" class="flex items-center space-x-3 p-2 hover:bg-gray-100 rounded-lg transition-colors duration-150 focus:outline-none">
|
||||
<div class="w-9 h-9 rounded-full bg-primary flex items-center justify-center text-white font-semibold">
|
||||
<?= strtoupper(substr($_SESSION['username'] ?? 'A', 0, 1)) ?>
|
||||
</div>
|
||||
<?php
|
||||
// Get user data for avatar
|
||||
$userModel = new \App\Models\User();
|
||||
$user = $userModel->find($_SESSION['user_id'] ?? 0);
|
||||
$avatar = $user ? \App\Helpers\AvatarHelper::getAvatar($user, 36) : null;
|
||||
?>
|
||||
<?php if ($avatar && ($avatar['type'] === 'uploaded' || $avatar['type'] === 'gravatar')): ?>
|
||||
<img src="<?= htmlspecialchars($avatar['url']) ?>"
|
||||
alt="<?= htmlspecialchars($avatar['alt']) ?>"
|
||||
class="w-9 h-9 rounded-full object-cover"
|
||||
loading="lazy">
|
||||
<?php else: ?>
|
||||
<div class="w-9 h-9 rounded-full bg-primary flex items-center justify-center text-white font-semibold">
|
||||
<?= strtoupper(substr($_SESSION['username'] ?? 'A', 0, 1)) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="hidden lg:block text-left">
|
||||
<p class="text-sm font-medium text-gray-700"><?= htmlspecialchars($_SESSION['username'] ?? 'User') ?></p>
|
||||
<p class="text-sm font-medium text-gray-700"><?= htmlspecialchars($_SESSION['full_name'] ?? $_SESSION['username'] ?? 'User') ?></p>
|
||||
<p class="text-xs text-gray-500"><?= htmlspecialchars($_SESSION['email'] ?? '') ?></p>
|
||||
</div>
|
||||
<i class="fas fa-chevron-down text-gray-400 text-xs hidden md:block"></i>
|
||||
</button>
|
||||
|
||||
<!-- Dropdown Menu -->
|
||||
<div id="userDropdown" class="dropdown-menu absolute right-0 mt-2 w-56 bg-white rounded-lg shadow-lg py-2 border border-gray-200">
|
||||
<div class="px-4 py-3 border-b border-gray-200">
|
||||
<p class="text-sm font-medium text-gray-900"><?= htmlspecialchars($_SESSION['full_name'] ?? $_SESSION['username'] ?? 'User') ?></p>
|
||||
<p class="text-xs text-gray-500 mt-1"><?= htmlspecialchars($_SESSION['email'] ?? 'user@example.com') ?></p>
|
||||
<div class="flex items-center gap-2 mt-2">
|
||||
<span class="inline-flex items-center px-2.5 py-1 bg-<?= $_SESSION['role'] === 'admin' ? 'amber' : 'blue' ?>-100 text-<?= $_SESSION['role'] === 'admin' ? 'amber' : 'blue' ?>-800 text-xs font-semibold rounded border border-<?= $_SESSION['role'] === 'admin' ? 'amber' : 'blue' ?>-200">
|
||||
<i class="fas fa-<?= $_SESSION['role'] === 'admin' ? 'crown' : 'user' ?> mr-1.5"></i>
|
||||
<?= ucfirst($_SESSION['role'] ?? 'user') ?>
|
||||
</span>
|
||||
<span class="inline-flex items-center px-2.5 py-1 bg-green-100 text-green-800 text-xs font-semibold rounded border border-green-200">
|
||||
<i class="fas fa-circle text-xs mr-1"></i>
|
||||
Online
|
||||
</span>
|
||||
<div id="userDropdown" class="dropdown-menu absolute right-0 mt-2 w-56 bg-white rounded-lg shadow-lg border border-gray-200 overflow-hidden pb-2">
|
||||
<!-- Welcome Header -->
|
||||
<div class="px-4 py-4 border-b border-gray-200 bg-gradient-to-r from-gray-50 to-gray-100">
|
||||
<div class="text-center">
|
||||
<div class="relative w-12 h-12 mx-auto mb-2">
|
||||
<?php if ($avatar && ($avatar['type'] === 'uploaded' || $avatar['type'] === 'gravatar')): ?>
|
||||
<img src="<?= htmlspecialchars($avatar['url']) ?>"
|
||||
alt="<?= htmlspecialchars($avatar['alt']) ?>"
|
||||
class="w-12 h-12 rounded-full object-cover"
|
||||
loading="lazy">
|
||||
<?php else: ?>
|
||||
<div class="w-12 h-12 rounded-full bg-primary flex items-center justify-center text-white font-bold text-lg">
|
||||
<?= strtoupper(substr($_SESSION['username'] ?? 'A', 0, 1)) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<!-- Online status dot -->
|
||||
<div class="absolute -bottom-1 -right-1 w-4 h-4 bg-green-500 rounded-full border-2 border-white flex items-center justify-center">
|
||||
<div class="w-2 h-2 bg-white rounded-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm font-semibold text-gray-900">Welcome back!</p>
|
||||
<p class="text-xs text-gray-500 mt-1"><?= htmlspecialchars($_SESSION['full_name'] ?? $_SESSION['username'] ?? 'User') ?></p>
|
||||
<!-- Role indicator -->
|
||||
<div class="mt-2">
|
||||
<span class="inline-flex items-center px-2 py-1 bg-<?= $_SESSION['role'] === 'admin' ? 'amber' : 'blue' ?>-100 text-<?= $_SESSION['role'] === 'admin' ? 'amber' : 'blue' ?>-700 text-xs font-medium rounded-full">
|
||||
<i class="fas fa-<?= $_SESSION['role'] === 'admin' ? 'crown' : 'user' ?> mr-1"></i>
|
||||
<?= ucfirst($_SESSION['role'] ?? 'user') ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ ob_start();
|
||||
$twoFactorStatus = $userModel->getTwoFactorStatus($user['id']);
|
||||
$twoFactorService = new \App\Services\TwoFactorService();
|
||||
$twoFactorPolicy = $twoFactorService->getTwoFactorPolicy();
|
||||
|
||||
// Get avatar data
|
||||
$avatar = \App\Helpers\AvatarHelper::getAvatar($user, 80);
|
||||
?>
|
||||
|
||||
<!-- Main Profile Layout -->
|
||||
@@ -19,8 +22,28 @@ $twoFactorPolicy = $twoFactorService->getTwoFactorPolicy();
|
||||
<!-- User Info Section -->
|
||||
<div class="p-6 border-b border-gray-200 bg-gray-50">
|
||||
<div class="flex flex-col items-center text-center">
|
||||
<div class="w-20 h-20 rounded-full bg-primary flex items-center justify-center text-white text-2xl font-bold">
|
||||
<?= strtoupper(substr($user['username'] ?? 'U', 0, 1)) ?>
|
||||
<div class="relative">
|
||||
<?php if ($avatar['type'] === 'uploaded' || $avatar['type'] === 'gravatar'): ?>
|
||||
<img src="<?= htmlspecialchars($avatar['url']) ?>"
|
||||
alt="<?= htmlspecialchars($avatar['alt']) ?>"
|
||||
class="w-20 h-20 rounded-full object-cover border-2 border-white shadow-sm"
|
||||
loading="lazy">
|
||||
<?php else: ?>
|
||||
<div class="w-20 h-20 rounded-full bg-primary flex items-center justify-center text-white text-2xl font-bold border-2 border-white shadow-sm">
|
||||
<?= $avatar['initials'] ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Avatar type indicator -->
|
||||
<div class="absolute -bottom-1 -right-1 w-6 h-6 bg-white rounded-full border-2 border-gray-200 flex items-center justify-center">
|
||||
<?php if ($avatar['type'] === 'uploaded'): ?>
|
||||
<i class="fas fa-image text-xs text-blue-600" title="Uploaded avatar"></i>
|
||||
<?php elseif ($avatar['type'] === 'gravatar'): ?>
|
||||
<i class="fas fa-globe text-xs text-green-600" title="Gravatar"></i>
|
||||
<?php else: ?>
|
||||
<i class="fas fa-user text-xs text-gray-500" title="Initials"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="mt-4 text-base font-semibold text-gray-900"><?= htmlspecialchars($user['full_name'] ?? $user['username']) ?></h3>
|
||||
<p class="text-sm text-gray-500 mt-1">@<?= htmlspecialchars($user['username'] ?? '') ?></p>
|
||||
@@ -90,6 +113,93 @@ $twoFactorPolicy = $twoFactorService->getTwoFactorPolicy();
|
||||
<p class="text-sm text-gray-600 mt-1">Update your personal details and account information</p>
|
||||
</div>
|
||||
|
||||
<!-- Avatar Upload Section -->
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h4 class="text-base font-semibold text-gray-900 mb-3">Profile Picture</h4>
|
||||
<div class="flex items-center space-x-4">
|
||||
<!-- Current Avatar Display -->
|
||||
<div class="relative">
|
||||
<?php if ($avatar['type'] === 'uploaded' || $avatar['type'] === 'gravatar'): ?>
|
||||
<img src="<?= htmlspecialchars($avatar['url']) ?>"
|
||||
alt="<?= htmlspecialchars($avatar['alt']) ?>"
|
||||
class="w-16 h-16 rounded-full object-cover border-2 border-gray-200"
|
||||
loading="lazy">
|
||||
<?php else: ?>
|
||||
<div class="w-16 h-16 rounded-full bg-primary flex items-center justify-center text-white text-lg font-bold border-2 border-gray-200">
|
||||
<?= $avatar['initials'] ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Avatar type indicator -->
|
||||
<div class="absolute -bottom-1 -right-1 w-5 h-5 bg-white rounded-full border-2 border-gray-200 flex items-center justify-center">
|
||||
<?php if ($avatar['type'] === 'uploaded'): ?>
|
||||
<i class="fas fa-image text-xs text-blue-600" title="Uploaded avatar"></i>
|
||||
<?php elseif ($avatar['type'] === 'gravatar'): ?>
|
||||
<i class="fas fa-globe text-xs text-green-600" title="Gravatar"></i>
|
||||
<?php else: ?>
|
||||
<i class="fas fa-user text-xs text-gray-500" title="Initials"></i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Avatar Controls -->
|
||||
<div class="flex-1">
|
||||
<div class="space-y-2">
|
||||
<!-- Upload Form -->
|
||||
<form method="POST" action="/profile/upload-avatar" enctype="multipart/form-data" class="inline-block">
|
||||
<?= csrf_field() ?>
|
||||
<div class="flex items-center space-x-2">
|
||||
<input type="file"
|
||||
id="avatar"
|
||||
name="avatar"
|
||||
accept="image/jpeg,image/png,image/gif,image/webp"
|
||||
class="hidden"
|
||||
onchange="this.form.submit()">
|
||||
<label for="avatar"
|
||||
class="inline-flex items-center px-3 py-2 border border-gray-300 rounded-lg text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 cursor-pointer">
|
||||
<i class="fas fa-upload mr-2"></i>
|
||||
Upload New
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Delete Avatar Button -->
|
||||
<?php if ($avatar['type'] === 'uploaded'): ?>
|
||||
<form method="POST" action="/profile/delete-avatar" class="inline-block ml-2">
|
||||
<?= csrf_field() ?>
|
||||
<button type="submit"
|
||||
class="inline-flex items-center px-3 py-2 border border-red-300 rounded-lg text-sm font-medium text-red-700 bg-white hover:bg-red-50"
|
||||
onclick="return confirm('Are you sure you want to remove your avatar?')">
|
||||
<i class="fas fa-trash mr-2"></i>
|
||||
Remove
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Avatar Info -->
|
||||
<div class="mt-2 text-xs text-gray-500">
|
||||
<?php if ($avatar['type'] === 'uploaded'): ?>
|
||||
Using uploaded image
|
||||
<?php elseif ($avatar['type'] === 'gravatar'): ?>
|
||||
Using Gravatar from <?= htmlspecialchars($user['email'] ?? '') ?>
|
||||
<?php else: ?>
|
||||
Using initials (upload an image or set up Gravatar)
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Gravatar Info -->
|
||||
<?php if ($avatar['type'] !== 'gravatar' && !empty($user['email'])): ?>
|
||||
<div class="mt-1 text-xs text-gray-400">
|
||||
<a href="https://gravatar.com" target="_blank" class="text-blue-600 hover:text-blue-800">
|
||||
Set up Gravatar for automatic avatar
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="/profile/update" class="p-6">
|
||||
<?= csrf_field() ?>
|
||||
<div class="space-y-5">
|
||||
|
||||
@@ -207,10 +207,21 @@ $pagination = $pagination ?? [
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0 h-10 w-10 bg-primary bg-opacity-10 rounded-lg flex items-center justify-center">
|
||||
<span class="text-primary font-semibold text-sm">
|
||||
<?= strtoupper(substr($user['username'], 0, 1)) ?>
|
||||
</span>
|
||||
<?php
|
||||
// Get avatar data for this user (now fast with database caching)
|
||||
$avatar = \App\Helpers\AvatarHelper::getAvatar($user, 40);
|
||||
?>
|
||||
<div class="flex-shrink-0 h-10 w-10 rounded-lg overflow-hidden bg-primary bg-opacity-10 flex items-center justify-center">
|
||||
<?php if ($avatar['type'] === 'uploaded' || $avatar['type'] === 'gravatar'): ?>
|
||||
<img src="<?= htmlspecialchars($avatar['url']) ?>"
|
||||
alt="<?= htmlspecialchars($avatar['alt']) ?>"
|
||||
class="w-full h-full object-cover"
|
||||
loading="lazy">
|
||||
<?php else: ?>
|
||||
<span class="text-primary font-semibold text-sm">
|
||||
<?= $avatar['initials'] ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="ml-4">
|
||||
<div class="text-sm font-semibold text-gray-900"><?= htmlspecialchars($user['full_name'] ?? 'N/A') ?></div>
|
||||
|
||||
Reference in New Issue
Block a user