note 92675 added to function.chown
| From: | david at ordal dot com | Date: | Mon, 03 Aug 2009 19:28:12 +0000 |
| Subject: | note 92675 added to function.chown | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159058@lists.php.net to get a copy of this message | ||
An improved recursive chown, based on nicolas@infosoft...'s recursive chmod.
<?php
function chownr($path, $uid) {
if (!is_dir($path))
return chown($path, $uid);
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
if(is_link($fullpath))
return FALSE;
elseif(!is_dir($fullpath) && !chown($fullpath, $uid))
return FALSE;
elseif(!chownr($fullpath, $uid))
return FALSE;
}
}
closedir($dh);
if(chown($path, $uid))
return TRUE;
else
return FALSE;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 168.189.13.46
----
Manual Page -- http://www.php.net/manual/en/function.chown.php
Edit -- https://master.php.net/note/edit/92675
Del: integrated -- https://master.php.net/note/delete/92675/integrated
Del: useless -- https://master.php.net/note/delete/92675/useless
Del: bad code -- https://master.php.net/note/delete/92675/bad+code
Del: spam -- https://master.php.net/note/delete/92675/spam
Del: non-english -- https://master.php.net/note/delete/92675/non-english
Del: in docs -- https://master.php.net/note/delete/92675/in+docs
Del: other reasons-- https://master.php.net/note/delete/92675
Reject -- https://master.php.net/note/reject/92675
Search -- https://master.php.net/manage/user-notes.php