Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix typo access.sftp_psl
Browse files Browse the repository at this point in the history
  • Loading branch information
warhawk3407 committed Dec 12, 2013
1 parent 961a5ed commit 2ddf975
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 160 deletions.
88 changes: 38 additions & 50 deletions core/src/plugins/access.sftp_psl/SFTPPSL_StreamWrapper.php
Expand Up @@ -8,7 +8,7 @@
* Requirement: phpseclib - PHP Secure Communications Library
*
* Filename: SFTPPSL_StreamWrapper.php
* Classname: SFTP_StreamWrapper
* Classname: SFTPPSL_StreamWrapper
*
* #######################################################################
* # Protocol sftp://
Expand Down Expand Up @@ -112,8 +112,8 @@
* @package Net_SFTP_StreamWrapper
* @link http://www.php.net/manual/en/class.streamwrapper.php
*/
class SFTPPSL_StreamWrapper{

class SFTPPSL_StreamWrapper
{
/**
* SFTP Object
*
Expand Down Expand Up @@ -144,7 +144,7 @@ class SFTPPSL_StreamWrapper{
* @var Resource
* @access public
*/
var $context;
public $context;

/**
* Mode
Expand Down Expand Up @@ -185,7 +185,7 @@ class SFTPPSL_StreamWrapper{
* @return bool
* @access public
*/
function dir_closedir()
public function dir_closedir()
{
$this->stream_close();

Expand All @@ -209,13 +209,12 @@ function dir_closedir()
* @return bool
* @access public
*/
function dir_opendir($path, $options)
public function dir_opendir($path, $options)
{
if ( $this->stream_open($path, NULL, NULL, $opened_path) ) {
$this->dir_entries = $this->sftp->nlist($this->path);
return TRUE;
}
else {
} else {
return FALSE;
}
}
Expand All @@ -230,7 +229,7 @@ function dir_opendir($path, $options)
* @return string
* @access public
*/
function dir_readdir()
public function dir_readdir()
{
if ($this->dir_entries === false) {
return FALSE;
Expand All @@ -242,8 +241,7 @@ function dir_readdir()
$this->position += 1;

return $filename;
}
else {
} else {
return FALSE;
}
}
Expand All @@ -256,7 +254,7 @@ function dir_readdir()
* @return bool
* @access public
*/
function dir_rewinddir()
public function dir_rewinddir()
{
$this->position = 0;

Expand All @@ -276,7 +274,7 @@ function dir_rewinddir()
* @return bool
* @access public
*/
function mkdir($path, $mode, $options)
public function mkdir($path, $mode, $options)
{
$connection = $this->stream_open($path, NULL, NULL, $opened_path);
if ($connection === false) {
Expand All @@ -285,8 +283,7 @@ function mkdir($path, $mode, $options)

if ( $options === STREAM_MKDIR_RECURSIVE ) {
$mkdir = $this->sftp->mkdir($this->path, $mode, true);
}
else {
} else {
$mkdir = $this->sftp->mkdir($this->path, $mode, false);
}

Expand All @@ -306,7 +303,7 @@ function mkdir($path, $mode, $options)
* @return bool
* @access public
*/
function rename($path_from, $path_to)
public function rename($path_from, $path_to)
{
$path1 = parse_url($path_from);
$path2 = parse_url($path_to);
Expand Down Expand Up @@ -351,7 +348,7 @@ function rename($path_from, $path_to)
* @return bool
* @access public
*/
function rmdir($path, $options)
public function rmdir($path, $options)
{
$connection = $this->stream_open($path, NULL, NULL, $opened_path);
if ($connection === false) {
Expand All @@ -374,7 +371,7 @@ function rmdir($path, $options)
* @return resource
* @access public
*/
function stream_cast($cast_as)
public function stream_cast($cast_as)
{
return $this->sftp->fsock;
}
Expand All @@ -387,7 +384,7 @@ function stream_cast($cast_as)
* @return void
* @access public
*/
function stream_close()
public function stream_close()
{
// We do not really close connections because
// connections are assigned to a class static variable, so the Net_SFTP object will persist
Expand All @@ -408,7 +405,7 @@ function stream_close()
* @return bool
* @access public
*/
function stream_eof()
public function stream_eof()
{
$filesize = $this->sftp->size($this->path);

Expand All @@ -427,7 +424,7 @@ function stream_eof()
* @return bool
* @access public
*/
function stream_flush()
public function stream_flush()
{
return TRUE;
}
Expand All @@ -441,7 +438,7 @@ function stream_flush()
* @return Boolean
* @access public
*/
function stream_lock($operation)
public function stream_lock($operation)
{
return FALSE;
}
Expand All @@ -461,7 +458,7 @@ function stream_lock($operation)
* @return bool
* @access public
*/
function stream_metadata($path, $option, $var)
public function stream_metadata($path, $option, $var)
{
$connection = $this->stream_open($path, NULL, NULL, $opened_path);
if ($connection === false) {
Expand Down Expand Up @@ -525,7 +522,7 @@ function stream_metadata($path, $option, $var)
* @return bool
* @access public
*/
function stream_open($path, $mode, $options, &$opened_path)
public function stream_open($path, $mode, $options, &$opened_path)
{
$url = parse_url($path);

Expand All @@ -538,13 +535,10 @@ function stream_open($path, $mode, $options, &$opened_path)

$connection_uuid = md5( $host.$port.$user ); // Generate a unique ID for the current connection

if ( isset(self::$instances[$connection_uuid]) )
{
if ( isset(self::$instances[$connection_uuid]) ) {
// Get previously established connection
$this->sftp = self::$instances[$connection_uuid];
}
else
{
} else {
//$context = stream_context_get_options($this->context);

if (!isset($user) || !isset($pass)) {
Expand All @@ -568,8 +562,7 @@ function stream_open($path, $mode, $options, &$opened_path)

if (isset($mode)) {
$this->mode = preg_replace('#[bt]$#', '', $mode);
}
else {
} else {
$this->mode = 'r';
}

Expand All @@ -581,17 +574,15 @@ function stream_open($path, $mode, $options, &$opened_path)
$this->position = 0;
if ($filesize === FALSE) {
$this->sftp->touch( $this->path );
}
else {
} else {
$this->sftp->truncate( $this->path, 0 );
}
break;
case 'a':
if ($filesize === FALSE) {
$this->position = 0;
$this->sftp->touch( $this->path );
}
else {
} else {
$this->position = $filesize;
}
break;
Expand Down Expand Up @@ -622,7 +613,7 @@ function stream_open($path, $mode, $options, &$opened_path)
* @return mixed
* @access public
*/
function stream_read($count)
public function stream_read($count)
{
switch ($this->mode) {
case 'w':
Expand Down Expand Up @@ -650,7 +641,7 @@ function stream_read($count)
* @return bool
* @access public
*/
function stream_seek($offset, $whence)
public function stream_seek($offset, $whence)
{
$filesize = $this->sftp->size($this->path);

Expand Down Expand Up @@ -689,7 +680,7 @@ function stream_seek($offset, $whence)
* @return Boolean
* @access public
*/
function stream_set_option($option, $arg1, $arg2)
public function stream_set_option($option, $arg1, $arg2)
{
return FALSE;
}
Expand All @@ -702,11 +693,11 @@ function stream_set_option($option, $arg1, $arg2)
* @return mixed
* @access public
*/
function stream_stat()
public function stream_stat()
{
$stat = $this->sftp->stat($this->path);

if( !empty($stat) ) {
if ( !empty($stat) ) {
// mode fix
$stat['mode'] = $stat['permissions'];
unset($stat['permissions']);
Expand All @@ -725,7 +716,7 @@ function stream_stat()
* @return Integer
* @access public
*/
function stream_tell()
public function stream_tell()
{
return $this->position;
}
Expand All @@ -745,7 +736,7 @@ function stream_tell()
* @return bool
* @access public
*/
function stream_truncate($new_size)
public function stream_truncate($new_size)
{
return $this->sftp->truncate( $this->path, $new_size );
}
Expand All @@ -759,7 +750,7 @@ function stream_truncate($new_size)
* @return mixed
* @access public
*/
function stream_write($data)
public function stream_write($data)
{
switch ($this->mode) {
case 'r':
Expand All @@ -784,7 +775,7 @@ function stream_write($data)
* @return bool
* @access public
*/
function unlink($path)
public function unlink($path)
{
$connection = $this->stream_open($path, NULL, NULL, $opened_path);
if ($connection === false) {
Expand All @@ -809,7 +800,7 @@ function unlink($path)
* @return mixed
* @access public
*/
function url_stat($path, $flags)
public function url_stat($path, $flags)
{
$connection = $this->stream_open($path, NULL, NULL, $opened_path);
if ($connection === false) {
Expand All @@ -818,14 +809,13 @@ function url_stat($path, $flags)

if ( $flags === STREAM_URL_STAT_LINK ) {
$stat = $this->sftp->lstat($this->path);
}
else {
} else {
$stat = $this->sftp->stat($this->path);
}

$this->stream_close();

if( !empty($stat) ) {
if ( !empty($stat) ) {
// mode fix
$stat['mode'] = $stat['permissions'];
unset($stat['permissions']);
Expand All @@ -843,5 +833,3 @@ function url_stat($path, $flags)
*/
stream_wrapper_register('sftp', 'SFTPPSL_StreamWrapper')
or die ('Failed to register protocol');

?>

0 comments on commit 2ddf975

Please sign in to comment.