Last active
September 30, 2018 18:00
-
-
Save loorlab/6b3686e2e65c7fd0cfc3 to your computer and use it in GitHub Desktop.
Delete File/Folder Persistent CHMOD 777
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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