104        foreach ($this->configurable as $setting) {
 
  105            if ( ! isset(
$config[$setting])) {
 
  109            $method = 
'set' . ucfirst($setting);
 
  111            if (method_exists($this, $method)) {
 
  112                $this->$method(
$config[$setting]);
 
  200        $this->port = (int) 
$port;
 
  226        $username = $this->safeStorage->retrieveSafely(
'username');
 
  228        return $username !== 
null ? $username : 
'anonymous';
 
  240        $this->safeStorage->storeSafely(
'username', $username);
 
  252        return $this->safeStorage->retrieveSafely(
'password');
 
  264        $this->safeStorage->storeSafely(
'password', 
$password);
 
  341        while ($item = array_shift($listing)) {
 
  342            if (preg_match(
'#^.*:$#', $item)) {
 
  343                $base = trim($item, 
':');
 
  362        $compare = 
function ($one, $two) {
 
  363            return strnatcmp($one[
'path'], $two[
'path']);
 
  404        $item = preg_replace(
'#\s+#', 
' ', trim($item), 7);
 
  406        if (count(explode(
' ', $item, 9)) !== 9) {
 
  407            throw new RuntimeException(
"Metadata can't be parsed from item '$item' , not enough parts.");
 
  410        list($permissions, , , , 
$size, , , , 
$name) = explode(
' ', $item, 9);
 
  414        if (
$type === 
'dir') {
 
  415            return compact(
'type', 
'path');
 
  422        return compact(
'type', 
'path', 
'visibility', 
'size');
 
  435        $item = preg_replace(
'#\s+#', 
' ', trim($item), 3);
 
  437        if (count(explode(
' ', $item, 4)) !== 4) {
 
  438            throw new RuntimeException(
"Metadata can't be parsed from item '$item' , not enough parts.");
 
  445        $format = strlen($date) === 8 ? 
'm-d-yH:iA' : 
'Y-m-dH:i';
 
  446        $dt = DateTime::createFromFormat(
$format, $date . 
$time);
 
  447        $timestamp = $dt ? $dt->getTimestamp() : (int) strtotime(
"$date $time");
 
  449        if (
$size === 
'<DIR>') {
 
  452            return compact(
'type', 
'path', 
'timestamp');
 
  459        return compact(
'type', 
'path', 
'visibility', 
'size', 
'timestamp');
 
  471        return preg_match(
'/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', $item) ? 
'windows' : 
'unix';
 
  483        return substr($permissions, 0, 1) === 
'd' ? 
'dir' : 
'file';
 
  496        $permissions = substr($permissions, 1);
 
  499        $map = [
'-' => 
'0', 
'r' => 
'4', 
'w' => 
'2', 
'x' => 
'1'];
 
  500        $permissions = strtr($permissions, $map);
 
  503        $parts = str_split($permissions, 3);
 
  506        $mapper = 
function ($part) {
 
  507            return array_sum(str_split($part));
 
  511        return array_sum(array_map($mapper, $parts));
 
  523        $filter = 
function ($line) {
 
  524            if ( ! empty($line) && ! preg_match(
'#.* \.(\.)?$|^total#', $line)) {
 
  531        return array_filter(
$list, $filter);
 
  565        if ( ! empty($dirname) && ! $this->
has($dirname)) {
 
foreach($mandatory_scripts as $file) $timestamp
An exception for terminatinating execution or to throw for unit testing.
normalizeListing(array $listing, $prefix='')
Normalize a directory listing.
getRoot()
Returns the root folder to work from.
sortListing(array $result)
Sort a directory listing.
normalizePermissions($permissions)
Normalize a permissions string.
setTimeout($timeout)
Set the amount of seconds before the connection should timeout.
getPassword()
Returns the password.
setSystemType($systemType)
Set the FTP system type (windows or unix).
listContents($directory='', $recursive=false)
List contents of a directory.array
ensureDirectory($dirname)
Ensure a directory exists.
getTimeout()
Returns the amount of seconds before the connection will timeout.
getVisibility($path)
Get the visibility of a file.array|false
getSize($path)
Get the size of a file.array|false
getHost()
Returns the host.
getPermPublic()
Get the public permission value.
setUsername($username)
Set ftp username.
setHost($host)
Set the host.
setConfig(array $config)
Set the config.
__destruct()
Disconnect on destruction.
removeDotDirectories(array $list)
Filter out dot-directories.
getPort()
Returns the ftp port.
setRoot($root)
Set the root folder to work from.
getSystemType()
Return the FTP system type.
getPermPrivate()
Get the private permission value.
listDirectoryContents($directory, $recursive=false)
disconnect()
Close the connection.
setPermPrivate($permPrivate)
Set the private permission value.
has($path)
Check whether a file exists.array|bool|null
setPermPublic($permPublic)
Set the public permission value.
connect()
Establish a connection.
detectType($permissions)
Get the file type from the permissions.
isConnected()
Check if a connection is active.
setPassword($password)
Set the ftp password.
detectSystemType($item)
Get the system type from a listing item.
normalizeWindowsObject($item, $base)
Normalize a Windows/DOS file entry.
normalizeUnixObject($item, $base)
Normalize a Unix file entry.
getUsername()
Returns the ftp username.
setPort($port)
Set the ftp port.
normalizeObject($item, $base)
Normalize a file entry.
__construct(array $config)
Constructor.
static forFtpSystemType($systemType)
Create a new exception for a link.
const VISIBILITY_PUBLIC
@const VISIBILITY_PUBLIC public visibility
createDir($dirname, Config $config)
Create a directory.
const VISIBILITY_PRIVATE
@const VISIBILITY_PRIVATE private visibility
getMetadata($path)
Get all the meta data of a file or directory.
if(isset($_REQUEST['delete'])) $list