Skip to content
Browse files

Added FTP-SSL support to the FTP class (Safe Mode Hack) (#1968)

  • Loading branch information...
1 parent bfb6119 commit 6e628da1ff4e3b2e07ae87badb10db83470b2a26 @leofeyer leofeyer committed May 29, 2010
View
1 contao-2.9/CHANGELOG.txt
@@ -26,6 +26,7 @@ Version 2.9.RC1 (2010--)
- Added: added an option to extend the mime types array of the File class (#1352)
- Added: use the code editor (EditArea) for all HTML and code fields (#1477)
- Added: add the file modification time to CSS and JavaScript files in the page header (#1830)
+- Added: added FTP-SSL support to the FTP class (Safe Mode Hack) (#1968)
- Fixed: recoverable error in the registration module (#1926)
- Fixed: the event list did not show a "read more" link when redirecting to an article (#1944)
- Fixed: the textarea widget did not ignore the maxlength attribute (#1960)
View
17 contao-2.9/contao/install.php
@@ -93,26 +93,29 @@ public function run()
*/
if ($this->Input->post('FORM_SUBMIT') == 'tl_ftp')
{
- $GLOBALS['TL_CONFIG']['useFTP'] = true;
-
+ $GLOBALS['TL_CONFIG']['useFTP'] = true;
$GLOBALS['TL_CONFIG']['ftpHost'] = $this->Input->post('host');
$GLOBALS['TL_CONFIG']['ftpPath'] = $this->Input->post('path');
$GLOBALS['TL_CONFIG']['ftpUser'] = $this->Input->post('username', true);
$GLOBALS['TL_CONFIG']['ftpPass'] = $this->Input->post('password', true);
+ $GLOBALS['TL_CONFIG']['ftpSSL'] = $this->Input->post('ssl');
+ $GLOBALS['TL_CONFIG']['ftpPort'] = $this->Input->post('port');
- // Add trailing slash
+ // Add a trailing slash
if ($GLOBALS['TL_CONFIG']['ftpPath'] != '' && substr($GLOBALS['TL_CONFIG']['ftpPath'], -1) != '/')
{
$GLOBALS['TL_CONFIG']['ftpPath'] .= '/';
}
- // Try to connect and locate Contao directory
- if (($resFtp = @ftp_connect($GLOBALS['TL_CONFIG']['ftpHost'])) == false)
+ $ftp_connect = ($GLOBALS['TL_CONFIG']['ftpSSL'] && function_exists('ftp_ssl_connect')) ? 'ftp_ssl_connect' : 'ftp_connect';
+
+ // Try to connect and locate the Contao directory
+ if (($resFtp = $ftp_connect($GLOBALS['TL_CONFIG']['ftpHost'], $GLOBALS['TL_CONFIG']['ftpPort'], 5)) == false)
{
$this->Template->ftpHostError = true;
$this->outputAndExit();
}
- elseif (!@ftp_login($resFtp, $GLOBALS['TL_CONFIG']['ftpUser'], $GLOBALS['TL_CONFIG']['ftpPass']))
+ elseif (!ftp_login($resFtp, $GLOBALS['TL_CONFIG']['ftpUser'], $GLOBALS['TL_CONFIG']['ftpPass']))
{
$this->Template->ftpUserError = true;
$this->outputAndExit();
@@ -131,6 +134,8 @@ public function run()
$this->Config->update("\$GLOBALS['TL_CONFIG']['ftpPath']", $GLOBALS['TL_CONFIG']['ftpPath']);
$this->Config->update("\$GLOBALS['TL_CONFIG']['ftpUser']", $GLOBALS['TL_CONFIG']['ftpUser']);
$this->Config->update("\$GLOBALS['TL_CONFIG']['ftpPass']", $GLOBALS['TL_CONFIG']['ftpPass']);
+ $this->Config->update("\$GLOBALS['TL_CONFIG']['ftpSSL']", $GLOBALS['TL_CONFIG']['ftpSSL']);
+ $this->Config->update("\$GLOBALS['TL_CONFIG']['ftpPort']", $GLOBALS['TL_CONFIG']['ftpPort']);
$this->reload();
}
View
2 contao-2.9/system/config/config.php
@@ -161,6 +161,8 @@
$GLOBALS['TL_CONFIG']['ftpPath'] = '';
$GLOBALS['TL_CONFIG']['ftpUser'] = '';
$GLOBALS['TL_CONFIG']['ftpPass'] = '';
+$GLOBALS['TL_CONFIG']['ftpSSL'] = false;
+$GLOBALS['TL_CONFIG']['ftpPort'] = 21;
/**
View
4 contao-2.9/system/libraries/FTP.php
@@ -96,8 +96,10 @@ public function connect()
throw new Exception('The FTP password must not be empty');
}
+ $ftp_connect = ($GLOBALS['TL_CONFIG']['ftpSSL'] && function_exists('ftp_ssl_connect')) ? 'ftp_ssl_connect' : 'ftp_connect';
+
// Try to connect
- if (($resConnection = ftp_connect($GLOBALS['TL_CONFIG']['ftpHost'])) == false)
+ if (($resConnection = $ftp_connect($GLOBALS['TL_CONFIG']['ftpHost'], $GLOBALS['TL_CONFIG']['ftpPort'], 5)) == false)
{
throw new Exception('Could not connect to the FTP server');
}
View
3 contao-2.9/system/modules/backend/languages/de/tl_install.php
@@ -93,6 +93,9 @@
$GLOBALS['TL_LANG']['tl_install']['ftpPath'] = 'Relativer Pfad zum Contao-Verzeichnis (z.B. <em>httpdocs/</em>)';
$GLOBALS['TL_LANG']['tl_install']['ftpUser'] = 'FTP-Benutzername';
$GLOBALS['TL_LANG']['tl_install']['ftpPass'] = 'FTP-Passwort';
+$GLOBALS['TL_LANG']['tl_install']['ftpSSLh4'] = 'Sichere Verbindung';
+$GLOBALS['TL_LANG']['tl_install']['ftpSSL'] = 'Über FTP-SSL verbinden';
+$GLOBALS['TL_LANG']['tl_install']['ftpPort'] = 'FTP-Port';
$GLOBALS['TL_LANG']['tl_install']['ftpSave'] = 'FTP-Einstellungen speichern';
$GLOBALS['TL_LANG']['tl_install']['ftpHostError'] = 'Keine Verbindung zum FTP-Server %s möglich';
$GLOBALS['TL_LANG']['tl_install']['ftpUserError'] = 'Anmeldung als "%s" fehlgeschlagen';
View
3 contao-2.9/system/modules/backend/languages/en/tl_install.php
@@ -93,6 +93,9 @@
$GLOBALS['TL_LANG']['tl_install']['ftpPath'] = 'Relative path to Contao directory (e.g. <em>httpdocs/</em>)';
$GLOBALS['TL_LANG']['tl_install']['ftpUser'] = 'FTP username';
$GLOBALS['TL_LANG']['tl_install']['ftpPass'] = 'FTP password';
+$GLOBALS['TL_LANG']['tl_install']['ftpSSLh4'] = 'Secure connection';
+$GLOBALS['TL_LANG']['tl_install']['ftpSSL'] = 'Connect via FTP-SSL';
+$GLOBALS['TL_LANG']['tl_install']['ftpPort'] = 'FTP port';
$GLOBALS['TL_LANG']['tl_install']['ftpSave'] = 'Save FTP settings';
$GLOBALS['TL_LANG']['tl_install']['ftpHostError'] = 'Could not connect to FTP server %s';
$GLOBALS['TL_LANG']['tl_install']['ftpUserError'] = 'Could not login as "%s"';
View
6 contao-2.9/system/modules/backend/templates/be_install.tpl
@@ -56,6 +56,12 @@
<input type="text" name="username" id="username" class="tl_text" value="<?php echo $GLOBALS['TL_CONFIG']['ftpUser']; ?>" />
<h4><?php echo $GLOBALS['TL_LANG']['tl_install']['ftpPass']; ?></h4>
<input type="password" name="password" id="password" class="tl_text" value="<?php echo $GLOBALS['TL_CONFIG']['ftpPass']; ?>" />
+ <h4><?php echo $GLOBALS['TL_LANG']['tl_install']['ftpSSLh4']; ?></h4>
+ <div class="tl_checkbox_container" style="margin-top:3px;">
+ <input type="checkbox" name="ssl" id="ctrl_ssl" class="tl_checkbox" value="1"<?php echo $GLOBALS['TL_CONFIG']['ftpSSL'] ? ' checked="checked"' : ''; ?> /> <label for="ctrl_ssl"><?php echo $GLOBALS['TL_LANG']['tl_install']['ftpSSL']; ?></label>
+ </div>
+ <h4><?php echo $GLOBALS['TL_LANG']['tl_install']['ftpPort']; ?></h4>
+ <input type="text" name="port" id="port" class="tl_text" value="<?php echo $GLOBALS['TL_CONFIG']['ftpPort']; ?>" />
</div>
<div class="tl_formbody_submit">
<div class="tl_submit_container">

0 comments on commit 6e628da

Please sign in to comment.
Something went wrong with that request. Please try again.