Advertisements

get_filesystem_method

Definition:
function get_filesystem_method($args = array() {}

Determines which Filesystem Method to use.
The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsockopen())

Parameters

  • array $args: Connection details.
  • string $context: Full path to the directory that is tested for being writable.

Return values

returns:The transport to use, see description for valid return values.

Defined filters

  • filesystem_method
    apply_filters('filesystem_method', $method, $args)

Source code

function get_filesystem_method($args = array(), $context = false) {

	$method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'



	if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){

		if ( !$context )

			$context = WP_CONTENT_DIR;

		$context = trailingslashit($context);

		$temp_file_name = $context . 'temp-write-test-' . time();

		$temp_handle = @fopen($temp_file_name, 'w');

		if ( $temp_handle ) {

			if ( getmyuid() == @fileowner($temp_file_name) )

				$method = 'direct';

			@fclose($temp_handle);

			@unlink($temp_file_name);

		}

 	}



	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';

	if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';

	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread

	return apply_filters('filesystem_method', $method, $args);

}

1392

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: