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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/bpkd/admin//services.php
<?php
$page_title = 'Manajemen Layanan';
require_once 'config/database.php';
require_once '../includes/config.php'; // Load BASE_URL
require_once 'includes/init.php';
requireLogin();

// =====================================================
// HANDLE ADD
// =====================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add'])) {
    $title = sanitize($_POST['title']);
    $description = sanitize($_POST['description']);
    $icon = sanitize($_POST['icon']);
    $link = sanitize($_POST['link']);
    $button_text = sanitize($_POST['button_text'] ?: 'Selengkapnya');
    $status = sanitize($_POST['status']);
    $service_order = (int)$_POST['service_order'];
    $featured = isset($_POST['featured']) ? 1 : 0;
    
    $query = "INSERT INTO services (title, description, icon, link, button_text, status, service_order, featured) 
              VALUES ('$title', '$description', '$icon', '$link', '$button_text', '$status', $service_order, $featured)";
    
    if ($conn->query($query)) {
        redirect(BASE_URL . '/admin/services.php?msg=added');
    } else {
        $error = "Error: " . $conn->error;
    }
}

// =====================================================
// HANDLE EDIT
// =====================================================
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['edit'])) {
    $id = (int)$_POST['id'];
    $title = sanitize($_POST['title']);
    $description = sanitize($_POST['description']);
    $icon = sanitize($_POST['icon']);
    $link = sanitize($_POST['link']);
    $button_text = sanitize($_POST['button_text']);
    $status = sanitize($_POST['status']);
    $service_order = (int)$_POST['service_order'];
    $featured = isset($_POST['featured']) ? 1 : 0;
    
    $query = "UPDATE services SET 
              title = '$title', 
              description = '$description', 
              icon = '$icon', 
              link = '$link', 
              button_text = '$button_text', 
              status = '$status', 
              service_order = $service_order, 
              featured = $featured 
              WHERE id = $id";
    
    if ($conn->query($query)) {
        redirect(BASE_URL . '/admin/services.php?msg=updated');
    } else {
        $error = "Error: " . $conn->error;
    }
}

// =====================================================
// HANDLE DELETE
// =====================================================
if (isset($_GET['delete'])) {
    $id = (int)$_GET['delete'];
    $conn->query("DELETE FROM services WHERE id = $id");
    redirect(BASE_URL . '/admin/services.php?msg=deleted');
}

// =====================================================
// HANDLE TOGGLE FEATURED
// =====================================================
if (isset($_GET['toggle_featured'])) {
    $id = (int)$_GET['toggle_featured'];
    $current = $conn->query("SELECT featured FROM services WHERE id = $id")->fetch_assoc();
    $new_value = $current['featured'] ? 0 : 1;
    $conn->query("UPDATE services SET featured = $new_value WHERE id = $id");
    redirect(BASE_URL . '/admin/services.php');
}

// =====================================================
// GET DATA
// =====================================================
$services = $conn->query("SELECT * FROM services ORDER BY featured DESC, service_order ASC, id ASC");

// Get for edit
$edit_service = null;
if (isset($_GET['edit'])) {
    $id = (int)$_GET['edit'];
    $result = $conn->query("SELECT * FROM services WHERE id = $id");
    $edit_service = $result->fetch_assoc();
}

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

require_once 'includes/header.php';
?>

<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">
            <i class="fas fa-hand-holding-heart me-2"></i>Manajemen Layanan
        </h1>
        <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addModal">
            <i class="fas fa-plus me-2"></i>Tambah Layanan
        </button>
    </div>

    <?php echo $msg; ?>
    <?php if (isset($error)) echo '<div class="alert alert-danger">' . $error . '</div>'; ?>

    <!-- Add/Edit Form Modals -->
    <?php include 'services_form.php'; ?>

    <!-- Services List -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-white">Daftar Layanan</h6>
        </div>
        <div class="card-body">
            <?php if ($services && $services->num_rows > 0): ?>
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th>Icon</th>
                                <th>Judul</th>
                                <th>Deskripsi</th>
                                <th>Link</th>
                                <th>Status</th>
                                <th>Urutan</th>
                                <th>Unggulan</th>
                                <th>Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php while($service = $services->fetch_assoc()): ?>
                            <tr>
                                <td style="font-size: 24px;">
                                    <i class="<?php echo $service['icon']; ?> text-primary"></i>
                                </td>
                                <td>
                                    <strong><?php echo htmlspecialchars($service['title']); ?></strong>
                                </td>
                                <td>
                                    <small><?php echo substr(htmlspecialchars($service['description']), 0, 50); ?>...</small>
                                </td>
                                <td>
                                    <code><?php echo $service['link']; ?></code>
                                </td>
                                <td>
                                    <span class="badge bg-<?php echo $service['status'] == 'active' ? 'success' : 'secondary'; ?>">
                                        <?php echo ucfirst($service['status']); ?>
                                    </span>
                                </td>
                                <td><?php echo $service['service_order']; ?></td>
                                <td>
                                    <a href="?toggle_featured=<?php echo $service['id']; ?>" class="btn btn-sm btn-<?php echo $service['featured'] ? 'warning' : 'secondary'; ?>">
                                        <i class="fas fa-star"></i>
                                    </a>
                                </td>
                                <td>
                                    <a href="<?php echo BASE_URL; ?>/admin/services.php?edit=<?php echo $service['id']; ?>" class="btn btn-sm btn-info">
                                        <i class="fas fa-edit"></i>
                                    </a>
                                    <a href="<?php echo BASE_URL; ?>/admin/services.php?delete=<?php echo $service['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Yakin ingin menghapus?')">
                                        <i class="fas fa-trash"></i>
                                    </a>
                                </td>
                            </tr>
                            <?php endwhile; ?>
                        </tbody>
                    </table>
                </div>
            <?php else: ?>
                <div class="text-center py-5">
                    <i class="fas fa-hand-holding-heart fa-4x text-muted mb-3"></i>
                    <h5>Belum ada layanan</h5>
                    <p class="text-muted">Klik tombol "Tambah Layanan" untuk menambahkan layanan pertama.</p>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

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

Youez - 2016 - github.com/yon3zu
LinuXploit