ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
League\Flysystem\Adapter\Ftp Class Reference
+ Inheritance diagram for League\Flysystem\Adapter\Ftp:
+ Collaboration diagram for League\Flysystem\Adapter\Ftp:

Public Member Functions

 setTransferMode ($mode)
 Set the transfer mode. More...
 
 setSsl ($ssl)
 Set if Ssl is enabled. More...
 
 setPassive ($passive=true)
 Set if passive mode should be used. More...
 
 setIgnorePassiveAddress ($ignorePassiveAddress)
 
 setRecurseManually ($recurseManually)
 
 setUtf8 ($utf8)
 
 connect ()
 Connect to the FTP server. More...
 
 disconnect ()
 Disconnect from the FTP server. More...
 
 write ($path, $contents, Config $config)
 Write a new file.
Parameters
string$path
string$contents
Config$configConfig object
Returns
array|false false on failure file meta data on success
More...
 
 writeStream ($path, $resource, Config $config)
 Write a new file using a stream.
Parameters
string$path
resource$resource
Config$configConfig object
Returns
array|false false on failure file meta data on success
More...
 
 update ($path, $contents, Config $config)
 Update a file.
Parameters
string$path
string$contents
Config$configConfig object
Returns
array|false false on failure file meta data on success
More...
 
 updateStream ($path, $resource, Config $config)
 Update a file using a stream.
Parameters
string$path
resource$resource
Config$configConfig object
Returns
array|false false on failure file meta data on success
More...
 
 rename ($path, $newpath)
 Rename a file.
Parameters
string$path
string$newpath
Returns
bool
More...
 
 delete ($path)
 Delete a file.
Parameters
string$path
Returns
bool
More...
 
 deleteDir ($dirname)
 Delete a directory.
Parameters
string$dirname
Returns
bool
More...
 
 createDir ($dirname, Config $config)
 Create a directory.
Parameters
string$dirnamedirectory name
Config$config
Returns
array|false
More...
 
 getMetadata ($path)
 Get all the meta data of a file or directory.
Parameters
string$path
Returns
array|false
More...
 
 getMimetype ($path)
 Get the mimetype of a file.
Parameters
string$path
Returns
array|false
More...
 
 getTimestamp ($path)
 Get the timestamp of a file.
Parameters
string$path
Returns
array|false
More...
 
 read ($path)
 Read a file.
Parameters
string$path
Returns
array|false
More...
 
 readStream ($path)
 Read a file as a stream.
Parameters
string$path
Returns
array|false
More...
 
 setVisibility ($path, $visibility)
 Set the visibility for a file.
Parameters
string$path
string$visibility
Returns
array|false file meta data
More...
 
 isConnected ()
 Check if the connection is open. More...
 
- Public Member Functions inherited from League\Flysystem\Adapter\AbstractFtpAdapter
 __construct (array $config)
 Constructor. More...
 
 setConfig (array $config)
 Set the config. More...
 
 getHost ()
 Returns the host. More...
 
 setHost ($host)
 Set the host. More...
 
 setPermPublic ($permPublic)
 Set the public permission value. More...
 
 setPermPrivate ($permPrivate)
 Set the private permission value. More...
 
 getPort ()
 Returns the ftp port. More...
 
 getRoot ()
 Returns the root folder to work from. More...
 
 setPort ($port)
 Set the ftp port. More...
 
 setRoot ($root)
 Set the root folder to work from. More...
 
 getUsername ()
 Returns the ftp username. More...
 
 setUsername ($username)
 Set ftp username. More...
 
 getPassword ()
 Returns the password. More...
 
 setPassword ($password)
 Set the ftp password. More...
 
 getTimeout ()
 Returns the amount of seconds before the connection will timeout. More...
 
 setTimeout ($timeout)
 Set the amount of seconds before the connection should timeout. More...
 
 getSystemType ()
 Return the FTP system type. More...
 
 setSystemType ($systemType)
 Set the FTP system type (windows or unix). More...
 
 listContents ($directory='', $recursive=false)
 List contents of a directory.
Parameters
string$directory
bool$recursive
Returns
array
More...
 
 removeDotDirectories (array $list)
 Filter out dot-directories. More...
 
 has ($path)
 Check whether a file exists.
Parameters
string$path
Returns
array|bool|null
More...
 
 getSize ($path)
 Get the size of a file.
Parameters
string$path
Returns
array|false
More...
 
 getVisibility ($path)
 Get the visibility of a file.
Parameters
string$path
Returns
array|false
More...
 
 ensureDirectory ($dirname)
 Ensure a directory exists. More...
 
 getConnection ()
 
 getPermPublic ()
 Get the public permission value. More...
 
 getPermPrivate ()
 Get the private permission value. More...
 
 __destruct ()
 Disconnect on destruction. More...
 
 connect ()
 Establish a connection. More...
 
 disconnect ()
 Close the connection. More...
 
 isConnected ()
 Check if a connection is active. More...
 
- Public Member Functions inherited from League\Flysystem\Adapter\AbstractAdapter
 setPathPrefix ($prefix)
 Set the path prefix. More...
 
 getPathPrefix ()
 Get the path prefix. More...
 
 applyPathPrefix ($path)
 Prefix a path. More...
 
 removePathPrefix ($path)
 Remove a path prefix. More...
 
- Public Member Functions inherited from League\Flysystem\AdapterInterface
 copy ($path, $newpath)
 Copy a file. More...
 

Protected Member Functions

 setUtf8Mode ()
 Set the connection to UTF-8 mode. More...
 
 setConnectionPassiveMode ()
 Set the connections to passive mode. More...
 
 setConnectionRoot ()
 Set the connection root. More...
 
 login ()
 Login. More...
 
 createActualDirectory ($directory, $connection)
 Create a directory. More...
 
 listDirectoryContents ($directory, $recursive=true)
 
 listDirectoryContentsRecursive ($directory)
 
 isPureFtpdServer ()
 
 ftpRawlist ($options, $path)
 The ftp_rawlist function with optional escaping. More...
 
- Protected Member Functions inherited from League\Flysystem\Adapter\AbstractFtpAdapter
 listDirectoryContents ($directory, $recursive=false)
 
 normalizeListing (array $listing, $prefix='')
 Normalize a directory listing. More...
 
 sortListing (array $result)
 Sort a directory listing. More...
 
 normalizeObject ($item, $base)
 Normalize a file entry. More...
 
 normalizeUnixObject ($item, $base)
 Normalize a Unix file entry. More...
 
 normalizeWindowsObject ($item, $base)
 Normalize a Windows/DOS file entry. More...
 
 detectSystemType ($item)
 Get the system type from a listing item. More...
 
 detectType ($permissions)
 Get the file type from the permissions. More...
 
 normalizePermissions ($permissions)
 Normalize a permissions string. More...
 

Protected Attributes

 $transferMode = FTP_BINARY
 
 $ignorePassiveAddress = null
 
 $recurseManually = false
 
 $utf8 = false
 
 $configurable
 
 $isPureFtpd
 
- Protected Attributes inherited from League\Flysystem\Adapter\AbstractFtpAdapter
 $connection
 
 $host
 
 $port = 21
 
 $ssl = false
 
 $timeout = 90
 
 $passive = true
 
 $separator = '/'
 
 $root
 
 $permPublic = 0744
 
 $permPrivate = 0700
 
 $configurable = []
 
 $systemType
 
 $alternativeRecursion = false
 
 $safeStorage
 
- Protected Attributes inherited from League\Flysystem\Adapter\AbstractAdapter
 $pathPrefix
 
 $pathSeparator = '/'
 

Additional Inherited Members

- Data Fields inherited from League\Flysystem\AdapterInterface
const VISIBILITY_PUBLIC = 'public'
 VISIBILITY_PUBLIC public visibility More...
 
const VISIBILITY_PRIVATE = 'private'
 VISIBILITY_PRIVATE private visibility More...
 

Detailed Description

Definition at line 13 of file Ftp.php.

Member Function Documentation

◆ connect()

League\Flysystem\Adapter\Ftp::connect ( )

Connect to the FTP server.

Definition at line 128 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\getHost(), League\Flysystem\Adapter\AbstractFtpAdapter\getPort(), League\Flysystem\Adapter\AbstractFtpAdapter\getTimeout(), League\Flysystem\Adapter\Ftp\isPureFtpdServer(), League\Flysystem\Adapter\Ftp\login(), League\Flysystem\Adapter\Ftp\setConnectionPassiveMode(), League\Flysystem\Adapter\Ftp\setConnectionRoot(), and League\Flysystem\Adapter\Ftp\setUtf8Mode().

