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
 write ($path, $contents, Config $config)
 Write a new file. More...
 
 writeStream ($path, $resource, Config $config)
 Write a new file using a stream. More...
 
 update ($path, $contents, Config $config)
 Update a file. More...
 
 updateStream ($path, $resource, Config $config)
 Update a file using a stream. More...
 
 rename ($path, $newpath)
 Rename a file. More...
 
 copy ($path, $newpath)
 Copy a file. More...
 
 delete ($path)
 Delete a file. More...
 
 deleteDir ($dirname)
 Delete a directory. More...
 
 createDir ($dirname, Config $config)
 Create a directory. More...
 
 setVisibility ($path, $visibility)
 Set the visibility for a file. More...
 
 has ($path)
 Check whether a file exists. More...
 
 read ($path)
 Read a file. More...
 
 readStream ($path)
 Read a file as a stream. More...
 
 listContents ($directory='', $recursive=false)
 List contents of a directory. More...
 
 getMetadata ($path)
 Get all the meta data of a file or directory. More...
 
 getSize ($path)
 Get the size of a file. More...
 
 getMimetype ($path)
 Get the mimetype of a file. More...
 
 getTimestamp ($path)
 Get the timestamp of a file. More...
 
 getVisibility ($path)
 Get the visibility of 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'
 @const VISIBILITY_PUBLIC public visibility More...
 
const VISIBILITY_PRIVATE = 'private'
 @const 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.

Reimplemented from League\Flysystem\Adapter\AbstractFtpAdapter.

Definition at line 128 of file Ftp.php.

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();
143 $this->setConnectionRoot();
144 $this->isPureFtpd = $this->isPureFtpdServer();
145 }
getTimeout()
Returns the amount of seconds before the connection will timeout.
setUtf8Mode()
Set the connection to UTF-8 mode.
Definition: Ftp.php:150
setConnectionRoot()
Set the connection root.
Definition: Ftp.php:183
setConnectionPassiveMode()
Set the connections to passive mode.
Definition: Ftp.php:167

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().

+ 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.

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

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

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

+ 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.

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

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

+ 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.

304 {
305 return ftp_delete($this->getConnection(), $path);
306 }

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

+ 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.

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

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

+ Here is the call graph for this function:

◆ disconnect()

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

Disconnect from the FTP server.

Reimplemented from League\Flysystem\Adapter\AbstractFtpAdapter.

Definition at line 226 of file Ftp.php.

227 {
228 if (is_resource($this->connection)) {
229 ftp_close($this->connection);
230 }
231
232 $this->connection = null;
233 }

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

+ 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.

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

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().

+ 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.

Reimplemented in League\Flysystem\Adapter\Ftpd.

Definition at line 381 of file Ftp.php.

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

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().

+ 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.

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

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

+ 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.

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

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

+ Here is the call graph for this function:

◆ isConnected()

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

Check if the connection is open.

Returns
bool
Exceptions
ErrorException

Reimplemented from League\Flysystem\Adapter\AbstractFtpAdapter.

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.

546 {
547 $response = ftp_raw($this->connection, 'HELP');
548
549 return stripos(implode(' ', $response), 'Pure-FTPd') !== false;
550 }
$response

References $response.

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

+ Here is the caller graph for this function:

◆ listDirectoryContents()

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

Parameters
string$directory

Reimplemented from League\Flysystem\Adapter\AbstractFtpAdapter.

Reimplemented in League\Flysystem\Adapter\Ftpd.

Definition at line 489 of file Ftp.php.

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 }
normalizeListing(array $listing, $prefix='')
Normalize a directory listing.
listDirectoryContentsRecursive($directory)
Definition: Ftp.php:508

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().

+ 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.

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 }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output

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

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

+ 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.

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

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().

+ 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.

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

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

+ 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.

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.

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

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

+ 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.

296 {
297 return ftp_rename($this->getConnection(), $path, $newpath);
298 }

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

+ 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.

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

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

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

+ 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.

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.

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().

+ 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.

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

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

◆ 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.

◆ setRecurseManually()

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

Definition at line 112 of file Ftp.php.

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

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

◆ 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.

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

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

◆ 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.

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

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

◆ setUtf8Mode()

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

Set the connection to UTF-8 mode.

Definition at line 150 of file Ftp.php.

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 }

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

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

+ 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.

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 }
getPermPublic()
Get the public permission value.
getPermPrivate()
Get the private permission value.
const VISIBILITY_PUBLIC
@const VISIBILITY_PUBLIC public visibility

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().

+ 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.

280 {
281 return $this->write($path, $contents, $config);
282 }
write($path, $contents, Config $config)
Write a new file.array|false false on failure file meta data on success
Definition: Ftp.php:238

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

+ 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.

288 {
289 return $this->writeStream($path, $resource, $config);
290 }
writeStream($path, $resource, Config $config)
Write a new file using a stream.array|false false on failure file meta data on success
Definition: Ftp.php:259

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

+ 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.

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;
252
253 return $result;
254 }
static guessMimeType($path, $content)
Guess MIME Type based on the path of the file and it's content.
Definition: Util.php:177

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

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

+ 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.

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.
setVisibility($path, $visibility)
Set the visibility for a file.array|false file meta data
Definition: Ftp.php:473
static dirname($path)
Get a normalized dirname from a path.
Definition: Util.php:45
$type

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

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

+ 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: