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/settings.php
<?php
$page_title = 'Pengaturan Website';

// Load konfigurasi dengan urutan yang benar
require_once 'config/database.php';
require_once 'includes/init.php';

// Cek login
requireLogin();

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

// Handle save settings
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Untuk checkbox, jika tidak dicentang maka nilainya tidak terkirim
    $_POST['whatsapp_active'] = isset($_POST['whatsapp_active']) ? '1' : '0';
    
    // Loop melalui semua POST data
    foreach ($_POST as $key => $value) {
        if ($key != 'save_settings') {
            // Gunakan fungsi sanitize yang sudah didefinisikan di init.php
            $value = sanitize($value);
            
            // Cek apakah setting sudah ada
            $check = $conn->query("SELECT id FROM settings WHERE setting_key = '$key'");
            if ($check && $check->num_rows > 0) {
                $conn->query("UPDATE settings SET setting_value = '$value' WHERE setting_key = '$key'");
            } else {
                $conn->query("INSERT INTO settings (setting_key, setting_value, setting_group) VALUES ('$key', '$value', 'general')");
            }
        }
    }
    
    // Handle logo upload
    if (isset($_FILES['site_logo']) && $_FILES['site_logo']['error'] == 0) {
        $target_dir = "../uploads/settings/";
        if (!file_exists($target_dir)) {
            mkdir($target_dir, 0777, true);
        }
        
        $file_ext = strtolower(pathinfo($_FILES['site_logo']['name'], PATHINFO_EXTENSION));
        $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
        
        if (in_array($file_ext, $allowed)) {
            if ($_FILES['site_logo']['size'] <= 2 * 1024 * 1024) {
                $image_name = 'logo_' . time() . '_' . uniqid() . '.' . $file_ext;
                $target_file = $target_dir . $image_name;
                
                if (move_uploaded_file($_FILES['site_logo']['tmp_name'], $target_file)) {
                    $logo_path = 'uploads/settings/' . $image_name;
                    $conn->query("UPDATE settings SET setting_value = '$logo_path' WHERE setting_key = 'site_logo'");
                }
            } else {
                $error = "Ukuran file logo maksimal 2MB!";
            }
        } else {
            $error = "Format file logo tidak diizinkan! Gunakan JPG, PNG, GIF, atau WEBP.";
        }
    }
    
    // Handle favicon upload
    if (isset($_FILES['site_favicon']) && $_FILES['site_favicon']['error'] == 0) {
        $target_dir = "../uploads/settings/";
        if (!file_exists($target_dir)) {
            mkdir($target_dir, 0777, true);
        }
        
        $file_ext = strtolower(pathinfo($_FILES['site_favicon']['name'], PATHINFO_EXTENSION));
        $allowed = ['ico', 'png', 'jpg', 'jpeg'];
        
        if (in_array($file_ext, $allowed)) {
            if ($_FILES['site_favicon']['size'] <= 1 * 1024 * 1024) {
                $image_name = 'favicon_' . time() . '_' . uniqid() . '.' . $file_ext;
                $target_file = $target_dir . $image_name;
                
                if (move_uploaded_file($_FILES['site_favicon']['tmp_name'], $target_file)) {
                    $favicon_path = 'uploads/settings/' . $image_name;
                    $conn->query("UPDATE settings SET setting_value = '$favicon_path' WHERE setting_key = 'site_favicon'");
                }
            } else {
                $error = "Ukuran file favicon maksimal 1MB!";
            }
        } else {
            $error = "Format file favicon tidak diizinkan! Gunakan ICO, PNG, JPG.";
        }
    }
    
    $success = "Pengaturan berhasil disimpan!";
    
    // Refresh settings
    $settings = [];
    $result = $conn->query("SELECT * FROM settings");
    if ($result) {
        while($row = $result->fetch_assoc()) {
            $settings[$row['setting_key']] = $row['setting_value'];
        }
    }

    if (empty($error)) {
        echo "<script>alert('Pengaturan berhasil disimpan!'); window.location.href = 'settings.php';</script>";
        exit;
    }
}

