note 70699 deleted from function.fileperms by nlopess
| From: | nlopess@php.net | Date: | Thu, 01 Feb 2007 17:45:35 +0000 |
| Subject: | note 70699 deleted from function.fileperms by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122481@lists.php.net to get a copy of this message | ||
Note Submitter: ravensworld at gmx dot de
----
Maybe it helps for a better reading.
function FilePermsDecode( $perms ){
$oct = str_split( strrev( decoct( $perms ) ), 1 );
// 0 1 2 3 4 5 6 7
$masks = array( '---', '--x', '-w-', '-wx',
'r--', 'r-x', 'rw-', 'rwx' );
return(
sprintf( '%s %s %s',
array_key_exists( $oct[ 2 ], $masks ) ? $masks[ $oct[ 2 ] ] : '###',
array_key_exists( $oct[ 1 ], $masks ) ? $masks[ $oct[ 1 ] ] : '###',
array_key_exists( $oct[ 0 ], $masks ) ? $masks[ $oct[ 0 ] ] : '###'
)
);
}
$perms = fileperms( "$u_folder/$_curId" );
if( $perms !== false ){
printf(
'decimal: %d | octal: %o | readable: %s',
$perms, $perms, FilePermsDecode( $perms )
);
}