Skip to content

FileZilla PHP Library to work with the config files that FileZilla provides

License

Notifications You must be signed in to change notification settings

h2ooooooo/FileZilla

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FileZilla Configuration Parser

Latest Stable Version License

A powerful PHP library for parsing and working with FileZilla sitemanager.xml files. It allows you to extract server details, manage configurations, and integrate FileZilla data into your PHP applications.


Features

  • πŸŽ‰ Parse FileZilla sitemanager.xml files: Extract and work with server folders as well as individual server details.
  • πŸ”’ Stop using credentials in your code: If FileZilla already provides this unencrypted, and you're already using it, why not just read it from there?
  • ✨ Supports all FileZilla server attributes: Including host, port, protocol, and more.
  • πŸ”§ Flexible API: Query specific server details or all servers in a folder.
  • πŸ“œ Enum-Based Design: Strongly typed enums for protocols, logon types, and more.
  • βš™οΈ Works out of the box: The library defaults to the sitemanager.xml of your system. No need to specify a path.
  • πŸš€ PHP 8.0+ Compatible: Built with modern PHP practices and strict typing.

Installation

Install the package via Composer:

composer require jalsoedesign/filezilla

Usage

Basic usage

Load the default sitemanager.xml from your system (using fromSystem()) and iterate through all servers and print their name.

use jalsoedesign\filezilla\SiteManager;

$siteManager = SiteManager::fromSystem();

$servers = $siteManager->getServers();

foreach ($servers as $server) {
    echo 'Full server path: ' . $server->getPath() . PHP_EOL;
}

Many other examples

See the examples folder.

Structure of sitemanager.xml

The test fixture tests/fixtures/sitemanager.xml provides an example of all possible options.

Folder structure of sitemanager.xml
πŸ“ My Sites
β”‚   πŸ“ Protocols
β”‚   β”œβ”€β”€ ☁️ azure-blob-storage.example.com
β”‚   β”œβ”€β”€ ☁️ azure-file-storage.example.com
β”‚   β”œβ”€β”€ ☁️ backblaze-b2.example.com
β”‚   β”œβ”€β”€ ☁️ box.example.com
β”‚   β”œβ”€β”€ ☁️ dropbox.example.com
β”‚   β”œβ”€β”€ 🌐 ftp.example.com - explicit ftp over tls
β”‚   β”œβ”€β”€ 🌐 ftp.example.com - explicit ftp over tls if available
β”‚   β”œβ”€β”€ 🌐 ftp.example.com - implicit ftp over tls
β”‚   β”œβ”€β”€ 🌐 ftp.example.com - plain ftp
β”‚   β”œβ”€β”€ 🌐 google-cloudstorage.example.com
β”‚   β”œβ”€β”€ ☁️ google-drive.example.com
β”‚   β”œβ”€β”€ ☁️ onedrive.example.com
β”‚   β”œβ”€β”€ ☁️ openstack-swift.example.com
β”‚   β”œβ”€β”€ ☁️ rackspace-cloud-storage.example.com
β”‚   β”œβ”€β”€ ☁️ s3.example.com
β”‚   β”œβ”€β”€ 🌐 sftp.example.com
β”‚   β”œβ”€β”€ 🌐 webdav.example.com - http
β”‚   β”œβ”€β”€ 🌐 webdav.example.com - https
β”‚   πŸ“ Settings
β”‚   β”‚   πŸ“ Advanced
β”‚   β”‚   β”œβ”€β”€ 🌐 _default
β”‚   β”‚   β”‚   πŸ“ Adjusted server time
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 minus 1 hour
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 plus 1 hour
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 plus 30 minutes
β”‚   β”‚   β”‚   πŸ“ Bypass proxy
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 disabled
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 enabled
β”‚   β”‚   β”‚   πŸ“ Directory comparison
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 disabled
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 enabled
β”‚   β”‚   β”‚   πŸ“ Local directory
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 local directory - Unix
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 local directory - Windows
β”‚   β”‚   β”‚   πŸ“ Remote directory
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 remote directory - Unix
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 remote directory - Windows
β”‚   β”‚   β”‚   πŸ“ Server type
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 cygwin
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 default
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 dos with back slashes
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 dos with forward slashes
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 doslike
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 hp nonstop
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 mvs
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 unix
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 vms
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 vxworks
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 zvm
β”‚   β”‚   β”‚   πŸ“ Synchronized browsing
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 disabled
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 enabled
β”‚   β”‚   πŸ“ Charset
β”‚   β”‚   β”œβ”€β”€ 🌐 autodetect
β”‚   β”‚   β”œβ”€β”€ 🌐 custom charset - utf16
β”‚   β”‚   β”œβ”€β”€ 🌐 force utf8
β”‚   β”‚   πŸ“ General
β”‚   β”‚   β”‚   πŸ“ Background color
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 none
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 red
β”‚   β”‚   β”‚   πŸ“ Comments
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 no comments
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 with comments
β”‚   β”‚   β”‚   πŸ“ Custom port
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 custom port 8080
β”‚   β”‚   β”‚   β”œβ”€β”€ 🌐 default port
β”‚   β”‚   πŸ“ Transfer Settings
β”‚   β”‚   β”œβ”€β”€ 🌐 transfer mode - 6 limit
β”‚   β”‚   β”œβ”€β”€ 🌐 transfer mode - Active
β”‚   β”‚   β”œβ”€β”€ 🌐 transfer mode - Default
β”‚   β”‚   β”œβ”€β”€ 🌐 transfer mode - No limit
β”‚   β”‚   β”œβ”€β”€ 🌐 transfer mode - Passive
β”‚   πŸ“ Various
β”‚   β”œβ”€β”€ 🌐 Special !"#Β€%&()=<>
β”‚   β”œβ”€β”€ 🌐 Utf8 πŸ’žπŸ’’πŸ’«

