Yanz Mini Shell
[_]
[-]
[X]
[
HomeShell 1
] [
HomeShell 2
] [
Upload
] [
Command Shell
] [
Scripting
] [
About
]
[ Directory ] =>
/
home
uncpac53
public_html
fsains.uncp.ac.id
pages
partials
Action
[*]
New File
[*]
New Folder
Sensitive File
[*]
/etc/passwd
[*]
/etc/shadow
[*]
/etc/resolv.conf
[
Delete
] [
Edit
] [
Rename
] [
Back
]
<?php // ============================================================= // detail-berita.php - Halaman detail berita // ============================================================= require_once __DIR__ . '/../config/config.php'; $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if ($id <= 0) { header("Location: " . $base_url . "/404.php"); exit; } // Ambil berita $stmt = $conn->prepare("SELECT * FROM news WHERE id = ?" . softDeleteFilter($conn, 'news')); $stmt->bind_param("i", $id); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows === 0) { header("Location: " . $base_url . "/404.php"); exit; } $berita = $result->fetch_assoc(); $stmt->close(); // Increment views (kolom `views` ditambahkan di database_upgrade.sql) @$conn->query("UPDATE news SET views = views + 1 WHERE id = " . (int)$id); // Ambil berita terkait (3 berita lain dengan kategori sama) $related = []; if (!empty($berita['category'])) { $rs = $conn->prepare("SELECT id, title, image, date_posted FROM news WHERE category = ? AND id != ? " . softDeleteFilter($conn, 'news') . " ORDER BY date_posted DESC LIMIT 3"); $rs->bind_param("si", $berita['category'], $id); $rs->execute(); $rr = $rs->get_result(); while ($r = $rr->fetch_assoc()) $related[] = $r; $rs->close(); } $page_title = $berita['title'] . ' - ' . setting('site_name'); $meta_description = potong(strip_tags($berita['content']), 160); // OG image untuk share di sosmed if (!empty($berita['image'])) { $og_image = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $base_url . '/assets/images/news/' . $berita['image']; } include __DIR__ . '/../includes/header.php'; // URL share $current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $share_text = urlencode($berita['title']); $share_url = urlencode($current_url); ?> <div class="page-hero" style="background: linear-gradient(135deg, #0a2b3e, #115277); color: white; padding: 70px 0 50px;"> <div class="container"> <nav style="font-size: 0.85rem; opacity: 0.8; margin-bottom: 16px;"> <a href="<?= $base_url ?>/index.php" style="color: #fff000; text-decoration: none;">Beranda</a> <span style="margin: 0 8px;">›</span> <a href="<?= $base_url ?>/pages/berita.php" style="color: #fff000; text-decoration: none;">Berita</a> <span style="margin: 0 8px;">›</span> <span style="opacity:0.7;"><?= e(potong($berita['title'], 50)) ?></span> </nav> <?php if (!empty($berita['category'])): ?> <span style="display:inline-block;background:#fff000;color:#0a2b3e; padding:4px 14px;border-radius:40px;font-size:0.75rem; font-weight:700;letter-spacing:1px;margin-bottom:16px;"> <?= e(strtoupper($berita['category'])) ?> </span> <?php endif; ?> <h1 style="font-family: 'Poppins', sans-serif; font-size: 2.4rem; font-weight: 800; line-height:1.2;" data-aos="fade-up"> <?= e($berita['title']) ?> </h1> <div style="margin-top: 16px; font-size: 0.9rem; opacity: 0.85; display:flex; gap:20px; flex-wrap:wrap;"> <span><i class="far fa-calendar"></i> <?= tanggalIndo($berita['date_posted']) ?></span> <span><i class="far fa-user"></i> <?= e($berita['author'] ?? 'Admin') ?></span> <?php if (isset($berita['views'])): ?> <span><i class="far fa-eye"></i> <?= number_format((int)$berita['views']) ?> views</span> <?php endif; ?> </div> </div> </div> <div class="container" style="padding: 50px 0;"> <article style="max-width: 820px; margin: 0 auto;" data-aos="fade-up"> <?php if (!empty($berita['image'])): ?> <div style="margin-bottom: 32px; border-radius: 20px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.15);"> <img src="<?= $base_url ?>/assets/images/news/<?= e($berita['image']) ?>" alt="<?= e($berita['title']) ?>" style="width: 100%; height: auto; display: block;"> </div> <?php endif; ?> <div class="news-content" style="font-size: 1.08rem; line-height: 1.85; color: #2c3e50;"> <style> .news-content p { margin-bottom: 16px; } .news-content h2 { font-family: 'Poppins',sans-serif; font-size: 1.5rem; color:#0a2b3e; margin-top: 24px; margin-bottom: 12px; } .news-content h3 { font-family: 'Poppins',sans-serif; font-size: 1.2rem; color:#115277; margin-top: 20px; margin-bottom: 10px; } .news-content ul, .news-content ol { margin: 12px 0 12px 24px; } .news-content blockquote { border-left: 4px solid #fff000; padding: 14px 22px; background: #f8fafc; margin: 20px 0; font-style: italic; border-radius: 0 12px 12px 0; } .news-content img { max-width: 100%; height: auto; border-radius: 12px; margin: 16px 0; } .news-content a { color: #00bfff; text-decoration: underline; } </style> <?php // Render content sebagai HTML. Content dibuat via TinyMCE editor (admin-only, // auth required), jadi aman. nl2br + escape akan double-render dan menampilkan // tag mentah jika content sudah berbentuk HTML. $body = $berita['content'] ?? ''; // Heuristic: kalau content sudah berisi tag HTML (mengandung <p, <h, <div, <ul, dll), // render apa adanya. Kalau content masih plain text (tidak ada HTML tag), pakai nl2br. if (preg_match('/<(p|h[1-6]|div|ul|ol|table|img|figure|blockquote|br)\b/i', $body)) { echo $body; // already HTML from TinyMCE } else { echo nl2br(e($body)); // plain text fallback (lama) } ?> </div> <!-- Share --> <div style="border-top: 1px solid #e5e7eb; border-bottom: 1px solid #e5e7eb; padding: 24px 0; margin: 40px 0; display:flex; gap:12px; align-items:center; flex-wrap:wrap;"> <strong style="color: #64748b; margin-right: 8px;">Bagikan:</strong> <a href="https://www.facebook.com/sharer/sharer.php?u=<?= $share_url ?>" target="_blank" rel="noopener" style="display:inline-flex;align-items:center;gap:8px;padding:10px 18px; background:#1877F2;color:white;border-radius:10px;text-decoration:none; font-size:0.9rem;font-weight:600;"> <i class="fab fa-facebook-f"></i> Facebook </a> <a href="https://twitter.com/intent/tweet?text=<?= $share_text ?>&url=<?= $share_url ?>" target="_blank" rel="noopener" style="display:inline-flex;align-items:center;gap:8px;padding:10px 18px; background:#1DA1F2;color:white;border-radius:10px;text-decoration:none; font-size:0.9rem;font-weight:600;"> <i class="fab fa-twitter"></i> Twitter </a> <a href="https://wa.me/?text=<?= $share_text ?>%20<?= $share_url ?>" target="_blank" rel="noopener" style="display:inline-flex;align-items:center;gap:8px;padding:10px 18px; background:#25D366;color:white;border-radius:10px;text-decoration:none; font-size:0.9rem;font-weight:600;"> <i class="fab fa-whatsapp"></i> WhatsApp </a> <button onclick="navigator.clipboard.writeText('<?= e($current_url) ?>').then(()=>{this.innerText='✓ Tersalin!';setTimeout(()=>{this.innerHTML='<i class="fas fa-link"></i> Salin Link';},2000);})" style="display:inline-flex;align-items:center;gap:8px;padding:10px 18px; background:#475569;color:white;border:none;border-radius:10px; font-size:0.9rem;font-weight:600;cursor:pointer;font-family:inherit;"> <i class="fas fa-link"></i> Salin Link </button> </div> <!-- Tombol kembali --> <a href="<?= $base_url ?>/pages/berita.php" style="display:inline-block;color:#00bfff;text-decoration:none;font-weight:600;"> ← Kembali ke daftar berita </a> </article> <!-- Berita Terkait --> <?php if (!empty($related)): ?> <section style="max-width: 1200px; margin: 60px auto 0;" data-aos="fade-up"> <h2 style="font-family:'Poppins',sans-serif;font-size:1.6rem;color:#0a2b3e;margin-bottom:24px;"> Berita Terkait </h2> <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px;"> <?php foreach ($related as $rel): $rel_img = !empty($rel['image']) ? $base_url . '/assets/images/news/' . $rel['image'] : $base_url . '/assets/images/hero/hero-1.jpg'; ?> <a href="<?= $base_url ?>/pages/detail-berita.php?id=<?= (int)$rel['id'] ?>" style="background:white;border-radius:16px;overflow:hidden;text-decoration:none; color:inherit;box-shadow:0 8px 24px rgba(0,0,0,0.06); transition:transform 0.3s;" onmouseover="this.style.transform='translateY(-4px)'" onmouseout="this.style.transform='translateY(0)'"> <img src="<?= e($rel_img) ?>" alt="<?= e($rel['title']) ?>" loading="lazy" style="width:100%;height:160px;object-fit:cover;"> <div style="padding: 18px;"> <h4 style="font-family:'Poppins',sans-serif;font-size:1rem;font-weight:600; color:#0a2b3e;line-height:1.45;margin-bottom:8px;"> <?= e(potong($rel['title'], 70)) ?> </h4> <p style="font-size:0.8rem;color:#64748b;margin:0;"> <?= tanggalIndo($rel['date_posted']) ?> </p> </div> </a> <?php endforeach; ?> </div> </section> <?php endif; ?> </div> <?php include __DIR__ . '/../includes/footer.php'; ?>
Free Space : 55487967232 Byte