129  {
130  if ($this->ssl) {
131  $this->connection = ftp_ssl_connect($this->getHost(), $this->getPort(), $this->getTimeout());
132  } else {
133  $this->connection = ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout());
134  }
135 
136  if ( ! $this->connection) {
137  throw new RuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort());
138  }
139 
140  $this->login();
141  $this->setUtf8Mode();
142  $this->setConnectionPassiveMode();
143  $this->setConnectionRoot();
144  $this->isPureFtpd = $this->isPureFtpdServer();
145  }
setUtf8Mode()
Set the connection to UTF-8 mode.
Definition: Ftp.php:150
getTimeout()
Returns the amount of seconds before the connection will timeout.
setConnectionPassiveMode()
Set the connections to passive mode.
Definition: Ftp.php:167
setConnectionRoot()
Set the connection root.
Definition: Ftp.php:183
+ Here is the call graph for this function:

◆ createActualDirectory()

League\Flysystem\Adapter\Ftp::createActualDirectory (   $directory,
  $connection 
)
protected

Create a directory.

Parameters
string$directory
resource$connection
Returns
bool

Definition at line 360 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$connection, and $key.

Referenced by League\Flysystem\Adapter\Ftp\createDir().

361  {
362  // List the current directory
363  $listing = ftp_nlist($connection, '.') ?: [];
364 
365  foreach ($listing as $key => $item) {
366  if (preg_match('~^\./.*~', $item)) {
367  $listing[$key] = substr($item, 2);
368  }
369  }
370 
371  if (in_array($directory, $listing, true)) {
372  return true;
373  }
374 
375  return (boolean) ftp_mkdir($connection, $directory);
376  }
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ createDir()

League\Flysystem\Adapter\Ftp::createDir (   $dirname,
Config  $config 
)

Create a directory.

Parameters
string$dirnamedirectory name
Config$config
Returns
array|false

Implements League\Flysystem\AdapterInterface.

Definition at line 332 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$connection, League\Flysystem\Adapter\Ftp\createActualDirectory(), League\Flysystem\Adapter\AbstractFtpAdapter\getConnection(), and League\Flysystem\Adapter\Ftp\setConnectionRoot().

333  {
334  $connection = $this->getConnection();
335  $directories = explode('/', $dirname);
336 
337  foreach ($directories as $directory) {
338  if (false === $this->createActualDirectory($directory, $connection)) {
339  $this->setConnectionRoot();
340 
341  return false;
342  }
343 
344  ftp_chdir($connection, $directory);
345  }
346 
347  $this->setConnectionRoot();
348 
349  return ['type' => 'dir', 'path' => $dirname];
350  }
createActualDirectory($directory, $connection)
Create a directory.
Definition: Ftp.php:360
setConnectionRoot()
Set the connection root.
Definition: Ftp.php:183
+ Here is the call graph for this function:

◆ delete()

League\Flysystem\Adapter\Ftp::delete (   $path)

Delete a file.

Parameters
string$path
Returns
bool

Implements League\Flysystem\AdapterInterface.

Definition at line 303 of file Ftp.php.

References $path, and League\Flysystem\Adapter\AbstractFtpAdapter\getConnection().

304  {
305  return ftp_delete($this->getConnection(), $path);
306  }
+ Here is the call graph for this function:

◆ deleteDir()

League\Flysystem\Adapter\Ftp::deleteDir (   $dirname)

Delete a directory.

Parameters
string$dirname
Returns
bool

Implements League\Flysystem\AdapterInterface.

Definition at line 311 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$connection, $contents, League\Flysystem\Adapter\AbstractFtpAdapter\getConnection(), and League\Flysystem\Adapter\Ftp\listDirectoryContents().

312  {
313  $connection = $this->getConnection();
314  $contents = array_reverse($this->listDirectoryContents($dirname));
315 
316  foreach ($contents as $object) {
317  if ($object['type'] === 'file') {
318  if ( ! ftp_delete($connection, $object['path'])) {
319  return false;
320  }
321  } elseif ( ! ftp_rmdir($connection, $object['path'])) {
322  return false;
323  }
324  }
325 
326  return ftp_rmdir($connection, $dirname);
327  }
listDirectoryContents($directory, $recursive=true)
Definition: Ftp.php:489
+ Here is the call graph for this function:

◆ disconnect()

League\Flysystem\Adapter\Ftp::disconnect ( )

Disconnect from the FTP server.

Definition at line 226 of file Ftp.php.

Referenced by League\Flysystem\Adapter\Ftp\login().

