Skip to content

Instantly share code, notes, and snippets.

@loorlab
Last active September 30, 2018 18:00
Show Gist options
  • Save loorlab/6b3686e2e65c7fd0cfc3 to your computer and use it in GitHub Desktop.
Save loorlab/6b3686e2e65c7fd0cfc3 to your computer and use it in GitHub Desktop.
Delete File/Folder Persistent CHMOD 777
<?php
function rchmod($parent, $dmod, $fmod) {
if (is_dir($parent)) {
$old = umask(0000);
chmod($parent, $dmod);
umask($old);
if ($handle = opendir($parent)) {
while (($file = readdir($handle)) !== false) {
if ($file === "." or $file === "..") {
continue;
} elseif (is_dir($parent . '/' . $file)) {
rchmod($parent . '/' . $file, $dmod, $fmod);
} else {
$old = umask(0000);
chmod($parent . '/' . $file, $fmod);
umask($old);
}
}
closedir($handle);
}
} else {
$old = umask(0000);
chmod($parent, $fmod);
umask($old);
}
}
rchmod('foldername/', 0777, 0666);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment