added ftp_ssl support (not sftp!)

This commit is contained in:
Chris
2020-01-11 15:20:38 +01:00
parent 3a90787091
commit 6c556e921f
3 changed files with 10 additions and 2 deletions

View File

@@ -61,6 +61,8 @@ This probably requires the php-ftp package but on some platforms it's included i
|Option | value type | What it does| |Option | value type | What it does|
|--- | --- | ---| |--- | --- | ---|
|FTP_SERVER | string | IP or hostname of your FTP Server | |FTP_SERVER | string | IP or hostname of your FTP Server |
|FTP_PORT | int | Port number of your FTP Server. Defaults to 21 |
|FTP_SSL | bool | If your FTP server supports SSL-FTP (note: not sFTP! not the same), set it to true |
|FTP_USER | string | FTP Username | |FTP_USER | string | FTP Username |
|FTP_PASS | string | FTP Password | |FTP_PASS | string | FTP Password |
|FTP_BASEDIR | string | Base path where files will be stored. Must end with / eg `/web/pictshare/` | |FTP_BASEDIR | string | Base path where files will be stored. Must end with / eg `/web/pictshare/` |

View File

@@ -14,8 +14,13 @@ class FTPStorage implements StorageController
function connect() function connect()
{ {
if(!$this->connection) if(!$this->connection)
$this->connection = ftp_connect(FTP_SERVER); {
if(!$this->login) if(defined('FTP_SSL') && FTP_SSL === true)
$this->connection = ftp_ssl_connect(FTP_SERVER, ((defined('FTP_SSL') && is_numeric(FTP_PORT))?FTP_PORT:21) );
else
$this->connection = ftp_connect(FTP_SERVER, ((defined('FTP_SSL') && is_numeric(FTP_PORT))?FTP_PORT:21) );
}
if($this->connection && !$this->login)
{ {
$this->login = ftp_login($this->connection, FTP_USER, FTP_PASS); $this->login = ftp_login($this->connection, FTP_USER, FTP_PASS);
ftp_pasv($this->connection, TRUE); ftp_pasv($this->connection, TRUE);

View File

@@ -23,6 +23,7 @@ foreach($sc as $contr)
if((new $contr())->isEnabled()===true) if((new $contr())->isEnabled()===true)
{ {
$controllers[] = new $contr(); $controllers[] = new $contr();
echo "[i] Found storage controller ".get_class($controllers[(count($controllers)-1)])."\n";
} }
} }