WP_Filesystem: Let the code breathe, add some additional whitespace between method definitions and comments.
Built from https://develop.svn.wordpress.org/trunk@25305 git-svn-id: http://core.svn.wordpress.org/trunk@25267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6d1ffc62ea
commit
7a6fad844a
|
@ -20,6 +20,7 @@ class WP_Filesystem_Base {
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
var $verbose = false;
|
var $verbose = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached list of local filepaths to mapped remote filepaths.
|
* Cached list of local filepaths to mapped remote filepaths.
|
||||||
*
|
*
|
||||||
|
@ -47,11 +48,12 @@ class WP_Filesystem_Base {
|
||||||
*/
|
*/
|
||||||
function abspath() {
|
function abspath() {
|
||||||
$folder = $this->find_folder(ABSPATH);
|
$folder = $this->find_folder(ABSPATH);
|
||||||
//Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
|
// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
|
||||||
if ( ! $folder && $this->is_dir('/wp-includes') )
|
if ( ! $folder && $this->is_dir('/wp-includes') )
|
||||||
$folder = '/';
|
$folder = '/';
|
||||||
return $folder;
|
return $folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path on the remote filesystem of WP_CONTENT_DIR
|
* Returns the path on the remote filesystem of WP_CONTENT_DIR
|
||||||
*
|
*
|
||||||
|
@ -62,6 +64,7 @@ class WP_Filesystem_Base {
|
||||||
function wp_content_dir() {
|
function wp_content_dir() {
|
||||||
return $this->find_folder(WP_CONTENT_DIR);
|
return $this->find_folder(WP_CONTENT_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path on the remote filesystem of WP_PLUGIN_DIR
|
* Returns the path on the remote filesystem of WP_PLUGIN_DIR
|
||||||
*
|
*
|
||||||
|
@ -73,6 +76,7 @@ class WP_Filesystem_Base {
|
||||||
function wp_plugins_dir() {
|
function wp_plugins_dir() {
|
||||||
return $this->find_folder(WP_PLUGIN_DIR);
|
return $this->find_folder(WP_PLUGIN_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path on the remote filesystem of the Themes Directory
|
* Returns the path on the remote filesystem of the Themes Directory
|
||||||
*
|
*
|
||||||
|
@ -91,6 +95,7 @@ class WP_Filesystem_Base {
|
||||||
|
|
||||||
return $this->find_folder( $theme_root );
|
return $this->find_folder( $theme_root );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path on the remote filesystem of WP_LANG_DIR
|
* Returns the path on the remote filesystem of WP_LANG_DIR
|
||||||
*
|
*
|
||||||
|
@ -121,6 +126,7 @@ class WP_Filesystem_Base {
|
||||||
$this->verbose = $echo;
|
$this->verbose = $echo;
|
||||||
return $this->abspath();
|
return $this->abspath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locates a folder on the remote filesystem.
|
* Locates a folder on the remote filesystem.
|
||||||
*
|
*
|
||||||
|
@ -188,17 +194,17 @@ class WP_Filesystem_Base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ( 'direct' == $this->method ) {
|
} elseif ( 'direct' == $this->method ) {
|
||||||
$folder = str_replace('\\', '/', $folder); //Windows path sanitisation
|
$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
|
||||||
return trailingslashit($folder);
|
return trailingslashit($folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
$folder = preg_replace('|^([a-z]{1}):|i', '', $folder); //Strip out windows drive letter if it's there.
|
$folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there.
|
||||||
$folder = str_replace('\\', '/', $folder); //Windows path sanitisation
|
$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
|
||||||
|
|
||||||
if ( isset($this->cache[ $folder ] ) )
|
if ( isset($this->cache[ $folder ] ) )
|
||||||
return $this->cache[ $folder ];
|
return $this->cache[ $folder ];
|
||||||
|
|
||||||
if ( $this->exists($folder) ) { //Folder exists at that absolute path.
|
if ( $this->exists($folder) ) { // Folder exists at that absolute path.
|
||||||
$folder = trailingslashit($folder);
|
$folder = trailingslashit($folder);
|
||||||
$this->cache[ $folder ] = $folder;
|
$this->cache[ $folder ] = $folder;
|
||||||
return $folder;
|
return $folder;
|
||||||
|
@ -239,14 +245,14 @@ class WP_Filesystem_Base {
|
||||||
|
|
||||||
foreach ( $folder_parts as $index => $key ) {
|
foreach ( $folder_parts as $index => $key ) {
|
||||||
if ( $index == $last_index )
|
if ( $index == $last_index )
|
||||||
continue; //We want this to be caught by the next code block.
|
continue; // We want this to be caught by the next code block.
|
||||||
|
|
||||||
//Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
|
// Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,
|
||||||
// If it's found, change into it and follow through looking for it.
|
// If it's found, change into it and follow through looking for it.
|
||||||
// If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on.
|
// If it cant find WordPress down that route, it'll continue onto the next folder level, and see if that matches, and so on.
|
||||||
// If it reaches the end, and still cant find it, it'll return false for the entire function.
|
// If it reaches the end, and still cant find it, it'll return false for the entire function.
|
||||||
if ( isset($files[ $key ]) ){
|
if ( isset($files[ $key ]) ){
|
||||||
//Lets try that folder:
|
// Lets try that folder:
|
||||||
$newdir = trailingslashit(path_join($base, $key));
|
$newdir = trailingslashit(path_join($base, $key));
|
||||||
if ( $this->verbose )
|
if ( $this->verbose )
|
||||||
printf( "\n" . __('Changing to %s') . "<br/>\n", $newdir );
|
printf( "\n" . __('Changing to %s') . "<br/>\n", $newdir );
|
||||||
|
@ -257,7 +263,7 @@ class WP_Filesystem_Base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Only check this as a last resort, to prevent locating the incorrect install. All above procedures will fail quickly if this is the right branch to take.
|
// Only check this as a last resort, to prevent locating the incorrect install. All above procedures will fail quickly if this is the right branch to take.
|
||||||
if (isset( $files[ $last_path ] ) ) {
|
if (isset( $files[ $last_path ] ) ) {
|
||||||
if ( $this->verbose )
|
if ( $this->verbose )
|
||||||
printf( "\n" . __('Found %s') . "<br/>\n", $base . $last_path );
|
printf( "\n" . __('Found %s') . "<br/>\n", $base . $last_path );
|
||||||
|
@ -372,6 +378,6 @@ class WP_Filesystem_Base {
|
||||||
* @return bool true if string is binary, false otherwise
|
* @return bool true if string is binary, false otherwise
|
||||||
*/
|
*/
|
||||||
function is_binary( $text ) {
|
function is_binary( $text ) {
|
||||||
return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127)
|
return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
$this->method = 'direct';
|
$this->method = 'direct';
|
||||||
$this->errors = new WP_Error();
|
$this->errors = new WP_Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* connect filesystem.
|
* connect filesystem.
|
||||||
*
|
*
|
||||||
|
@ -33,6 +34,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
function connect() {
|
function connect() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads entire file into a string
|
* Reads entire file into a string
|
||||||
*
|
*
|
||||||
|
@ -42,6 +44,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
function get_contents($file) {
|
function get_contents($file) {
|
||||||
return @file_get_contents($file);
|
return @file_get_contents($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads entire file into an array
|
* Reads entire file into an array
|
||||||
*
|
*
|
||||||
|
@ -51,6 +54,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
function get_contents_array($file) {
|
function get_contents_array($file) {
|
||||||
return @file($file);
|
return @file($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a string to a file
|
* Write a string to a file
|
||||||
*
|
*
|
||||||
|
@ -75,6 +79,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current working directory
|
* Gets the current working directory
|
||||||
*
|
*
|
||||||
|
@ -83,6 +88,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
function cwd() {
|
function cwd() {
|
||||||
return @getcwd();
|
return @getcwd();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change directory
|
* Change directory
|
||||||
*
|
*
|
||||||
|
@ -92,6 +98,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
function chdir($dir) {
|
function chdir($dir) {
|
||||||
return @chdir($dir);
|
return @chdir($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes file group
|
* Changes file group
|
||||||
*
|
*
|
||||||
|
@ -107,7 +114,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
return @chgrp($file, $group);
|
return @chgrp($file, $group);
|
||||||
if ( ! $this->is_dir($file) )
|
if ( ! $this->is_dir($file) )
|
||||||
return @chgrp($file, $group);
|
return @chgrp($file, $group);
|
||||||
//Is a directory, and we want recursive
|
// Is a directory, and we want recursive
|
||||||
$file = trailingslashit($file);
|
$file = trailingslashit($file);
|
||||||
$filelist = $this->dirlist($file);
|
$filelist = $this->dirlist($file);
|
||||||
foreach ($filelist as $filename)
|
foreach ($filelist as $filename)
|
||||||
|
@ -115,6 +122,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes filesystem permissions
|
* Changes filesystem permissions
|
||||||
*
|
*
|
||||||
|
@ -135,7 +143,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
|
|
||||||
if ( ! $recursive || ! $this->is_dir($file) )
|
if ( ! $recursive || ! $this->is_dir($file) )
|
||||||
return @chmod($file, $mode);
|
return @chmod($file, $mode);
|
||||||
//Is a directory, and we want recursive
|
// Is a directory, and we want recursive
|
||||||
$file = trailingslashit($file);
|
$file = trailingslashit($file);
|
||||||
$filelist = $this->dirlist($file);
|
$filelist = $this->dirlist($file);
|
||||||
foreach ( (array)$filelist as $filename => $filemeta)
|
foreach ( (array)$filelist as $filename => $filemeta)
|
||||||
|
@ -143,6 +151,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes file owner
|
* Changes file owner
|
||||||
*
|
*
|
||||||
|
@ -158,13 +167,14 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
return @chown($file, $owner);
|
return @chown($file, $owner);
|
||||||
if ( ! $this->is_dir($file) )
|
if ( ! $this->is_dir($file) )
|
||||||
return @chown($file, $owner);
|
return @chown($file, $owner);
|
||||||
//Is a directory, and we want recursive
|
// Is a directory, and we want recursive
|
||||||
$filelist = $this->dirlist($file);
|
$filelist = $this->dirlist($file);
|
||||||
foreach ($filelist as $filename) {
|
foreach ($filelist as $filename) {
|
||||||
$this->chown($file . '/' . $filename, $owner, $recursive);
|
$this->chown($file . '/' . $filename, $owner, $recursive);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets file owner
|
* Gets file owner
|
||||||
*
|
*
|
||||||
|
@ -180,6 +190,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
$ownerarray = posix_getpwuid($owneruid);
|
$ownerarray = posix_getpwuid($owneruid);
|
||||||
return $ownerarray['name'];
|
return $ownerarray['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets file permissions
|
* Gets file permissions
|
||||||
*
|
*
|
||||||
|
@ -191,6 +202,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
function getchmod($file) {
|
function getchmod($file) {
|
||||||
return substr(decoct(@fileperms($file)),3);
|
return substr(decoct(@fileperms($file)),3);
|
||||||
}
|
}
|
||||||
|
|
||||||
function group($file) {
|
function group($file) {
|
||||||
$gid = @filegroup($file);
|
$gid = @filegroup($file);
|
||||||
if ( ! $gid )
|
if ( ! $gid )
|
||||||
|
@ -228,27 +240,30 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($file, $recursive = false, $type = false) {
|
function delete($file, $recursive = false, $type = false) {
|
||||||
if ( empty($file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
|
if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
|
||||||
return false;
|
return false;
|
||||||
$file = str_replace('\\', '/', $file); //for win32, occasional problems deleting files otherwise
|
$file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
|
||||||
|
|
||||||
if ( 'f' == $type || $this->is_file($file) )
|
if ( 'f' == $type || $this->is_file($file) )
|
||||||
return @unlink($file);
|
return @unlink($file);
|
||||||
if ( ! $recursive && $this->is_dir($file) )
|
if ( ! $recursive && $this->is_dir($file) )
|
||||||
return @rmdir($file);
|
return @rmdir($file);
|
||||||
|
|
||||||
//At this point it's a folder, and we're in recursive mode
|
// At this point it's a folder, and we're in recursive mode
|
||||||
$file = trailingslashit($file);
|
$file = trailingslashit($file);
|
||||||
$filelist = $this->dirlist($file, true);
|
$filelist = $this->dirlist($file, true);
|
||||||
|
|
||||||
$retval = true;
|
$retval = true;
|
||||||
if ( is_array($filelist) ) //false if no files, So check first.
|
if ( is_array( $filelist ) ) {
|
||||||
foreach ($filelist as $filename => $fileinfo)
|
foreach ( $filelist as $filename => $fileinfo ) {
|
||||||
if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) )
|
if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) )
|
||||||
$retval = false;
|
$retval = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( file_exists($file) && ! @rmdir($file) )
|
if ( file_exists($file) && ! @rmdir($file) )
|
||||||
$retval = false;
|
$retval = false;
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,6 +294,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||||
function mtime($file) {
|
function mtime($file) {
|
||||||
return @filemtime($file);
|
return @filemtime($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function size($file) {
|
function size($file) {
|
||||||
return @filesize($file);
|
return @filesize($file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,13 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
$this->method = 'ftpext';
|
$this->method = 'ftpext';
|
||||||
$this->errors = new WP_Error();
|
$this->errors = new WP_Error();
|
||||||
|
|
||||||
//Check if possible to use ftp functions.
|
// Check if possible to use ftp functions.
|
||||||
if ( ! extension_loaded('ftp') ) {
|
if ( ! extension_loaded('ftp') ) {
|
||||||
$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
|
$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set defaults:
|
// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
|
||||||
//This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
|
|
||||||
|
|
||||||
if ( ! defined('FS_TIMEOUT') )
|
if ( ! defined('FS_TIMEOUT') )
|
||||||
define('FS_TIMEOUT', 240);
|
define('FS_TIMEOUT', 240);
|
||||||
|
@ -80,7 +79,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set the Connection to use Passive FTP
|
// Set the Connection to use Passive FTP
|
||||||
@ftp_pasv( $this->link, true );
|
@ftp_pasv( $this->link, true );
|
||||||
if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT )
|
if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT )
|
||||||
@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
|
@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
|
||||||
|
@ -98,7 +97,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY ) )
|
if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
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 = '';
|
||||||
|
|
||||||
while ( ! feof($temp) )
|
while ( ! feof($temp) )
|
||||||
|
@ -108,6 +107,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
unlink($tempfile);
|
unlink($tempfile);
|
||||||
return $contents;
|
return $contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_contents_array($file) {
|
function get_contents_array($file) {
|
||||||
return explode("\n", $this->get_contents($file));
|
return explode("\n", $this->get_contents($file));
|
||||||
}
|
}
|
||||||
|
@ -136,18 +136,22 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cwd() {
|
function cwd() {
|
||||||
$cwd = @ftp_pwd($this->link);
|
$cwd = @ftp_pwd($this->link);
|
||||||
if ( $cwd )
|
if ( $cwd )
|
||||||
$cwd = trailingslashit($cwd);
|
$cwd = trailingslashit($cwd);
|
||||||
return $cwd;
|
return $cwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
function chdir($dir) {
|
function chdir($dir) {
|
||||||
return @ftp_chdir($this->link, $dir);
|
return @ftp_chdir($this->link, $dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgrp($file, $group, $recursive = false ) {
|
function chgrp($file, $group, $recursive = false ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function chmod($file, $mode = false, $recursive = false) {
|
function chmod($file, $mode = false, $recursive = false) {
|
||||||
if ( ! $mode ) {
|
if ( ! $mode ) {
|
||||||
if ( $this->is_file($file) )
|
if ( $this->is_file($file) )
|
||||||
|
@ -170,21 +174,26 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
|
return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
|
||||||
return (bool)@ftp_chmod($this->link, $mode, $file);
|
return (bool)@ftp_chmod($this->link, $mode, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function chown($file, $owner, $recursive = false ) {
|
function chown($file, $owner, $recursive = false ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function owner($file) {
|
function owner($file) {
|
||||||
$dir = $this->dirlist($file);
|
$dir = $this->dirlist($file);
|
||||||
return $dir[$file]['owner'];
|
return $dir[$file]['owner'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getchmod($file) {
|
function getchmod($file) {
|
||||||
$dir = $this->dirlist($file);
|
$dir = $this->dirlist($file);
|
||||||
return $dir[$file]['permsn'];
|
return $dir[$file]['permsn'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function group($file) {
|
function group($file) {
|
||||||
$dir = $this->dirlist($file);
|
$dir = $this->dirlist($file);
|
||||||
return $dir[$file]['group'];
|
return $dir[$file]['group'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function copy($source, $destination, $overwrite = false, $mode = false) {
|
function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||||
if ( ! $overwrite && $this->exists($destination) )
|
if ( ! $overwrite && $this->exists($destination) )
|
||||||
return false;
|
return false;
|
||||||
|
@ -193,6 +202,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
return false;
|
return false;
|
||||||
return $this->put_contents($destination, $content, $mode);
|
return $this->put_contents($destination, $content, $mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function move($source, $destination, $overwrite = false) {
|
function move($source, $destination, $overwrite = false) {
|
||||||
return ftp_rename($this->link, $source, $destination);
|
return ftp_rename($this->link, $source, $destination);
|
||||||
}
|
}
|
||||||
|
@ -216,9 +226,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
$list = @ftp_nlist($this->link, $file);
|
$list = @ftp_nlist($this->link, $file);
|
||||||
return !empty($list); //empty list = no file, so invert.
|
return !empty($list); //empty list = no file, so invert.
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_file($file) {
|
function is_file($file) {
|
||||||
return $this->exists($file) && !$this->is_dir($file);
|
return $this->exists($file) && !$this->is_dir($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_dir($path) {
|
function is_dir($path) {
|
||||||
$cwd = $this->cwd();
|
$cwd = $this->cwd();
|
||||||
$result = @ftp_chdir($this->link, trailingslashit($path) );
|
$result = @ftp_chdir($this->link, trailingslashit($path) );
|
||||||
|
@ -228,26 +240,31 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_readable($file) {
|
function is_readable($file) {
|
||||||
//Get dir list, Check if the file is readable by the current user??
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_writable($file) {
|
function is_writable($file) {
|
||||||
//Get dir list, Check if the file is writable by the current user??
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function atime($file) {
|
function atime($file) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mtime($file) {
|
function mtime($file) {
|
||||||
return ftp_mdtm($this->link, $file);
|
return ftp_mdtm($this->link, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function size($file) {
|
function size($file) {
|
||||||
return ftp_size($this->link, $file);
|
return ftp_size($this->link, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function touch($file, $time = 0, $atime = 0) {
|
function touch($file, $time = 0, $atime = 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||||
$path = untrailingslashit($path);
|
$path = untrailingslashit($path);
|
||||||
if ( empty($path) )
|
if ( empty($path) )
|
||||||
|
@ -262,6 +279,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||||
$this->chgrp($path, $chgrp);
|
$this->chgrp($path, $chgrp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rmdir($path, $recursive = false) {
|
function rmdir($path, $recursive = false) {
|
||||||
return $this->delete($path, $recursive);
|
return $this->delete($path, $recursive);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||||
$this->method = 'ftpsockets';
|
$this->method = 'ftpsockets';
|
||||||
$this->errors = new WP_Error();
|
$this->errors = new WP_Error();
|
||||||
|
|
||||||
//Check if possible to use ftp functions.
|
// Check if possible to use ftp functions.
|
||||||
if ( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' )
|
if ( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' )
|
||||||
return false;
|
return false;
|
||||||
$this->ftp = new ftp();
|
$this->ftp = new ftp();
|
||||||
|
|
||||||
//Set defaults:
|
|
||||||
if ( empty($opt['port']) )
|
if ( empty($opt['port']) )
|
||||||
$this->options['port'] = 21;
|
$this->options['port'] = 21;
|
||||||
else
|
else
|
||||||
|
@ -93,10 +92,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||||
if ( ! $this->ftp->fget($temphandle, $file) ) {
|
if ( ! $this->ftp->fget($temphandle, $file) ) {
|
||||||
fclose($temphandle);
|
fclose($temphandle);
|
||||||
unlink($temp);
|
unlink($temp);
|
||||||
return ''; //Blank document, File does exist, It's just blank.
|
return ''; // Blank document, File does exist, It's just blank.
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek($temphandle, 0); //Skip back to the start of the file being written to
|
fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
|
||||||
$contents = '';
|
$contents = '';
|
||||||
|
|
||||||
while ( ! feof($temphandle) )
|
while ( ! feof($temphandle) )
|
||||||
|
@ -242,12 +241,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_readable($file) {
|
function is_readable($file) {
|
||||||
//Get dir list, Check if the file is writable by the current user??
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_writable($file) {
|
function is_writable($file) {
|
||||||
//Get dir list, Check if the file is writable by the current user??
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue