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 :  /bpkd/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bpkd/admin//carousel.php
<?php
// Aktifkan error reporting untuk debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Start session jika belum dimulai
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

// Load konfigurasi
require_once 'config/database.php';
require_once '../includes/config.php'; // Load BASE_URL
require_once 'includes/init.php';

// Cek login
requireLogin();

$page_title = 'Manajemen Carousel';
$msg = '';
$error = '';

// =====================================================
// HANDLE ADD SLIDE
// =====================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add'])) {
    try {
        $title = sanitize($_POST['title']);
        $subtitle = sanitize($_POST['subtitle'] ?? '');
        $description = sanitize($_POST['description'] ?? '');
        $button_text = sanitize($_POST['button_text'] ?? '');
        $button_link = sanitize($_POST['button_link'] ?? '');
        $button_text_2 = sanitize($_POST['button_text_2'] ?? '');
        $button_link_2 = sanitize($_POST['button_link_2'] ?? '');
        $status = sanitize($_POST['status'] ?? 'active');
        $slide_order = (int)($_POST['slide_order'] ?? 0);
        
        // Validasi title tidak boleh kosong
        if (empty($title)) {
            throw new Exception('Judul slide harus diisi!');
        }
        
        // Handle image upload untuk desktop
        $image = '';
        if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
            $target_dir = dirname(__DIR__) . "/uploads/carousel/";
            if (!file_exists($target_dir)) {
                mkdir($target_dir, 0777, true);
            }
            
            $file_ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION));
            $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
            
            if (!in_array($file_ext, $allowed)) {
                throw new Exception('Format file desktop tidak diizinkan! Gunakan JPG, PNG, GIF, atau WEBP.');
            }
            
            if ($_FILES['image']['size'] > 3 * 1024 * 1024) {
                throw new Exception('Ukuran file desktop maksimal 3MB!');
            }
            
            $image_name = time() . '_' . uniqid() . '.' . $file_ext;
            $target_file = $target_dir . $image_name;
            
            if (move_uploaded_file($_FILES['image']['tmp_name'], $target_file)) {
                $image = 'uploads/carousel/' . $image_name;
            } else {
                throw new Exception('Gagal upload gambar desktop!');
            }
        } else {
            throw new Exception('Gambar desktop harus diupload!');
        }
        
        // Handle image upload untuk mobile (opsional)
        $image_mobile = '';
        if (isset($_FILES['image_mobile']) && $_FILES['image_mobile']['error'] == 0) {
            $file_ext = strtolower(pathinfo($_FILES['image_mobile']['name'], PATHINFO_EXTENSION));
            $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
            
            if (!in_array($file_ext, $allowed)) {
                throw new Exception('Format file mobile tidak diizinkan! Gunakan JPG, PNG, GIF, atau WEBP.');
            }
            
            if ($_FILES['image_mobile']['size'] > 3 * 1024 * 1024) {
                throw new Exception('Ukuran file mobile maksimal 3MB!');
            }
            
            $image_name = 'mobile_' . time() . '_' . uniqid() . '.' . $file_ext;
            $target_file = $target_dir . $image_name;
            
            if (move_uploaded_file($_FILES['image_mobile']['tmp_name'], $target_file)) {
                $image_mobile = 'uploads/carousel/' . $image_name;
            } else {
                throw new Exception('Gagal upload gambar mobile!');
            }
        }
        
        $query = "INSERT INTO carousel (title, subtitle, description, image, image_mobile, button_text, button_link, button_text_2, button_link_2, status, slide_order) 
                  VALUES ('$title', '$subtitle', '$description', '$image', '$image_mobile', '$button_text', '$button_link', '$button_text_2', '$button_link_2', '$status', $slide_order)";
        
        if ($conn->query($query)) {
            $msg = '<div class="alert alert-success">Slide berhasil ditambahkan!</div>';
            // Refresh data
            $slides = $conn->query("SELECT * FROM carousel ORDER BY slide_order ASC, id ASC");
        } else {
            throw new Exception('Error: ' . $conn->error);
        }
    } catch (Exception $e) {
        $error = '<div class="alert alert-danger">' . $e->getMessage() . '</div>';
    }
}