227  {
228  if (is_resource($this->connection)) {
229  ftp_close($this->connection);
230  }
231 
232  $this->connection = null;
233  }
+ Here is the caller graph for this function:

◆ ftpRawlist()

League\Flysystem\Adapter\Ftp::ftpRawlist (   $options,
  $path 
)
protected

The ftp_rawlist function with optional escaping.

Parameters
string$options
string$path
Returns
array

Definition at line 560 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$connection, $options, $path, and League\Flysystem\Adapter\AbstractFtpAdapter\getConnection().

Referenced by League\Flysystem\Adapter\Ftp\getMetadata(), League\Flysystem\Adapter\Ftp\listDirectoryContents(), and League\Flysystem\Adapter\Ftp\listDirectoryContentsRecursive().

561  {
562  $connection = $this->getConnection();
563 
564  if ($this->isPureFtpd) {
565  $path = str_replace(' ', '\ ', $path);
566  }
567  return ftp_rawlist($connection, $options . ' ' . $path);
568  }
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMetadata()

League\Flysystem\Adapter\Ftp::getMetadata (   $path)

Get all the meta data of a file or directory.

Parameters
string$path
Returns
array|false

Implements League\Flysystem\ReadInterface.

Definition at line 381 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$connection, $path, League\Flysystem\Adapter\Ftp\ftpRawlist(), League\Flysystem\Adapter\AbstractFtpAdapter\getConnection(), League\Flysystem\Adapter\AbstractFtpAdapter\normalizeObject(), and League\Flysystem\Adapter\Ftp\setConnectionRoot().

Referenced by League\Flysystem\Adapter\Ftp\getMimetype().

382  {
383  $connection = $this->getConnection();
384 
385  if ($path === '') {
386  return ['type' => 'dir', 'path' => ''];
387  }
388 
389  if (@ftp_chdir($connection, $path) === true) {
390  $this->setConnectionRoot();
391 
392  return ['type' => 'dir', 'path' => $path];
393  }
394 
395  $listing = $this->ftpRawlist('-A', str_replace('*', '\\*', $path));
396 
397  if (empty($listing) || in_array('total 0', $listing, true)) {
398  return false;
399  }
400 
401  if (preg_match('/.* not found/', $listing[0])) {
402  return false;
403  }
404 
405  if (preg_match('/^total [0-9]*$/', $listing[0])) {
406  array_shift($listing);
407  }
408 
409  return $this->normalizeObject($listing[0], '');
410  }
normalizeObject($item, $base)
Normalize a file entry.
ftpRawlist($options, $path)
The ftp_rawlist function with optional escaping.
Definition: Ftp.php:560
setConnectionRoot()
Set the connection root.
Definition: Ftp.php:183
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMimetype()

League\Flysystem\Adapter\Ftp::getMimetype (   $path)

Get the mimetype of a file.

Parameters
string$path
Returns
array|false

Implements League\Flysystem\ReadInterface.

Definition at line 415 of file Ftp.php.

References $metadata, $path, League\Flysystem\Util\MimeType\detectByFilename(), and League\Flysystem\Adapter\Ftp\getMetadata().

416  {
417  if ( ! $metadata = $this->getMetadata($path)) {
418  return false;
419  }
420 
422 
423  return $metadata;
424  }
static detectByFilename($filename)
Definition: MimeType.php:61
$metadata['__DYNAMIC:1__']
getMetadata($path)
Get all the meta data of a file or directory.array|false
Definition: Ftp.php:381
+ Here is the call graph for this function:

◆ getTimestamp()

League\Flysystem\Adapter\Ftp::getTimestamp (   $path)

Get the timestamp of a file.

Parameters
string$path
Returns
array|false

Implements League\Flysystem\ReadInterface.

Definition at line 429 of file Ftp.php.

References $path, $timestamp, and League\Flysystem\Adapter\AbstractFtpAdapter\getConnection().

430  {
431  $timestamp = ftp_mdtm($this->getConnection(), $path);
432 
433  return ($timestamp !== -1) ? ['path' => $path, 'timestamp' => $timestamp] : false;
434  }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
+ Here is the call graph for this function:

◆ isConnected()

League\Flysystem\Adapter\Ftp::isConnected ( )

Check if the connection is open.

Returns
bool
Exceptions
ErrorException

Definition at line 529 of file Ftp.php.

530  {
531  try {
532  return is_resource($this->connection) && ftp_rawlist($this->connection, '/') !== false;
533  } catch (ErrorException $e) {
534  if (strpos($e->getMessage(), 'ftp_rawlist') === false) {
535  throw $e;
536  }
537 
538  return false;
539  }
540  }

◆ isPureFtpdServer()

League\Flysystem\Adapter\Ftp::isPureFtpdServer ( )
protected
Returns
null|string

Definition at line 545 of file Ftp.php.

References $response.

Referenced by League\Flysystem\Adapter\Ftp\connect().

546  {
547  $response = ftp_raw($this->connection, 'HELP');
548 
549  return stripos(implode(' ', $response), 'Pure-FTPd') !== false;
550  }
$response
+ Here is the caller graph for this function:

◆ listDirectoryContents()

League\Flysystem\Adapter\Ftp::listDirectoryContents (   $directory,
  $recursive = true 
)
protected

Parameters
string$directory

Definition at line 489 of file Ftp.php.

References $options, League\Flysystem\Adapter\Ftp\ftpRawlist(), League\Flysystem\Adapter\Ftp\listDirectoryContentsRecursive(), and League\Flysystem\Adapter\AbstractFtpAdapter\normalizeListing().

Referenced by League\Flysystem\Adapter\Ftp\deleteDir().

490  {
491  $directory = str_replace('*', '\\*', $directory);
492 
493  if ($recursive && $this->recurseManually) {
494  return $this->listDirectoryContentsRecursive($directory);
495  }
496 
497  $options = $recursive ? '-alnR' : '-aln';
498  $listing = $this->ftpRawlist($options, $directory);
499 
500  return $listing ? $this->normalizeListing($listing, $directory) : [];
501  }
listDirectoryContentsRecursive($directory)
Definition: Ftp.php:508
ftpRawlist($options, $path)
The ftp_rawlist function with optional escaping.
Definition: Ftp.php:560
normalizeListing(array $listing, $prefix='')
Normalize a directory listing.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listDirectoryContentsRecursive()

League\Flysystem\Adapter\Ftp::listDirectoryContentsRecursive (   $directory)
protected

Parameters
string$directory

Definition at line 508 of file Ftp.php.

References $output, League\Flysystem\Adapter\Ftp\ftpRawlist(), and League\Flysystem\Adapter\AbstractFtpAdapter\normalizeListing().

Referenced by League\Flysystem\Adapter\Ftp\listDirectoryContents().

509  {
510  $listing = $this->normalizeListing($this->ftpRawlist('-aln', $directory) ?: []);
511  $output = [];
512 
513  foreach ($listing as $directory) {
514  $output[] = $directory;
515  if ($directory['type'] !== 'dir') continue;
516 
517  $output = array_merge($output, $this->listDirectoryContentsRecursive($directory['path']));
518  }
519 
520  return $output;
521  }
listDirectoryContentsRecursive($directory)
Definition: Ftp.php:508
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
ftpRawlist($options, $path)
The ftp_rawlist function with optional escaping.
Definition: Ftp.php:560
normalizeListing(array $listing, $prefix='')
Normalize a directory listing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ login()

League\Flysystem\Adapter\Ftp::login ( )
protected

Login.

Exceptions
RuntimeException

Definition at line 204 of file Ftp.php.

References League\Flysystem\Adapter\Ftp\disconnect(), League\Flysystem\Adapter\AbstractFtpAdapter\getHost(), League\Flysystem\Adapter\AbstractFtpAdapter\getPassword(), League\Flysystem\Adapter\AbstractFtpAdapter\getPort(), and League\Flysystem\Adapter\AbstractFtpAdapter\getUsername().

Referenced by League\Flysystem\Adapter\Ftp\connect().

205  {
206  set_error_handler(function () {});
207  $isLoggedIn = ftp_login(
208  $this->connection,
209  $this->getUsername(),
210  $this->getPassword()
211  );
212  restore_error_handler();
213 
214  if ( ! $isLoggedIn) {
215  $this->disconnect();
216  throw new RuntimeException(
217  'Could not login with connection: ' . $this->getHost() . '::' . $this->getPort(
218  ) . ', username: ' . $this->getUsername()
219  );
220  }
221  }
disconnect()
Disconnect from the FTP server.
Definition: Ftp.php:226
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

League\Flysystem\Adapter\Ftp::read (   $path)

Read a file.

Parameters
string$path
Returns
array|false

Implements League\Flysystem\ReadInterface.

