protected function _createHash($password, $username) { return sha1($username . utf8_unhtml($password)); }
/** * Convert the given text to valid UTF-8 * * @param string $string * @param boolean $entities Convert < (and other) entities back to < characters * * @return string */ protected function _convertToUtf8($string, $entities = null) { // note: assumes charset is ascii compatible if (preg_match('/[\\x80-\\xff]/', $string)) { if (function_exists('iconv')) { $string = @iconv($this->_charset, 'utf-8//IGNORE', $string); } else { if (function_exists('mb_convert_encoding')) { $string = mb_convert_encoding($string, 'utf-8', $this->_charset); } } } $string = utf8_unhtml($string, $entities); return preg_replace('/[\\xF0-\\xF7].../', '', $string); }
/** * Convert the given text to valid UTF-8 * * @param string $string * @param boolean $entities Convert < (and other) entities back to < characters * * @return string */ protected function _convertToUtf8($string, $entities = null) { // note: assumes charset is ascii compatible if (preg_match('/[\\x80-\\xff]/', $string)) { $newString = false; if (function_exists('iconv')) { $newString = @iconv($this->_charset, 'utf-8//IGNORE', $string); } if (!$newString && function_exists('mb_convert_encoding')) { $newString = @mb_convert_encoding($string, 'utf-8', $this->_charset); } $string = $newString ? $newString : preg_replace('/[\\x80-\\xff]/', '', $string); } $string = utf8_unhtml($string, $entities); $string = preg_replace('/[\\xF0-\\xF7].../', '', $string); $string = preg_replace('/[\\xF8-\\xFB]..../', '', $string); return $string; }
function test_with_entities() { $out = '&&#38;'; $in = '&#38;&amp;#38;'; $this->assertEqual(utf8_unhtml($in, HTML_ENTITIES), $out); }