// =====================================================
// HANDLE EDIT SLIDE
// =====================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['edit'])) {
    try {
        $id = (int)$_POST['id'];
        $title = sanitize($_POST['title']);
        $subtitle = sanitize($_POST['subtitle'] ?? '');
        $description = sanitize($_POST['description'] ?? '');
        $button_text = sanitize($_POST['button_text'] ?? '');
        $button_link = sanitize($_POST['button_link'] ?? '');
        $button_text_2 = sanitize($_POST['button_text_2'] ?? '');
        $button_link_2 = sanitize($_POST['button_link_2'] ?? '');
        $status = sanitize($_POST['status'] ?? 'active');
        $slide_order = (int)($_POST['slide_order'] ?? 0);
        
        if (empty($title)) {
            throw new Exception('Judul slide harus diisi!');
        }
        
        $old = $conn->query("SELECT image, image_mobile FROM carousel WHERE id = $id")->fetch_assoc();
        $image = $old['image'];
        $image_mobile = $old['image_mobile'];
        
        // Handle image upload untuk desktop
        if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
            $target_dir = dirname(__DIR__) . "/uploads/carousel/";
            $file_ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION));
            $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
            
            if (!in_array($file_ext, $allowed)) {
                throw new Exception('Format file desktop tidak diizinkan!');
            }
            
            if ($_FILES['image']['size'] > 2 * 1024 * 1024) {
                throw new Exception('Ukuran file desktop maksimal 2MB!');
            }
            
            $image_name = time() . '_' . uniqid() . '.' . $file_ext;
            $target_file = $target_dir . $image_name;
            
            if (move_uploaded_file($_FILES['image']['tmp_name'], $target_file)) {
                $old_file = dirname(__DIR__) . "/" . $old['image'];
                if (!empty($old['image']) && file_exists($old_file)) {
                    unlink($old_file);
                }
                $image = 'uploads/carousel/' . $image_name;
            } else {
                throw new Exception('Gagal upload gambar desktop!');
            }
        }
        
        // Handle image upload untuk mobile
        if (isset($_FILES['image_mobile']) && $_FILES['image_mobile']['error'] == 0) {
            $target_dir = dirname(__DIR__) . "/uploads/carousel/";
            $file_ext = strtolower(pathinfo($_FILES['image_mobile']['name'], PATHINFO_EXTENSION));
            $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
            
            if (!in_array($file_ext, $allowed)) {
                throw new Exception('Format file mobile tidak diizinkan!');
            }
            
            if ($_FILES['image_mobile']['size'] > 2 * 1024 * 1024) {
                throw new Exception('Ukuran file mobile maksimal 2MB!');
            }
            
            $image_name = 'mobile_' . time() . '_' . uniqid() . '.' . $file_ext;
            $target_file = $target_dir . $image_name;
            
            if (move_uploaded_file($_FILES['image_mobile']['tmp_name'], $target_file)) {
                $old_file = dirname(__DIR__) . "/" . $old['image_mobile'];
                if (!empty($old['image_mobile']) && file_exists($old_file)) {
                    unlink($old_file);
                }
                $image_mobile = 'uploads/carousel/' . $image_name;
            } else {
                throw new Exception('Gagal upload gambar mobile!');
            }
        }
        
        $query = "UPDATE carousel SET 
                  title = '$title', 
                  subtitle = '$subtitle', 
                  description = '$description', 
                  image = '$image', 
                  image_mobile = '$image_mobile', 
                  button_text = '$button_text', 
                  button_link = '$button_link', 
                  button_text_2 = '$button_text_2', 
                  button_link_2 = '$button_link_2', 
                  status = '$status', 
                  slide_order = $slide_order 
                  WHERE id = $id";
        
        if ($conn->query($query)) {
            $msg = '<div class="alert alert-success">Slide berhasil diupdate!</div>';
        } else {
            throw new Exception('Error: ' . $conn->error);
        }
    } catch (Exception $e) {
        $error = '<div class="alert alert-danger">' . $e->getMessage() . '</div>';
    }
}

// =====================================================
// HANDLE DELETE SLIDE
// =====================================================
if (isset($_GET['delete'])) {
    try {
        $id = (int)$_GET['delete'];
        
        $slide = $conn->query("SELECT image, image_mobile FROM carousel WHERE id = $id")->fetch_assoc();
        if ($slide && !empty($slide['image']) && file_exists(dirname(__DIR__) . "/" . $slide['image'])) {
            unlink(dirname(__DIR__) . "/" . $slide['image']);
        }
        if ($slide && !empty($slide['image_mobile']) && file_exists(dirname(__DIR__) . "/" . $slide['image_mobile'])) {
            unlink(dirname(__DIR__) . "/" . $slide['image_mobile']);
        }
        
        if ($conn->query("DELETE FROM carousel WHERE id = $id")) {
            $msg = '<div class="alert alert-success">Slide berhasil dihapus!</div>';
        } else {
            throw new Exception('Error: ' . $conn->error);
        }
    } catch (Exception $e) {
        $error = '<div class="alert alert-danger">' . $e->getMessage() . '</div>';
    }
}