Documentation

API Reference

Server

The Server class represents a single server configuration from the FileZilla sitemanager.xml file. It provides access to all attributes of a server, including its host, protocol, directories, and more.

Method Returns Description
getHost() string Get the server's hostname or IP address.
getPort() int Get the server's port number.
getProtocol() int Get the server's protocol (ServerProtocol enum).
getLogonType() int Get the server's logon type (LogonType enum).
getUser() ?string Get the username for authentication (nullable).
getPassword() ?string Get the password for authentication (nullable).
getKeyFile() ?string Get the path to the server's private key file (nullable).
getTimezoneOffset() ?int Get the server's timezone offset (nullable).
getPassiveMode() ?string Get the server's passive mode (PassiveMode enum, nullable).
getMaximumMultipleConnections() ?int Get the maximum concurrent connections (nullable).
getEncodingType() ?string Get the encoding type (CharsetEncoding enum, nullable).
getCustomEncoding() ?string Get the custom encoding if the encoding type is custom.
getBypassProxy() ?bool Check whether the server bypasses the proxy (nullable).
getType() int Get the server's type (ServerType enum).
getName() string Get the name of the server as it appears in FileZilla.
getComments() ?string Get the server's comments (nullable).
getLocalDirectory() ?string Get the initial local directory for the server (nullable).
getRemoteDirectory(string $default = null, bool $useRootPrefix = true) ?string Parse and return the server's remote directory (nullable).
getSynchronizedBrowsing() ?bool Check whether synchronized browsing is enabled (nullable).
getDirectoryComparison() ?bool Check whether directory comparison is enabled (nullable).
getColour() int Get the background color.
getColor() ?string Alias for getColour() (nullable).

Folder

The Folder class represents a collection of Server and/or Folder objects, allowing for recursive structures of servers and folders.

Method Returns Description
getName() string Get the name of the folder.
getChildren(bool $recursive, ?string $filter) Server[]/Folder[] Get all children in the folder, optionally recursive and filtered by type.
countServers(bool $recursive) int Count the number of servers in the folder, optionally including subfolders.
countFolders(bool $recursive) int Count the number of folders in the folder, optionally including subfolders.
getServers(bool $recursive) Server[] Get all servers in the folder, optionally including subfolders.
getFolders(bool $recursive) Folder[] Get all folders in the folder, optionally including subfolders.
getServer(string $serverPath) Server Get a specific server by its path.
getFolder(string $folderPath) Folder Get a specific folder by its path.
getChildPath(string $childName, ?string $childPath) string Construct a full path for a child within the folder.

SiteManager

The SiteManager class extends Folder, inheriting all of its functionality, and represents the root structure of FileZilla's server and folder configuration as defined in the sitemanager.xml file. In addition to managing nested folders and servers, it provides access to metadata about the configuration file itself.

Method Returns Description
SiteManager::fromSystem() SiteManager Create a SiteManager instance from the system's default configuration.
getVersion() string Get the version of the sitemanager.xml file.
getPlatform() string Get the platform specified in the sitemanager.xml file.

Enums

Enum Class Description
CharsetEncoding Charset encodings (Auto, UTF-8 or Custom)
Colour Background colours (e.g. Red, Green, Blue).
LogonType User authentication types (e.g., Normal, Anonymous).
PassiveType The PasvMode setting (MODE_DEFAULT, MODE_ACTIVE or MODE_PASSIVE)
ServerProtocol Server protocols like FTP, SFTP, FTPS, etc.
ServerType Server types like Unix, DOS, etc.

All enum classes have Enum::toCamelCase($value) as well as Enum::getConstantName($value) methods.

Filezilla config parsing

FileZilla Field Attribute Casting Note
Host host string Required
Port port int
Protocol protocol int
Type type int
User user string Required
Pass password string Required. Base64 encoded if encoding="base64"
Keyfile keyFile string Required
Colour colour int
Logontype logonType int
TimezoneOffset timezoneOffset int
PasvMode passiveMode string Required
MaximumMultipleConnections maximumMultipleConnections int
EncodingType encodingType string Required
BypassProxy bypassProxy bool
Name name string Required
Comments comments string Required
LocalDir localDirectory string Required
RemoteDir remoteDirectory string Required
SyncBrowsing synchronizedBrowsing bool
DirectoryComparison directoryComparison bool
CustomEncoding customEncoding string Required

Contributing

Contributions are welcome! Please submit a pull request or open an issue if you find a bug or have an idea for an enhancement.


License

This library is open-sourced under the MIT license.


Credits


Support

If you find this library useful, feel free to ⭐ the repository or share your feedback!

About

FileZilla PHP Library to work with the config files that FileZilla provides

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages