added setting and possible fix for passive mode. fixes #135 probably

This commit is contained in:
Christian Haschek
2022-01-24 15:23:38 +01:00
parent b669e69511
commit 9200d3d93c
3 changed files with 11 additions and 1 deletions

View File

@@ -45,6 +45,7 @@ _buildConfig() {
echo "define('FTP_PORT', ${FTP_PORT:-21});" echo "define('FTP_PORT', ${FTP_PORT:-21});"
echo "define('FTP_USER', '${FTP_USER:-}');" echo "define('FTP_USER', '${FTP_USER:-}');"
echo "define('FTP_PASS', '${FTP_PASS:-}');" echo "define('FTP_PASS', '${FTP_PASS:-}');"
echo "define('FTP_PASSIVEMODE', ${FTP_PASSIVEMODE:-true});"
echo "define('FTP_SSL', ${FTP_SSL:-false});" echo "define('FTP_SSL', ${FTP_SSL:-false});"
echo "define('FTP_BASEDIR', '${FTP_BASEDIR:-}');" echo "define('FTP_BASEDIR', '${FTP_BASEDIR:-}');"
echo "define('ENCRYPTION_KEY', '${ENCRYPTION_KEY:-}');" echo "define('ENCRYPTION_KEY', '${ENCRYPTION_KEY:-}');"

View File

@@ -81,3 +81,4 @@ This probably requires the php-ftp package but on some platforms it's included i
|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/` |
|FTP_PASSIVEMODE | bool | Wether to use passive mode or not. If you have troubles with uploading, switch this setting maybe |

View File

@@ -23,7 +23,15 @@ class FTPStorage implements StorageController
if($this->connection && !$this->login) 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);
if( (defined('FTP_PASSIVEMODE') && FTP_PASSIVEMODE === true) || !defined('FTP_PASSIVEMODE') )
{
ftp_set_option($this->connection, FTP_USEPASVADDRESS, false);
ftp_pasv($this->connection, TRUE);
}
else
ftp_pasv($this->connection, false);
} }
// Was the connection successful? // Was the connection successful?