private static function is_really_writable($file)
{
// Create cache directory if not exists
if (!file_exists($file)) {
mkdir($file, 0755);
}
// If we're on a Unix server with safe_mode off we call is_writable
if (DIRECTORY_SEPARATOR === '/' && (version_compare(PHP_VERSION, '5.4', '>=') or !ini_get('safe_mode'))) {
return is_writable($file);
}
/* For Windows servers and safe_mode "on" installations we'll actually
* write a file then read it. Bah...
*/
if (is_dir($file)) {
$file = rtrim($file, '/') . '/' . md5(mt_rand());
if (($fp = @fopen($file, 'ab')) === FALSE) {
return FALSE;
}
fclose($fp);
@chmod($file, 0777);
@unlink($file);
return TRUE;
} elseif (!is_file($file) or ($fp = @fopen($file, 'ab')) === FALSE) {
return FALSE;
}
fclose($fp);
return TRUE;
}