I'm having issues with my OVH hosting. I have an "Archive" folder that I created (which is not a WordPress or Joomla folder) and I can't delete it; I don't even have access to the permissions. Has anyone encountered this problem and what solution should be adopted?
The email from OVH tells me there is a cache.php file, which is a hacker file, inside this folder.
<?php
// Activate error display
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Set the path to your folder (e.g., 'wp-content/uploads/weird-folder' or 'weird-folder')
$target = '1';
function forceDelete($dir) {
if (!file_exists($dir)) {
return "Le dossier n'existe pas à cet emplacement : " . htmlspecialchars($dir);
}
if (!is_dir($dir)) {
chmod($dir, 0777);
return unlink($dir) ? "Fichier supprimé : $dir" : "Échec suppression fichier : $dir";
}
// Force the permissions of the main folder
chmod($dir, 0777);
// Iterate over all files and subfolders (including hidden ones like .htaccess)
$items = array_diff(scandir($dir), array('.', '..'));
foreach ($items as $item) {
$path = $dir . DIRECTORY_SEPARATOR . $item;
chmod($path, 0777);
if (is_dir($path)) {
forceDelete($path);
} else {
if (!unlink($path)) {
echo "Impossible de supprimer le fichier : " . htmlspecialchars($path) . "<br>";
}
}
}
return rmdir($dir) ? "<b>Dossier supprimé avec succès !</b>" : "<b>Échec de la suppression du dossier racine.</b>";
}
echo forceDelete($target);
?>
<?php
// Enable error display
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Set the path to your folder (e.g., 'wp-content/uploads/weird-folder' or 'weird-folder')
$target = '1';
function forceDelete($dir) {
if (!file_exists($dir)) {
return "The folder does not exist at this location: " . htmlspecialchars($dir);
}
if (!is_dir($dir)) {
chmod($dir, 0777);
return unlink($dir) ? "File deleted: $dir" : "Failed to delete file: $dir";
}
// Force permissions on the main folder
chmod($dir, 0777);
// Iterate over all files and subfolders (including hidden ones like .htaccess)
$items = array_diff(scandir($dir), array('.', '..'));
foreach ($items as $item) {
$path = $dir . DIRECTORY_SEPARATOR . $item;
chmod($path, 0777);
if (is_dir($path)) {
forceDelete($path);
} else {
if (!unlink($path)) {
echo "Unable to delete file: " . htmlspecialchars($path) . "<br>";
}
}
}
return rmdir($dir) ? "<b>Folder successfully deleted!</b>" : "<b>Failed to delete the root folder.</b>";
}
echo forceDelete($target);
?>