note 47744 added to function.chmod

From: Date: Sat, 27 Nov 2004 20:09:09 +0000
Subject: note 47744 added to function.chmod
Groups: php.notes 
Request: Send a blank email to php-notes+get-81097@lists.php.net to get a copy of this message
For recursive chmod'ing see the function below. Only really usefull when chmod'ing a tree containing directories only, jet, since you don't want an executable bit on a regular file. Who completes the function so it's accepting strings like "g+w", and it's as usefull as unix "chmod -R" ? ;-) <?php function chmod_R($path, $filemode) { if (!is_dir($path)) return chmod($path, $filemode); $dh = opendir($path); while ($file = readdir($dh)) { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; if(!is_dir($fullpath)) { if (!chmod($fullpath, $filemode)) return FALSE; } else { if (!chmod_R($fullpath, $filemode)) return FALSE; } } } closedir($dh); if(chmod($path, $filemode)) return TRUE; else return FALSE; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.chmod.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47744 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47744&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47744&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47744&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47744&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47744&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47744&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47744&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81097) next »