hjkhjkjhkhjkgjghjhgjhgjghjhghjghjhgjjnbvnvbnvk
bnmbnmbnhjkhjkhjkhjktyutyutyuytutyutyutyhgjgjghjgjghjguytutyry
/
home
/
wjcvelqp
/
biblog
/
Upload FileeE
HOME
<?php require_once 'config/database.php'; require_once 'includes/functions.php'; // Top 3 Latest Posts for Scrolling $stmt = $pdo->query("SELECT p.*, c.name as category_name FROM posts p LEFT JOIN categories c ON p.category_id = c.id ORDER BY p.created_at DESC LIMIT 3"); $top_posts = $stmt->fetchAll(PDO::FETCH_ASSOC); // All Latest Posts $stmt = $pdo->query("SELECT p.*, c.name as category_name FROM posts p LEFT JOIN categories c ON p.category_id = c.id ORDER BY p.created_at DESC LIMIT 12"); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); // Trending & Most Read $trending = $pdo->query("SELECT p.*, c.name as category_name FROM posts p LEFT JOIN categories c ON p.category_id = c.id ORDER BY p.views DESC, p.likes DESC LIMIT 8")->fetchAll(PDO::FETCH_ASSOC); $most_read = $pdo->query("SELECT p.*, c.name as category_name FROM posts p LEFT JOIN categories c ON p.category_id = c.id ORDER BY p.views DESC LIMIT 6")->fetchAll(PDO::FETCH_ASSOC); $categories = getCategories($pdo); ?> <?php include 'includes/header.php'; ?> <div class="max-w-7xl mx-auto px-4 py-8"> <!-- AUTO SCROLLING TOP 3 LATEST POSTS --> <?php if(count($top_posts) > 0): ?> <div class="relative h-80 md:h-96 rounded-3xl overflow-hidden mb-12 shadow-2xl"> <div id="hero-slider" class="relative w-full h-full"> <?php foreach($top_posts as $index => $post): ?> <div class="absolute inset-0 transition-opacity duration-1000 <?= $index === 0 ? 'opacity-100' : 'opacity-0' ?>" style="display: <?= $index === 0 ? 'block' : 'none' ?>"> <?php if($post['featured_image']): ?> <img src="uploads/<?= htmlspecialchars($post['featured_image']) ?>" class="w-full h-full object-cover"> <?php endif; ?> <div class="absolute inset-0 bg-gradient-to-r from-black/80 to-transparent"></div> <div class="absolute bottom-0 left-0 p-8 md:p-16 text-white z-10 max-w-2xl"> <span class="bg-red-600 px-4 py-1 text-sm rounded-full"><?= htmlspecialchars($post['category_name']) ?></span> <h1 class="text-3xl md:text-5xl font-bold mt-4 leading-tight"><?= htmlspecialchars($post['title']) ?></h1> <a href="single.php?id=<?= $post['id'] ?>" class="mt-6 inline-block bg-white text-green-800 font-semibold px-8 py-4 rounded-2xl hover:bg-yellow-300"> Read Full Story → </a> </div> </div> <?php endforeach; ?> </div> </div> <?php endif; ?> <div class="grid grid-cols-1 lg:grid-cols-12 gap-8"> <!-- Main Content --> <div class="lg:col-span-8"> <!-- TRENDING NOW --> <div class="mb-12"> <h2 class="text-3xl font-bold mb-6 flex items-center gap-3">🔥 Trending Now</h2> <div class="grid md:grid-cols-2 lg:grid-cols-4 gap-6"> <?php foreach($trending as $post): ?> <a href="single.php?id=<?= $post['id'] ?>" class="group block bg-white rounded-2xl overflow-hidden shadow hover:shadow-xl transition-all"> <?php if($post['featured_image']): ?> <img src="uploads/<?= htmlspecialchars($post['featured_image']) ?>" class="w-full h-48 object-cover group-hover:scale-105 transition"> <?php endif; ?> <div class="p-5"> <span class="text-xs text-green-700"><?= htmlspecialchars($post['category_name'] ?? 'News') ?></span> <h3 class="font-semibold mt-2 line-clamp-3 group-hover:text-green-700"><?= htmlspecialchars($post['title']) ?></h3> <p class="text-xs text-gray-500 mt-3"><?= number_format($post['views']) ?> views</p> </div> </a> <?php endforeach; ?> </div> </div> <!-- LATEST NEWS --> <h2 class="text-2xl font-bold mb-6">Latest News</h2> <div class="grid md:grid-cols-2 gap-6"> <?php foreach(array_slice($posts, 3) as $post): ?> <a href="single.php?id=<?= $post['id'] ?>" class="group bg-white rounded-2xl overflow-hidden shadow hover:shadow-lg transition"> <?php if($post['featured_image']): ?> <img src="uploads/<?= htmlspecialchars($post['featured_image']) ?>" class="w-full h-52 object-cover"> <?php endif; ?> <div class="p-6"> <span class="text-xs text-green-700"><?= htmlspecialchars($post['category_name'] ?? 'News') ?></span> <h3 class="font-semibold mt-3 line-clamp-3"><?= htmlspecialchars($post['title']) ?></h3> <p class="text-sm text-gray-500 mt-3"><?= number_format($post['views']) ?> views</p> </div> </a> <?php endforeach; ?> </div> </div> <!-- Sidebar --> <div class="lg:col-span-4 space-y-8"> <!-- Categories --> <div class="bg-white p-6 rounded-3xl shadow"> <h3 class="text-xl font-bold mb-5">Categories</h3> <div class="grid grid-cols-2 gap-3"> <?php foreach($categories as $cat): ?> <a href="category.php?slug=<?= $cat['slug'] ?>" class="block py-3 px-4 bg-gray-50 hover:bg-green-50 hover:text-green-700 rounded-2xl text-sm transition"> <?= htmlspecialchars($cat['name']) ?> </a> <?php endforeach; ?> </div> </div> <!-- Social Media --> <div class="bg-white p-6 rounded-3xl shadow"> <h3 class="text-xl font-bold mb-5">Follow Us</h3> <div class="flex gap-6 text-3xl justify-center text-gray-600"> <a href="#" class="hover:text-blue-600"><i class="fab fa-facebook-f"></i></a> <a href="#" class="hover:text-blue-500"><i class="fab fa-twitter"></i></a> <a href="#" class="hover:text-pink-600"><i class="fab fa-instagram"></i></a> <a href="#" class="hover:text-red-600"><i class="fab fa-youtube"></i></a> </div> <p class="text-center text-sm text-gray-500 mt-4">Stay connected with us</p> </div> <!-- Most Read --> <div class="bg-white p-6 rounded-3xl shadow"> <h3 class="text-xl font-bold mb-5">Most Read</h3> <?php foreach($most_read as $post): ?> <a href="single.php?id=<?= $post['id'] ?>" class="block py-5 border-b last:border-0 hover:text-green-700 group"> <p class="line-clamp-2 font-medium group-hover:underline"><?= htmlspecialchars($post['title']) ?></p> <span class="text-xs text-gray-500"><?= number_format($post['views']) ?> views</span> </a> <?php endforeach; ?> </div> </div> </div> </div> <script> // Auto Scrolling Top 3 Posts let currentSlide = 0; const slides = document.querySelectorAll('#hero-slider > div'); function showSlide(n) { slides.forEach((slide, index) => { slide.style.display = (index === n) ? 'block' : 'none'; slide.style.opacity = (index === n) ? '1' : '0'; }); } if (slides.length > 1) { setInterval(() => { currentSlide = (currentSlide + 1) % slides.length; showSlide(currentSlide); }, 5000); // Change every 5 seconds } </script> <?php include 'includes/footer.php'; ?>