403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  D:/laragon4/www/bpkd.test_/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/laragon4/www/bpkd.test_/admin//pages.php
<?php
$page_title = 'Manajemen Halaman';
require_once 'config/database.php';
require_once 'includes/header.php';
require_once 'includes/init.php';

// Cek apakah user adalah admin
if (!in_array($_SESSION['role'], ['superadmin','admin'])) {
    redirect('dashboard.php');
}

// =====================================================
// HANDLE DELETE
// =====================================================
if (isset($_GET['delete'])) {
    $id = (int)$_GET['delete'];
    
    // Ambil gambar untuk dihapus
    $page = $conn->query("SELECT featured_image FROM pages WHERE id = $id")->fetch_assoc();
    if ($page && !empty($page['featured_image']) && file_exists("../" . $page['featured_image'])) {
        unlink("../" . $page['featured_image']);
    }
    
    $conn->query("DELETE FROM pages WHERE id = $id");
    redirect('pages.php?msg=deleted');
}

// =====================================================
// PAGINATION SETUP
// =====================================================
$limit = 10;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($page < 1) $page = 1;
$offset = ($page - 1) * $limit;

// =====================================================
// SEARCH & FILTER
// =====================================================
$search = isset($_GET['search']) ? sanitize($_GET['search']) : '';
$template_filter = isset($_GET['template']) ? sanitize($_GET['template']) : '';
$status_filter = isset($_GET['status']) ? sanitize($_GET['status']) : '';

// Build WHERE clause
$where = ["1=1"];

if (!empty($search)) {
    $where[] = "(title LIKE '%$search%' OR content LIKE '%$search%' OR excerpt LIKE '%$search%')";
}

if (!empty($template_filter)) {
    $where[] = "template = '$template_filter'";
}

if (!empty($status_filter)) {
    $where[] = "status = '$status_filter'";
}

$where_clause = implode(' AND ', $where);

// =====================================================
// GET TOTAL RECORDS FOR PAGINATION
// =====================================================
$total_query = "SELECT COUNT(*) as total FROM pages WHERE $where_clause";
$total_result = $conn->query($total_query);
$total_records = $total_result->fetch_assoc()['total'];
$total_pages = ceil($total_records / $limit);