// =====================================================
// HANDLE UPDATE ORDER
// =====================================================
if (isset($_POST['update_order']) && isset($_POST['order'])) {
    $orders = explode(',', $_POST['order']);
    foreach ($orders as $index => $id) {
        $id = (int)$id;
        $order = $index + 1;
        $conn->query("UPDATE carousel SET slide_order = $order WHERE id = $id");
    }
    $msg = '<div class="alert alert-success">Urutan slide berhasil disimpan!</div>';
}

// =====================================================
// GET DATA
// =====================================================
$slides = $conn->query("SELECT * FROM carousel ORDER BY slide_order ASC, id ASC");

$edit_slide = null;
if (isset($_GET['edit'])) {
    $id = (int)$_GET['edit'];
    $result = $conn->query("SELECT * FROM carousel WHERE id = $id");
    if ($result && $result->num_rows > 0) {
        $edit_slide = $result->fetch_assoc();
    }
}

// Include header
require_once 'includes/header.php';
?>

<style>
.handle {
    cursor: move;
    opacity: 0.5;
    transition: opacity 0.3s;
}
.handle:hover {
    opacity: 1;
}
#sortable tr {
    transition: all 0.3s;
}
#sortable tr:hover {
    background: #f8f9fc;
}
.preview-img {
    width: 80px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
}
</style>

