public static function isWritable($directory, $excludeDirectory = array())
{
$folder = opendir($directory);
if (!is_resource($folder)) {
return false;
}
while (false !== ($file = readdir($folder))) {
$path = $directory . '/' . $file;
if (!in_array($file, array('.', '..')) and !in_array($path, $excludeDirectory)) {
$isWritable = true;
if (is_dir($path)) {
$isWritable = self::isWritable($path, $excludeDirectory);
}
if (empty($isWritable) or !is_writable($path)) {
closedir($folder);
return false;
}
}
}
closedir($folder);
return true;
}