Definition at line 439 of file Ftp.php.

References $path, and League\Flysystem\Adapter\Ftp\readStream().

440  {
441  if ( ! $object = $this->readStream($path)) {
442  return false;
443  }
444 
445  $object['contents'] = stream_get_contents($object['stream']);
446  fclose($object['stream']);
447  unset($object['stream']);
448 
449  return $object;
450  }
readStream($path)
Read a file as a stream.array|false
Definition: Ftp.php:455
+ Here is the call graph for this function:

◆ readStream()

League\Flysystem\Adapter\Ftp::readStream (   $path)

Read a file as a stream.

Parameters
string$path
Returns
array|false

Implements League\Flysystem\ReadInterface.

Definition at line 455 of file Ftp.php.

References $path, $result, GuzzleHttp\Psr7\$stream, and League\Flysystem\Adapter\AbstractFtpAdapter\getConnection().

Referenced by League\Flysystem\Adapter\Ftp\read().

456  {
457  $stream = fopen('php://temp', 'w+b');
458  $result = ftp_fget($this->getConnection(), $stream, $path, $this->transferMode);
459  rewind($stream);
460 
461  if ( ! $result) {
462  fclose($stream);
463 
464  return false;
465  }
466 
467  return ['type' => 'file', 'path' => $path, 'stream' => $stream];
468  }
$result
$stream
PHP stream implementation.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rename()

League\Flysystem\Adapter\Ftp::rename (   $path,
  $newpath 
)

Rename a file.

Parameters
string$path
string$newpath
Returns
bool

Implements League\Flysystem\AdapterInterface.

Definition at line 295 of file Ftp.php.

References $path, and League\Flysystem\Adapter\AbstractFtpAdapter\getConnection().

296  {
297  return ftp_rename($this->getConnection(), $path, $newpath);
298  }
+ Here is the call graph for this function:

◆ setConnectionPassiveMode()

League\Flysystem\Adapter\Ftp::setConnectionPassiveMode ( )
protected

Set the connections to passive mode.

Exceptions
RuntimeException

Definition at line 167 of file Ftp.php.

References defined, League\Flysystem\Adapter\AbstractFtpAdapter\getHost(), and League\Flysystem\Adapter\AbstractFtpAdapter\getPort().

Referenced by League\Flysystem\Adapter\Ftp\connect().

168  {
169  if (is_bool($this->ignorePassiveAddress) && defined('FTP_USEPASVADDRESS')) {
170  ftp_set_option($this->connection, FTP_USEPASVADDRESS, ! $this->ignorePassiveAddress);
171  }
172 
173  if ( ! ftp_pasv($this->connection, $this->passive)) {
174  throw new RuntimeException(
175  'Could not set passive mode for connection: ' . $this->getHost() . '::' . $this->getPort()
176  );
177  }
178  }
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setConnectionRoot()

League\Flysystem\Adapter\Ftp::setConnectionRoot ( )
protected

Set the connection root.

Definition at line 183 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$connection, League\Flysystem\Adapter\AbstractFtpAdapter\$root, and League\Flysystem\Adapter\AbstractFtpAdapter\getRoot().

Referenced by League\Flysystem\Adapter\Ftp\connect(), League\Flysystem\Adapter\Ftp\createDir(), and League\Flysystem\Adapter\Ftp\getMetadata().

184  {
185  $root = $this->getRoot();
187 
188  if (empty($root) === false && ! ftp_chdir($connection, $root)) {
189  throw new RuntimeException('Root is invalid or does not exist: ' . $this->getRoot());
190  }
191 
192  // Store absolute path for further reference.
193  // This is needed when creating directories and
194  // initial root was a relative path, else the root
195  // would be relative to the chdir'd path.
196  $this->root = ftp_pwd($connection);
197  }
getRoot()
Returns the root folder to work from.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIgnorePassiveAddress()

League\Flysystem\Adapter\Ftp::setIgnorePassiveAddress (   $ignorePassiveAddress)
Parameters
bool$ignorePassiveAddress

Definition at line 104 of file Ftp.php.

References League\Flysystem\Adapter\Ftp\$ignorePassiveAddress.

105  {
106  $this->ignorePassiveAddress = $ignorePassiveAddress;
107  }

◆ setPassive()

League\Flysystem\Adapter\Ftp::setPassive (   $passive = true)

Set if passive mode should be used.

Parameters
bool$passive

