:: **Zploit** v1.0 | Current Path: **/home/iictguj2/indiadealfinder.com/public_html/**
:: Editing File: index.php
<?php include('includes/db.php'); ?> <?php include('header.php'); ?> <div class="container"> <h1>Latest Deals & Freebies</h1> <style> .container { max-width: 1200px; margin: auto; padding: 20px; font-family: Arial, sans-serif; } .deals-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; } @media (max-width: 992px) { .deals-grid { grid-template-columns: repeat(3, 1fr); } } @media (max-width: 600px) { .deals-grid { grid-template-columns: repeat(2, 1fr); } } .deal-card { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.1); padding: 15px; display: flex; flex-direction: column; transition: box-shadow 0.3s ease; height: 100%; } .deal-card:hover { box-shadow: 0 5px 15px rgb(0 0 0 / 0.15); } .deal-image { width: 100%; height: 160px; object-fit: cover; border-radius: 6px; margin-bottom: 12px; } .deal-title { font-size: 16px; margin: 0 0 10px 0; color: #333; flex-shrink: 0; } .deal-description { flex-grow: 1; font-size: 14px; color: #555; margin-bottom: 10px; overflow: hidden; max-height: 48px; } .deal-category, .deal-expires { font-size: 12px; color: #999; margin-bottom: 8px; } .grab-deal-btn { background-color: #007bff; color: #fff; padding: 10px 12px; border: none; border-radius: 5px; font-weight: bold; cursor: pointer; text-align: center; text-decoration: none; transition: background-color 0.3s ease; user-select: none; } .grab-deal-btn:hover { background-color: #0056b3; } .like-btn { background: none; border: none; color: #007bff; cursor: pointer; font-size: 14px; padding: 0; margin-bottom: 10px; } .like-btn:hover { text-decoration: underline; } .pagination { margin-top: 30px; text-align: center; } .pagination a { display: inline-block; padding: 8px 12px; margin: 0 4px; background: #007bff; color: white; border-radius: 4px; text-decoration: none; } .pagination a:hover { background: #0056b3; } .pagination .current-page { font-weight: bold; background: #0056b3; } .price-info { font-size: 14px; margin-bottom: 10px; } .price-info .strike { text-decoration: line-through; color: #999; } .price-info .deal-price { font-weight: bold; color: #28a745; } .price-info .discount { background: #dc3545; color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 13px; display: inline-block; } .strike { text-decoration: line-through; color: #999; } </style> <?php function truncateTitle($text, $maxWords = 12, $maxChars = 48) { $text = html_entity_decode($text); $words = preg_split('/\s+/', $text); if (count($words) > $maxWords) { $words = array_slice($words, 0, $maxWords); $truncated = implode(' ', $words); if (strlen($truncated) > $maxChars) { $truncated = mb_substr($truncated, 0, $maxChars); $truncated = rtrim($truncated); } return htmlspecialchars($truncated) . '...'; } else { if (strlen($text) > $maxChars) { $truncated = mb_substr($text, 0, $maxChars); $truncated = rtrim($truncated); return htmlspecialchars($truncated) . '...'; } else { return htmlspecialchars($text); } } } $limit = 20; $page = isset($_GET['page']) && is_numeric($_GET['page']) ? intval($_GET['page']) : 1; $offset = ($page - 1) * $limit; // Count total active deals $countRes = $conn->query("SELECT COUNT(*) AS total FROM deals WHERE is_active = 1"); $totalDeals = $countRes->fetch_assoc()['total']; $totalPages = ceil($totalDeals / $limit); $sql = "SELECT deals.*, categories.name AS category FROM deals LEFT JOIN categories ON deals.category_id = categories.id WHERE is_active = 1 ORDER BY created_at DESC LIMIT $limit OFFSET $offset"; $result = $conn->query($sql); ?> <div class="deals-grid"> <?php if ($result->num_rows > 0): ?> <?php while ($row = $result->fetch_assoc()): ?> <?php if (empty($row['expires_at'])) { // Check if the deal is older than 7 days from the created_at $created_at = strtotime($row['created_at']); $now = time(); $diff = $now - $created_at; if ($diff > (7 * 24 * 60 * 60)) { // 7 days in seconds $expire_str = "<span style='color:red;'>Expired</span>"; } else { $expire_str = "<span style='color:green;'>Soon</span>"; } } else { $expires = strtotime($row['expires_at']); $now = time(); $diff = $expires - $now; if ($diff > 0) { $days = floor($diff / (60 * 60 * 24)); $hours = floor(($diff % (60 * 60 * 24)) / 3600); $mins = floor(($diff % 3600) / 60); $expire_str = "{$days}d {$hours}h {$mins}m left"; } else { $expire_str = "<span style='color:red;'>Expired</span>"; } } // Handle image URL (absolute or relative) $image = ''; if (!empty($row['image'])) { if (strpos($row['image'], 'http://') === 0 || strpos($row['image'], 'https://') === 0) { $image = htmlspecialchars($row['image']); } else { $image = 'uploads/' . htmlspecialchars($row['image']); } } else { $image = 'placeholder.jpg'; // fallback } // Handle affiliate URL prefix removal $affiliate_url = $row['affiliate_url'] ?? ''; $prefix = 'https://dealofthedayindia.com/go.php?'; if (strpos($affiliate_url, $prefix) === 0) { $affiliate_url = substr($affiliate_url, strlen($prefix)); } ?> <div class="deal-card"> <img class="deal-image" src="<?= $image ?>" alt="<?= truncateTitle($row['title']) ?>" loading="lazy" /> <h2 class="deal-title"> <a href="deal.php?id=<?= $row['id'] ?>" style="color: inherit; text-decoration: none;"> <?= truncateTitle($row['title']) ?> </a> </h2> <p class="deal-description"><?= htmlspecialchars(html_entity_decode(substr(strip_tags($row['description']), 0, 150))) ?>...</p> <p class="deal-category"><strong>Category:</strong> <?= htmlspecialchars($row['category']) ?></p> <p class="deal-expires"><strong>Expires In:</strong> <?= $expire_str ?></p> <?php if ($row['mrp_price'] && $row['deal_price']): ?> <div class="price-info"> <p><strong>MRP:</strong> <span class="strike">₹<?= number_format($row['mrp_price'], 2) ?></span></p> <p><strong>Deal Price:</strong> <span class="deal-price">₹<?= number_format($row['deal_price'], 2) ?></span></p> <?php if ($row['discount_percent']): ?> <p><strong>Discount:</strong> <span class="discount"><?= $row['discount_percent'] ?>% OFF</span></p> <?php endif; ?> </div> <?php endif; ?> <button class="like-btn" data-id="<?= $row['id'] ?>">👍 Like (<span id="like-count-<?= $row['id'] ?>"><?= $row['likes'] ?></span>)</button> <a href="<?= htmlspecialchars($affiliate_url) ?>" target="_blank" rel="noopener noreferrer" class="grab-deal-btn">Grab Deal</a> </div> <?php endwhile; ?> <?php else: ?> <p>No deals available.</p> <?php endif; ?> </div> <!-- Pagination --> <div class="pagination"> <?php if ($page > 1): ?> <a href="?page=<?= $page - 1 ?>">« Prev</a> <?php endif; ?> <?php for ($i = 1; $i <= $totalPages; $i++): ?> <?php $url = ($i === 1) ? '/' : '?page=' . $i; $current = ($i === $page) ? 'current-page' : ''; ?> <a href="<?= $url ?>" class="<?= $current ?>"><?= $i ?></a> <?php endfor; ?> <?php if ($page < $totalPages): ?> <a href="?page=<?= $page + 1 ?>">Next »</a> <?php endif; ?> </div> </div> <?php include('footer.php'); include('scheduled.php'); ?> <!-- Like Button AJAX --> <script> document.querySelectorAll('.like-btn').forEach(btn => { btn.addEventListener('click', function () { const dealId = this.getAttribute('data-id'); fetch('like.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: 'deal_id=' + dealId }) .then(response => response.text()) .then(data => { document.getElementById('like-count-' + dealId).textContent = data; }); }); }); </script>