note 74116 added to function.chmod
| From: | AmbrielAngel at www dot ambriels dot net/entry | Date: | Mon, 26 Mar 2007 05:53:17 +0000 |
| Subject: | note 74116 added to function.chmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124801@lists.php.net to get a copy of this message | ||
Two Notes:
CORRECTION:
please note my following notes were incorrect:
# Public Read = 0004 (4) , Write = 0002 (2), Execute = 0001 (1)
# Group Read = 0040 (32) , Write = 0020 (16), Execute = 0010 (8)
# World Read 0400 (256), Write 0200 (128), Execute 0100 (64)
should be
# User Read = 0400 (256), Write = 0200 (128), Execute = 0100 (64)
# Group Read = 0040 (32), Write = 0020 (16), Execute = 0010 (8)
# Public Read = 0004 (4), Write = 0002 (2), Execute = 0001 (1)
and here is an extended "getmod" function
// Get file permissions supported by chmod
function getmod($filename) {
$val = 0;
$perms = fileperms($filename);
// Owner; User
$val += (($perms & 0x0100) ? 0x0100 : 0x0000); //Read
$val += (($perms & 0x0080) ? 0x0080 : 0x0000); //Write
$val += (($perms & 0x0040) ? 0x0040 : 0x0000); //Execute
// Group
$val += (($perms & 0x0020) ? 0x0020 : 0x0000); //Read
$val += (($perms & 0x0010) ? 0x0010 : 0x0000); //Write
$val += (($perms & 0x0008) ? 0x0008 : 0x0000); //Execute
// Global; World
$val += (($perms & 0x0004) ? 0x0004 : 0x0000); //Read
$val += (($perms & 0x0002) ? 0x0002 : 0x0000); //Write
$val += (($perms & 0x0001) ? 0x0001 : 0x0000); //Execute
// Misc
$val += (($perms & 0x40000) ? 0x40000 : 0x0000); //temporary file (01000000)
$val += (($perms & 0x80000) ? 0x80000 : 0x0000); //compressed file (02000000)
$val += (($perms & 0x100000) ? 0x100000 : 0x0000); //sparse file (04000000)
$val += (($perms & 0x0800) ? 0x0800 : 0x0000); //Hidden file (setuid bit) (04000)
$val += (($perms & 0x0400) ? 0x0400 : 0x0000); //System file (setgid bit) (02000)
$val += (($perms & 0x0200) ? 0x0200 : 0x0000); //Archive bit (sticky bit) (01000)
return $val;
}
----
Server IP: 69.147.83.197
Probable Submitter: 75.26.204.241
----
Manual Page -- http://www.php.net/manual/en/function.chmod.php
Edit -- https://master.php.net/note/edit/74116
Del: integrated -- https://master.php.net/note/delete/74116/integrated
Del: useless -- https://master.php.net/note/delete/74116/useless
Del: bad code -- https://master.php.net/note/delete/74116/bad+code
Del: spam -- https://master.php.net/note/delete/74116/spam
Del: non-english -- https://master.php.net/note/delete/74116/non-english
Del: in docs -- https://master.php.net/note/delete/74116/in+docs
Del: other reasons-- https://master.php.net/note/delete/74116
Reject -- https://master.php.net/note/reject/74116
Search -- https://master.php.net/manage/user-notes.php