// =====================================================
// GET PAGES WITH PAGINATION
// =====================================================
$pages = $conn->query("
    SELECT p.*, u.full_name as author_name,
           (SELECT title FROM pages WHERE id = p.parent_id) as parent_title
    FROM pages p 
    LEFT JOIN users u ON p.author_id = u.id 
    WHERE $where_clause 
    ORDER BY p.menu_order ASC, p.title ASC 
    LIMIT $offset, $limit
");

// =====================================================
// GET FILTER DATA
// =====================================================
$templates = $conn->query("SELECT DISTINCT template FROM pages WHERE template IS NOT NULL AND template != ''");

// =====================================================
// MESSAGES
// =====================================================
$msg = '';
if (isset($_GET['msg'])) {
    if ($_GET['msg'] == 'added') $msg = '<div class="alert alert-success">Halaman berhasil ditambahkan!</div>';
    if ($_GET['msg'] == 'updated') $msg = '<div class="alert alert-success">Halaman berhasil diupdate!</div>';
    if ($_GET['msg'] == 'deleted') $msg = '<div class="alert alert-success">Halaman berhasil dihapus!</div>';
}
?>

<div class="container-fluid">
    <div class="d-sm-flex align-items-center justify-content-between mb-4">
        <h1 class="h3 mb-0 text-gray-800">Manajemen Halaman Profil</h1>
        <a href="page-add.php" class="btn btn-primary">
            <i class="fas fa-plus me-2"></i>Tambah Halaman Baru
        </a>
    </div>

    <?php echo $msg; ?>

    <!-- Search and Filter Card -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-white">
                <i class="fas fa-filter me-2"></i>Filter Pencarian
            </h6>
        </div>
        <div class="card-body">
            <form method="GET" class="row g-3">
                <div class="col-md-4">
                    <label class="form-label">Kata Kunci</label>
                    <div class="input-group">
                        <span class="input-group-text"><i class="fas fa-search"></i></span>
                        <input type="text" class="form-control" name="search" placeholder="Cari judul atau konten..." value="<?php echo htmlspecialchars($search); ?>">
                    </div>
                </div>
                
                <div class="col-md-3">
                    <label class="form-label">Template</label>
                    <select class="form-control" name="template">
                        <option value="">Semua Template</option>
                        <?php while($template = $templates->fetch_assoc()): ?>
                            <option value="<?php echo $template['template']; ?>" <?php echo $template_filter == $template['template'] ? 'selected' : ''; ?>>
                                <?php echo ucfirst($template['template']); ?>
                            </option>
                        <?php endwhile; ?>
                    </select>
                </div>
                
                <div class="col-md-3">
                    <label class="form-label">Status</label>
                    <select class="form-control" name="status">
                        <option value="">Semua Status</option>
                        <option value="published" <?php echo $status_filter == 'published' ? 'selected' : ''; ?>>Published</option>
                        <option value="draft" <?php echo $status_filter == 'draft' ? 'selected' : ''; ?>>Draft</option>
                    </select>
                </div>
                
                <div class="col-md-2">
                    <label class="form-label">Aksi</label>
                    <div class="d-flex">
                        <button type="submit" class="btn btn-primary me-2">
                            <i class="fas fa-filter me-2"></i>Filter
                        </button>
                        <a href="pages.php" class="btn btn-secondary">
                            <i class="fas fa-sync-alt"></i>
                        </a>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <!-- Pages Table Card -->
    <div class="card shadow mb-4">
        <div class="card-header py-3 d-flex justify-content-between align-items-center">
            <h6 class="m-0 font-weight-bold text-white">
                <i class="fas fa-file-alt me-2"></i>Daftar Halaman
                <span class="badge bg-primary ms-2"><?php echo $total_records; ?> Total</span>
            </h6>
            
            <?php if ($total_pages > 1): ?>
            <div class="pagination-info">
                Halaman <?php echo $page; ?> dari <?php echo $total_pages; ?>
            </div>
            <?php endif; ?>
        </div>
        
        <div class="card-body">
            <?php if ($pages && $pages->num_rows > 0): ?>
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>Judul</th>
                                <th>Slug</th>
                                <th>Induk</th>
                                <th>Template</th>
                                <th>Status</th>
                                <th>Penulis</th>
                                <th>Tanggal</th>
                                <th>Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php while($page = $pages->fetch_assoc()): 
                                // ===== PERBAIKAN: Buat URL lengkap dengan prefix dan slug =====
                                $url_prefix = !empty($page['url_prefix']) ? $page['url_prefix'] : 'halaman';
                                $full_url = '/bpkd/' . $url_prefix . '/' . $page['slug'];
                            ?>
                            <tr>
                                <td>
                                    <strong><?php echo htmlspecialchars($page['title']); ?></strong>
                                    <?php if(!empty($page['featured_image'])): ?>
                                        <i class="fas fa-image text-primary ms-1" title="Memiliki gambar"></i>
                                    <?php endif; ?>
                                    <?php if($page['parent_id'] > 0): ?>
                                        <span class="badge bg-info">Sub Halaman</span>
                                    <?php endif; ?>
                                </td>
                                <td><code><?php echo htmlspecialchars($full_url); ?></code></td>
                                <td><?php echo $page['parent_title'] ?: '-'; ?></td>
                                <td><span class="badge bg-secondary"><?php echo ucfirst($page['template'] ?: 'default'); ?></span></td>
                                <td>
                                    <span class="badge bg-<?php echo $page['status'] == 'published' ? 'success' : 'secondary'; ?>">
                                        <?php echo $page['status'] == 'published' ? 'Published' : 'Draft'; ?>
                                    </span>
                                </td>
                                <td><?php echo $page['author_name']; ?></td>
                                <td>
                                    <small>
                                        <i class="far fa-calendar-alt me-1"></i><?php echo date('d/m/Y', strtotime($page['created_at'])); ?>
                                    </small>
                                </td>
                                <td>
                                    <div class="btn-group" role="group">
                                        <a href="<?php echo $full_url; ?>" target="_blank" class="btn btn-sm btn-info" title="Lihat">
                                            <i class="fas fa-eye"></i>
                                        </a>
                                        <a href="page-edit.php?id=<?php echo $page['id']; ?>" class="btn btn-sm btn-warning" title="Edit">
                                            <i class="fas fa-edit"></i>
                                        </a>
                                        <a href="?delete=<?php echo $page['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Yakin ingin menghapus halaman ini?')" title="Hapus">
                                            <i class="fas fa-trash"></i>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                            <?php endwhile; ?>
                        </tbody>
                    </table>
                </div>
                
                <!-- Pagination -->
                <?php if ($total_pages > 1): ?>
                <nav aria-label="Page navigation" class="mt-4">
                    <ul class="pagination justify-content-center">
                        <!-- First Page -->
                        <li class="page-item <?php echo $page <= 1 ? 'disabled' : ''; ?>">
                            <a class="page-link" href="?page=1<?php echo buildQueryString(['page']); ?>">
                                <i class="fas fa-angle-double-left"></i>
                            </a>
                        </li>
                        
                        <!-- Previous Page -->
                        <li class="page-item <?php echo $page <= 1 ? 'disabled' : ''; ?>">
                            <a class="page-link" href="?page=<?php echo $page-1; ?><?php echo buildQueryString(['page']); ?>">
                                <i class="fas fa-angle-left"></i>
                            </a>
                        </li>


                        
                        <!-- Page Numbers -->
                        <?php
                        $start = max(1, $page - 2);
                        $end = min($total_pages, $page + 2);
                        
                        if ($start > 1) {
                            echo '<li class="page-item disabled"><span class="page-link">...</span></li>';
                        }
                        
                        for ($i = $start; $i <= $end; $i++):
                        ?>
                        <li class="page-item <?php echo $i == $page ? 'active' : ''; ?>">
                            <a class="page-link" href="?page=<?php echo $i; ?><?php echo buildQueryString(['page']); ?>">
                                <?php echo $i; ?>
                            </a>
                        </li>
                        <?php endfor;
                        
                        if ($end < $total_pages) {
                            echo '<li class="page-item disabled"><span class="page-link">...</span></li>';
                        }
                        ?>
                        
                        <!-- Next Page -->
                        <li class="page-item <?php echo $page >= $total_pages ? 'disabled' : ''; ?>">
                            <a class="page-link" href="?page=<?php echo $page+1; ?><?php echo buildQueryString(['page']); ?>">
                                <i class="fas fa-angle-right"></i>
                            </a>
                        </li>
                        
                        <!-- Last Page -->
                        <li class="page-item <?php echo $page >= $total_pages ? 'disabled' : ''; ?>">
                            <a class="page-link" href="?page=<?php echo $total_pages; ?><?php echo buildQueryString(['page']); ?>">
                                <i class="fas fa-angle-double-right"></i>
                            </a>
                        </li>
                    </ul>
                </nav>
                
                <!-- Page Info -->
                <div class="text-center text-muted mt-2">
                    Menampilkan <?php echo $offset + 1; ?> - <?php echo min($offset + $limit, $total_records); ?> dari <?php echo $total_records; ?> halaman
                </div>
                <?php endif; ?>
                
            <?php else: ?>
                <div class="text-center py-5">
                    <i class="fas fa-file-alt fa-4x text-muted mb-3"></i>
                    <h5>Tidak ada halaman</h5>
                    <p class="text-muted">Belum ada halaman yang ditemukan dengan filter yang dipilih.</p>
                    <a href="page-add.php" class="btn btn-primary">
                        <i class="fas fa-plus me-2"></i>Tambah Halaman Baru
                    </a>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

<?php 
// Helper function to build query string
function buildQueryString($exclude = []) {
    $params = $_GET;
    foreach($exclude as $key) {
        unset($params[$key]);
    }
    if(empty($params)) return '';
    return '&' . http_build_query($params);
}

require_once 'includes/footer.php'; 
?>

Youez - 2016 - github.com/yon3zu
LinuXploit