// Get all settings
$settings = [];
$result = $conn->query("SELECT * FROM settings");
if ($result) {
    while($row = $result->fetch_assoc()) {
        $settings[$row['setting_key']] = $row['setting_value'];
    }
}

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

<style>
    html {
        scroll-behavior: smooth;
    }
</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">Pengaturan Website</h1>
    </div>

    <?php if (isset($success)): ?>
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            <i class="fas fa-check-circle me-2"></i><?php echo $success; ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <?php if (isset($error)): ?>
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            <i class="fas fa-exclamation-circle me-2"></i><?php echo $error; ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <form method="POST" enctype="multipart/form-data" id="settingsForm">
        <!-- ===== PENGATURAN UMUM ===== -->
        <?php if ($_SESSION['role']=='superadmin') {?>
        <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-globe me-2"></i>Pengaturan Umum
                </h6>
            </div>

            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Judul Website</label>
                            <input type="text" class="form-control" name="site_title" value="<?php echo htmlspecialchars($settings['site_title'] ?? ''); ?>">
                            <small class="text-muted">Nama website yang akan tampil di browser tab</small>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Deskripsi Website</label>
                            <textarea class="form-control" name="site_description" rows="3"><?php echo htmlspecialchars($settings['site_description'] ?? ''); ?></textarea>
                            <small class="text-muted">Deskripsi singkat untuk SEO (max 160 karakter)</small>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Kata Kunci (SEO)</label>
                            <input type="text" class="form-control" name="site_keywords" value="<?php echo htmlspecialchars($settings['site_keywords'] ?? ''); ?>">
                            <small class="text-muted">Pisahkan dengan koma, contoh: instansi, pemerintah, layanan</small>
                        </div>
                    </div>
                    
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Logo Website</label>
                            <?php if (!empty($settings['site_logo'])): ?>
                                <div class="mb-2">
                                    <img src="../<?php echo $settings['site_logo']; ?>" alt="Logo" style="max-height: 100px;" class="img-thumbnail">
                                </div>
                            <?php endif; ?>
                            <input type="file" class="form-control" name="site_logo" accept="image/*">
                            <small class="text-muted">Format: JPG, PNG, GIF, WEBP. Maks 2MB</small>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Favicon</label>
                            <?php if (!empty($settings['site_favicon'])): ?>
                                <div class="mb-2">
                                    <img src="../<?php echo $settings['site_favicon']; ?>" alt="Favicon" style="max-height: 32px;" class="img-thumbnail">
                                </div>
                            <?php endif; ?>
                            <input type="file" class="form-control" name="site_favicon" accept=".ico,.png,.jpg,.jpeg">
                            <small class="text-muted">Format: ICO, PNG. Maks 1MB</small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php } ?>

        <!-- ===== INFORMASI KONTAK ===== -->
        <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-address-book me-2"></i>Informasi Kontak
                </h6>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Alamat</label>
                            <textarea class="form-control" name="site_address" rows="3"><?php echo htmlspecialchars($settings['site_address'] ?? ''); ?></textarea>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Telepon</label>
                            <input type="text" class="form-control" name="site_phone" value="<?php echo htmlspecialchars($settings['site_phone'] ?? ''); ?>">
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Email</label>
                            <input type="email" class="form-control" name="site_email" value="<?php echo htmlspecialchars($settings['site_email'] ?? ''); ?>">
                        </div>
                    </div>
                    
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">WhatsApp</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-whatsapp"></i></span>
                                <input type="text" class="form-control" name="site_whatsapp" value="<?php echo htmlspecialchars($settings['site_whatsapp'] ?? ''); ?>" placeholder="628123456789">
                            </div>
                            <small class="text-muted">Nomor WhatsApp tanpa + dan spasi</small>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Latitude (Koordinat Peta)</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fas fa-map-pin"></i></span>
                                <input type="text" class="form-control" name="map_latitude" value="<?php echo htmlspecialchars($settings['map_latitude'] ?? '-6.200000'); ?>" placeholder="-6.200000">
                            </div>
                            <small class="text-muted">Koordinat latitude lokasi Anda</small>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Longitude (Koordinat Peta)</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fas fa-map-pin"></i></span>
                                <input type="text" class="form-control" name="map_longitude" value="<?php echo htmlspecialchars($settings['map_longitude'] ?? '106.816666'); ?>" placeholder="106.816666">
                            </div>
                            <small class="text-muted">Koordinat longitude lokasi Anda</small>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Zoom Level Peta</label>
                            <input type="number" class="form-control" name="map_zoom" value="<?php echo htmlspecialchars($settings['map_zoom'] ?? '15'); ?>" min="1" max="20">
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Google Maps API Key (Opsional)</label>
                            <input type="text" class="form-control" name="google_maps_api_key" value="<?php echo htmlspecialchars($settings['google_maps_api_key'] ?? ''); ?>" placeholder="AIzaSy...">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- ===== MEDIA SOSIAL ===== -->
        <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-share-alt me-2"></i>Media Sosial
                </h6>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Facebook</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-facebook"></i></span>
                                <input type="url" class="form-control" name="facebook_url" value="<?php echo htmlspecialchars($settings['facebook_url'] ?? ''); ?>" placeholder="https://facebook.com/...">
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Twitter</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-twitter"></i></span>
                                <input type="url" class="form-control" name="twitter_url" value="<?php echo htmlspecialchars($settings['twitter_url'] ?? ''); ?>" placeholder="https://twitter.com/...">
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Instagram</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-instagram"></i></span>
                                <input type="url" class="form-control" name="instagram_url" value="<?php echo htmlspecialchars($settings['instagram_url'] ?? ''); ?>" placeholder="https://instagram.com/...">
                            </div>
                        </div>
                    </div>
                    
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">YouTube</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-youtube"></i></span>
                                <input type="url" class="form-control" name="youtube_url" value="<?php echo htmlspecialchars($settings['youtube_url'] ?? ''); ?>" placeholder="https://youtube.com/...">
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">LinkedIn</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-linkedin"></i></span>
                                <input type="url" class="form-control" name="linkedin_url" value="<?php echo htmlspecialchars($settings['linkedin_url'] ?? ''); ?>" placeholder="https://linkedin.com/...">
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">TikTok</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-tiktok"></i></span>
                                <input type="url" class="form-control" name="tiktok_url" value="<?php echo htmlspecialchars($settings['tiktok_url'] ?? ''); ?>" placeholder="https://tiktok.com/...">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- ===== PENGATURAN EMAIL ===== -->
        <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-envelope me-2"></i>Pengaturan Email
                </h6>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">SMTP Host</label>
                            <input type="text" class="form-control" name="smtp_host" value="<?php echo htmlspecialchars($settings['smtp_host'] ?? ''); ?>" placeholder="smtp.gmail.com">
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">SMTP Port</label>
                            <input type="number" class="form-control" name="smtp_port" value="<?php echo htmlspecialchars($settings['smtp_port'] ?? '587'); ?>" placeholder="587">
                        </div>
                    </div>
                    
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">SMTP Username</label>
                            <input type="email" class="form-control" name="smtp_username" value="<?php echo htmlspecialchars($settings['smtp_username'] ?? ''); ?>" placeholder="email@domain.com">
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">SMTP Password</label>
                            <input type="password" class="form-control" name="smtp_password" value="<?php echo htmlspecialchars($settings['smtp_password'] ?? ''); ?>" placeholder="********">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- ===== WHATSAPP FLOATING BUTTON SETTINGS ===== -->
        <div class="card shadow mb-4">
            <div class="card-header py-3">
                <h6 class="m-0 font-weight-bold text-white">
                    <i class="fab fa-whatsapp me-2"></i>WhatsApp Floating Button
                </h6>
            </div>
            <div class="card-body">
                <div class="row">
                    <div class="col-md-6">
                        <div class="mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" name="whatsapp_active" id="whatsapp_active" value="1" <?php echo ($settings['whatsapp_active'] ?? '0') == '1' ? 'checked' : ''; ?>>
                                <label class="form-check-label" for="whatsapp_active">
                                    <strong>Aktifkan Tombol WhatsApp Melayang</strong>
                                </label>
                            </div>
                            <small class="text-muted">Jika diaktifkan, tombol WhatsApp akan muncul di pojok kanan bawah website</small>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Nomor WhatsApp</label>
                            <div class="input-group">
                                <span class="input-group-text"><i class="fab fa-whatsapp"></i></span>
                                <input type="text" class="form-control" name="whatsapp_number" value="<?php echo htmlspecialchars($settings['whatsapp_number'] ?? '6281234567890'); ?>" placeholder="6281234567890">
                            </div>
                            <small class="text-muted">Gunakan format internasional tanpa tanda + (contoh: 6281234567890)</small>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Pesan Default</label>
                            <textarea class="form-control" name="whatsapp_message" rows="2"><?php echo htmlspecialchars($settings['whatsapp_message'] ?? 'Halo, saya ingin bertanya tentang layanan di website ini'); ?></textarea>
                            <small class="text-muted">Pesan yang akan terisi otomatis saat chat dimulai</small>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="mb-3">
                            <label class="form-label">Teks Tombol (Opsional)</label>
                            <input type="text" class="form-control" name="whatsapp_text" value="<?php echo htmlspecialchars($settings['whatsapp_text'] ?? 'Chat via WhatsApp'); ?>" placeholder="Chat via WhatsApp">
                            <small class="text-muted">Teks yang muncul saat hover (kosongkan jika tidak ingin teks)</small>
                        </div>
                    </div>
                </div>
                
                <!-- Preview -->
                <div class="alert alert-info mt-3">
                    <strong>Preview:</strong><br>
                    <?php 
                    $wa_number = $settings['whatsapp_number'] ?? '6281234567890';
                    $wa_message = urlencode($settings['whatsapp_message'] ?? 'Halo, saya ingin bertanya tentang layanan di website ini');
                    $wa_url = "https://wa.me/{$wa_number}?text={$wa_message}";
                    ?>
                    <a href="<?php echo $wa_url; ?>" target="_blank" class="btn btn-success btn-sm">
                        <i class="fab fa-whatsapp me-1"></i> Test Link WhatsApp
                    </a>
                    <small class="text-muted ms-2">Klik untuk menguji link WhatsApp</small>
                </div>
            </div>
        </div>

        <!-- Save Button -->
        <div class="text-end mb-4">
            <button type="submit" name="save_settings" class="btn btn-primary btn-lg">
                <i class="fas fa-save me-2"></i>Simpan Semua Pengaturan
            </button>
        </div>
    </form>
</div>

<script>
// =====================================================
// SCRIPT MINIMAL - TANPA EVENT LISTENER BERMASALAH
// =====================================================

// Validasi file logo
const logoInput = document.querySelector('input[name="site_logo"]');
if (logoInput) {
    logoInput.addEventListener('change', function() {
        if (this.files[0] && this.files[0].size > 2 * 1024 * 1024) {
            alert('Ukuran file logo maksimal 2MB!');
            this.value = '';
        }
    });
}

// Validasi file favicon
const faviconInput = document.querySelector('input[name="site_favicon"]');
if (faviconInput) {
    faviconInput.addEventListener('change', function() {
        if (this.files[0] && this.files[0].size > 1 * 1024 * 1024) {
            alert('Ukuran file favicon maksimal 1MB!');
            this.value = '';
        }
    });
}

// Loading saat submit (tanpa konfirmasi)
const settingsForm = document.getElementById('settingsForm');
if (settingsForm) {
    settingsForm.addEventListener('submit', function() {
        const btn = this.querySelector('button[type="submit"]');
        if (btn) {
            btn.disabled = true;
            btn.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i>Menyimpan...';
        }
    });
}
</script>

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

Youez - 2016 - github.com/yon3zu
LinuXploit