$limit ? mb_substr($text, 0, $limit) . "โ€ฆ" : $text; } function limitBody($text, $limitChars = 500, $id = null) { $plain = strip_tags($text); if (mb_strlen($plain) > $limitChars) { return mb_substr($plain, 0, $limitChars) . '... See More'; } return $plain; } function withIcon($text, $icons) { $icon = isset($icons[$text]) ? $icons[$text] . ' ' : ''; return $icon . $text; } $categories = ['Property','Vehicle','House','Medical','Restaurants','Business','Electronics','Service','Job Vacancy','Education','Sabun dan Pencuci','Other']; $typesList = ['Sale','Rent','Wanted','Event','Info','Sponsor','Loan','Other']; $categoryIcons = [ 'Property' => '๐Ÿ ', 'Vehicle' => '๐Ÿš—', 'House' => '๐Ÿก', 'Medical' => '๐Ÿ’Š', 'Restaurants' => '๐Ÿฝ๏ธ', 'Business' => '๐Ÿ’ผ', 'Electronics' => '๐Ÿ’ป', 'Service' => '๐Ÿ› ๏ธ', 'Job Vacancy' => '๐Ÿ’ผ', 'Education' => '๐ŸŽ“', 'Sabun dan Pencuci' => '๐Ÿงผ', 'Other' => '๐Ÿ“ฆ' ]; $typeIcons = [ 'Sale' => '๐Ÿ’ฐ', 'Rent' => '๐Ÿ”‘', 'Wanted' => '๐Ÿ”', 'Event' => '๐ŸŽ‰', 'Info' => 'โ„น๏ธ', 'Sponsor' => '๐Ÿค', 'Loan' => '๐Ÿ’ธ', 'Other' => '๐Ÿ“ฆ', ]; // GET parameters for filtering $category = isset($_GET['category']) ? $conn->real_escape_string($_GET['category']) : ''; $type = isset($_GET['type']) ? $conn->real_escape_string($_GET['type']) : ''; $search = isset($_GET['search']) ? $conn->real_escape_string($_GET['search']) : ''; $selectedCategory = $category; $selectedType = $type; // --- Pagination for Blog Grid --- $blogsPerPage = 6; $totalBlogsRes = $conn->query("SELECT COUNT(*) AS total FROM blogs"); $totalBlogsRow = $totalBlogsRes->fetch_assoc(); $totalBlogs = min($totalBlogsRow['total'], 30); // max 30 blogs $totalPages = ceil($totalBlogs / $blogsPerPage); $page = isset($_GET['blogs_page']) ? intval($_GET['blogs_page']) : 1; if ($page < 1) $page = 1; if ($page > $totalPages) $page = $totalPages; $offset = ($page - 1) * $blogsPerPage; $blogs = $conn->query("SELECT * FROM blogs ORDER BY created_at DESC LIMIT $offset, $blogsPerPage"); // Helper to pick first image function pickBlogImage($row) { if (!empty($row['images'])) { $imgsArray = array_filter(array_map('trim', explode(',', $row['images']))); if (!empty($imgsArray)) return $imgsArray[0]; } if (!empty($row['image'])) return $row['image']; if (!empty($row['content'])) { if (preg_match('/]+src="([^"]+)"/i', $row['content'], $matches)) return $matches[1]; } return 'default.jpg'; } ?> Baling Direktori
โž• Add Entry ๐Ÿ  Dashboard ๐Ÿ”‘ Login
Penafian: Kandungan iklan adalah diiklankan oleh pengguna dan Admin tidak bertanggungjawab di atas kandungan tersebut. Sekiranya anda mendapati terdapat kandungan yang menyalahi undang-undang, jelik, memfitnah, menceroboh hak peribadi, melanggar hakcipta, berunsur penipuan atau mana-mana perlanggaran undang-undang lainnya, sila dengan segera hubungi Admin.

๐Ÿ“ฐ Highlights

query("SELECT * FROM blogs WHERE id IN ($idsStr) ORDER BY created_at DESC"); if ($blogs && $blogs->num_rows > 0): while($b = $blogs->fetch_assoc()): $img = pickBlogImage($b); $imgSrc = preg_match('~^https?://~i', $img) ? $img : 'uploads/' . $img; ?> <?= htmlspecialchars($b['title']) ?>
No blogs found.

"; endif; } ?>

prepare($sql); if ($params) { $stmt->bind_param($types, ...$params); } $stmt->execute(); $res = $stmt->get_result(); // --- Fetch results --- if($res && $res->num_rows > 0): while($row = $res->fetch_assoc()): include 'render_entry.php'; endwhile; else: echo "

No entries found.

"; endif; // --- Total rows for Entries Pagination --- $totalSql = "SELECT COUNT(*) AS total FROM entries WHERE 1=1"; $paramsTotal = []; $typesTotal = ''; if($category) { $totalSql .= " AND category = ?"; $paramsTotal[] = $category; $typesTotal .= 's'; } if($type) { $totalSql .= " AND type = ?"; $paramsTotal[] = $type; $typesTotal .= 's'; } if($search) { $totalSql .= " AND (title LIKE ? OR content LIKE ?)"; $paramsTotal[] = "%$search%"; $paramsTotal[] = "%$search%"; $typesTotal .= 'ss'; } $stmtTotal = $conn->prepare($totalSql); if ($paramsTotal) { $stmtTotal->bind_param($typesTotal, ...$paramsTotal); } $stmtTotal->execute(); $totalRes = $stmtTotal->get_result(); $totalRows = ($totalRes && $row = $totalRes->fetch_assoc()) ? $row['total'] : 0; $totalPages = ceil($totalRows / $entriesLimit); // --- Output Entries Pagination --- if ($totalPages > 1): echo ''; endif; ?>

๐Ÿ“ฐ News & Articles

query("SELECT COUNT(*) AS total FROM blogs"); $totalBlogsRow = $totalBlogsRes->fetch_assoc(); $totalBlogs = $totalBlogsRow['total']; $totalBlogPages = ceil($totalBlogs / $blogsPerPage); $offset = ($blogsPage - 1) * $blogsPerPage; $blogs = $conn->query("SELECT * FROM blogs ORDER BY created_at DESC LIMIT $offset, $blogsPerPage"); if($blogs && $blogs->num_rows > 0): while($row = $blogs->fetch_assoc()): include 'render_blog_preview.php'; endwhile; else: echo "

No blogs found.

"; endif; ?>
1): echo ''; endif; ?>