本文整理汇总了PHP中JClientHelper::setCredentials方法的典型用法代码示例。如果您正苦于以下问题:PHP JClientHelper::setCredentials方法的具体用法?PHP JClientHelper::setCredentials怎么用?PHP JClientHelper::setCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JClientHelper
的用法示例。
在下文中一共展示了JClientHelper::setCredentials方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCredentialsFromRequest
/**
* Determine whether input fields for client settings need to be shown
*
* If valid credentials were passed along with the request, they are saved to the session.
* This functions returns an exception if invalid credentials have been given or if the
* connection to the server failed for some other reason.
*
* @param string $client The name of the client.
*
* @return mixed True, if FTP settings should be shown or an exception
*
* @since 11.1
*/
public static function setCredentialsFromRequest($client)
{
// Determine wether FTP credentials have been passed along with the current request
$user = JRequest::getString('username', null, 'POST', JREQUEST_ALLOWRAW);
$pass = JRequest::getString('password', null, 'POST', JREQUEST_ALLOWRAW);
if ($user != '' && $pass != '') {
// Add credentials to the session
if (JClientHelper::setCredentials($client, $user, $pass)) {
$return = false;
} else {
$return = JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_CLIENT_ERROR_HELPER_SETCREDENTIALSFROMREQUEST_FAILED'));
}
} else {
// Just determine if the FTP input fields need to be shown
$return = !JClientHelper::hasCredentials('ftp');
}
return $return;
}
示例2: _applyCredentials
/**
* Applies FTP credentials to Joomla! itself, when required
*
* @return void
*
* @since 2.5.4
*/
protected function _applyCredentials()
{
if (!JClientHelper::hasCredentials('ftp')) {
$user = JFactory::getApplication()->getUserStateFromRequest('com_joomlaupdate.ftp_user', 'ftp_user', null, 'raw');
$pass = JFactory::getApplication()->getUserStateFromRequest('com_joomlaupdate.ftp_pass', 'ftp_pass', null, 'raw');
if ($user != '' && $pass != '') {
// Add credentials to the session
if (!JClientHelper::setCredentials('ftp', $user, $pass)) {
JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_CLIENT_ERROR_HELPER_SETCREDENTIALSFROMREQUEST_FAILED'));
}
}
}
}
示例3:
/**
* Determine wether input fields for client settings need to be shown
*
* If valid credentials were passed along with the request, they are saved to the session.
* This functions returns an exeption if invalid credentials have been given or if the
* connection to the server failed for some other reason.
* @static
* @return boolean|JExeption True, if FTP settings should be shown, or an exeption
* @since 1.5
*/
function &setCredentialsFromRequest($client)
{
// Determine wether FTP credentials have been passed along with the current request
$user = JRequest::getString('username', null, 'POST', JREQUEST_ALLOWRAW);
$pass = JRequest::getString('password', null, 'POST', JREQUEST_ALLOWRAW);
if ($user != '' && $pass != '') {
// Add credentials to the session
if (JClientHelper::setCredentials($client, $user, $pass)) {
$return = false;
} else {
$return =& JError::raiseWarning('SOME_ERROR_CODE', 'JClientHelper::setCredentialsFromRequest failed');
}
} else {
// Just determine if the FTP input fields need to be shown
$return = !JClientHelper::hasCredentials('ftp');
}
return $return;
}
示例4: setCredentials
/**
* Helper wrapper method for setCredentials
*
* @param string $client Client name, currently only 'ftp' is supported
* @param string $user Username
* @param string $pass Password
*
* @return boolean True if the given login credentials have been set and are valid
*
* @see JClientHelper::setCredentials()
* @since 3.4
*/
public function setCredentials($client, $user, $pass)
{
return JClientHelper::setCredentials($client, $user, $pass);
}
示例5: needsFTPCredentials
/**
* Does the user need to provide FTP credentials? It also registers any FTP credentials provided in the URL.
*
* @return bool True if the user needs to provide FTP credentials
*/
public function needsFTPCredentials()
{
// Determine wether FTP credentials have been passed along with the current request
\JLoader::import('joomla.client.helper');
$user = $this->input->get('username', null, 'raw');
$pass = $this->input->get('password', null, 'raw');
if (!($user == '' && $pass == '')) {
// Add credentials to the session
if (\JClientHelper::setCredentials('ftp', $user, $pass)) {
return false;
}
return true;
}
return !\JClientHelper::hasCredentials('ftp');
}
示例6: _applyFTPCredentials
private function _applyFTPCredentials()
{
$session = JFactory::getSession();
$credentials = $session->get('ftp', array('user' => '', 'pass' => ''), 'akeeba');
JClientHelper::setCredentials('ftp', $credentials['user'], $credentials['pass']);
}
示例7: getFTPOptions
/**
* Returns an array with the configured FTP options
*
* @return array
*/
public function getFTPOptions()
{
// Initialise from Joomla! Global Configuration
$config = JFactory::getConfig();
$retArray = array('enable' => $config->get('ftp_enable', 0), 'host' => $config->get('ftp_host', 'localhost'), 'port' => $config->get('ftp_port', '21'), 'user' => $config->get('ftp_user', ''), 'pass' => $config->get('ftp_pass', ''), 'root' => $config->get('ftp_root', ''), 'tempdir' => $config->get('tmp_path', ''));
// Get the username and password from the state variables, if it exists
$stateUser = '';
//$this->getState('user', '', 'raw');
$statePass = '';
//$this->getState('pass', '', 'raw');
if (!empty($stateUser)) {
$retArray['user'] = $stateUser;
}
if (!empty($statePass)) {
$retArray['pass'] = $statePass;
}
// Apply the FTP credentials to Joomla! itself
JLoader::import('joomla.client.helper');
JClientHelper::setCredentials('ftp', $retArray['user'], $retArray['pass']);
return $retArray;
}