:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/demo/soulmeetvivah.com/member/php/**
:: Editing File: inbox.php
<?php include('header.php'); ?> <style> .upgrade_link_url { color: #cd4252; text-decoration: none; font-weight: 600; } .upgrade_link_url:hover { color: #b83847; text-decoration: underline; } </style> <div style="height: 100px;"></div> <div class="page-content"> <div class="container"> <!-- Inbox Header --> <div class="block-box user-about mb-4"> <div class="widget-heading" style="background: linear-gradient(135deg, #cd4252 0%, #b83847 100%); padding: 20px; border-radius: 15px 15px 0 0;"> <h3 style="color: #fff; margin: 0; font-size: 24px; font-weight: 600;"> <i class="icofont-envelope" style="margin-right: 10px;"></i>Your Inbox </h3> </div> </div> <!-- Loading Spinner --> <div id="inbox-loading" class="text-center py-5" style="display: none;"> <div class="spinner-border text-danger" role="status" style="width: 3rem; height: 3rem;"> <span class="visually-hidden">Loading...</span> </div> <p class="mt-3 text-muted">Loading conversations...</p> </div> <!-- Inbox Container --> <div id="inbox-container" class="row"> <!-- Messages will be inserted here --> </div> <!-- Empty State --> <div id="inbox-empty" class="text-center py-5" style="display: none;"> <div class="block-box user-about"> <div class="widget-heading text-center py-5"> <i class="icofont-envelope-open" style="font-size: 80px; color: #ddd; margin-bottom: 20px;"></i> <h4 style="color: #999; font-weight: 400;">No messages yet</h4> <p style="color: #bbb; margin-top: 10px;">Start a conversation by viewing someone's profile!</p> </div> </div> </div> </div> </div> <input type="hidden" id="user_id" value="<?= $_SESSION['user_id'] ?>"> <style> body { background-color: #f5f5f5; } /* Inbox Card Styles */ .inbox-card { background: #fff; border-radius: 15px; box-shadow: 0 3px 15px rgba(0,0,0,0.08); margin-bottom: 20px; transition: all 0.3s ease; cursor: pointer; overflow: hidden; border: 2px solid transparent; } .inbox-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(205, 66, 82, 0.15); border-color: #cd4252; } .inbox-card.unread { background: linear-gradient(90deg, #fff 0%, #fffef7 100%); border-left: 4px solid #cd4252; } .inbox-card-content { padding: 20px; display: flex; align-items: center; gap: 20px; } /* Avatar Styles */ .inbox-avatar { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; border: 3px solid #cd4252; box-shadow: 0 3px 10px rgba(205, 66, 82, 0.2); flex-shrink: 0; } /* Message Info Styles */ .inbox-message-info { flex: 1; min-width: 0; } .inbox-name { font-size: 18px; font-weight: 600; color: #333; margin: 0 0 8px 0; display: flex; align-items: center; gap: 10px; } .inbox-name .unread-badge { display: inline-block; width: 10px; height: 10px; background: #cd4252; border-radius: 50%; animation: pulse 2s infinite; } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } } .inbox-message-preview { font-size: 14px; color: #666; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.5; } .inbox-message-preview.locked { color: #cd4252; font-style: italic; } /* Time Styles */ .inbox-time { text-align: right; flex-shrink: 0; min-width: 100px; } .inbox-time-text { font-size: 12px; color: #999; margin-bottom: 8px; display: block; } .inbox-action-btn { background: #cd4252; color: #fff; border: none; padding: 8px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; text-decoration: none; display: inline-block; } .inbox-action-btn:hover { background: #b83847; color: #fff; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(205, 66, 82, 0.3); } .inbox-action-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; } /* Responsive Styles */ @media (max-width: 768px) { .inbox-card-content { flex-direction: column; text-align: center; } .inbox-avatar { width: 60px; height: 60px; } .inbox-time { text-align: center; width: 100%; } .inbox-name { justify-content: center; } } /* Sent by me indicator */ .sent-by-me { font-size: 11px; color: #999; font-style: italic; margin-top: 4px; } </style> <script> const receiver_id = document.getElementById("user_id").value; const inboxContainer = document.getElementById("inbox-container"); const inboxLoading = document.getElementById("inbox-loading"); const inboxEmpty = document.getElementById("inbox-empty"); function formatTime(timestamp) { const date = new Date(timestamp); const now = new Date(); const diff = now - date; const seconds = Math.floor(diff / 1000); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); if (days > 7) { return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: date.getFullYear() !== now.getFullYear() ? 'numeric' : undefined }); } else if (days > 0) { return `${days} day${days > 1 ? 's' : ''} ago`; } else if (hours > 0) { return `${hours} hour${hours > 1 ? 's' : ''} ago`; } else if (minutes > 0) { return `${minutes} minute${minutes > 1 ? 's' : ''} ago`; } else { return 'Just now'; } } function getProfileImageUrl(profileImg) { if (!profileImg || profileImg === 'default.jpg') { return '../admin/images/members/default.jpg'; } return '../admin/images/members/' + profileImg; } function loadInbox() { inboxLoading.style.display = 'block'; inboxContainer.innerHTML = ''; inboxEmpty.style.display = 'none'; const fd = new FormData(); fd.append("receiver_id", receiver_id); fetch("php/chat/fetch_inbox_users.php", { method: "POST", body: fd }) .then(r => r.json()) .then(data => { inboxLoading.style.display = 'none'; if (data.status === "success" && data.inbox && data.inbox.length > 0) { data.inbox.forEach(row => { const time = formatTime(row.timestamp); const name = `${row.first_name} ${row.last_name}`; const profileImg = getProfileImageUrl(row.profile_img); const isUnread = !row.sent_by_me && row.is_read === 0; let messagePreview = ''; if (row.allowed) { // Strip HTML tags and truncate const textContent = row.message.replace(/<[^>]*>/g, ''); messagePreview = textContent.length > 60 ? textContent.substring(0, 60) + '...' : textContent; } else { messagePreview = '🔒 Upgrade your plan to view this message'; } const cardClass = isUnread ? 'inbox-card unread' : 'inbox-card'; const messageClass = row.allowed ? 'inbox-message-preview' : 'inbox-message-preview locked'; inboxContainer.insertAdjacentHTML("beforeend", ` <div class="col-lg-6 col-md-12"> <div class="${cardClass}" onclick="window.location.href='profile?uid=${row.user_id}'"> <div class="inbox-card-content"> <img src="${profileImg}" alt="${name}" class="inbox-avatar" onerror="this.src='../admin/images/members/default.jpg'"> <div class="inbox-message-info"> <h5 class="inbox-name"> ${name} ${isUnread ? '<span class="unread-badge"></span>' : ''} </h5> <p class="${messageClass}">${messagePreview}</p> ${row.sent_by_me ? '<span class="sent-by-me">Sent by you</span>' : ''} </div> <div class="inbox-time"> <span class="inbox-time-text">${time}</span> <a href="profile?uid=${row.user_id}" class="inbox-action-btn" ${row.allowed ? "" : "disabled"} onclick="event.stopPropagation();"> View </a> </div> </div> </div> </div> `); }); } else { inboxEmpty.style.display = 'block'; } }) .catch(error => { inboxLoading.style.display = 'none'; inboxContainer.innerHTML = ` <div class="col-12"> <div class="alert alert-danger" role="alert"> <i class="icofont-warning"></i> An error occurred while loading your inbox. Please try again. </div> </div> `; console.error('Error loading inbox:', error); }); } // Auto-refresh inbox every 30 seconds document.addEventListener("DOMContentLoaded", function() { loadInbox(); setInterval(loadInbox, 30000); }); </script> <?php include('footer.php'); ?>