Definition at line 96 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$passive.

97  {
98  $this->passive = $passive;
99  }

◆ setRecurseManually()

League\Flysystem\Adapter\Ftp::setRecurseManually (   $recurseManually)
Parameters
bool$recurseManually

Definition at line 112 of file Ftp.php.

References League\Flysystem\Adapter\Ftp\$recurseManually.

113  {
114  $this->recurseManually = $recurseManually;
115  }

◆ setSsl()

League\Flysystem\Adapter\Ftp::setSsl (   $ssl)

Set if Ssl is enabled.

Parameters
bool$ssl
Returns
$this

Definition at line 84 of file Ftp.php.

References League\Flysystem\Adapter\AbstractFtpAdapter\$ssl.

85  {
86  $this->ssl = (bool) $ssl;
87 
88  return $this;
89  }

◆ setTransferMode()

League\Flysystem\Adapter\Ftp::setTransferMode (   $mode)

Set the transfer mode.

Parameters
int$mode
Returns
$this

Definition at line 70 of file Ftp.php.

71  {
72  $this->transferMode = $mode;
73 
74  return $this;
75  }

◆ setUtf8()

League\Flysystem\Adapter\Ftp::setUtf8 (   $utf8)
Parameters
bool$utf8

Definition at line 120 of file Ftp.php.

References League\Flysystem\Adapter\Ftp\$utf8.

121  {
122  $this->utf8 = (bool) $utf8;
123  }

◆ setUtf8Mode()

League\Flysystem\Adapter\Ftp::setUtf8Mode ( )
protected

Set the connection to UTF-8 mode.

Definition at line 150 of file Ftp.php.

References $response, League\Flysystem\Adapter\AbstractFtpAdapter\getHost(), and League\Flysystem\Adapter\AbstractFtpAdapter\getPort().

Referenced by League\Flysystem\Adapter\Ftp\connect().

151  {
152  if ($this->utf8) {
153  $response = ftp_raw($this->connection, "OPTS UTF8 ON");
154  if (substr($response[0], 0, 3) !== '200') {
155  throw new RuntimeException(
156  'Could not set UTF-8 mode for connection: ' . $this->getHost() . '::' . $this->getPort()
157  );
158  }
159  }
160  }
$response
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setVisibility()

League\Flysystem\Adapter\Ftp::setVisibility (   $path,
  $visibility 
)

Set the visibility for a file.

Parameters
string$path
string$visibility
Returns
array|false file meta data

Implements League\Flysystem\AdapterInterface.

Definition at line 473 of file Ftp.php.

References $path, League\Flysystem\Adapter\AbstractFtpAdapter\getConnection(), League\Flysystem\Adapter\AbstractFtpAdapter\getPermPrivate(), League\Flysystem\Adapter\AbstractFtpAdapter\getPermPublic(), and League\Flysystem\AdapterInterface\VISIBILITY_PUBLIC.

Referenced by League\Flysystem\Adapter\Ftp\writeStream().

474  {
475  $mode = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? $this->getPermPublic() : $this->getPermPrivate();
476 
477  if ( ! ftp_chmod($this->getConnection(), $mode, $path)) {
478  return false;
479  }
480 
481  return compact('path', 'visibility');
482  }
const VISIBILITY_PUBLIC
VISIBILITY_PUBLIC public visibility
getPermPrivate()
Get the private permission value.
getPermPublic()
Get the public permission value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

League\Flysystem\Adapter\Ftp::update (   $path,
  $contents,
Config  $config 
)

Update a file.

Parameters
string$path
string$contents
Config$configConfig object
Returns
array|false false on failure file meta data on success

Implements League\Flysystem\AdapterInterface.

Definition at line 279 of file Ftp.php.

References $contents, $path, and League\Flysystem\Adapter\Ftp\write().

280  {
281  return $this->write($path, $contents, $config);
282  }
write($path, $contents, Config $config)
Write a new file.Config objectarray|false false on failure file meta data on success ...
Definition: Ftp.php:238
+ Here is the call graph for this function:

◆ updateStream()

League\Flysystem\Adapter\Ftp::updateStream (   $path,
  $resource,
Config  $config 
)

Update a file using a stream.

Parameters
string$path
resource$resource
Config$configConfig object
Returns
array|false false on failure file meta data on success

Implements League\Flysystem\AdapterInterface.

Definition at line 287 of file Ftp.php.

References $path, and League\Flysystem\Adapter\Ftp\writeStream().