<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 Carousel</h1>
        <div>
            <a href="<?php echo BASE_URL; ?>/admin/carousel_settings.php" class="btn btn-info me-2">
                <i class="fas fa-sliders-h me-2"></i>Pengaturan Carousel
            </a>
            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addSlideModal">
                <i class="fas fa-plus me-2"></i>Tambah Slide Baru
            </button>
        </div>
    </div>

    <?php echo $msg; ?>
    <?php echo $error; ?>

    <!-- Info Alert -->
    <div class="alert alert-info">
        <i class="fas fa-info-circle me-2"></i>
        <strong>Tips:</strong> 
        <ul class="mb-0 mt-2">
            <li>Gambar <strong>Desktop</strong> akan tampil pada layar lebar (≥768px) - Ukuran ideal: <?php echo $settings['carousel_width'] ?? '1920'; ?> x <?php echo $settings['carousel_height'] ?? '800'; ?> px</li>
            <li>Gambar <strong>Mobile</strong> akan tampil pada layar kecil (&#60;768px) - Ukuran ideal: <?php echo $settings['carousel_mobile_width'] ?? '768'; ?> x <?php echo $settings['carousel_mobile_height'] ?? '500'; ?> px</li>
            <li>Jika gambar mobile tidak diupload, sistem akan menggunakan gambar desktop sebagai fallback</li>
        </ul>
    </div>

    <!-- Slides List -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-white">Daftar Slide Carousel</h6>
        </div>
        <div class="card-body">
            <?php if ($slides && $slides->num_rows > 0): ?>
                <form method="POST" id="orderForm">
                    <div class="table-responsive">
                        <table class="table table-hover" id="sortable-table">
                            <thead>
                                <tr>
                                    <th style="width: 50px">Urutan</th>
                                    <th style="width: 100px">Gambar Desktop</th>
                                    <th style="width: 100px">Gambar Mobile</th>
                                    <th>Judul</th>
                                    <th>Subtitle</th>
                                    <th>Tombol</th>
                                    <th>Status</th>
                                    <th style="width: 120px">Aksi</th>
                                </tr>
                            </thead>
                            <tbody id="sortable">
                                <?php while($slide = $slides->fetch_assoc()): ?>
                                <tr data-id="<?php echo $slide['id']; ?>">
                                    <td class="text-center">
                                        <i class="fas fa-grip-vertical text-muted handle" style="cursor: move;"></i>
                                        <span class="badge bg-secondary ms-2"><?php echo $slide['slide_order']; ?></span>
                                    </td>
                                    <td>
                                        <?php if(!empty($slide['image']) && file_exists(dirname(__DIR__) . "/" . $slide['image'])): ?>
                                            <img src="<?php echo BASE_URL; ?>/<?php echo $slide['image']; ?>" alt="Desktop" class="preview-img">
                                        <?php else: ?>
                                            <span class="text-muted">-</span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <?php if(!empty($slide['image_mobile']) && file_exists(dirname(__DIR__) . "/" . $slide['image_mobile'])): ?>
                                            <img src="<?php echo BASE_URL; ?>/<?php echo $slide['image_mobile']; ?>" alt="Mobile" class="preview-img">
                                        <?php else: ?>
                                            <span class="text-muted text-center">-</span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <strong><?php echo htmlspecialchars($slide['title']); ?></strong>
                                        <?php if(!empty($slide['description'])): ?>
                                            <br><small class="text-muted"><?php echo substr(htmlspecialchars($slide['description']), 0, 50); ?>...</small>
                                        <?php endif; ?>
                                    </td>
                                    <td><?php echo htmlspecialchars($slide['subtitle'] ?: '-'); ?></td>
                                    <td>
                                        <?php if(!empty($slide['button_text'])): ?>
                                            <span class="badge bg-info"><?php echo $slide['button_text']; ?></span>
                                        <?php endif; ?>
                                        <?php if(!empty($slide['button_text_2'])): ?>
                                            <span class="badge bg-secondary"><?php echo $slide['button_text_2']; ?></span>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <span class="badge bg-<?php echo $slide['status'] == 'active' ? 'success' : 'danger'; ?>">
                                            <?php echo $slide['status'] == 'active' ? 'Aktif' : 'Tidak Aktif'; ?>
                                        </span>
                                    </td>
                                    <td>
                                        <button type="button" class="btn btn-sm btn-info" onclick="editSlide(<?php echo $slide['id']; ?>)">
                                            <i class="fas fa-edit"></i>
                                        </button>
                                        <a href="<?php echo BASE_URL; ?>/admin/carousel.php?delete=<?php echo $slide['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Yakin ingin menghapus slide ini?')">
                                            <i class="fas fa-trash"></i>
                                        </a>
                                    </td>
                                </tr>
                                <?php endwhile; ?>
                            </tbody>
                        </table>
                    </div>
                    <input type="hidden" name="order" id="orderInput">
                    <button type="submit" name="update_order" class="btn btn-success mt-3" id="saveOrderBtn">
                        <i class="fas fa-save me-2"></i>Simpan Urutan
                    </button>
                </form>
            <?php else: ?>
                <div class="text-center py-5">
                    <i class="fas fa-images fa-4x text-muted mb-3"></i>
                    <h5>Belum ada slide carousel</h5>
                    <p class="text-muted">Klik tombol "Tambah Slide Baru" untuk menambahkan slide pertama.</p>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

<!-- Modal Add Slide -->
<div class="modal fade" id="addSlideModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form method="POST" enctype="multipart/form-data" action="<?php echo BASE_URL; ?>/admin/carousel.php">
                <div class="modal-header">
                    <h5 class="modal-title">Tambah Slide Carousel Baru</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Judul Slide <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" name="title" required>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Subtitle</label>
                            <input type="text" class="form-control" name="subtitle" placeholder="Contoh: Layanan Unggulan">
                        </div>
                        <div class="col-12 mb-3">
                            <label class="form-label">Deskripsi</label>
                            <textarea class="form-control" name="description" rows="3"></textarea>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Gambar Desktop <span class="text-danger">*</span></label>
                            <input type="file" class="form-control" name="image" accept="image/*" required>
                            <small class="text-muted">Format: JPG, PNG, GIF, WEBP. Maks 2MB. Ukuran ideal: 1920x800px</small>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Gambar Mobile <span class="text-muted">(Opsional)</span></label>
                            <input type="file" class="form-control" name="image_mobile" accept="image/*">
                            <small class="text-muted">Format: JPG, PNG, GIF, WEBP. Maks 2MB. Ukuran ideal: 768x500px</small>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Urutan</label>
                            <input type="number" class="form-control" name="slide_order" value="0" min="0">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Status</label>
                            <select class="form-control" name="status">
                                <option value="active">Aktif</option>
                                <option value="inactive">Tidak Aktif</option>
                            </select>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Tombol 1 (Kiri)</label>
                            <input type="text" class="form-control" name="button_text" placeholder="Teks tombol">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Link Tombol 1</label>
                            <input type="text" class="form-control" name="button_link" placeholder="profil.php atau https://...">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Tombol 2 (Kanan)</label>
                            <input type="text" class="form-control" name="button_text_2" placeholder="Teks tombol">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Link Tombol 2</label>
                            <input type="text" class="form-control" name="button_link_2" placeholder="kontak.php atau https://...">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" name="add" class="btn btn-primary">Simpan Slide</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- Modal Edit Slide -->
<div class="modal fade" id="editSlideModal" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form method="POST" enctype="multipart/form-data" action="<?php echo BASE_URL; ?>/admin/carousel.php">
                <div class="modal-header">
                    <h5 class="modal-title">Edit Slide Carousel</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body" id="editModalBody">
                    <!-- Content will be loaded via AJAX -->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" name="edit" class="btn btn-primary">Update Slide</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- Sortable JS -->
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
<script>
// Pass BASE_URL ke JavaScript
const BASE_URL = '<?php echo BASE_URL; ?>';

// Sortable for drag & drop ordering
const sortableTable = document.getElementById('sortable');
if (sortableTable) {
    new Sortable(sortableTable, {
        handle: '.handle',
        animation: 150,
        onEnd: function() {
            document.getElementById('saveOrderBtn').disabled = false;
        }
    });
}

// Save order
document.getElementById('orderForm')?.addEventListener('submit', function(e) {
    const items = document.querySelectorAll('#sortable tr');
    const order = [];
    items.forEach(item => {
        order.push(item.dataset.id);
    });
    document.getElementById('orderInput').value = order.join(',');
});

// Edit slide function with AJAX load
function editSlide(id) {
    fetch(BASE_URL + '/admin/carousel_get.php?id=' + id)
        .then(response => response.json())
        .then(data => {
            if (data.success) {
                const html = `
                    <input type="hidden" name="id" value="${data.id}">
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Judul Slide <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" name="title" value="${escapeHtml(data.title)}" required>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Subtitle</label>
                            <input type="text" class="form-control" name="subtitle" value="${escapeHtml(data.subtitle || '')}">
                        </div>
                        <div class="col-12 mb-3">
                            <label class="form-label">Deskripsi</label>
                            <textarea class="form-control" name="description" rows="3">${escapeHtml(data.description || '')}</textarea>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Gambar Desktop</label>
                            ${data.image ? `<div class="mb-2"><img src="${BASE_URL}/${data.image}" class="preview-img" style="height:50px; width:auto;"><small class="text-muted ms-2">File saat ini: ${data.image.split('/').pop()}</small></div>` : ''}
                            <input type="file" class="form-control" name="image" accept="image/*">
                            <small class="text-muted">Kosongkan jika tidak ingin mengubah gambar</small>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Gambar Mobile <span class="text-muted">(Opsional)</span></label>
                            ${data.image_mobile ? `<div class="mb-2"><img src="${BASE_URL}/${data.image_mobile}" class="preview-img" style="height:50px; width:auto;"><small class="text-muted ms-2">File saat ini: ${data.image_mobile.split('/').pop()}</small></div>` : '<small class="text-muted">Belum ada gambar mobile</small>'}
                            <input type="file" class="form-control" name="image_mobile" accept="image/*">
                            <small class="text-muted">Kosongkan jika tidak ingin mengubah gambar</small>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Urutan</label>
                            <input type="number" class="form-control" name="slide_order" value="${data.slide_order}" min="0">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Status</label>
                            <select class="form-control" name="status">
                                <option value="active" ${data.status == 'active' ? 'selected' : ''}>Aktif</option>
                                <option value="inactive" ${data.status == 'inactive' ? 'selected' : ''}>Tidak Aktif</option>
                            </select>
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Tombol 1 (Kiri)</label>
                            <input type="text" class="form-control" name="button_text" value="${escapeHtml(data.button_text || '')}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Link Tombol 1</label>
                            <input type="text" class="form-control" name="button_link" value="${escapeHtml(data.button_link || '')}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Tombol 2 (Kanan)</label>
                            <input type="text" class="form-control" name="button_text_2" value="${escapeHtml(data.button_text_2 || '')}">
                        </div>
                        <div class="col-md-6 mb-3">
                            <label class="form-label">Link Tombol 2</label>
                            <input type="text" class="form-control" name="button_link_2" value="${escapeHtml(data.button_link_2 || '')}">
                        </div>
                    </div>
                `;
                document.getElementById('editModalBody').innerHTML = html;
                new bootstrap.Modal(document.getElementById('editSlideModal')).show();
            } else {
                alert('Gagal memuat data slide');
            }
        })
        .catch(error => {
            console.error('Error:', error);
            alert('Terjadi kesalahan saat memuat data');
        });
}

function escapeHtml(str) {
    if (!str) return '';
    return str.replace(/[&<>]/g, function(m) {
        if (m === '&') return '&amp;';
        if (m === '<') return '&lt;';
        if (m === '>') return '&gt;';
        return m;
    });
}
</script>

<?php require_once 'includes/footer.php'; ?>

Youez - 2016 - github.com/yon3zu
LinuXploit