red-x Posted November 23, 2008 Share Posted November 23, 2008 Hi, I tried looking for this on Google and I can't find it. How can I know if a file is chmod to 777? Thank you in advance Link to comment https://forums.phpfreaks.com/topic/133932-how-to-check-if-a-file-is-chmod/ Share on other sites More sharing options...
laPistola Posted November 23, 2008 Share Posted November 23, 2008 do you have access to the file via FTP or even a webbased file manager for it? Link to comment https://forums.phpfreaks.com/topic/133932-how-to-check-if-a-file-is-chmod/#findComment-697190 Share on other sites More sharing options...
red-x Posted November 23, 2008 Author Share Posted November 23, 2008 Yes I do but I want to check it on my settings page. So I don't have to check it with a FTP client. Link to comment https://forums.phpfreaks.com/topic/133932-how-to-check-if-a-file-is-chmod/#findComment-697200 Share on other sites More sharing options...
laPistola Posted November 23, 2008 Share Posted November 23, 2008 fileperms(URLfilename) Link to comment https://forums.phpfreaks.com/topic/133932-how-to-check-if-a-file-is-chmod/#findComment-697206 Share on other sites More sharing options...
red-x Posted November 23, 2008 Author Share Posted November 23, 2008 Is not doing anything, I'm doing it like this.. $filename = "something.php"; $file = fileperms($filename); echo $file; Is this right? Link to comment https://forums.phpfreaks.com/topic/133932-how-to-check-if-a-file-is-chmod/#findComment-697217 Share on other sites More sharing options...
Mark Baker Posted November 23, 2008 Share Posted November 23, 2008 <?php function lGetFilePerms($filename) { $sP; $perms = fileperms($filename); if ($perms & 0x1000) { $sP = 'p'; } // FIFO pipe elseif ($perms & 0x2000) { $sP = 'c'; } // Character special elseif ($perms & 0x4000) { $sP = 'd'; } // Directory elseif ($perms & 0x6000) { $sP = 'b'; } // Block special elseif ($perms & 0x8000) { $sP = '-'; } // Regular elseif ($perms & 0xA000) { $sP = 'l'; } // Symbolic Link elseif ($perms & 0xC000) { $sP = 's'; } // Socket else { $sP = 'u'; } // UNKNOWN // owner $sP .= (($perms & 0x0100) ? 'r' : '-').(($perms & 0x0080) ? 'w' : '-').(($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-')); // group $sP .= (($perms & 0x0020) ? 'r' : '-').(($perms & 0x0010) ? 'w' : '-').(($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-')); // world $sP .= (($perms & 0x0004) ? 'r' : '-').(($perms & 0x0002) ? 'w' : '-').(($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-')); return $sP; } // function lGetFilePerms() ?> Link to comment https://forums.phpfreaks.com/topic/133932-how-to-check-if-a-file-is-chmod/#findComment-697221 Share on other sites More sharing options...
red-x Posted November 23, 2008 Author Share Posted November 23, 2008 OK thank you I'll try that. Link to comment https://forums.phpfreaks.com/topic/133932-how-to-check-if-a-file-is-chmod/#findComment-697232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.