Example #1
0
 protected function _createHash($password, $username)
 {
     return sha1($username . utf8_unhtml($password));
 }
Example #2
0
 /**
  * Convert the given text to valid UTF-8
  *
  * @param string $string
  * @param boolean $entities Convert &lt; (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);
 }
Example #3
0
 /**
  * Convert the given text to valid UTF-8
  *
  * @param string $string
  * @param boolean $entities Convert &lt; (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;
 }
Example #4
0
 function test_with_entities()
 {
     $out = '&#38;&amp;#38;';
     $in = '&amp;#38;&#38;amp;#38;';
     $this->assertEqual(utf8_unhtml($in, HTML_ENTITIES), $out);
 }