Source for file ftp.php
Documentation is available at ftp.php
* @package Joomla.Installation
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* FTP configuration model for the Joomla Core Installer.
* @package Joomla.Installation
* Find the ftp filesystem root for a given user/pass pair.
* @param array $options Configuration options.
* @return mixed FTP root for given FTP user, or boolean false if not found.
/* @var InstallationApplicationWeb $app */
// Get the options as a object for easier handling.
// Connect and login to the FTP server.
// Use binary transfer mode to be able to compare files.
// Check to make sure FTP is connected and authenticated.
if (!$ftp->isConnected())
$app->enqueueMessage($options->get('ftp_host') .
':' .
$options->get('ftp_port') .
' ' .
JText::_('INSTL_FTP_NOCONNECT'), 'error');
if (!$ftp->login($options->get('ftp_user'), $options->get('ftp_pass')))
$app->enqueueMessage(JText::_('INSTL_FTP_NOLOGIN'), 'error');
// Get the current working directory from the FTP server.
$app->enqueueMessage(JText::_('INSTL_FTP_NOPWD'), 'error');
// Get a list of folders in the current working directory.
$cwdFolders =
$ftp->listDetails(null, 'folders');
if ($cwdFolders ===
false ||
count($cwdFolders) ==
0)
$app->enqueueMessage(JText::_('INSTL_FTP_NODIRECTORYLISTING'), 'error');
// Get just the folder names from the list of folder data.
for ($i =
0, $n =
count($cwdFolders); $i <
$n; $i++
)
$cwdFolders[$i] =
$cwdFolders[$i]['name'];
// Check to see if Joomla is installed at the FTP current working directory.
$known =
array('administrator', 'components', 'installation', 'language', 'libraries', 'plugins');
// Search through the segments of JPATH_SITE looking for root possibilities.
for ($i =
count($parts) -
1; $i >=
0; $i--
)
$tmp =
'/' .
$parts[$i] .
$tmp;
// Check all possible paths for the real Joomla installation by comparing version files.
$filePath =
rtrim($tmp, '/') .
'/libraries/cms/version/version.php';
@ $ftp->read($filePath, $buffer);
if ($buffer ==
$checkValue)
// Close the FTP connection.
// Return an error if no root path was found.
$app->enqueueMessage(JText::_('INSTL_FTP_UNABLE_DETECT_ROOT_FOLDER'), 'error');
* Verify the FTP settings as being functional and correct.
* @param array $options Configuration options.
* @return mixed FTP root for given FTP user, or boolean false if not found.
/* @var InstallationApplicationWeb $app */
// Get the options as a object for easier handling.
// Connect and login to the FTP server.
// Check to make sure FTP is connected and authenticated.
if (!$ftp->isConnected())
$app->enqueueMessage(JText::_('INSTL_FTP_NOCONNECT'), 'error');
if (!$ftp->login($options->get('ftp_user'), $options->get('ftp_pass')))
$app->enqueueMessage(JText::_('INSTL_FTP_NOLOGIN'), 'error');
// Since the root path will be trimmed when it gets saved to configuration.php,
// we want to test with the same value as well.
$root =
rtrim($options->get('ftp_root'), '/');
if ($ftp->pwd() ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NOPWD'), 'error');
// Verify root path exists
$app->enqueueMessage(JText::_('INSTL_FTP_NOROOT'), 'error');
if (($rootList =
$ftp->listNames()) ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NONLST'), 'error');
if ($ftp->listDetails() ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NOLIST'), 'error');
if ($ftp->syst() ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NOSYST'), 'error');
// Verify valid root path, part one
$checkList =
array('robots.txt', 'index.php');
$app->enqueueMessage(JText::_('INSTL_FTP_INVALIDROOT'), 'error');
if ($ftp->read($root .
'/libraries/cms/version/version.php', $buffer) ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NORETR'), 'error');
// Verify valid root path, part two
if ($buffer !==
$checkValue)
$app->enqueueMessage(JText::_('INSTL_FTP_INVALIDROOT'), 'error');
if ($ftp->create($root .
'/ftp_testfile') ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NOSTOR'), 'error');
if ($ftp->delete($root .
'/ftp_testfile') ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NODELE'), 'error');
if ($ftp->mkdir($root .
'/ftp_testdir') ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NOMKD'), 'error');
if ($ftp->delete($root .
'/ftp_testdir') ===
false)
$app->enqueueMessage(JText::_('INSTL_FTP_NORMD'), 'error');
Documentation generated on Tue, 19 Nov 2013 15:03:58 +0100 by phpDocumentor 1.4.3