Source for file password.php
Documentation is available at password.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Form Rule class for the Joomla Platform.
* @package Joomla.Libraries
* Method to test if two values are not equal. To use this rule, the form
* XML needs a validate attribute of equals and a field attribute
* that is equal to the field to test against.
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form.
* @param JForm $form The form object for which the field is being tested.
* @return boolean True if the value is valid, false otherwise.
* @throws InvalidArgumentException
* @throws UnexpectedValueException
public function test(SimpleXMLElement $element, $value, $group =
null, JRegistry $input =
null, JForm $form =
null)
$meter = isset
($this->element['strengthmeter']) ?
' meter="0"' :
'1';
$threshold = isset
($this->element['threshold']) ? (int)
$this->element['threshold'] :
66;
$minimumLength = isset
($this->element['minimum_length']) ? (int)
$this->element['minimum_length'] :
4;
$minimumIntegers = isset
($this->element['minimum_integers']) ? (int)
$this->element['minimum_integers'] :
0;
$minimumSymbols = isset
($this->element['minimum_symbols']) ? (int)
$this->element['minimum_symbols'] :
0;
$minimumUppercase = isset
($this->element['minimum_uppercase']) ? (int)
$this->element['minimum_uppercase'] :
0;
// If we have parameters from com_users, use those instead.
// Some of these may be empty for legacy reasons.
$minimumLengthp =
$params->get('minimum_length');
$minimumIntegersp =
$params->get('minimum_integers');
$minimumSymbolsp =
$params->get('minimum_symbols');
$minimumUppercasep =
$params->get('minimum_uppercase');
$meterp =
$params->get('meter');
$thresholdp =
$params->get('threshold');
empty($minimumLengthp) ? :
$minimumLength = (int)
$minimumLengthp;
empty($minimumIntegersp) ? :
$minimumIntegers = (int)
$minimumIntegersp;
empty($minimumSymbolsp) ? :
$minimumSymbols = (int)
$minimumSymbolsp;
empty($minimumUppercasep) ? :
$minimumUppercase = (int)
$minimumUppercasep;
empty($meterp) ? :
$meter =
$meterp;
empty($thresholdp) ? :
$threshold =
$thresholdp;
// If the field is empty and not required, the field is valid.
$required =
((string)
$element['required'] ==
'true' || (string)
$element['required'] ==
'required');
if (!$required &&
empty($value))
$valueLength =
strlen($value);
* We set a maximum length to prevent abuse since it is unfiltered.
* 55 is the length we use because that is roughly the maximum for bcrypt
// We don't allow white space inside passwords
$valueTrim =
trim($value);
// Set a variable to check if any errors are made in password
if (strlen($valueTrim) !=
$valueLength)
JText::_('COM_USERS_MSG_SPACES_IN_PASSWORD'),
// Minimum number of integers required
if (!empty($minimumIntegers))
if ($nInts <
$minimumIntegers)
JText::plural('COM_USERS_MSG_NOT_ENOUGH_INTEGERS_N', $minimumIntegers),
// Minimum number of symbols required
if (!empty($minimumSymbols))
if ($nsymbols <
$minimumSymbols)
JText::plural('COM_USERS_MSG_NOT_ENOUGH_SYMBOLS_N', $minimumSymbols),
// Minimum number of upper case ASII characters required
if (!empty($minimumUppercase))
if ($nUppercase <
$minimumUppercase)
JText::plural('COM_USERS_MSG_NOT_ENOUGH_UPPERCASE_LETTERS_N', $minimumUppercase),
if (!empty($minimumLength))
if (strlen((string)
$value) <
$minimumLength)
JText::plural('COM_USERS_MSG_PASSWORD_TOO_SHORT_N', $minimumLength),
// If valid has violated any rules above return false.
Documentation generated on Tue, 19 Nov 2013 15:10:19 +0100 by phpDocumentor 1.4.3