Add domain status notifications & login alerts
Introduce richer notifications and domain status handling across the app. - NotificationService: Add domain status alert formatting/sending, in-app notifications for available/registered/redemption/pending_delete, richer session_new and session_failed notifications (geolocation + UA parsing) and helpers for human-readable status labels. - Auth/TwoFactor: Emit notifications for successful logins (including remember-me and 2FA) and failed login attempts; update last-login timestamp on various flows. - DomainController: Wrap bulk domain create in try/catch to handle duplicate race conditions and log failures. - WhoisService: Detect redemption_period and pending_delete statuses from WHOIS/EPP statuses. - Settings/Setting: Add settings support for notification status triggers and bump default app_version to 1.1.2; persist/update status trigger values. - Views/Layout/View helpers: Add parsing/formatting for login notification data, add new status labels/classes (available, redemption_period, pending_delete), update notification icons/colors mapping. - Top-nav & Notifications UI: Enhance dropdown with rich login/failed-login display (flags, device icons), clickable domain redirects when marking read, badge IDs for dynamic updates. - Error admin UI: Add copy error report button with robust clipboard fallback and toast UI reused from messages; improved copy UX in admin index/detail. - Installer: Add new migration 024 to installer migration lists and adjust detected toVersion to 1.1.2. - DB: Add migration file 024_add_status_notifications_v1.1.2.sql (new file). These changes add user-facing alerts for domain lifecycle events and stronger login/security notifications while improving UI feedback and robustness during bulk operations.
This commit is contained in:
@@ -94,10 +94,10 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
$logger = new \App\Services\Logger();
|
||||
$logger->warning("Login failed - User not found or not active", [
|
||||
$this->logger->warning("Login failed - User not found or not active", [
|
||||
'username' => $username,
|
||||
'ip' => $_SERVER['REMOTE_ADDR'] ?? 'unknown'
|
||||
'ip' => $_SERVER['REMOTE_ADDR'] ?? 'unknown',
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? 'unknown'
|
||||
]);
|
||||
$_SESSION['error'] = 'Invalid username or password';
|
||||
$this->redirect('/login');
|
||||
@@ -106,11 +106,23 @@ class AuthController extends Controller
|
||||
|
||||
// Verify password
|
||||
if (!$this->userModel->verifyPassword($password, $user['password'])) {
|
||||
$logger = new \App\Services\Logger();
|
||||
$logger->warning("Login failed - Password verification failed", [
|
||||
$this->logger->warning("Login failed - Wrong password", [
|
||||
'username' => $username,
|
||||
'ip' => $_SERVER['REMOTE_ADDR'] ?? 'unknown'
|
||||
'user_id' => $user['id'],
|
||||
'ip' => $_SERVER['REMOTE_ADDR'] ?? 'unknown',
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? 'unknown'
|
||||
]);
|
||||
|
||||
// Notify the target user about failed login attempt (wrong password)
|
||||
try {
|
||||
$ipAddress = $_SERVER['REMOTE_ADDR'] ?? 'unknown';
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? null;
|
||||
$notificationService = new \App\Services\NotificationService();
|
||||
$notificationService->notifyFailedLogin($user['id'], 'Wrong password', $ipAddress, $userAgent, $username);
|
||||
} catch (\Exception $e) {
|
||||
// Don't block response if notification fails
|
||||
}
|
||||
|
||||
$_SESSION['error'] = 'Invalid username or password';
|
||||
$this->redirect('/login');
|
||||
return;
|
||||
@@ -183,6 +195,16 @@ class AuthController extends Controller
|
||||
// Update last login
|
||||
$this->userModel->updateLastLogin($user['id']);
|
||||
|
||||
// Create login notification
|
||||
try {
|
||||
$ipAddress = $_SERVER['REMOTE_ADDR'] ?? 'unknown';
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? null;
|
||||
$notificationService = new \App\Services\NotificationService();
|
||||
$notificationService->notifyNewLogin($user['id'], 'Direct login', $ipAddress, $userAgent);
|
||||
} catch (\Exception $e) {
|
||||
// Don't block login if notification fails
|
||||
}
|
||||
|
||||
// Set success message for login
|
||||
$_SESSION['success'] = 'Login successful! Welcome back, ' . htmlspecialchars($user['full_name']) . '.';
|
||||
|
||||
@@ -744,6 +766,19 @@ class AuthController extends Controller
|
||||
// Session is automatically tracked by DatabaseSessionHandler
|
||||
// No need to manually create session record
|
||||
|
||||
// Update last login timestamp
|
||||
$this->userModel->updateLastLogin($user['id']);
|
||||
|
||||
// Create login notification for remember-me auto-login
|
||||
try {
|
||||
$ipAddress = $_SERVER['REMOTE_ADDR'] ?? 'unknown';
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? null;
|
||||
$notificationService = new \App\Services\NotificationService();
|
||||
$notificationService->notifyNewLogin($user['id'], 'Remember me', $ipAddress, $userAgent);
|
||||
} catch (\Exception $e) {
|
||||
// Don't block login if notification fails
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -680,6 +680,7 @@ class DomainController extends Controller
|
||||
$availableCount++;
|
||||
}
|
||||
|
||||
try {
|
||||
$domainId = $this->domainModel->create([
|
||||
'domain_name' => $domainName,
|
||||
'notification_group_id' => $groupId,
|
||||
@@ -702,6 +703,18 @@ class DomainController extends Controller
|
||||
}
|
||||
|
||||
$added++;
|
||||
} catch (\PDOException $e) {
|
||||
// Handle duplicate key (race condition between existsByDomain check and insert)
|
||||
if (str_contains($e->getMessage(), 'Duplicate entry')) {
|
||||
$skipped++;
|
||||
} else {
|
||||
$logger->error('Failed to add domain in bulk', [
|
||||
'domain' => $domainName,
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
$errors[] = $domainName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Log bulk add completion
|
||||
|
||||
@@ -54,6 +54,7 @@ class InstallerController extends Controller
|
||||
'021_add_avatar_field.sql',
|
||||
'022_add_pushover_channel_type.sql',
|
||||
'023_update_app_version_to_1.1.1.sql',
|
||||
'024_add_status_notifications_v1.1.2.sql',
|
||||
];
|
||||
|
||||
try {
|
||||
@@ -194,6 +195,7 @@ class InstallerController extends Controller
|
||||
'021_add_avatar_field.sql',
|
||||
'022_add_pushover_channel_type.sql',
|
||||
'023_update_app_version_to_1.1.1.sql',
|
||||
'024_add_status_notifications_v1.1.2.sql',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -379,6 +381,7 @@ class InstallerController extends Controller
|
||||
'021_add_avatar_field.sql',
|
||||
'022_add_pushover_channel_type.sql',
|
||||
'023_update_app_version_to_1.1.1.sql',
|
||||
'024_add_status_notifications_v1.1.2.sql',
|
||||
];
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?) ON DUPLICATE KEY UPDATE migration=migration");
|
||||
@@ -597,10 +600,12 @@ class InstallerController extends Controller
|
||||
|
||||
// Determine from/to versions based on migrations
|
||||
$fromVersion = '1.0.0';
|
||||
$toVersion = '1.1.1';
|
||||
$toVersion = '1.1.2';
|
||||
|
||||
// Detect version based on which migrations were run
|
||||
if (in_array('022_add_pushover_channel_type.sql', $executed)) {
|
||||
if (in_array('024_add_status_notifications_v1.1.2.sql', $executed)) {
|
||||
$toVersion = '1.1.2';
|
||||
} elseif (in_array('022_add_pushover_channel_type.sql', $executed)) {
|
||||
$toVersion = '1.1.1';
|
||||
} elseif (in_array('011_create_sessions_table.sql', $executed) ||
|
||||
in_array('012_link_remember_tokens_to_sessions.sql', $executed) ||
|
||||
|
||||
@@ -57,6 +57,7 @@ class NotificationController extends Controller
|
||||
$notification['time_ago'] = $this->timeAgo($notification['created_at']);
|
||||
$notification['icon'] = $this->getNotificationIcon($notification['type']);
|
||||
$notification['color'] = $this->getNotificationColor($notification['type']);
|
||||
$notification['login_data'] = \App\Helpers\LayoutHelper::parseLoginData($notification);
|
||||
}
|
||||
|
||||
$this->view('notifications/index', [
|
||||
@@ -77,6 +78,7 @@ class NotificationController extends Controller
|
||||
|
||||
/**
|
||||
* Mark notification as read
|
||||
* Supports optional redirect to domain if ?redirect=domain
|
||||
*/
|
||||
public function markAsRead($params = [])
|
||||
{
|
||||
@@ -90,6 +92,27 @@ class NotificationController extends Controller
|
||||
}
|
||||
|
||||
$this->notificationModel->markAsRead($notificationId, $userId);
|
||||
|
||||
// If redirect=domain, go to the domain view page
|
||||
$redirect = $_GET['redirect'] ?? '';
|
||||
if ($redirect === 'domain') {
|
||||
$domainId = (int)($_GET['domain_id'] ?? 0);
|
||||
if ($domainId > 0) {
|
||||
$this->redirect('/domains/' . $domainId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// AJAX request - return JSON (check multiple detection methods)
|
||||
$isAjax = (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest')
|
||||
|| (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)
|
||||
|| !empty($_GET['ajax']);
|
||||
if ($isAjax) {
|
||||
$unreadCount = $this->notificationModel->getUnreadCount($userId);
|
||||
$this->json(['success' => true, 'id' => $notificationId, 'unread_count' => $unreadCount]);
|
||||
return;
|
||||
}
|
||||
|
||||
$_SESSION['success'] = 'Notification marked as read';
|
||||
$this->redirect('/notifications');
|
||||
}
|
||||
@@ -191,9 +214,14 @@ class NotificationController extends Controller
|
||||
{
|
||||
return match($type) {
|
||||
'domain_expiring' => 'exclamation-triangle',
|
||||
'domain_expired' => 'times-circle',
|
||||
'domain_expired', 'domain_expired_status' => 'times-circle',
|
||||
'domain_available' => 'check-circle',
|
||||
'domain_registered' => 'globe',
|
||||
'domain_redemption' => 'hourglass-half',
|
||||
'domain_pending_delete' => 'trash-alt',
|
||||
'domain_updated' => 'sync-alt',
|
||||
'session_new' => 'sign-in-alt',
|
||||
'session_failed' => 'shield-alt',
|
||||
'whois_failed' => 'exclamation-circle',
|
||||
'system_welcome' => 'hand-sparkles',
|
||||
'system_upgrade' => 'arrow-up',
|
||||
@@ -208,9 +236,14 @@ class NotificationController extends Controller
|
||||
{
|
||||
return match($type) {
|
||||
'domain_expiring' => 'orange',
|
||||
'domain_expired' => 'red',
|
||||
'domain_expired', 'domain_expired_status' => 'red',
|
||||
'domain_available' => 'blue',
|
||||
'domain_registered' => 'green',
|
||||
'domain_redemption' => 'amber',
|
||||
'domain_pending_delete' => 'rose',
|
||||
'domain_updated' => 'green',
|
||||
'session_new' => 'blue',
|
||||
'session_failed' => 'red',
|
||||
'whois_failed' => 'gray',
|
||||
'system_welcome' => 'purple',
|
||||
'system_upgrade' => 'indigo',
|
||||
|
||||
@@ -66,6 +66,9 @@ class SettingsController extends Controller
|
||||
['label' => 'Weekly (168 hours)', 'value' => 168]
|
||||
];
|
||||
|
||||
// Status notification triggers
|
||||
$statusTriggers = $this->settingModel->getNotificationStatusTriggers();
|
||||
|
||||
$this->view('settings/index', [
|
||||
'settings' => $settings,
|
||||
'appSettings' => $appSettings,
|
||||
@@ -75,6 +78,7 @@ class SettingsController extends Controller
|
||||
'isolationSettings' => $isolationSettings,
|
||||
'notificationPresets' => $notificationPresets,
|
||||
'checkIntervalPresets' => $checkIntervalPresets,
|
||||
'statusTriggers' => $statusTriggers,
|
||||
'title' => 'Settings'
|
||||
]);
|
||||
}
|
||||
@@ -132,9 +136,16 @@ class SettingsController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
// Update status notification triggers
|
||||
$statusTriggers = $_POST['notification_status_triggers'] ?? [];
|
||||
if (!is_array($statusTriggers)) {
|
||||
$statusTriggers = [];
|
||||
}
|
||||
|
||||
// Save settings
|
||||
$this->settingModel->setValue('notification_days_before', $notificationDays);
|
||||
$this->settingModel->setValue('check_interval_hours', $checkInterval);
|
||||
$this->settingModel->updateNotificationStatusTriggers($statusTriggers);
|
||||
|
||||
$_SESSION['success'] = 'Settings updated successfully';
|
||||
$this->redirect('/settings#monitoring');
|
||||
|
||||
@@ -295,9 +295,30 @@ class TwoFactorController extends Controller
|
||||
'method' => $method
|
||||
]);
|
||||
|
||||
// Update last login timestamp
|
||||
$this->userModel->updateLastLogin($userId);
|
||||
|
||||
// Create login notification
|
||||
try {
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? null;
|
||||
$notificationService = new \App\Services\NotificationService();
|
||||
$notificationService->notifyNewLogin($userId, "2FA ($method)", $ipAddress, $userAgent);
|
||||
} catch (\Exception $e) {
|
||||
// Don't block login if notification fails
|
||||
}
|
||||
|
||||
$_SESSION['success'] = 'Login successful! Welcome back, ' . htmlspecialchars($user['full_name']) . '.';
|
||||
$this->redirect('/');
|
||||
} else {
|
||||
// Notify user about failed 2FA attempt
|
||||
try {
|
||||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? null;
|
||||
$notificationService = new \App\Services\NotificationService();
|
||||
$notificationService->notifyFailedLogin($userId, 'Failed 2FA verification', $ipAddress, $userAgent, $user['username']);
|
||||
} catch (\Exception $e) {
|
||||
// Don't block response if notification fails
|
||||
}
|
||||
|
||||
$_SESSION['error'] = 'Invalid verification code. Please try again.';
|
||||
$this->redirect('/2fa/verify');
|
||||
}
|
||||
|
||||
@@ -145,6 +145,16 @@ class DomainHelper
|
||||
'text' => 'Expired',
|
||||
'icon' => 'fa-times-circle'
|
||||
],
|
||||
'redemption_period' => [
|
||||
'class' => 'bg-amber-100 text-amber-700 border-amber-200',
|
||||
'text' => 'Redemption Period',
|
||||
'icon' => 'fa-hourglass-half'
|
||||
],
|
||||
'pending_delete' => [
|
||||
'class' => 'bg-rose-100 text-rose-700 border-rose-200',
|
||||
'text' => 'Pending Delete',
|
||||
'icon' => 'fa-trash-alt'
|
||||
],
|
||||
'error' => [
|
||||
'class' => 'bg-gray-100 text-gray-700 border-gray-200',
|
||||
'text' => 'Error',
|
||||
|
||||
@@ -22,6 +22,7 @@ class LayoutHelper
|
||||
$notif['time_ago'] = self::timeAgo($notif['created_at']);
|
||||
$notif['icon'] = self::getNotificationIcon($notif['type']);
|
||||
$notif['color'] = self::getNotificationColor($notif['type']);
|
||||
$notif['login_data'] = self::parseLoginData($notif);
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -52,6 +53,43 @@ class LayoutHelper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse session_new notification message (JSON)
|
||||
* Returns structured data for rich display, or null if not parseable
|
||||
*/
|
||||
public static function parseLoginData(array $notification): ?array
|
||||
{
|
||||
if ($notification['type'] !== 'session_new' && $notification['type'] !== 'session_failed') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($notification['message'] ?? '', true);
|
||||
|
||||
if (is_array($data) && isset($data['ip'])) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format session_new notification for dropdown display (compact)
|
||||
*/
|
||||
public static function formatLoginDropdown(array $loginData): string
|
||||
{
|
||||
$parts = [];
|
||||
if ($loginData['city'] !== 'Unknown' && $loginData['city'] !== 'Local') {
|
||||
$parts[] = $loginData['city'];
|
||||
}
|
||||
if ($loginData['country'] !== 'Unknown' && $loginData['country'] !== 'Local') {
|
||||
$parts[] = $loginData['country'];
|
||||
}
|
||||
$location = !empty($parts) ? implode(', ', $parts) : $loginData['ip'];
|
||||
|
||||
$browser = $loginData['browser'] ?? 'Unknown';
|
||||
return "{$location} · {$browser}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert timestamp to "time ago" format
|
||||
*/
|
||||
@@ -83,9 +121,14 @@ class LayoutHelper
|
||||
{
|
||||
return match($type) {
|
||||
'domain_expiring' => 'exclamation-triangle',
|
||||
'domain_expired' => 'times-circle',
|
||||
'domain_expired', 'domain_expired_status' => 'times-circle',
|
||||
'domain_available' => 'check-circle',
|
||||
'domain_registered' => 'globe',
|
||||
'domain_redemption' => 'hourglass-half',
|
||||
'domain_pending_delete' => 'trash-alt',
|
||||
'domain_updated' => 'sync-alt',
|
||||
'session_new' => 'sign-in-alt',
|
||||
'session_failed' => 'shield-alt',
|
||||
'whois_failed' => 'exclamation-circle',
|
||||
'system_welcome' => 'hand-sparkles',
|
||||
'system_upgrade' => 'arrow-up',
|
||||
@@ -100,9 +143,14 @@ class LayoutHelper
|
||||
{
|
||||
return match($type) {
|
||||
'domain_expiring' => 'orange',
|
||||
'domain_expired' => 'red',
|
||||
'domain_expired', 'domain_expired_status' => 'red',
|
||||
'domain_available' => 'blue',
|
||||
'domain_registered' => 'green',
|
||||
'domain_redemption' => 'amber',
|
||||
'domain_pending_delete' => 'rose',
|
||||
'domain_updated' => 'green',
|
||||
'session_new' => 'blue',
|
||||
'session_failed' => 'red',
|
||||
'whois_failed' => 'gray',
|
||||
'system_welcome' => 'purple',
|
||||
'system_upgrade' => 'indigo',
|
||||
|
||||
@@ -53,6 +53,9 @@ class ViewHelper
|
||||
'active' => 'bg-green-100 text-green-800 border-green-200',
|
||||
'expiring_soon' => 'bg-orange-100 text-orange-800 border-orange-200',
|
||||
'expired' => 'bg-red-100 text-red-800 border-red-200',
|
||||
'available' => 'bg-blue-100 text-blue-800 border-blue-200',
|
||||
'redemption_period' => 'bg-amber-100 text-amber-800 border-amber-200',
|
||||
'pending_delete' => 'bg-rose-100 text-rose-800 border-rose-200',
|
||||
'inactive' => 'bg-gray-100 text-gray-800 border-gray-200',
|
||||
];
|
||||
|
||||
@@ -60,6 +63,9 @@ class ViewHelper
|
||||
'active' => 'Active',
|
||||
'expiring_soon' => 'Expiring Soon',
|
||||
'expired' => 'Expired',
|
||||
'available' => 'Available',
|
||||
'redemption_period' => 'Redemption Period',
|
||||
'pending_delete' => 'Pending Delete',
|
||||
'inactive' => 'Inactive',
|
||||
];
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class Setting extends Model
|
||||
*/
|
||||
public function getAppVersion(): string
|
||||
{
|
||||
return $this->getValue('app_version', '1.1.1');
|
||||
return $this->getValue('app_version', '1.1.2');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,6 +301,27 @@ class Setting extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification status triggers as array
|
||||
* Returns which domain status changes should trigger notifications
|
||||
*/
|
||||
public function getNotificationStatusTriggers(): array
|
||||
{
|
||||
$value = $this->getValue('notification_status_triggers', 'available,registered,expired,redemption_period,pending_delete');
|
||||
return array_map('trim', explode(',', $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update notification status triggers
|
||||
*/
|
||||
public function updateNotificationStatusTriggers(array $triggers): bool
|
||||
{
|
||||
$validTriggers = ['available', 'registered', 'expired', 'redemption_period', 'pending_delete'];
|
||||
$triggers = array_intersect($triggers, $validTriggers);
|
||||
$value = implode(',', $triggers);
|
||||
return $this->setValue('notification_status_triggers', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear old notification logs
|
||||
*/
|
||||
|
||||
@@ -119,6 +119,95 @@ class NotificationService
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send domain status change notification via external channels
|
||||
*/
|
||||
public function sendDomainStatusAlert(array $domain, array $notificationChannels, string $newStatus, string $oldStatus): array
|
||||
{
|
||||
$message = $this->formatStatusChangeMessage($domain, $newStatus, $oldStatus);
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ($notificationChannels as $channel) {
|
||||
$config = json_decode($channel['channel_config'], true);
|
||||
$success = $this->send(
|
||||
$channel['channel_type'],
|
||||
$config,
|
||||
$message,
|
||||
[
|
||||
'domain' => $domain['domain_name'],
|
||||
'domain_id' => $domain['id'],
|
||||
'new_status' => $newStatus,
|
||||
'old_status' => $oldStatus,
|
||||
'registrar' => $domain['registrar'] ?? 'Unknown'
|
||||
]
|
||||
);
|
||||
|
||||
$results[] = [
|
||||
'channel' => $channel['channel_type'],
|
||||
'success' => $success
|
||||
];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format status change notification message
|
||||
*/
|
||||
private function formatStatusChangeMessage(array $domain, string $newStatus, string $oldStatus): string
|
||||
{
|
||||
$domainName = $domain['domain_name'];
|
||||
$registrar = $domain['registrar'] ?? 'Unknown';
|
||||
$oldStatusLabel = self::getStatusLabel($oldStatus);
|
||||
$newStatusLabel = self::getStatusLabel($newStatus);
|
||||
|
||||
return match($newStatus) {
|
||||
'available' => "🟢 AVAILABLE: Domain '$domainName' is now available for registration!\n\n" .
|
||||
"Previous status: $oldStatusLabel\n" .
|
||||
"This domain can now be registered.",
|
||||
|
||||
'active' => "✅ REGISTERED: Domain '$domainName' is now registered and active.\n\n" .
|
||||
"Previous status: $oldStatusLabel\n" .
|
||||
"Registrar: $registrar",
|
||||
|
||||
'expired' => "🚨 EXPIRED: Domain '$domainName' has expired!\n\n" .
|
||||
"Previous status: $oldStatusLabel\n" .
|
||||
"Registrar: $registrar\n" .
|
||||
"Please renew immediately to avoid losing your domain.",
|
||||
|
||||
'redemption_period' => "⚠️ REDEMPTION PERIOD: Domain '$domainName' has entered the redemption period!\n\n" .
|
||||
"Previous status: $oldStatusLabel\n" .
|
||||
"Registrar: $registrar\n" .
|
||||
"The domain can still be recovered, but additional fees may apply. Act quickly!",
|
||||
|
||||
'pending_delete' => "🔴 PENDING DELETE: Domain '$domainName' is scheduled for deletion!\n\n" .
|
||||
"Previous status: $oldStatusLabel\n" .
|
||||
"Registrar: $registrar\n" .
|
||||
"The domain will be released for public registration soon.",
|
||||
|
||||
default => "ℹ️ STATUS CHANGE: Domain '$domainName' status changed from $oldStatusLabel to $newStatusLabel.\n\n" .
|
||||
"Registrar: $registrar"
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get human-readable status label
|
||||
*/
|
||||
public static function getStatusLabel(string $status): string
|
||||
{
|
||||
return match($status) {
|
||||
'active' => 'Active',
|
||||
'expiring_soon' => 'Expiring Soon',
|
||||
'expired' => 'Expired',
|
||||
'available' => 'Available',
|
||||
'redemption_period' => 'Redemption Period',
|
||||
'pending_delete' => 'Pending Delete',
|
||||
'error' => 'Error',
|
||||
default => ucfirst(str_replace('_', ' ', $status))
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Format expiration message
|
||||
*/
|
||||
@@ -195,6 +284,67 @@ class NotificationService
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a domain available notification (in-app)
|
||||
*/
|
||||
public function notifyDomainAvailable(int $userId, string $domainName, int $domainId): void
|
||||
{
|
||||
$notificationModel = new \App\Models\Notification();
|
||||
$notificationModel->createNotification(
|
||||
$userId,
|
||||
'domain_available',
|
||||
'Domain Available',
|
||||
"{$domainName} is now available for registration",
|
||||
$domainId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a domain registered notification (in-app)
|
||||
* Triggered when a domain transitions from available/expired/pending_delete to active
|
||||
*/
|
||||
public function notifyDomainRegistered(int $userId, string $domainName, int $domainId): void
|
||||
{
|
||||
$notificationModel = new \App\Models\Notification();
|
||||
$notificationModel->createNotification(
|
||||
$userId,
|
||||
'domain_registered',
|
||||
'Domain Registered',
|
||||
"{$domainName} has been registered and is now active",
|
||||
$domainId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a domain redemption period notification (in-app)
|
||||
*/
|
||||
public function notifyDomainRedemption(int $userId, string $domainName, int $domainId): void
|
||||
{
|
||||
$notificationModel = new \App\Models\Notification();
|
||||
$notificationModel->createNotification(
|
||||
$userId,
|
||||
'domain_redemption',
|
||||
'Domain in Redemption Period',
|
||||
"{$domainName} has entered the redemption period - recovery fees may apply",
|
||||
$domainId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a domain pending delete notification (in-app)
|
||||
*/
|
||||
public function notifyDomainPendingDelete(int $userId, string $domainName, int $domainId): void
|
||||
{
|
||||
$notificationModel = new \App\Models\Notification();
|
||||
$notificationModel->createNotification(
|
||||
$userId,
|
||||
'domain_pending_delete',
|
||||
'Domain Pending Deletion',
|
||||
"{$domainName} is scheduled for deletion and will be available soon",
|
||||
$domainId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a domain WHOIS updated notification (in-app)
|
||||
*/
|
||||
@@ -234,20 +384,174 @@ class NotificationService
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new login notification (in-app)
|
||||
* Create a new login notification (in-app) with rich geolocation data
|
||||
*/
|
||||
public function notifyNewLogin(int $userId, string $location, string $ipAddress): void
|
||||
public function notifyNewLogin(int $userId, string $method, string $ipAddress, ?string $userAgent = null): void
|
||||
{
|
||||
// Get geolocation data
|
||||
$geo = \App\Models\SessionManager::getGeolocationData($ipAddress);
|
||||
|
||||
// Parse browser/device from user agent
|
||||
$browser = 'Unknown Browser';
|
||||
$device = 'Desktop';
|
||||
$deviceIcon = 'desktop';
|
||||
|
||||
if ($userAgent) {
|
||||
$ua = strtolower($userAgent);
|
||||
|
||||
// Browser detection
|
||||
if (strpos($ua, 'edg') !== false) {
|
||||
$browser = 'Edge';
|
||||
} elseif (strpos($ua, 'opr') !== false || strpos($ua, 'opera') !== false) {
|
||||
$browser = 'Opera';
|
||||
} elseif (strpos($ua, 'chrome') !== false) {
|
||||
$browser = 'Chrome';
|
||||
} elseif (strpos($ua, 'safari') !== false) {
|
||||
$browser = 'Safari';
|
||||
} elseif (strpos($ua, 'firefox') !== false) {
|
||||
$browser = 'Firefox';
|
||||
}
|
||||
|
||||
// Device detection
|
||||
if (strpos($ua, 'mobile') !== false || strpos($ua, 'android') !== false || strpos($ua, 'iphone') !== false) {
|
||||
$device = 'Mobile';
|
||||
$deviceIcon = 'mobile-alt';
|
||||
} elseif (strpos($ua, 'tablet') !== false || strpos($ua, 'ipad') !== false) {
|
||||
$device = 'Tablet';
|
||||
$deviceIcon = 'tablet-alt';
|
||||
}
|
||||
|
||||
// OS detection
|
||||
$os = 'Unknown';
|
||||
if (strpos($ua, 'windows') !== false) $os = 'Windows';
|
||||
elseif (strpos($ua, 'macintosh') !== false || strpos($ua, 'mac os') !== false) $os = 'macOS';
|
||||
elseif (strpos($ua, 'linux') !== false) $os = 'Linux';
|
||||
elseif (strpos($ua, 'android') !== false) $os = 'Android';
|
||||
elseif (strpos($ua, 'iphone') !== false || strpos($ua, 'ipad') !== false) $os = 'iOS';
|
||||
}
|
||||
|
||||
// Build location string
|
||||
$locationParts = [];
|
||||
if ($geo['city'] !== 'Unknown' && $geo['city'] !== 'Local') {
|
||||
$locationParts[] = $geo['city'];
|
||||
}
|
||||
if ($geo['country'] !== 'Unknown' && $geo['country'] !== 'Local') {
|
||||
$locationParts[] = $geo['country'];
|
||||
}
|
||||
$locationStr = !empty($locationParts) ? implode(', ', $locationParts) : 'Unknown location';
|
||||
|
||||
// Store rich data as JSON in message field
|
||||
$messageData = json_encode([
|
||||
'method' => $method,
|
||||
'ip' => $ipAddress,
|
||||
'country' => $geo['country'],
|
||||
'country_code' => $geo['country_code'],
|
||||
'city' => $geo['city'],
|
||||
'region' => $geo['region'],
|
||||
'isp' => $geo['isp'],
|
||||
'browser' => $browser,
|
||||
'device' => $device,
|
||||
'device_icon' => $deviceIcon,
|
||||
'os' => $os ?? 'Unknown',
|
||||
'location' => $locationStr,
|
||||
]);
|
||||
|
||||
$notificationModel = new \App\Models\Notification();
|
||||
$notificationModel->createNotification(
|
||||
$userId,
|
||||
'session_new',
|
||||
'New Login Detected',
|
||||
"Login from {$location} ({$ipAddress})",
|
||||
$messageData,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a failed login notification (in-app) with rich geolocation data
|
||||
*/
|
||||
public function notifyFailedLogin(int $userId, string $reason, string $ipAddress, ?string $userAgent = null, ?string $attemptedUsername = null): void
|
||||
{
|
||||
// Get geolocation data
|
||||
$geo = \App\Models\SessionManager::getGeolocationData($ipAddress);
|
||||
|
||||
// Parse browser/device from user agent
|
||||
$browser = 'Unknown Browser';
|
||||
$device = 'Desktop';
|
||||
$deviceIcon = 'desktop';
|
||||
|
||||
if ($userAgent) {
|
||||
$ua = strtolower($userAgent);
|
||||
|
||||
// Browser detection
|
||||
if (strpos($ua, 'edg') !== false) {
|
||||
$browser = 'Edge';
|
||||
} elseif (strpos($ua, 'opr') !== false || strpos($ua, 'opera') !== false) {
|
||||
$browser = 'Opera';
|
||||
} elseif (strpos($ua, 'chrome') !== false) {
|
||||
$browser = 'Chrome';
|
||||
} elseif (strpos($ua, 'safari') !== false) {
|
||||
$browser = 'Safari';
|
||||
} elseif (strpos($ua, 'firefox') !== false) {
|
||||
$browser = 'Firefox';
|
||||
}
|
||||
|
||||
// Device detection
|
||||
if (strpos($ua, 'mobile') !== false || strpos($ua, 'android') !== false || strpos($ua, 'iphone') !== false) {
|
||||
$device = 'Mobile';
|
||||
$deviceIcon = 'mobile-alt';
|
||||
} elseif (strpos($ua, 'tablet') !== false || strpos($ua, 'ipad') !== false) {
|
||||
$device = 'Tablet';
|
||||
$deviceIcon = 'tablet-alt';
|
||||
}
|
||||
|
||||
// OS detection
|
||||
$os = 'Unknown';
|
||||
if (strpos($ua, 'windows') !== false) $os = 'Windows';
|
||||
elseif (strpos($ua, 'macintosh') !== false || strpos($ua, 'mac os') !== false) $os = 'macOS';
|
||||
elseif (strpos($ua, 'linux') !== false) $os = 'Linux';
|
||||
elseif (strpos($ua, 'android') !== false) $os = 'Android';
|
||||
elseif (strpos($ua, 'iphone') !== false || strpos($ua, 'ipad') !== false) $os = 'iOS';
|
||||
}
|
||||
|
||||
// Build location string
|
||||
$locationParts = [];
|
||||
if ($geo['city'] !== 'Unknown' && $geo['city'] !== 'Local') {
|
||||
$locationParts[] = $geo['city'];
|
||||
}
|
||||
if ($geo['country'] !== 'Unknown' && $geo['country'] !== 'Local') {
|
||||
$locationParts[] = $geo['country'];
|
||||
}
|
||||
$locationStr = !empty($locationParts) ? implode(', ', $locationParts) : 'Unknown location';
|
||||
|
||||
// Store rich data as JSON in message field
|
||||
$messageData = json_encode([
|
||||
'reason' => $reason,
|
||||
'attempted_username' => $attemptedUsername,
|
||||
'ip' => $ipAddress,
|
||||
'country' => $geo['country'],
|
||||
'country_code' => $geo['country_code'],
|
||||
'city' => $geo['city'],
|
||||
'region' => $geo['region'],
|
||||
'isp' => $geo['isp'],
|
||||
'browser' => $browser,
|
||||
'device' => $device,
|
||||
'device_icon' => $deviceIcon,
|
||||
'os' => $os ?? 'Unknown',
|
||||
'location' => $locationStr,
|
||||
]);
|
||||
|
||||
$notificationModel = new \App\Models\Notification();
|
||||
$notificationModel->createNotification(
|
||||
$userId,
|
||||
'session_failed',
|
||||
'Failed Login Attempt',
|
||||
$messageData,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
// Future improvement: Add notifyAdminsFailedLogin() to send in-app alerts to all admins on failed login attempts (e.g. unknown usernames, brute-force detection)
|
||||
|
||||
/**
|
||||
* Create welcome notification for new users/fresh install (in-app)
|
||||
*/
|
||||
|
||||
@@ -1107,6 +1107,29 @@ class WhoisService
|
||||
}
|
||||
}
|
||||
|
||||
// Check for pending delete status (EPP: pendingDelete)
|
||||
// Must check before active/registered indicators since a domain can have both
|
||||
foreach ($statusArray as $status) {
|
||||
if (stripos($status, 'pendingDelete') !== false ||
|
||||
stripos($status, 'pending delete') !== false ||
|
||||
stripos($status, 'pending_delete') !== false ||
|
||||
stripos($status, 'PENDING-DELETE') !== false) {
|
||||
return 'pending_delete';
|
||||
}
|
||||
}
|
||||
|
||||
// Check for redemption period status (EPP: redemptionPeriod)
|
||||
// Must check before active/registered indicators
|
||||
foreach ($statusArray as $status) {
|
||||
if (stripos($status, 'redemptionPeriod') !== false ||
|
||||
stripos($status, 'redemption period') !== false ||
|
||||
stripos($status, 'redemption_period') !== false ||
|
||||
stripos($status, 'REDEMPTION-PERIOD') !== false ||
|
||||
stripos($status, 'pendingRestore') !== false) {
|
||||
return 'redemption_period';
|
||||
}
|
||||
}
|
||||
|
||||
// If domain has "active" status but no expiration date, consider it active
|
||||
// This handles TLDs like .nl that don't provide expiration dates via RDAP
|
||||
foreach ($statusArray as $status) {
|
||||
|
||||
@@ -68,7 +68,10 @@ $currentFilters = $filters ?? ['search' => '', 'status' => '', 'group' => '', 's
|
||||
<option value="">All Statuses</option>
|
||||
<option value="active" <?= $currentFilters['status'] === 'active' ? 'selected' : '' ?>>Active</option>
|
||||
<option value="expiring_soon" <?= $currentFilters['status'] === 'expiring_soon' ? 'selected' : '' ?>>Expiring Soon</option>
|
||||
<option value="expired" <?= $currentFilters['status'] === 'expired' ? 'selected' : '' ?>>Expired</option>
|
||||
<option value="available" <?= $currentFilters['status'] === 'available' ? 'selected' : '' ?>>Available</option>
|
||||
<option value="redemption_period" <?= $currentFilters['status'] === 'redemption_period' ? 'selected' : '' ?>>Redemption Period</option>
|
||||
<option value="pending_delete" <?= $currentFilters['status'] === 'pending_delete' ? 'selected' : '' ?>>Pending Delete</option>
|
||||
<option value="error" <?= $currentFilters['status'] === 'error' ? 'selected' : '' ?>>Error</option>
|
||||
<option value="inactive" <?= $currentFilters['status'] === 'inactive' ? 'selected' : '' ?>>Inactive</option>
|
||||
</select>
|
||||
|
||||
@@ -9,14 +9,18 @@ $isResolved = (bool)$error['is_resolved'];
|
||||
$errorTypeShort = substr(strrchr($error['error_type'], '\\'), 1) ?: $error['error_type'];
|
||||
?>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<!-- Back Navigation -->
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<a href="/errors" class="text-gray-600 hover:text-primary">
|
||||
<a href="/errors" class="inline-flex items-center px-3 py-2 border border-gray-300 text-gray-700 text-sm rounded-lg hover:bg-gray-50 transition-colors font-medium">
|
||||
<i class="fas fa-arrow-left mr-2"></i>
|
||||
Back to Error Logs
|
||||
</a>
|
||||
|
||||
<div class="flex items-center space-x-2">
|
||||
<button onclick="copyErrorReport()" class="px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary-dark transition-colors text-sm font-medium">
|
||||
<i class="fas fa-clipboard mr-2"></i>
|
||||
Copy Error Report
|
||||
</button>
|
||||
<?php if ($isResolved): ?>
|
||||
<form method="POST" action="/errors/<?= htmlspecialchars($error['error_id']) ?>/unresolve" class="inline">
|
||||
<input type="hidden" name="csrf_token" value="<?= csrf_token() ?>">
|
||||
@@ -354,31 +358,157 @@ function copyToClipboard(text) {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
showCopySuccess();
|
||||
}).catch(() => {
|
||||
fallbackCopy(text);
|
||||
});
|
||||
} else {
|
||||
fallbackCopy(text);
|
||||
}
|
||||
}
|
||||
|
||||
function fallbackCopy(text) {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.left = '-999999px';
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
showCopySuccess();
|
||||
} catch (err) {
|
||||
console.error('Copy failed:', err);
|
||||
}
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
|
||||
function copyErrorReport() {
|
||||
const errorType = <?= json_encode($error['error_type'] ?? 'Error') ?>;
|
||||
const errorMessage = <?= json_encode($error['error_message'] ?? 'Unknown error') ?>;
|
||||
const errorFile = <?= json_encode($error['error_file'] ?? 'Unknown') ?>;
|
||||
const errorLine = <?= json_encode($error['error_line'] ?? '?') ?>;
|
||||
const errorId = <?= json_encode($error['error_id'] ?? 'N/A') ?>;
|
||||
const phpVersion = <?= json_encode($error['php_version'] ?? 'Unknown') ?>;
|
||||
const memoryUsage = <?= json_encode($error['memory_usage'] ?? 'Unknown') ?>;
|
||||
const requestMethod = <?= json_encode($error['request_method'] ?? 'GET') ?>;
|
||||
const requestUri = <?= json_encode($error['request_uri'] ?? '/') ?>;
|
||||
const userAgent = <?= json_encode($error['user_agent'] ?? 'Unknown') ?>;
|
||||
const ipAddress = <?= json_encode($error['ip_address'] ?? 'Unknown') ?>;
|
||||
const occurredAt = <?= json_encode(date('Y-m-d H:i:s', strtotime($error['occurred_at']))) ?>;
|
||||
const lastOccurredAt = <?= json_encode(date('Y-m-d H:i:s', strtotime($error['last_occurred_at'] ?? $error['occurred_at']))) ?>;
|
||||
const occurrences = <?= json_encode($error['occurrences'] ?? 1) ?>;
|
||||
const isResolved = <?= json_encode($isResolved) ?>;
|
||||
const requestData = <?= json_encode($error['request_data'] ?? null) ?>;
|
||||
const sessionData = <?= json_encode($error['session_data'] ?? null) ?>;
|
||||
|
||||
// Get stack trace from the rendered elements
|
||||
const traceFrames = document.querySelectorAll('#content-stack-trace .bg-gray-50');
|
||||
let stackTrace = 'Not available';
|
||||
if (traceFrames.length > 0) {
|
||||
let traceLines = [];
|
||||
traceFrames.forEach((frame, i) => {
|
||||
const fileLine = frame.querySelector('.font-mono.text-xs');
|
||||
const funcLine = frame.querySelector('.font-mono.text-sm');
|
||||
let line = '#' + i + ' ';
|
||||
if (fileLine) line += fileLine.textContent.trim().replace(/\s+/g, ' ');
|
||||
if (funcLine) line += ' ' + funcLine.textContent.trim().replace(/\s+/g, '');
|
||||
traceLines.push(line);
|
||||
});
|
||||
stackTrace = traceLines.join('\n');
|
||||
}
|
||||
|
||||
// Format request data sections
|
||||
let requestDataText = 'Not available';
|
||||
if (requestData && typeof requestData === 'object' && Object.keys(requestData).length > 0) {
|
||||
let sections = [];
|
||||
for (const [key, value] of Object.entries(requestData)) {
|
||||
sections.push(` [${key.toUpperCase()}]\n ${JSON.stringify(value, null, 2).split('\n').join('\n ')}`);
|
||||
}
|
||||
requestDataText = sections.join('\n\n');
|
||||
}
|
||||
|
||||
// Format session data
|
||||
let sessionDataText = 'Not available';
|
||||
if (sessionData && typeof sessionData === 'object' && Object.keys(sessionData).length > 0) {
|
||||
sessionDataText = ' ' + JSON.stringify(sessionData, null, 2).split('\n').join('\n ');
|
||||
}
|
||||
|
||||
const errorReport = `=== DOMAIN MONITOR ERROR REPORT ===
|
||||
|
||||
ERROR INFORMATION:
|
||||
- Error ID: ${errorId}
|
||||
- Type: ${errorType}
|
||||
- Message: ${errorMessage}
|
||||
- Status: ${isResolved ? 'Resolved' : 'Unresolved'}
|
||||
- Occurrences: ${occurrences}
|
||||
|
||||
LOCATION:
|
||||
- File: ${errorFile}
|
||||
- Line: ${errorLine}
|
||||
|
||||
REQUEST DETAILS:
|
||||
- Method: ${requestMethod}
|
||||
- URI: ${requestUri}
|
||||
- IP Address: ${ipAddress}
|
||||
- User Agent: ${userAgent}
|
||||
- First Occurred: ${occurredAt}
|
||||
- Last Occurred: ${lastOccurredAt}
|
||||
|
||||
REQUEST DATA:
|
||||
${requestDataText}
|
||||
|
||||
SESSION DATA:
|
||||
${sessionDataText}
|
||||
|
||||
SYSTEM INFORMATION:
|
||||
- PHP Version: ${phpVersion}
|
||||
- Memory Usage: ${memoryUsage}
|
||||
|
||||
STACK TRACE:
|
||||
${stackTrace}
|
||||
|
||||
=== END OF ERROR REPORT ===
|
||||
|
||||
Reference ID: ${errorId}
|
||||
Please include this report when reporting bugs.`;
|
||||
|
||||
copyToClipboard(errorReport);
|
||||
}
|
||||
|
||||
function showCopySuccess() {
|
||||
const message = document.createElement('div');
|
||||
message.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 py-3 rounded-lg shadow-lg z-50 flex items-center';
|
||||
message.innerHTML = '<i class="fas fa-check mr-2"></i>Copied to clipboard!';
|
||||
document.body.appendChild(message);
|
||||
// Use the existing toast container from messages.php
|
||||
let container = document.getElementById('toast-container');
|
||||
if (!container) {
|
||||
container = document.createElement('div');
|
||||
container.id = 'toast-container';
|
||||
container.className = 'fixed bottom-4 right-4 z-[9999] space-y-3 max-w-sm';
|
||||
document.body.appendChild(container);
|
||||
}
|
||||
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'toast bg-white border-l-4 border-green-500 rounded-lg shadow-lg p-4 flex items-start animate-slide-in';
|
||||
toast.innerHTML = `
|
||||
<div class="flex-shrink-0">
|
||||
<div class="w-8 h-8 bg-green-100 rounded-full flex items-center justify-center">
|
||||
<i class="fas fa-check text-green-600 text-sm"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-3 flex-1">
|
||||
<p class="text-sm font-medium text-gray-900">Success</p>
|
||||
<p class="text-sm text-gray-600 mt-0.5">Copied to clipboard!</p>
|
||||
</div>
|
||||
<button onclick="this.parentElement.remove()" class="ml-3 flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors">
|
||||
<i class="fas fa-times text-sm"></i>
|
||||
</button>
|
||||
`;
|
||||
container.appendChild(toast);
|
||||
|
||||
setTimeout(() => {
|
||||
message.style.opacity = '0';
|
||||
message.style.transition = 'opacity 0.3s';
|
||||
setTimeout(() => message.remove(), 300);
|
||||
}, 2000);
|
||||
toast.style.transition = 'opacity 0.3s ease-out, transform 0.3s ease-out';
|
||||
toast.style.opacity = '0';
|
||||
toast.style.transform = 'translateX(100%)';
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function markResolved() {
|
||||
|
||||
@@ -432,16 +432,39 @@ function copyToClipboard(text) {
|
||||
}
|
||||
|
||||
function showCopySuccess() {
|
||||
const message = document.createElement('div');
|
||||
message.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 py-3 rounded-lg shadow-lg z-50 flex items-center';
|
||||
message.innerHTML = '<i class="fas fa-check mr-2"></i>Copied to clipboard!';
|
||||
document.body.appendChild(message);
|
||||
// Use the existing toast container from messages.php
|
||||
let container = document.getElementById('toast-container');
|
||||
if (!container) {
|
||||
container = document.createElement('div');
|
||||
container.id = 'toast-container';
|
||||
container.className = 'fixed bottom-4 right-4 z-[9999] space-y-3 max-w-sm';
|
||||
document.body.appendChild(container);
|
||||
}
|
||||
|
||||
const toast = document.createElement('div');
|
||||
toast.className = 'toast bg-white border-l-4 border-green-500 rounded-lg shadow-lg p-4 flex items-start animate-slide-in';
|
||||
toast.innerHTML = `
|
||||
<div class="flex-shrink-0">
|
||||
<div class="w-8 h-8 bg-green-100 rounded-full flex items-center justify-center">
|
||||
<i class="fas fa-check text-green-600 text-sm"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-3 flex-1">
|
||||
<p class="text-sm font-medium text-gray-900">Success</p>
|
||||
<p class="text-sm text-gray-600 mt-0.5">Copied to clipboard!</p>
|
||||
</div>
|
||||
<button onclick="this.parentElement.remove()" class="ml-3 flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors">
|
||||
<i class="fas fa-times text-sm"></i>
|
||||
</button>
|
||||
`;
|
||||
container.appendChild(toast);
|
||||
|
||||
setTimeout(() => {
|
||||
message.style.opacity = '0';
|
||||
message.style.transition = 'opacity 0.3s';
|
||||
setTimeout(() => message.remove(), 300);
|
||||
}, 2000);
|
||||
toast.style.transition = 'opacity 0.3s ease-out, transform 0.3s ease-out';
|
||||
toast.style.opacity = '0';
|
||||
toast.style.transform = 'translateX(100%)';
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
let currentErrorId = null;
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold text-gray-900">Notifications</h3>
|
||||
<?php if ($unreadNotifications > 0): ?>
|
||||
<span class="px-2 py-0.5 bg-orange-100 text-orange-700 text-xs font-semibold rounded"><?= $unreadNotifications ?> new</span>
|
||||
<span id="dropdownHeaderBadge" class="px-2 py-0.5 bg-orange-100 text-orange-700 text-xs font-semibold rounded"><?= $unreadNotifications ?> new</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -83,19 +83,84 @@
|
||||
<div class="max-h-96 overflow-y-auto">
|
||||
<?php if (!empty($recentNotifications)): ?>
|
||||
<?php foreach ($recentNotifications as $notif): ?>
|
||||
<div class="px-4 py-3 hover:bg-gray-50 border-b border-gray-100 bg-blue-50 transition-colors cursor-pointer">
|
||||
<?php
|
||||
// Build the click URL: if domain notification, go to domain; otherwise just mark as read
|
||||
$hasDomain = !empty($notif['domain_id']);
|
||||
$notifUrl = $hasDomain
|
||||
? '/notifications/' . $notif['id'] . '/mark-read?redirect=domain&domain_id=' . $notif['domain_id']
|
||||
: '/notifications/' . $notif['id'] . '/mark-read';
|
||||
?>
|
||||
<div class="px-4 py-3 hover:bg-gray-50 border-b border-gray-100 bg-blue-50 transition-colors notification-item" data-id="<?= $notif['id'] ?>">
|
||||
<div class="flex items-start space-x-3">
|
||||
<div class="w-8 h-8 bg-<?= $notif['color'] ?>-100 rounded-lg flex items-center justify-center flex-shrink-0">
|
||||
<i class="fas fa-<?= $notif['icon'] ?> text-<?= $notif['color'] ?>-600 text-sm"></i>
|
||||
<?php $loginData = $notif['login_data'] ?? null; ?>
|
||||
<?php if ($loginData && $notif['type'] === 'session_failed'): ?>
|
||||
<!-- Failed login notification (mirrors successful login layout) -->
|
||||
<a href="<?= $notifUrl ?>" class="w-8 h-8 bg-red-100 rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
|
||||
<?php if (($loginData['country_code'] ?? 'xx') !== 'xx'): ?>
|
||||
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-base rounded-sm"></span>
|
||||
<?php else: ?>
|
||||
<i class="fas fa-shield-alt text-red-600 text-sm"></i>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<a href="<?= $notifUrl ?>" class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2">
|
||||
<p class="text-sm font-semibold text-red-700"><?= htmlspecialchars($notif['title']) ?></p>
|
||||
<span class="w-2 h-2 bg-red-500 rounded-full flex-shrink-0"></span>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-xs text-gray-600 mt-0.5">
|
||||
<?= htmlspecialchars(\App\Helpers\LayoutHelper::formatLoginDropdown($loginData)) ?>
|
||||
</p>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> mr-0.5"></i>
|
||||
<?= htmlspecialchars($loginData['reason'] ?? 'Failed') ?> · <?= $notif['time_ago'] ?>
|
||||
</p>
|
||||
</a>
|
||||
<?php elseif ($loginData && $notif['type'] === 'session_new'): ?>
|
||||
<!-- Session notification with flag icon -->
|
||||
<a href="<?= $notifUrl ?>" class="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
|
||||
<?php if ($loginData['country_code'] !== 'xx'): ?>
|
||||
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-base rounded-sm"></span>
|
||||
<?php else: ?>
|
||||
<i class="fas fa-sign-in-alt text-blue-600 text-sm"></i>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<a href="<?= $notifUrl ?>" class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2">
|
||||
<p class="text-sm font-semibold text-gray-900"><?= htmlspecialchars($notif['title']) ?></p>
|
||||
<span class="w-2 h-2 bg-blue-500 rounded-full"></span>
|
||||
<span class="w-2 h-2 bg-blue-500 rounded-full flex-shrink-0"></span>
|
||||
</div>
|
||||
<p class="text-xs text-gray-600 mt-0.5">
|
||||
<?= htmlspecialchars(\App\Helpers\LayoutHelper::formatLoginDropdown($loginData)) ?>
|
||||
</p>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> mr-0.5"></i>
|
||||
<?= htmlspecialchars($loginData['method'] ?? 'Login') ?> · <?= $notif['time_ago'] ?>
|
||||
</p>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<!-- Standard notification -->
|
||||
<a href="<?= $notifUrl ?>" class="w-8 h-8 bg-<?= $notif['color'] ?>-100 rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
|
||||
<i class="fas fa-<?= $notif['icon'] ?> text-<?= $notif['color'] ?>-600 text-sm"></i>
|
||||
</a>
|
||||
<a href="<?= $notifUrl ?>" class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2">
|
||||
<p class="text-sm font-semibold text-gray-900"><?= htmlspecialchars($notif['title']) ?></p>
|
||||
<span class="w-2 h-2 bg-blue-500 rounded-full flex-shrink-0"></span>
|
||||
</div>
|
||||
<p class="text-xs text-gray-600 mt-0.5"><?= htmlspecialchars($notif['message']) ?></p>
|
||||
<p class="text-xs text-gray-400 mt-1"><?= $notif['time_ago'] ?></p>
|
||||
</div>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
<?= $notif['time_ago'] ?>
|
||||
<?php if ($hasDomain): ?>
|
||||
<span class="text-primary ml-1"><i class="fas fa-external-link-alt text-[10px]"></i> View domain</span>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<button onclick="event.stopPropagation(); markNotifRead(<?= $notif['id'] ?>, this)"
|
||||
class="w-7 h-7 flex items-center justify-center text-gray-400 hover:text-green-600 hover:bg-green-50 rounded transition-colors flex-shrink-0"
|
||||
title="Mark as read">
|
||||
<i class="fas fa-check text-xs"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
@@ -194,7 +259,7 @@
|
||||
<i class="fas fa-bell w-5 text-gray-400 mr-3"></i>
|
||||
Notifications
|
||||
<?php if ($unreadNotifications > 0): ?>
|
||||
<span class="ml-auto px-2 py-0.5 bg-orange-500 text-white text-xs font-bold rounded-full">
|
||||
<span id="userDropdownNotifBadge" class="ml-auto px-2 py-0.5 bg-orange-500 text-white text-xs font-bold rounded-full">
|
||||
<?= $unreadNotifications ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
@@ -220,3 +285,69 @@
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Notification AJAX handler -->
|
||||
<script>
|
||||
function markNotifRead(notifId, btn) {
|
||||
fetch('/notifications/' + notifId + '/mark-read?ajax=1', {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
})
|
||||
.then(r => {
|
||||
if (!r.ok) throw new Error('Request failed');
|
||||
return r.json();
|
||||
})
|
||||
.then(data => {
|
||||
if (!data.success) return;
|
||||
|
||||
const newCount = data.unread_count ?? 0;
|
||||
|
||||
// Remove the notification item from dropdown
|
||||
const item = btn.closest('.notification-item');
|
||||
if (item) {
|
||||
const scrollable = document.querySelector('#notificationsDropdown .max-h-96');
|
||||
const isLast = scrollable && scrollable.querySelectorAll('.notification-item').length <= 1;
|
||||
|
||||
if (isLast && scrollable) {
|
||||
scrollable.style.transition = 'opacity 0.2s';
|
||||
scrollable.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
scrollable.innerHTML = '<div class="px-4 py-8 text-center">' +
|
||||
'<i class="fas fa-bell-slash text-gray-300 text-3xl mb-2"></i>' +
|
||||
'<p class="text-sm text-gray-600">No new notifications</p>' +
|
||||
'<p class="text-xs text-gray-400 mt-0.5">You\'re all caught up!</p>' +
|
||||
'</div>';
|
||||
scrollable.style.opacity = '1';
|
||||
}, 200);
|
||||
} else {
|
||||
item.style.transition = 'opacity 0.2s, max-height 0.3s';
|
||||
item.style.opacity = '0';
|
||||
item.style.maxHeight = '0';
|
||||
item.style.overflow = 'hidden';
|
||||
item.style.padding = '0';
|
||||
item.style.margin = '0';
|
||||
setTimeout(() => item.remove(), 300);
|
||||
}
|
||||
}
|
||||
|
||||
// Update all badges using server-returned count
|
||||
const headerBadge = document.getElementById('dropdownHeaderBadge');
|
||||
const userBadge = document.getElementById('userDropdownNotifBadge');
|
||||
const bellDot = document.querySelector('[onclick="toggleNotifications()"] .absolute.top-1');
|
||||
|
||||
if (newCount <= 0) {
|
||||
if (headerBadge) headerBadge.remove();
|
||||
if (userBadge) userBadge.remove();
|
||||
if (bellDot) bellDot.remove();
|
||||
} else {
|
||||
if (headerBadge) headerBadge.textContent = newCount + ' new';
|
||||
if (userBadge) userBadge.textContent = newCount;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
window.location.href = '/notifications/' + notifId + '/mark-read';
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -56,11 +56,16 @@ $offset = $pagination['showing_from'] - 1;
|
||||
<optgroup label="Domain">
|
||||
<option value="domain_expiring" <?= $filterType === 'domain_expiring' ? 'selected' : '' ?>>Domain Expiring</option>
|
||||
<option value="domain_expired" <?= $filterType === 'domain_expired' ? 'selected' : '' ?>>Domain Expired</option>
|
||||
<option value="domain_available" <?= $filterType === 'domain_available' ? 'selected' : '' ?>>Domain Available</option>
|
||||
<option value="domain_registered" <?= $filterType === 'domain_registered' ? 'selected' : '' ?>>Domain Registered</option>
|
||||
<option value="domain_redemption" <?= $filterType === 'domain_redemption' ? 'selected' : '' ?>>Redemption Period</option>
|
||||
<option value="domain_pending_delete" <?= $filterType === 'domain_pending_delete' ? 'selected' : '' ?>>Pending Delete</option>
|
||||
<option value="domain_updated" <?= $filterType === 'domain_updated' ? 'selected' : '' ?>>Domain Updated</option>
|
||||
<option value="whois_failed" <?= $filterType === 'whois_failed' ? 'selected' : '' ?>>WHOIS Failed</option>
|
||||
</optgroup>
|
||||
<optgroup label="System">
|
||||
<option value="session_new" <?= $filterType === 'session_new' ? 'selected' : '' ?>>New Login</option>
|
||||
<option value="session_failed" <?= $filterType === 'session_failed' ? 'selected' : '' ?>>Failed Login</option>
|
||||
<option value="system_welcome" <?= $filterType === 'system_welcome' ? 'selected' : '' ?>>Welcome</option>
|
||||
<option value="system_upgrade" <?= $filterType === 'system_upgrade' ? 'selected' : '' ?>>System Upgrade</option>
|
||||
</optgroup>
|
||||
@@ -129,34 +134,178 @@ $offset = $pagination['showing_from'] - 1;
|
||||
$bgClass = $notification['is_read'] ? '' : 'bg-blue-50';
|
||||
$iconBgClass = "bg-{$notification['color']}-100";
|
||||
$iconTextClass = "text-{$notification['color']}-600";
|
||||
$hasDomain = !empty($notification['domain_id']);
|
||||
$domainUrl = $hasDomain ? '/domains/' . $notification['domain_id'] : null;
|
||||
$clickUrl = null;
|
||||
if ($hasDomain && !$notification['is_read']) {
|
||||
$clickUrl = '/notifications/' . $notification['id'] . '/mark-read?redirect=domain&domain_id=' . $notification['domain_id'];
|
||||
} elseif ($hasDomain) {
|
||||
$clickUrl = $domainUrl;
|
||||
}
|
||||
$loginData = $notification['login_data'] ?? null;
|
||||
$isLogin = ($notification['type'] === 'session_new' && $loginData);
|
||||
$isFailedLogin = ($notification['type'] === 'session_failed' && $loginData);
|
||||
?>
|
||||
<div class="px-4 py-3 hover:bg-gray-50 transition-colors <?= $bgClass ?>">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex items-start gap-3">
|
||||
<!-- Icon -->
|
||||
<div class="w-8 h-8 <?= $iconBgClass ?> rounded-lg flex items-center justify-center flex-shrink-0">
|
||||
<i class="fas fa-<?= $notification['icon'] ?> <?= $iconTextClass ?> text-xs"></i>
|
||||
<?php if ($isFailedLogin): ?>
|
||||
<div class="w-10 h-10 bg-red-100 rounded-lg flex items-center justify-center flex-shrink-0">
|
||||
<i class="fas fa-shield-alt text-red-600"></i>
|
||||
</div>
|
||||
<?php elseif ($isLogin): ?>
|
||||
<div class="w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center flex-shrink-0">
|
||||
<i class="fas fa-sign-in-alt text-blue-600"></i>
|
||||
</div>
|
||||
<?php elseif ($clickUrl): ?>
|
||||
<a href="<?= $clickUrl ?>" class="w-10 h-10 <?= $iconBgClass ?> rounded-lg flex items-center justify-center flex-shrink-0 hover:opacity-80 transition-opacity">
|
||||
<i class="fas fa-<?= $notification['icon'] ?> <?= $iconTextClass ?> text-sm"></i>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<div class="w-10 h-10 <?= $iconBgClass ?> rounded-lg flex items-center justify-center flex-shrink-0">
|
||||
<i class="fas fa-<?= $notification['icon'] ?> <?= $iconTextClass ?> text-sm"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Content -->
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-2">
|
||||
<?php if ($clickUrl): ?>
|
||||
<a href="<?= $clickUrl ?>" class="text-sm font-medium text-gray-900 hover:text-primary transition-colors"><?= htmlspecialchars($notification['title']) ?></a>
|
||||
<?php else: ?>
|
||||
<h3 class="text-sm font-medium text-gray-900"><?= htmlspecialchars($notification['title']) ?></h3>
|
||||
<?php endif; ?>
|
||||
<?php if (!$notification['is_read']): ?>
|
||||
<span class="flex h-1.5 w-1.5">
|
||||
<span class="flex h-1.5 w-1.5 relative">
|
||||
<span class="animate-ping absolute inline-flex h-1.5 w-1.5 rounded-full bg-blue-400 opacity-75"></span>
|
||||
<span class="relative inline-flex rounded-full h-1.5 w-1.5 bg-blue-500"></span>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<span class="text-xs text-gray-400 ml-auto">
|
||||
<span class="text-xs text-gray-400 ml-auto flex-shrink-0">
|
||||
<i class="fas fa-clock mr-1"></i>
|
||||
<?= $notification['time_ago'] ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php if ($isFailedLogin): ?>
|
||||
<!-- Rich failed login details (mirrors successful login layout) -->
|
||||
<div class="mt-1.5 bg-red-50 rounded-lg p-3 border border-red-200">
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-x-4 gap-y-2 text-xs">
|
||||
<!-- Location -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-map-marker-alt text-red-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Location:</span>
|
||||
<span class="text-gray-800 font-medium">
|
||||
<?php if (($loginData['country_code'] ?? 'xx') !== 'xx'): ?>
|
||||
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-xs mr-0.5 rounded-sm"></span>
|
||||
<?php endif; ?>
|
||||
<?= htmlspecialchars($loginData['location'] ?? 'Unknown') ?>
|
||||
</span>
|
||||
</div>
|
||||
<!-- IP Address -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-network-wired text-blue-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">IP:</span>
|
||||
<span class="text-gray-800 font-medium font-mono text-[11px]"><?= htmlspecialchars($loginData['ip'] ?? 'unknown') ?></span>
|
||||
</div>
|
||||
<!-- Browser -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-globe text-green-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Browser:</span>
|
||||
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['browser'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
<!-- Device -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> text-purple-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Device:</span>
|
||||
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['device'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
<!-- OS -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-laptop-code text-indigo-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">OS:</span>
|
||||
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['os'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
<!-- ISP -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-server text-amber-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">ISP:</span>
|
||||
<span class="text-gray-800 font-medium truncate"><?= htmlspecialchars($loginData['isp'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Reason (mirrors Method row) -->
|
||||
<div class="mt-2 pt-2 border-t border-red-200 flex items-center gap-1.5 text-xs">
|
||||
<i class="fas fa-exclamation-triangle text-gray-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Reason:</span>
|
||||
<span class="inline-flex items-center px-1.5 py-0.5 bg-red-100 text-red-700 rounded font-medium text-[11px]"><?= htmlspecialchars($loginData['reason'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($isLogin): ?>
|
||||
<!-- Rich login details -->
|
||||
<div class="mt-1.5 bg-gray-50 rounded-lg p-3 border border-gray-100">
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-x-4 gap-y-2 text-xs">
|
||||
<!-- Location -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-map-marker-alt text-red-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Location:</span>
|
||||
<span class="text-gray-800 font-medium">
|
||||
<?php if ($loginData['country_code'] !== 'xx'): ?>
|
||||
<span class="fi fi-<?= strtolower($loginData['country_code']) ?> text-xs mr-0.5 rounded-sm"></span>
|
||||
<?php endif; ?>
|
||||
<?= htmlspecialchars($loginData['location'] ?? 'Unknown') ?>
|
||||
</span>
|
||||
</div>
|
||||
<!-- IP Address -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-network-wired text-blue-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">IP:</span>
|
||||
<span class="text-gray-800 font-medium font-mono text-[11px]"><?= htmlspecialchars($loginData['ip'] ?? 'unknown') ?></span>
|
||||
</div>
|
||||
<!-- Browser -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-globe text-green-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Browser:</span>
|
||||
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['browser'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
<!-- Device -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-<?= htmlspecialchars($loginData['device_icon'] ?? 'desktop') ?> text-purple-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Device:</span>
|
||||
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['device'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
<!-- OS -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-laptop-code text-indigo-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">OS:</span>
|
||||
<span class="text-gray-800 font-medium"><?= htmlspecialchars($loginData['os'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
<!-- ISP -->
|
||||
<div class="flex items-center gap-1.5">
|
||||
<i class="fas fa-server text-amber-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">ISP:</span>
|
||||
<span class="text-gray-800 font-medium truncate"><?= htmlspecialchars($loginData['isp'] ?? 'Unknown') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Login method -->
|
||||
<div class="mt-2 pt-2 border-t border-gray-200 flex items-center gap-1.5 text-xs">
|
||||
<i class="fas fa-key text-gray-400 w-3.5 text-center"></i>
|
||||
<span class="text-gray-500">Method:</span>
|
||||
<span class="inline-flex items-center px-1.5 py-0.5 bg-blue-100 text-blue-700 rounded font-medium text-[11px]"><?= htmlspecialchars($loginData['method'] ?? 'Login') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<!-- Standard notification message -->
|
||||
<p class="text-xs text-gray-600 mt-0.5"><?= htmlspecialchars($notification['message']) ?></p>
|
||||
<?php if ($hasDomain && $clickUrl): ?>
|
||||
<a href="<?= $clickUrl ?>" class="text-xs text-primary mt-0.5 hover:underline inline-block">
|
||||
<i class="fas fa-external-link-alt text-[10px] mr-1"></i>View domain
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="flex items-center gap-1 ml-2">
|
||||
<div class="flex items-center gap-1 ml-2 flex-shrink-0">
|
||||
<?php if (!$notification['is_read']): ?>
|
||||
<a href="/notifications/<?= $notification['id'] ?>/mark-read" class="w-7 h-7 flex items-center justify-center text-gray-400 hover:text-green-600 hover:bg-green-50 rounded transition-colors" title="Mark as read">
|
||||
<i class="fas fa-check text-xs"></i>
|
||||
|
||||
@@ -372,6 +372,93 @@ foreach ($notificationPresets as $key => $preset) {
|
||||
|
||||
<div class="border-t border-gray-200 my-6"></div>
|
||||
|
||||
<!-- Status Change Notifications -->
|
||||
<div class="mb-6">
|
||||
<h4 class="text-base font-semibold text-gray-900 mb-2 flex items-center">
|
||||
<i class="fas fa-exchange-alt text-primary mr-2"></i>
|
||||
Status Change Notifications
|
||||
</h4>
|
||||
<p class="text-sm text-gray-600 mb-4">Choose which domain status changes should trigger notifications (both in-app and external channels).</p>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3">
|
||||
<!-- Available -->
|
||||
<label class="flex items-start p-3 bg-blue-50 border border-blue-200 rounded-lg cursor-pointer hover:bg-blue-100 transition-colors">
|
||||
<input type="checkbox" name="notification_status_triggers[]" value="available"
|
||||
<?= in_array('available', $statusTriggers) ? 'checked' : '' ?>
|
||||
class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500 mt-0.5">
|
||||
<div class="ml-3">
|
||||
<span class="text-sm font-medium text-blue-800">
|
||||
<i class="fas fa-check-circle mr-1"></i> Available
|
||||
</span>
|
||||
<p class="text-xs text-blue-600 mt-0.5">Domain becomes available for registration</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<!-- Registered -->
|
||||
<label class="flex items-start p-3 bg-green-50 border border-green-200 rounded-lg cursor-pointer hover:bg-green-100 transition-colors">
|
||||
<input type="checkbox" name="notification_status_triggers[]" value="registered"
|
||||
<?= in_array('registered', $statusTriggers) ? 'checked' : '' ?>
|
||||
class="w-4 h-4 text-green-600 border-gray-300 rounded focus:ring-green-500 mt-0.5">
|
||||
<div class="ml-3">
|
||||
<span class="text-sm font-medium text-green-800">
|
||||
<i class="fas fa-globe mr-1"></i> Registered
|
||||
</span>
|
||||
<p class="text-xs text-green-600 mt-0.5">Domain becomes registered / active</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<!-- Expired -->
|
||||
<label class="flex items-start p-3 bg-red-50 border border-red-200 rounded-lg cursor-pointer hover:bg-red-100 transition-colors">
|
||||
<input type="checkbox" name="notification_status_triggers[]" value="expired"
|
||||
<?= in_array('expired', $statusTriggers) ? 'checked' : '' ?>
|
||||
class="w-4 h-4 text-red-600 border-gray-300 rounded focus:ring-red-500 mt-0.5">
|
||||
<div class="ml-3">
|
||||
<span class="text-sm font-medium text-red-800">
|
||||
<i class="fas fa-times-circle mr-1"></i> Expired
|
||||
</span>
|
||||
<p class="text-xs text-red-600 mt-0.5">Domain status changes to expired</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<!-- Redemption Period -->
|
||||
<label class="flex items-start p-3 bg-amber-50 border border-amber-200 rounded-lg cursor-pointer hover:bg-amber-100 transition-colors">
|
||||
<input type="checkbox" name="notification_status_triggers[]" value="redemption_period"
|
||||
<?= in_array('redemption_period', $statusTriggers) ? 'checked' : '' ?>
|
||||
class="w-4 h-4 text-amber-600 border-gray-300 rounded focus:ring-amber-500 mt-0.5">
|
||||
<div class="ml-3">
|
||||
<span class="text-sm font-medium text-amber-800">
|
||||
<i class="fas fa-hourglass-half mr-1"></i> Redemption Period
|
||||
</span>
|
||||
<p class="text-xs text-amber-600 mt-0.5">Domain enters redemption period (recovery fees apply)</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<!-- Pending Delete -->
|
||||
<label class="flex items-start p-3 bg-rose-50 border border-rose-200 rounded-lg cursor-pointer hover:bg-rose-100 transition-colors">
|
||||
<input type="checkbox" name="notification_status_triggers[]" value="pending_delete"
|
||||
<?= in_array('pending_delete', $statusTriggers) ? 'checked' : '' ?>
|
||||
class="w-4 h-4 text-rose-600 border-gray-300 rounded focus:ring-rose-500 mt-0.5">
|
||||
<div class="ml-3">
|
||||
<span class="text-sm font-medium text-rose-800">
|
||||
<i class="fas fa-trash-alt mr-1"></i> Pending Delete
|
||||
</span>
|
||||
<p class="text-xs text-rose-600 mt-0.5">Domain is scheduled for deletion</p>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="bg-gray-50 border border-gray-200 rounded-lg p-3 mt-3">
|
||||
<p class="text-xs text-gray-600">
|
||||
<i class="fas fa-info-circle text-gray-400 mr-1"></i>
|
||||
<strong>Note:</strong> These notifications are triggered when a domain's status changes during a WHOIS check.
|
||||
Redemption Period and Pending Delete detection depends on the TLD registry reporting EPP statuses.
|
||||
Most gTLDs (.com, .net, .org) support this, but some ccTLDs may not.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-gray-200 my-6"></div>
|
||||
|
||||
<!-- Check Interval -->
|
||||
<div class="mb-6">
|
||||
<h4 class="text-base font-semibold text-gray-900 mb-4 flex items-center">
|
||||
|
||||
@@ -72,7 +72,10 @@ $currentFilters = $filters ?? ['search' => '', 'status' => '', 'registrar' => ''
|
||||
<option value="">All Statuses</option>
|
||||
<option value="active" <?= $currentFilters['status'] === 'active' ? 'selected' : '' ?>>Active</option>
|
||||
<option value="expiring_soon" <?= $currentFilters['status'] === 'expiring_soon' ? 'selected' : '' ?>>Expiring Soon</option>
|
||||
<option value="expired" <?= $currentFilters['status'] === 'expired' ? 'selected' : '' ?>>Expired</option>
|
||||
<option value="available" <?= $currentFilters['status'] === 'available' ? 'selected' : '' ?>>Available</option>
|
||||
<option value="redemption_period" <?= $currentFilters['status'] === 'redemption_period' ? 'selected' : '' ?>>Redemption Period</option>
|
||||
<option value="pending_delete" <?= $currentFilters['status'] === 'pending_delete' ? 'selected' : '' ?>>Pending Delete</option>
|
||||
<option value="error" <?= $currentFilters['status'] === 'error' ? 'selected' : '' ?>>Error</option>
|
||||
<option value="inactive" <?= $currentFilters['status'] === 'inactive' ? 'selected' : '' ?>>Inactive</option>
|
||||
</select>
|
||||
|
||||
@@ -6,126 +6,268 @@ $pageIcon = 'fas fa-user-edit';
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
<form method="POST" action="/users/update" class="max-w-2xl">
|
||||
<div class="max-w-3xl mx-auto">
|
||||
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-200">
|
||||
<h2 class="text-lg font-semibold text-gray-900 flex items-center">
|
||||
<i class="fas fa-user-edit text-gray-400 mr-2 text-sm"></i>
|
||||
User Information
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="p-6">
|
||||
<form method="POST" action="/users/update" class="space-y-5">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="id" value="<?= $user['id'] ?>">
|
||||
|
||||
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-200 bg-gray-50">
|
||||
<h3 class="text-lg font-semibold text-gray-900">User Information</h3>
|
||||
</div>
|
||||
|
||||
<div class="p-6 space-y-4">
|
||||
<!-- Name & Username Row -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<!-- Full Name -->
|
||||
<div>
|
||||
<label for="full_name" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
<label for="full_name" class="block text-sm font-medium text-gray-700 mb-1.5">
|
||||
Full Name <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<input type="text" id="full_name" name="full_name" required
|
||||
<input type="text"
|
||||
id="full_name"
|
||||
name="full_name"
|
||||
required
|
||||
autofocus
|
||||
value="<?= htmlspecialchars($user['full_name'] ?? '') ?>"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
|
||||
class="w-full px-3 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
|
||||
placeholder="John Doe">
|
||||
<p class="mt-1.5 text-xs text-gray-500">
|
||||
The user's display name
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Username (Read-only) -->
|
||||
<div>
|
||||
<label for="username" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
<label for="username" class="block text-sm font-medium text-gray-700 mb-1.5">
|
||||
Username
|
||||
</label>
|
||||
<input type="text" id="username" value="<?= htmlspecialchars($user['username']) ?>" readonly
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg bg-gray-50 text-gray-500 cursor-not-allowed">
|
||||
<p class="text-xs text-gray-500 mt-1">Username cannot be changed</p>
|
||||
<div class="relative">
|
||||
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400">
|
||||
<i class="fas fa-at text-sm"></i>
|
||||
</span>
|
||||
<input type="text"
|
||||
id="username"
|
||||
value="<?= htmlspecialchars($user['username']) ?>"
|
||||
readonly
|
||||
class="w-full pl-9 pr-3 py-2.5 border border-gray-300 rounded-lg bg-gray-50 text-gray-500 cursor-not-allowed text-sm">
|
||||
</div>
|
||||
<p class="mt-1.5 text-xs text-gray-500">
|
||||
Username cannot be changed
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Email & Role Row -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<!-- Email -->
|
||||
<div>
|
||||
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
<label for="email" class="block text-sm font-medium text-gray-700 mb-1.5">
|
||||
Email Address <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<input type="email" id="email" name="email" required
|
||||
<div class="relative">
|
||||
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400">
|
||||
<i class="fas fa-envelope text-sm"></i>
|
||||
</span>
|
||||
<input type="email"
|
||||
id="email"
|
||||
name="email"
|
||||
required
|
||||
value="<?= htmlspecialchars($user['email']) ?>"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
|
||||
class="w-full pl-9 pr-3 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
|
||||
placeholder="john@example.com">
|
||||
</div>
|
||||
<p class="mt-1.5 text-xs text-gray-500">
|
||||
Used for login and notifications
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Role -->
|
||||
<div>
|
||||
<label for="role" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
<label for="role" class="block text-sm font-medium text-gray-700 mb-1.5">
|
||||
Role <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<select id="role" name="role" required
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
|
||||
<div class="relative">
|
||||
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-400">
|
||||
<i class="fas fa-shield-alt text-sm"></i>
|
||||
</span>
|
||||
<select id="role"
|
||||
name="role"
|
||||
required
|
||||
class="w-full pl-9 pr-3 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm appearance-none bg-white">
|
||||
<option value="user" <?= $user['role'] === 'user' ? 'selected' : '' ?>>User</option>
|
||||
<option value="admin" <?= $user['role'] === 'admin' ? 'selected' : '' ?>>Admin</option>
|
||||
</select>
|
||||
<span class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none text-gray-400">
|
||||
<i class="fas fa-chevron-down text-xs"></i>
|
||||
</span>
|
||||
</div>
|
||||
<p class="mt-1.5 text-xs text-gray-500">
|
||||
Admins have full system access
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Status -->
|
||||
<div class="flex items-start">
|
||||
<div class="flex items-center h-5">
|
||||
<div class="flex items-center gap-3 bg-gray-50 border border-gray-200 rounded-lg px-4 py-3">
|
||||
<input type="checkbox" id="is_active" name="is_active" value="1"
|
||||
<?= $user['is_active'] ? 'checked' : '' ?>
|
||||
class="w-4 h-4 text-primary border-gray-300 rounded focus:ring-primary">
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<label for="is_active" class="text-sm font-medium text-gray-700">
|
||||
Active
|
||||
</label>
|
||||
<p class="text-xs text-gray-500">Inactive users cannot log in</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Password (Optional) -->
|
||||
<div class="border-t border-gray-200 pt-4 mt-4">
|
||||
<h4 class="text-sm font-semibold text-gray-900 mb-3">Change Password (Optional)</h4>
|
||||
|
||||
<div>
|
||||
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
<label for="is_active" class="text-sm font-medium text-gray-700">
|
||||
Active Account
|
||||
</label>
|
||||
<p class="text-xs text-gray-500">Inactive users cannot log in to the system</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Password Section -->
|
||||
<div class="border-t border-gray-200 pt-5 mt-5">
|
||||
<h3 class="text-sm font-semibold text-gray-900 mb-4 flex items-center">
|
||||
<i class="fas fa-lock text-gray-400 mr-2"></i>
|
||||
Change Password
|
||||
</h3>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<!-- New Password -->
|
||||
<div>
|
||||
<label for="password" class="block text-sm font-medium text-gray-700 mb-1.5">
|
||||
New Password
|
||||
</label>
|
||||
<input type="password" id="password" name="password" minlength="8"
|
||||
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary">
|
||||
<p class="text-xs text-gray-500 mt-1">Leave blank to keep current password. Minimum 8 characters if changing.</p>
|
||||
<div class="relative">
|
||||
<input type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
minlength="8"
|
||||
class="w-full px-3 py-2.5 pr-10 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
|
||||
placeholder="••••••••">
|
||||
<button type="button"
|
||||
onclick="togglePassword('password')"
|
||||
class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600">
|
||||
<i class="fas fa-eye text-sm" id="password-toggle-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
<p class="mt-1.5 text-xs text-gray-500">
|
||||
Leave blank to keep current password
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Account Info -->
|
||||
<div class="bg-gray-50 border border-gray-200 rounded-lg p-3 mt-4">
|
||||
<div class="grid grid-cols-2 gap-3 text-xs">
|
||||
<!-- Confirm Password -->
|
||||
<div>
|
||||
<span class="text-gray-600">Email Verified:</span>
|
||||
<span class="font-semibold <?= $user['email_verified'] ? 'text-green-600' : 'text-red-600' ?>">
|
||||
<?= $user['email_verified'] ? 'Yes' : 'No' ?>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-gray-600">Member Since:</span>
|
||||
<span class="font-semibold text-gray-900">
|
||||
<?= date('M d, Y', strtotime($user['created_at'])) ?>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-gray-600">Last Login:</span>
|
||||
<span class="font-semibold text-gray-900">
|
||||
<?= $user['last_login'] ? date('M d, Y H:i', strtotime($user['last_login'])) : 'Never' ?>
|
||||
</span>
|
||||
<label for="password_confirm" class="block text-sm font-medium text-gray-700 mb-1.5">
|
||||
Confirm Password
|
||||
</label>
|
||||
<div class="relative">
|
||||
<input type="password"
|
||||
id="password_confirm"
|
||||
name="password_confirm"
|
||||
minlength="8"
|
||||
class="w-full px-3 py-2.5 pr-10 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-primary transition-colors text-sm"
|
||||
placeholder="••••••••">
|
||||
<button type="button"
|
||||
onclick="togglePassword('password_confirm')"
|
||||
class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600">
|
||||
<i class="fas fa-eye text-sm" id="password_confirm-toggle-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
<p class="mt-1.5 text-xs text-gray-500">
|
||||
Re-enter the new password to confirm
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 border-t border-gray-200 bg-gray-50 flex items-center justify-between">
|
||||
<a href="/users" class="text-gray-600 hover:text-gray-800 text-sm font-medium">
|
||||
<i class="fas fa-arrow-left mr-1"></i> Cancel
|
||||
</a>
|
||||
<button type="submit" class="inline-flex items-center px-4 py-2.5 bg-primary text-white text-sm rounded-lg hover:bg-primary-dark transition-colors font-medium">
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex flex-col sm:flex-row gap-3 pt-3">
|
||||
<button type="submit"
|
||||
class="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-save mr-2"></i>
|
||||
Update User
|
||||
</button>
|
||||
<a href="/users"
|
||||
class="inline-flex items-center justify-center px-5 py-2.5 border border-gray-300 text-gray-700 rounded-lg font-medium hover:bg-gray-50 transition-colors text-sm">
|
||||
<i class="fas fa-times mr-2"></i>
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Account Info Section -->
|
||||
<div class="mt-4 bg-blue-50 border border-blue-200 rounded-lg p-4">
|
||||
<div class="flex items-start">
|
||||
<div class="flex-shrink-0">
|
||||
<div class="w-10 h-10 bg-blue-500 rounded-lg flex items-center justify-center">
|
||||
<i class="fas fa-info-circle text-white"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-semibold text-gray-900 mb-1">Account Details</h3>
|
||||
<ul class="text-xs text-gray-600 space-y-1">
|
||||
<li class="flex items-center">
|
||||
<i class="fas fa-circle text-blue-500" style="font-size: 6px;"></i>
|
||||
<span class="ml-2">Email Verified:
|
||||
<span class="font-semibold <?= $user['email_verified'] ? 'text-green-600' : 'text-red-600' ?>">
|
||||
<?= $user['email_verified'] ? 'Yes' : 'No' ?>
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="flex items-center">
|
||||
<i class="fas fa-circle text-blue-500" style="font-size: 6px;"></i>
|
||||
<span class="ml-2">Member Since:
|
||||
<span class="font-semibold text-gray-900"><?= date('M d, Y', strtotime($user['created_at'])) ?></span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="flex items-center">
|
||||
<i class="fas fa-circle text-blue-500" style="font-size: 6px;"></i>
|
||||
<span class="ml-2">Last Login:
|
||||
<span class="font-semibold text-gray-900"><?= $user['last_login'] ? date('M d, Y H:i', strtotime($user['last_login'])) : 'Never' ?></span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function togglePassword(fieldId) {
|
||||
const field = document.getElementById(fieldId);
|
||||
const icon = document.getElementById(fieldId + '-toggle-icon');
|
||||
|
||||
if (field.type === 'password') {
|
||||
field.type = 'text';
|
||||
icon.classList.remove('fa-eye');
|
||||
icon.classList.add('fa-eye-slash');
|
||||
} else {
|
||||
field.type = 'password';
|
||||
icon.classList.remove('fa-eye-slash');
|
||||
icon.classList.add('fa-eye');
|
||||
}
|
||||
}
|
||||
|
||||
// Password confirmation validation
|
||||
document.getElementById('password_confirm').addEventListener('input', function() {
|
||||
const password = document.getElementById('password').value;
|
||||
const confirm = this.value;
|
||||
|
||||
if (confirm && password !== confirm) {
|
||||
this.setCustomValidity('Passwords do not match');
|
||||
this.classList.add('border-red-300');
|
||||
this.classList.remove('border-gray-300');
|
||||
} else {
|
||||
this.setCustomValidity('');
|
||||
this.classList.remove('border-red-300');
|
||||
this.classList.add('border-gray-300');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
require __DIR__ . '/../layout/base.php';
|
||||
?>
|
||||
|
||||
|
||||
@@ -230,7 +230,18 @@ $pagination = $pagination ?? [
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<div class="text-sm text-gray-900"><?= htmlspecialchars($user['username']) ?></div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-sm text-gray-900"><?= htmlspecialchars($user['username']) ?></span>
|
||||
<?php if (!empty($user['two_factor_enabled'])): ?>
|
||||
<span class="inline-flex items-center px-1.5 py-0.5 bg-green-100 text-green-700 rounded text-[10px] font-semibold border border-green-200" title="Two-factor authentication enabled">
|
||||
<i class="fas fa-shield-alt mr-0.5"></i>2FA
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<span class="inline-flex items-center px-1.5 py-0.5 bg-gray-100 text-gray-400 rounded text-[10px] font-medium border border-gray-200" title="Two-factor authentication not enabled">
|
||||
<i class="fas fa-shield-alt mr-0.5"></i>No 2FA
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-semibold border
|
||||
|
||||
@@ -102,9 +102,14 @@ $stats = [
|
||||
'in_app_notifications_created' => 0,
|
||||
'domains_with_notifications' => 0,
|
||||
'notification_groups_used' => [],
|
||||
'domains_notified' => []
|
||||
'domains_notified' => [],
|
||||
'status_changes' => 0,
|
||||
'status_notifications_sent' => 0
|
||||
];
|
||||
|
||||
// Get notification status triggers from settings
|
||||
$statusTriggers = $settingModel->getNotificationStatusTriggers();
|
||||
|
||||
// Retry queue: domains that failed due to rate limiting
|
||||
$retryQueue = [];
|
||||
|
||||
@@ -180,34 +185,194 @@ foreach ($domains as $domain) {
|
||||
$stats['checked']++;
|
||||
$stats['updated']++;
|
||||
|
||||
// Detect status change
|
||||
$oldStatus = $domain['status'];
|
||||
logMessage(" ✓ Updated WHOIS data for $domainName");
|
||||
logMessage(" Expiration: " . ($whoisData['expiration_date'] ?? 'N/A') . ", Status: $status");
|
||||
logMessage(" Expiration: " . ($whoisData['expiration_date'] ?? 'N/A') . ", Status: $status" . ($oldStatus !== $status ? " (was: $oldStatus)" : ""));
|
||||
|
||||
// Add a small delay between domain checks to avoid rate limiting
|
||||
// This helps especially with .nl and other TLDs that have strict rate limits
|
||||
usleep(1000000); // 1 second delay between checks
|
||||
|
||||
// Check if notifications should be sent
|
||||
// ============================================================
|
||||
// STATUS CHANGE NOTIFICATIONS
|
||||
// ============================================================
|
||||
// Check if the domain status has changed and if the new status
|
||||
// is in the configured notification triggers
|
||||
$statusChanged = ($oldStatus !== $status);
|
||||
$statusNotificationType = null;
|
||||
|
||||
if ($statusChanged) {
|
||||
$stats['status_changes']++;
|
||||
logMessage(" 🔄 Status changed: $oldStatus → $status");
|
||||
|
||||
// Determine the notification trigger type for this status change
|
||||
// 'registered' trigger fires when status changes TO 'active' FROM certain statuses
|
||||
if ($status === 'available' && in_array('available', $statusTriggers)) {
|
||||
$statusNotificationType = 'domain_available';
|
||||
} elseif ($status === 'active' && in_array($oldStatus, ['available', 'expired', 'pending_delete', 'redemption_period', 'error']) && in_array('registered', $statusTriggers)) {
|
||||
$statusNotificationType = 'domain_registered';
|
||||
} elseif ($status === 'expired' && $oldStatus !== 'error' && in_array('expired', $statusTriggers)) {
|
||||
$statusNotificationType = 'domain_expired_status';
|
||||
} elseif ($status === 'redemption_period' && in_array('redemption_period', $statusTriggers)) {
|
||||
$statusNotificationType = 'domain_redemption';
|
||||
} elseif ($status === 'pending_delete' && in_array('pending_delete', $statusTriggers)) {
|
||||
$statusNotificationType = 'domain_pending_delete';
|
||||
}
|
||||
}
|
||||
|
||||
// Send status change notifications (both external and in-app)
|
||||
if ($statusNotificationType) {
|
||||
logMessage(" 📢 Status notification triggered: $statusNotificationType");
|
||||
|
||||
$domainData = $domainModel->find($domain['id']);
|
||||
|
||||
// --- External notifications (channels) ---
|
||||
if ($domain['notification_group_id']) {
|
||||
if (!$logModel->wasSentRecently($domain['id'], $statusNotificationType, 23)) {
|
||||
$channels = $channelModel->getActiveByGroupId($domain['notification_group_id']);
|
||||
|
||||
if (!empty($channels)) {
|
||||
logMessage(" 📤 Sending status change alerts to " . count($channels) . " channel(s)");
|
||||
|
||||
$results = $notificationService->sendDomainStatusAlert($domainData, $channels, $status, $oldStatus);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$success = $result['success'];
|
||||
$channel = $result['channel'];
|
||||
|
||||
if ($success) {
|
||||
logMessage(" ✓ Sent to $channel");
|
||||
$stats['status_notifications_sent']++;
|
||||
$stats['notifications_sent']++;
|
||||
} else {
|
||||
logMessage(" ✗ Failed to send to $channel");
|
||||
}
|
||||
|
||||
$logModel->log(
|
||||
$domain['id'],
|
||||
$statusNotificationType,
|
||||
$channel,
|
||||
"Domain $domainName status changed: $oldStatus → $status",
|
||||
$success,
|
||||
$success ? null : "Failed to send notification"
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logMessage(" → Status notification already sent recently (skipping external alerts)");
|
||||
}
|
||||
}
|
||||
|
||||
// --- In-app notifications (bell icon) ---
|
||||
$isolationMode = $settingModel->getValue('user_isolation_mode', 'shared');
|
||||
$usersToNotify = [];
|
||||
|
||||
if ($isolationMode === 'isolated') {
|
||||
$notificationUserId = null;
|
||||
if (!empty($domainData['user_id'])) {
|
||||
$notificationUserId = $domainData['user_id'];
|
||||
} elseif (!empty($domain['notification_group_id'])) {
|
||||
$group = $groupModel->find($domain['notification_group_id']);
|
||||
if ($group && !empty($group['user_id'])) {
|
||||
$notificationUserId = $group['user_id'];
|
||||
}
|
||||
}
|
||||
if ($notificationUserId) {
|
||||
$usersToNotify[] = $notificationUserId;
|
||||
}
|
||||
} else {
|
||||
$allUsers = $userModel->where('is_active', 1);
|
||||
foreach ($allUsers as $user) {
|
||||
$usersToNotify[] = $user['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($usersToNotify)) {
|
||||
$notifiedCount = 0;
|
||||
|
||||
foreach ($usersToNotify as $userId) {
|
||||
// Check for duplicate in-app notification
|
||||
$db = \Core\Database::getConnection();
|
||||
$stmt = $db->prepare(
|
||||
"SELECT COUNT(*) as count FROM user_notifications
|
||||
WHERE user_id = ? AND domain_id = ? AND type = ?
|
||||
AND created_at >= DATE_SUB(NOW(), INTERVAL 23 HOUR)"
|
||||
);
|
||||
$stmt->execute([$userId, $domain['id'], $statusNotificationType]);
|
||||
$result = $stmt->fetch();
|
||||
|
||||
if ($result && $result['count'] > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
match($statusNotificationType) {
|
||||
'domain_available' => $notificationService->notifyDomainAvailable($userId, $domainName, $domain['id']),
|
||||
'domain_registered' => $notificationService->notifyDomainRegistered($userId, $domainName, $domain['id']),
|
||||
'domain_expired_status' => $notificationService->notifyDomainExpired($userId, $domainName, $domain['id']),
|
||||
'domain_redemption' => $notificationService->notifyDomainRedemption($userId, $domainName, $domain['id']),
|
||||
'domain_pending_delete' => $notificationService->notifyDomainPendingDelete($userId, $domainName, $domain['id']),
|
||||
default => null
|
||||
};
|
||||
$notifiedCount++;
|
||||
} catch (Exception $e) {
|
||||
logMessage(" ⚠ Failed to create status notification for user $userId: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if ($notifiedCount > 0) {
|
||||
logMessage(" 🔔 Created status change notifications for $notifiedCount user(s)");
|
||||
$stats['in_app_notifications_created'] += $notifiedCount;
|
||||
$stats['domains_with_notifications']++;
|
||||
|
||||
$stats['domains_notified'][] = [
|
||||
'domain' => $domainName,
|
||||
'days_left' => null,
|
||||
'users_notified' => $notifiedCount,
|
||||
'has_group' => !empty($domain['notification_group_id']),
|
||||
'group_id' => $domain['notification_group_id'] ?? null,
|
||||
'status_change' => "$oldStatus → $status"
|
||||
];
|
||||
|
||||
if (!empty($domain['notification_group_id'])) {
|
||||
$groupId = $domain['notification_group_id'];
|
||||
if (!isset($stats['notification_groups_used'][$groupId])) {
|
||||
$stats['notification_groups_used'][$groupId] = 0;
|
||||
}
|
||||
$stats['notification_groups_used'][$groupId]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// EXPIRATION-BASED NOTIFICATIONS (existing logic)
|
||||
// ============================================================
|
||||
// Check if notifications should be sent based on days until expiration
|
||||
$daysLeft = $whoisService->daysUntilExpiration($whoisData['expiration_date']);
|
||||
|
||||
if ($daysLeft === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if this domain should trigger a notification
|
||||
// Check if this domain should trigger an expiration notification
|
||||
$shouldNotify = false;
|
||||
$notificationType = '';
|
||||
|
||||
if ($daysLeft <= 0) {
|
||||
// Only send expiration notification if we didn't already send a status change expired notification
|
||||
if ($statusNotificationType !== 'domain_expired_status') {
|
||||
$shouldNotify = true;
|
||||
$notificationType = 'expired';
|
||||
}
|
||||
} elseif (in_array($daysLeft, $notificationDays)) {
|
||||
$shouldNotify = true;
|
||||
$notificationType = "expiring_in_{$daysLeft}_days";
|
||||
}
|
||||
|
||||
if (!$shouldNotify) {
|
||||
logMessage(" → No notification needed ($daysLeft days left)");
|
||||
logMessage(" → No expiration notification needed ($daysLeft days left)");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -646,6 +811,8 @@ $formattedTime = formatElapsedTime($elapsedTime);
|
||||
logMessage("\n=== Cron job completed ===");
|
||||
logMessage("Domains checked: {$stats['checked']}");
|
||||
logMessage("Domains updated: {$stats['updated']}");
|
||||
logMessage("Status changes detected: {$stats['status_changes']}");
|
||||
logMessage("Status notifications sent: {$stats['status_notifications_sent']}");
|
||||
logMessage("External notifications sent: {$stats['notifications_sent']}");
|
||||
logMessage("In-app notifications created: {$stats['in_app_notifications_created']}");
|
||||
logMessage("Domains with notifications: {$stats['domains_with_notifications']}");
|
||||
|
||||
@@ -141,7 +141,7 @@ CREATE TABLE IF NOT EXISTS domains (
|
||||
updated_date DATE,
|
||||
abuse_email VARCHAR(255),
|
||||
last_checked TIMESTAMP NULL,
|
||||
status ENUM('active', 'expiring_soon', 'expired', 'error', 'available') DEFAULT 'active',
|
||||
status ENUM('active', 'expiring_soon', 'expired', 'error', 'available', 'redemption_period', 'pending_delete') DEFAULT 'active',
|
||||
whois_data JSON,
|
||||
notes TEXT,
|
||||
is_active BOOLEAN DEFAULT TRUE,
|
||||
@@ -362,7 +362,7 @@ INSERT INTO settings (setting_key, setting_value, `type`, `description`) VALUES
|
||||
('app_name', 'Domain Monitor', 'string', 'Application name'),
|
||||
('app_url', 'http://localhost:8000', 'string', 'Application URL'),
|
||||
('app_timezone', 'UTC', 'string', 'Application timezone'),
|
||||
('app_version', '1.1.1', 'string', 'Application version number'),
|
||||
('app_version', '1.1.2', 'string', 'Application version number'),
|
||||
|
||||
-- Email settings
|
||||
('mail_host', 'smtp.mailtrap.io', 'string', 'SMTP server host'),
|
||||
@@ -375,6 +375,7 @@ INSERT INTO settings (setting_key, setting_value, `type`, `description`) VALUES
|
||||
|
||||
-- Monitoring settings
|
||||
('notification_days_before', '60,30,21,14,7,5,3,2,1', 'string', 'Notification days before expiration'),
|
||||
('notification_status_triggers', 'available,registered,expired,redemption_period,pending_delete', 'string', 'Domain status changes that trigger notifications'),
|
||||
('check_interval_hours', '24', 'string', 'Domain check interval in hours'),
|
||||
('last_check_run', NULL, 'datetime', 'Last time cron job ran'),
|
||||
|
||||
|
||||
20
database/migrations/024_add_status_notifications_v1.1.2.sql
Normal file
20
database/migrations/024_add_status_notifications_v1.1.2.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- Migration: Add status-based notifications and new domain lifecycle statuses
|
||||
-- Version: 1.1.2
|
||||
-- This migration adds support for notifications based on domain status changes:
|
||||
-- available, registered, expired, redemption_period, pending_delete
|
||||
|
||||
-- 1. Expand domain status ENUM to include redemption_period and pending_delete
|
||||
ALTER TABLE domains MODIFY COLUMN status
|
||||
ENUM('active', 'expiring_soon', 'expired', 'error', 'available', 'redemption_period', 'pending_delete')
|
||||
DEFAULT 'active';
|
||||
|
||||
-- 2. Add setting for notification status triggers (which status changes trigger notifications)
|
||||
INSERT INTO settings (setting_key, setting_value, created_at, updated_at)
|
||||
VALUES ('notification_status_triggers', 'available,registered,expired,redemption_period,pending_delete', NOW(), NOW())
|
||||
ON DUPLICATE KEY UPDATE setting_key = setting_key;
|
||||
|
||||
-- 3. Update application version to 1.1.2
|
||||
UPDATE settings
|
||||
SET setting_value = '1.1.2'
|
||||
WHERE setting_key = 'app_version';
|
||||
|
||||
Reference in New Issue
Block a user