note 46194 deleted from function.fileperms by aidan

From: Date: Sat, 02 Oct 2004 06:42:29 +0000
Subject: note 46194 deleted from function.fileperms by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77730@lists.php.net to get a copy of this message
Note Submitter: justin dot shreve at gmail dot com ---- A quick function I wrote to check a file for permissions to see if it matches the $mode parameter (each mode is seperated by a coma (,): 0666,0777 <?php function check_filepermissions($file,$mode) { $modes = explode(",", $mode); foreach($modes as $perms) { if (preg_match("/".$perms."/i", substr(sprintf('%o',fileperms($file)), -4))) { return true; break; } } } ?> Can be used like so: <?php define("home",".././"); if (check_filepermissions(home."install/","0777,0666")) { correct("The file ".home."install/ has been chmodded sucsessfully"); } else { error("The file ".home."install/ has incorrect permissions, please chmod it to 0666 or 0777"); $errors++; } ?>

« previous php.notes (#77730) next »