288  {
289  return $this->writeStream($path, $resource, $config);
290  }
writeStream($path, $resource, Config $config)
Write a new file using a stream.Config objectarray|false false on failure file meta data on success ...
Definition: Ftp.php:259
+ Here is the call graph for this function:

◆ write()

League\Flysystem\Adapter\Ftp::write (   $path,
  $contents,
Config  $config 
)

Write a new file.

Parameters
string$path
string$contents
Config$configConfig object
Returns
array|false false on failure file meta data on success

Implements League\Flysystem\AdapterInterface.

Definition at line 238 of file Ftp.php.

References $contents, $path, $result, GuzzleHttp\Psr7\$stream, League\Flysystem\Util\guessMimeType(), and League\Flysystem\Adapter\Ftp\writeStream().

Referenced by League\Flysystem\Adapter\Ftp\update().

239  {
240  $stream = fopen('php://temp', 'w+b');
241  fwrite($stream, $contents);
242  rewind($stream);
244  fclose($stream);
245 
246  if ($result === false) {
247  return false;
248  }
249 
250  $result['contents'] = $contents;
251  $result['mimetype'] = Util::guessMimeType($path, $contents);
252 
253  return $result;
254  }
$result
static guessMimeType($path, $content)
Guess MIME Type based on the path of the file and it's content.
Definition: Util.php:177
$stream
PHP stream implementation.
writeStream($path, $resource, Config $config)
Write a new file using a stream.Config objectarray|false false on failure file meta data on success ...
Definition: Ftp.php:259
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeStream()

League\Flysystem\Adapter\Ftp::writeStream (   $path,
  $resource,
Config  $config 
)

Write a new file using a stream.

Parameters
string$path
resource$resource
Config$configConfig object
Returns
array|false false on failure file meta data on success

Implements League\Flysystem\AdapterInterface.

Definition at line 259 of file Ftp.php.

References $path, $type, League\Flysystem\Util\dirname(), League\Flysystem\Adapter\AbstractFtpAdapter\ensureDirectory(), League\Flysystem\Config\get(), League\Flysystem\Adapter\AbstractFtpAdapter\getConnection(), and League\Flysystem\Adapter\Ftp\setVisibility().

Referenced by League\Flysystem\Adapter\Ftp\updateStream(), and League\Flysystem\Adapter\Ftp\write().

260  {
262 
263  if ( ! ftp_fput($this->getConnection(), $path, $resource, $this->transferMode)) {
264  return false;
265  }
266 
267  if ($visibility = $config->get('visibility')) {
268  $this->setVisibility($path, $visibility);
269  }
270 
271  $type = 'file';
272 
273  return compact('type', 'path', 'visibility');
274  }
ensureDirectory($dirname)
Ensure a directory exists.
static dirname($path)
Get a normalized dirname from a path.
Definition: Util.php:45
$type
setVisibility($path, $visibility)
Set the visibility for a file.array|false file meta data
Definition: Ftp.php:473
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $configurable

League\Flysystem\Adapter\Ftp::$configurable
protected
Initial value:
= [
'host',
'port',
'username',
'password',
'ssl',
'timeout',
'root',
'permPrivate',
'permPublic',
'passive',
'transferMode',
'systemType',
'ignorePassiveAddress',
'recurseManually',
'utf8',
]

Definition at line 40 of file Ftp.php.

◆ $ignorePassiveAddress

League\Flysystem\Adapter\Ftp::$ignorePassiveAddress = null
protected

Definition at line 25 of file Ftp.php.

Referenced by League\Flysystem\Adapter\Ftp\setIgnorePassiveAddress().

◆ $isPureFtpd

League\Flysystem\Adapter\Ftp::$isPureFtpd
protected

Definition at line 61 of file Ftp.php.

◆ $recurseManually

League\Flysystem\Adapter\Ftp::$recurseManually = false
protected

Definition at line 30 of file Ftp.php.

Referenced by League\Flysystem\Adapter\Ftp\setRecurseManually().

◆ $transferMode

League\Flysystem\Adapter\Ftp::$transferMode = FTP_BINARY
protected

Definition at line 20 of file Ftp.php.

◆ $utf8

League\Flysystem\Adapter\Ftp::$utf8 = false
protected

Definition at line 35 of file Ftp.php.

Referenced by League\Flysystem\Adapter\Ftp\setUtf8().


The documentation for this class was generated from the following file: