ディレクトリが書き込み可能かどうかを確認するために使用している次の関数があります。
/**
* check if the path is writable. if the path is a folder it creates a test file.
*
* @param string $path
* @return boolean
*/
public static function is_writable( $path ) {
//will work in despite of Windows ACLs bug
//NOTE: use a trailing slash for folders!!!
//see http://bugs.php.net/bug.php?id=27609
//see http://bugs.php.net/bug.php?id=30931
if ( $path{strlen($path)-1} === DIRECTORY_SEPARATOR ) {// recursively return a temporary file path
return self::is_writable( $path . uniqid( mt_rand() ) . '.tmp' );
} else if ( is_dir( $path ) ) {
return self::is_writable( $path . DIRECTORY_SEPARATOR . uniqid( mt_rand() ) . '.tmp' );
}
$file_already_exists = file_exists( $path );
// check tmp file for read/write capabilities
$f = @fopen( $path, 'a');
if ( $f === false ) {
return false;
}
if ( ! $file_already_exists ) {
unlink( $path );
}
return true;
}
unlink()
これは、ファイルを削除する権限がないため、最近まで常に警告が表示されるまで常に正常に機能していました。しかし、一時ファイルは正常に作成されるため、ディレクトリに書き込むことができます。
警告: unlink(C:\Program Files (x86)\Zend\Apache2\htdocs\wordpress\wp-content\plugins\all-in-one-event-calendar-premium\cache\152006398050813468bb6ec.tmp) [function.unlink] : C:\Program Files (x86)\Zend\Apache2\htdocs\wordpress\wp-content\plugins\all-in-one-event-calendar-premium\lib\utility\class-ai1ec-filesystem-utility で許可が拒否されました.php 35 行目
これはどのように可能ですか?テストしているディレクトリに 777 を指定しようとしましたが、それでも警告が表示されます! Zendサーバーを搭載したWindows 7を使用しています