wpfs fixes from DD32. see #5586
git-svn-id: http://svn.automattic.com/wordpress/trunk@7164 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
224cd002de
commit
607ef8887d
|
@ -85,31 +85,37 @@ class WP_Filesystem_FTPext{
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_base_dir($base = '.',$echo = false){
|
function find_base_dir($base = '.',$echo = false){
|
||||||
|
$abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
|
||||||
|
if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
|
||||||
|
if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) )
|
||||||
|
$abspath = $mat[1];
|
||||||
|
}
|
||||||
|
|
||||||
if( empty( $base ) || '.' == $base ) $base = $this->cwd();
|
if( empty( $base ) || '.' == $base ) $base = $this->cwd();
|
||||||
if( empty( $base ) ) $base = '/';
|
if( empty( $base ) ) $base = '/';
|
||||||
if( '/' != substr($base, -1) ) $base .= '/';
|
if( '/' != substr($base, -1) ) $base .= '/';
|
||||||
|
|
||||||
if($echo) echo sprintf(__('Changing to %s'), $base) .'<br>';
|
if($echo) echo __('Changing to ') . $base .'<br>';
|
||||||
if( false === ftp_chdir($this->link, $base) )
|
if( false === $this->chdir($base) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( $this->exists($base . 'wp-settings.php') ){
|
if( $this->exists($base . 'wp-settings.php') ){
|
||||||
if($echo) echo sprintf(__('Found %s'), $base . 'wp-settings.php') . '<br>';
|
if($echo) echo __('Found ') . $base . 'wp-settings.php<br>';
|
||||||
$this->wp_base = $base;
|
$this->wp_base = $base;
|
||||||
return $this->wp_base;
|
return $this->wp_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( strpos(ABSPATH, $base) > 0)
|
if( strpos($abspath, $base) > 0)
|
||||||
$arrPath = split('/',substr(ABSPATH,strpos(ABSPATH, $base)));
|
$arrPath = split('/',substr($abspath,strpos($abspath, $base)));
|
||||||
else
|
else
|
||||||
$arrPath = split('/',ABSPATH);
|
$arrPath = split('/',$abspath);
|
||||||
|
|
||||||
for($i = 0; $i <= count($arrPath); $i++)
|
for($i = 0; $i <= count($arrPath); $i++)
|
||||||
if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] );
|
if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] );
|
||||||
|
|
||||||
foreach($arrPath as $key=>$folder){
|
foreach($arrPath as $key=>$folder){
|
||||||
if( $this->is_dir($base . $folder) ){
|
if( $this->is_dir($base . $folder) ){
|
||||||
if($echo) echo sprintf(__('Found %s'), $folder) . ' ' . sprintf(__('Changing to %s'), $base . $folder . '/') . '<br>';
|
if($echo) echo __('Found ') . $folder . ' ' . __('Changing to') . ' ' . $base . $folder . '/<br>';
|
||||||
return $this->find_base_dir($base . $folder . '/',$echo);
|
return $this->find_base_dir($base . $folder . '/',$echo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,6 +164,9 @@ class WP_Filesystem_FTPext{
|
||||||
function cwd(){
|
function cwd(){
|
||||||
return ftp_pwd($this->link);
|
return ftp_pwd($this->link);
|
||||||
}
|
}
|
||||||
|
function chdir($dir){
|
||||||
|
return @ftp_chdir($dir);
|
||||||
|
}
|
||||||
function chgrp($file,$group,$recursive=false){
|
function chgrp($file,$group,$recursive=false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -170,8 +179,8 @@ class WP_Filesystem_FTPext{
|
||||||
return false;
|
return false;
|
||||||
if ( ! $recursive || ! $this->is_dir($file) ){
|
if ( ! $recursive || ! $this->is_dir($file) ){
|
||||||
if (!function_exists('ftp_chmod'))
|
if (!function_exists('ftp_chmod'))
|
||||||
return ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
|
return @ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
|
||||||
return ftp_chmod($this->link,$mode,$file);
|
return @ftp_chmod($this->link,$mode,$file);
|
||||||
}
|
}
|
||||||
//Is a directory, and we want recursive
|
//Is a directory, and we want recursive
|
||||||
$filelist = $this->dirlist($file);
|
$filelist = $this->dirlist($file);
|
||||||
|
@ -267,7 +276,8 @@ class WP_Filesystem_FTPext{
|
||||||
function copy($source,$destination,$overwrite=false){
|
function copy($source,$destination,$overwrite=false){
|
||||||
if( ! $overwrite && $this->exists($destination) )
|
if( ! $overwrite && $this->exists($destination) )
|
||||||
return false;
|
return false;
|
||||||
if ( !$content = $this->get_contents($source) )
|
$content = $this->get_contents($source);
|
||||||
|
if( false === $content)
|
||||||
return false;
|
return false;
|
||||||
return $this->put_contents($destination,$content);
|
return $this->put_contents($destination,$content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,12 +87,18 @@ class WP_Filesystem_ftpsockets{
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_base_dir($base = '.',$echo = false) {
|
function find_base_dir($base = '.',$echo = false) {
|
||||||
|
$abspath = str_replace('\\','/',ABSPATH); //windows: Straighten up the paths..
|
||||||
|
if( strpos($abspath, ':') ){ //Windows, Strip out the driveletter
|
||||||
|
if( preg_match("|.{1}\:(.+)|i", $abspath, $mat) )
|
||||||
|
$abspath = $mat[1];
|
||||||
|
}
|
||||||
|
|
||||||
if( empty( $base ) || '.' == $base ) $base = $this->cwd();
|
if( empty( $base ) || '.' == $base ) $base = $this->cwd();
|
||||||
if( empty( $base ) ) $base = '/';
|
if( empty( $base ) ) $base = '/';
|
||||||
if( '/' != substr($base, -1) ) $base .= '/';
|
if( '/' != substr($base, -1) ) $base .= '/';
|
||||||
|
|
||||||
if($echo) echo __('Changing to ') . $base .'<br>';
|
if($echo) echo __('Changing to ') . $base .'<br>';
|
||||||
if( false === $this->ftp->chdir($base) )
|
if( false === $this->chdir($base) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( $this->exists($base . 'wp-settings.php') ){
|
if( $this->exists($base . 'wp-settings.php') ){
|
||||||
|
@ -101,10 +107,10 @@ class WP_Filesystem_ftpsockets{
|
||||||
return $this->wp_base;
|
return $this->wp_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( strpos(ABSPATH, $base) > 0)
|
if( strpos($abspath, $base) > 0)
|
||||||
$arrPath = split('/',substr(ABSPATH,strpos(ABSPATH, $base)));
|
$arrPath = split('/',substr($abspath,strpos($abspath, $base)));
|
||||||
else
|
else
|
||||||
$arrPath = split('/',ABSPATH);
|
$arrPath = split('/',$abspath);
|
||||||
|
|
||||||
for($i = 0; $i <= count($arrPath); $i++)
|
for($i = 0; $i <= count($arrPath); $i++)
|
||||||
if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] );
|
if( $arrPath[ $i ] == '' ) unset( $arrPath[ $i ] );
|
||||||
|
@ -129,6 +135,9 @@ class WP_Filesystem_ftpsockets{
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_contents($file,$type='',$resumepos=0){
|
function get_contents($file,$type='',$resumepos=0){
|
||||||
|
if( ! $this->exists($file) )
|
||||||
|
return false;
|
||||||
|
|
||||||
if( empty($type) ){
|
if( empty($type) ){
|
||||||
$extension = substr(strrchr($filename, "."), 1);
|
$extension = substr(strrchr($filename, "."), 1);
|
||||||
$type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII;
|
$type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_AUTOASCII;
|
||||||
|
@ -137,7 +146,7 @@ class WP_Filesystem_ftpsockets{
|
||||||
$temp = tmpfile();
|
$temp = tmpfile();
|
||||||
if ( ! $this->ftp->fget($temp, $file) ) {
|
if ( ! $this->ftp->fget($temp, $file) ) {
|
||||||
fclose($temp);
|
fclose($temp);
|
||||||
return false;
|
return ''; //Blank document, File does exist, Its just blank.
|
||||||
}
|
}
|
||||||
fseek($temp, 0); //Skip back to the start of the file being written to
|
fseek($temp, 0); //Skip back to the start of the file being written to
|
||||||
$contents = '';
|
$contents = '';
|
||||||
|
@ -287,7 +296,7 @@ class WP_Filesystem_ftpsockets{
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$content = $this->get_contents($source);
|
$content = $this->get_contents($source);
|
||||||
if ( !$content )
|
if ( false === $content )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return $this->put_contents($destination,$content);
|
return $this->put_contents($destination,$content);
|
||||||
|
|
Loading…
Reference in New Issue