Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.
1 to 4 of 4
function kill_dir($path) {
// Great removal function originally named advancedRmdir() by kisgabo94 at freemail dot hu
// if the path exists, attempt to delete it, else we don't need to do anything
if (isset($path) && file_exists($path)) {
$origipath = $path;
$handler = opendir($path);
while (true) {
$item = readdir($handler);
if ($item == '.' or $item == '..') {
continue;
} elseif (gettype($item) == 'boolean') {
closedir($handler);
// If safe_mode enabled, open the permissions first
if (is_safe_mode() && !is_writable(dirname($path).'/')) {
$parent_path = dirname($path).'/';
chmod_ftp($parent_path, 0777);
}
$remove = @rmdir($path);
// If safe_mode enabled, close the permissions back down to the default
if (is_safe_mode()) {
chmod_ftp($parent_path);
}
if (!$remove) {
return false;
}
if ($path == $origipath) {
break;
}
$path = substr($path, 0, strrpos($path, '/'));
$handler = opendir($path);
} elseif (is_dir($path.'/'.$item)) {
closedir($handler);
$path = $path.'/'.$item;
$handler = opendir($path);
} else {
// If safe_mode enabled, open the permissions first
if (is_safe_mode() && !is_writable($path)) {
chmod_ftp($path.'/', 0777);
}
@unlink($path.'/'.$item);
}
}
}
return true;
}
function kill_file($file) {
// if the path exists, attempt to delete it, else we don't need to do anything
if (isset($file) && file_exists($file)) {
// Check if it's an uploaded file
$uploaded = is_uploaded_file($file);
// If safe_mode enabled, open the permissions first
if (is_safe_mode() && !$uploaded) {
$parent_path = dirname($file).'/';
chmod_ftp($parent_path, 0777);
}
$remove = @unlink($file);
// If safe_mode enabled, close the permissions back down to the default
if (is_safe_mode() && !$uploaded) {
chmod_ftp($parent_path);
}
if (!$remove) {
return false;
}
}
return true;
}
1 to 4 of 4