36163-vm/message_template.php
2025-11-24 05:17:23 +00:00

23 lines
1.4 KiB
PHP

<?php
$is_sender = $msg['username'] === $current_username;
?>
<div class="flex items-start gap-3 <?= $is_sender ? 'justify-end' : '' ?>">
<?php if (!$is_sender): ?><img src="https://i.pravatar.cc/40?u=<?= htmlspecialchars($msg['username']) ?>" alt="Avatar" class="w-10 h-10 rounded-full"><?php endif; ?>
<div class="<?= $is_sender ? 'bg-primary text-white' : 'bg-white dark:bg-input-bg-dark' ?> p-3 rounded-lg max-w-lg shadow">
<p class="text-sm font-bold mb-1"><?= htmlspecialchars($msg['username']) ?></p>
<?php if (!empty($msg['message'])): ?>
<p class="text-sm"><?= nl2br(htmlspecialchars($msg['message'])) ?></p>
<?php endif; ?>
<?php if ($msg['has_attachment']): ?>
<div class="mt-2">
<a href="<?= htmlspecialchars($msg['file_path']) ?>" target="_blank" class="text-blue-500 hover:underline">
<?= htmlspecialchars($msg['file_name']) ?>
</a>
<span class="text-xs text-gray-500">(${(round($msg['file_size'] / 1024 / 1024, 2))}) MB)</span>
</div>
<?php endif; ?>
<span class="text-xs <?= $is_sender ? 'text-blue-200' : 'text-gray-400' ?> mt-1 block text-right"><?= date('h:i A', strtotime($msg['created_at'])) ?></span>
</div>
<?php if ($is_sender): ?><img src="https://i.pravatar.cc/40?u=<?= htmlspecialchars($current_username) ?>" alt="My Avatar" class="w-10 h-10 rounded-full"><?php endif; ?>
</div>