note 19708 added to function.fileperms
| From: | luzianwild at hotmail dot com | Date: | Fri, 08 Mar 2002 11:10:12 +0000 |
| Subject: | note 19708 added to function.fileperms | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27507@lists.php.net to get a copy of this message | ||
you can use this function to get permissions in standard unix format ("rwx rwx rwx" with
"-" as placeholder for a denied permission):
function get_perms($file) {
$p_bin = substr(decbin(fileperms($file)), -9) ;
$p_arr = explode(".", substr(chunk_split($p_bin, 1, "."), 0, 17)) ;
$perms = ""; $i = 0;
foreach ($p_arr as $this) {
$p_char = ( $i%3==0 ? "r" : ( $i%3==1 ? "w" : "x" ) );
$perms .= ( $this=="1" ? $p_char : "-" ) . ( $i%3==2 ? " " :
"" );
$i++;
}
return $perms;
}
--
http://www.php.net/manual/en/function.fileperms.php
http://master.php.net/manage/user-notes.php?action=edit+19708
http://master.php.net/manage/user-notes.php?action=delete+19708
http://master.php.net/manage/user-notes.php?action=reject+19708