public function setPasUsu($passwordUsuario) { if (SpoonFilter::isSmallerThan(40, strlen($passwordUsuario)) && SpoonFilter::isString($passwordUsuario) && SpoonFilter::isAlphaNumeric($passwordUsuario)) { $this->passwdUsu = sha1($passwordUsuario); } else { echo "Introduzca una contraseña correcta, use sólo números y letras"; exit; } }
/** * Checks if this field only contains letters & numbers (without spaces). * * @return bool * @param string[optional] $error The error message to set. */ public function isAlphaNumeric($error = null) { // filled if ($this->isFilled()) { // post/get data $data = $this->getMethod(true); // validate if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isAlphaNumeric($data[$this->attributes['name']])) { if ($error !== null) { $this->setError($error); } return false; } return true; } // not submitted if ($error !== null) { $this->setError($error); } return false; }
/** * Fetch the extension for a filename. * * @return string The extension. * @param string $filename The full path of the file. * @param bool[optional] $lowercase Should the extension be returned in lowercase or in its original form. */ public static function getExtension($filename, $lowercase = true) { // init var $filename = $lowercase ? strtolower((string) $filename) : (string) $filename; // fetch extension $chunks = (array) explode('.', $filename); // count the chunks $count = count($chunks); // has an extension if ($count != 0) { // extension can only have alphanumeric chars if (SpoonFilter::isAlphaNumeric($chunks[$count - 1])) { return $chunks[$count - 1]; } } // no extension return ''; }
public function testIsAlphaNumeric() { $this->assertTrue(SpoonFilter::isAlphaNumeric('John09')); $this->assertFalse(SpoonFilter::isAlphaNumeric('Johan Mayer 007')); // Simulating PHP < 5.4 behaviour $this->assertTrue(SpoonFilter::isAlphaNumeric(array('a', 'b'))); }
public function testIsAlphaNumeric() { $this->assertTrue(SpoonFilter::isAlphaNumeric('John09')); $this->assertFalse(SpoonFilter::isAlphaNumeric('Johan Mayer 007')); }