note 92674 added to function.chmod
| From: | david at ordal dot com | Date: | Mon, 03 Aug 2009 19:24:36 +0000 |
| Subject: | note 92674 added to function.chmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159057@lists.php.net to get a copy of this message | ||
An improvement on the recursive chmod from nicolas@infosoft.... in July 2008. This is a little
shorter and should handle all types of linux filesystem files.
<?php
function chmodr($path, $filemode) {
if (!is_dir($path))
return chmod($path, $filemode);
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
if(is_link($fullpath))
return FALSE;
elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode))
return FALSE;
elseif(!chmodr($fullpath, $filemode))
return FALSE;
}
}
closedir($dh);
if(chmod($path, $filemode))
return TRUE;
else
return FALSE;
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 168.189.13.46
----
Manual Page -- http://www.php.net/manual/en/function.chmod.php
Edit -- https://master.php.net/note/edit/92674
Del: integrated -- https://master.php.net/note/delete/92674/integrated
Del: useless -- https://master.php.net/note/delete/92674/useless
Del: bad code -- https://master.php.net/note/delete/92674/bad+code
Del: spam -- https://master.php.net/note/delete/92674/spam
Del: non-english -- https://master.php.net/note/delete/92674/non-english
Del: in docs -- https://master.php.net/note/delete/92674/in+docs
Del: other reasons-- https://master.php.net/note/delete/92674
Reject -- https://master.php.net/note/reject/92674
Search -- https://master.php.net/manage/user-notes.php