mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 11:35:48 +00:00
Move win_is_writable() from wp-admin/includes to wp-includes so that it's always available for get_temp_dir(). Fixes #20778
git-svn-id: http://core.svn.wordpress.org/trunk@22009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
079afa8ce2
commit
a41af6219a
@ -523,36 +523,6 @@ function saveDomDocument($doc, $filename) {
|
|||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Workaround for Windows bug in is_writable() function
|
|
||||||
*
|
|
||||||
* @since 2.8.0
|
|
||||||
*
|
|
||||||
* @param string $path
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function win_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] == '/' ) // recursively return a temporary file path
|
|
||||||
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
|
|
||||||
else if ( is_dir( $path ) )
|
|
||||||
return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
|
|
||||||
// check tmp file for read/write capabilities
|
|
||||||
$should_delete_tmp_file = !file_exists( $path );
|
|
||||||
$f = @fopen( $path, 'a' );
|
|
||||||
if ( $f === false )
|
|
||||||
return false;
|
|
||||||
fclose( $f );
|
|
||||||
if ( $should_delete_tmp_file )
|
|
||||||
unlink( $path );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the default admin color scheme picker (Used in user-edit.php)
|
* Display the default admin color scheme picker (Used in user-edit.php)
|
||||||
*
|
*
|
||||||
|
@ -1408,6 +1408,36 @@ function get_temp_dir() {
|
|||||||
return $temp;
|
return $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workaround for Windows bug in is_writable() function
|
||||||
|
*
|
||||||
|
* @since 2.8.0
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function win_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] == '/' ) // recursively return a temporary file path
|
||||||
|
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
|
||||||
|
else if ( is_dir( $path ) )
|
||||||
|
return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
|
||||||
|
// check tmp file for read/write capabilities
|
||||||
|
$should_delete_tmp_file = !file_exists( $path );
|
||||||
|
$f = @fopen( $path, 'a' );
|
||||||
|
if ( $f === false )
|
||||||
|
return false;
|
||||||
|
fclose( $f );
|
||||||
|
if ( $should_delete_tmp_file )
|
||||||
|
unlink( $path );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array containing the current upload directory's path and url.
|
* Get an array containing the current upload directory's path and url.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user