diff --git a/app/class/encoding.class.php b/app/class/encoding.class.php
index ce9f022..31e8cf7 100644
--- a/app/class/encoding.class.php
+++ b/app/class/encoding.class.php
@@ -36,9 +36,8 @@ POSSIBILITY OF SUCH DAMAGE.
* @example https://github.com/neitanod/forceutf8
* @license Revised BSD
*/
-
-
-class Encoding {
+class Encoding
+{
const ICONV_TRANSLIT = "TRANSLIT";
const ICONV_IGNORE = "IGNORE";
@@ -118,18 +117,18 @@ class Encoding {
"\xe2\x82\xac" => "\x80",
"\xe2\x80\x9a" => "\x82",
- "\xc6\x92" => "\x83",
+ "\xc6\x92" => "\x83",
"\xe2\x80\x9e" => "\x84",
"\xe2\x80\xa6" => "\x85",
"\xe2\x80\xa0" => "\x86",
"\xe2\x80\xa1" => "\x87",
- "\xcb\x86" => "\x88",
+ "\xcb\x86" => "\x88",
"\xe2\x80\xb0" => "\x89",
- "\xc5\xa0" => "\x8a",
+ "\xc5\xa0" => "\x8a",
"\xe2\x80\xb9" => "\x8b",
- "\xc5\x92" => "\x8c",
+ "\xc5\x92" => "\x8c",
- "\xc5\xbd" => "\x8e",
+ "\xc5\xbd" => "\x8e",
"\xe2\x80\x98" => "\x91",
@@ -139,17 +138,49 @@ class Encoding {
"\xe2\x80\xa2" => "\x95",
"\xe2\x80\x93" => "\x96",
"\xe2\x80\x94" => "\x97",
- "\xcb\x9c" => "\x98",
+ "\xcb\x9c" => "\x98",
"\xe2\x84\xa2" => "\x99",
- "\xc5\xa1" => "\x9a",
+ "\xc5\xa1" => "\x9a",
"\xe2\x80\xba" => "\x9b",
- "\xc5\x93" => "\x9c",
+ "\xc5\x93" => "\x9c",
- "\xc5\xbe" => "\x9e",
- "\xc5\xb8" => "\x9f"
+ "\xc5\xbe" => "\x9e",
+ "\xc5\xb8" => "\x9f"
);
- static function toUTF8($text){
+ static function toISO8859($text, $option = self::WITHOUT_ICONV)
+ {
+ return self::toWin1252($text, $option);
+ }
+
+ static function toWin1252($text, $option = self::WITHOUT_ICONV)
+ {
+ if (is_array($text)) {
+ foreach ($text as $k => $v) {
+ $text[$k] = self::toWin1252($v, $option);
+ }
+ return $text;
+ } elseif (is_string($text)) {
+ return static::utf8_decode($text, $option);
+ } else {
+ return $text;
+ }
+ }
+
+ protected static function utf8_decode($text, $option = self::WITHOUT_ICONV)
+ {
+ if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) {
+ $o = utf8_decode(
+ str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text))
+ );
+ } else {
+ $o = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text);
+ }
+ return $o;
+ }
+
+ static function toUTF8($text)
+ {
/**
* Function \ForceUTF8\Encoding::toUTF8
*
@@ -170,35 +201,33 @@ class Encoding {
* 3) when any of these: ðñòó are followed by THREE chars from group B.
*
* @name toUTF8
- * @param string $text Any string.
+ * @param string $text Any string.
* @return string The same string, UTF8 encoded
*
*/
- if(is_array($text))
- {
- foreach($text as $k => $v)
- {
+ if (is_array($text)) {
+ foreach ($text as $k => $v) {
$text[$k] = self::toUTF8($v);
}
return $text;
}
- if(!is_string($text)) {
+ if (!is_string($text)) {
return $text;
}
$max = self::strlen($text);
$buf = "";
- for($i = 0; $i < $max; $i++){
+ for ($i = 0; $i < $max; $i++) {
$c1 = $text{$i};
- if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already
- $c2 = $i+1 >= $max? "\x00" : $text{$i+1};
- $c3 = $i+2 >= $max? "\x00" : $text{$i+2};
- $c4 = $i+3 >= $max? "\x00" : $text{$i+3};
- if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8
- if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already
+ if ($c1 >= "\xc0") { //Should be converted to UTF8, if it's not UTF8 already
+ $c2 = $i + 1 >= $max ? "\x00" : $text{$i + 1};
+ $c3 = $i + 2 >= $max ? "\x00" : $text{$i + 2};
+ $c4 = $i + 3 >= $max ? "\x00" : $text{$i + 3};
+ if ($c1 >= "\xc0" & $c1 <= "\xdf") { //looks like 2 bytes UTF8
+ if ($c2 >= "\x80" && $c2 <= "\xbf") { //yeah, almost sure it's UTF8 already
$buf .= $c1 . $c2;
$i++;
} else { //not valid UTF8. Convert it.
@@ -206,8 +235,8 @@ class Encoding {
$cc2 = ($c1 & "\x3f") | "\x80";
$buf .= $cc1 . $cc2;
}
- } elseif($c1 >= "\xe0" & $c1 <= "\xef"){ //looks like 3 bytes UTF8
- if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf"){ //yeah, almost sure it's UTF8 already
+ } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { //looks like 3 bytes UTF8
+ if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { //yeah, almost sure it's UTF8 already
$buf .= $c1 . $c2 . $c3;
$i = $i + 2;
} else { //not valid UTF8. Convert it.
@@ -215,8 +244,8 @@ class Encoding {
$cc2 = ($c1 & "\x3f") | "\x80";
$buf .= $cc1 . $cc2;
}
- } elseif($c1 >= "\xf0" & $c1 <= "\xf7"){ //looks like 4 bytes UTF8
- if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf"){ //yeah, almost sure it's UTF8 already
+ } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { //looks like 4 bytes UTF8
+ if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { //yeah, almost sure it's UTF8 already
$buf .= $c1 . $c2 . $c3 . $c4;
$i = $i + 3;
} else { //not valid UTF8. Convert it.
@@ -229,8 +258,8 @@ class Encoding {
$cc2 = (($c1 & "\x3f") | "\x80");
$buf .= $cc1 . $cc2;
}
- } elseif(($c1 & "\xc0") == "\x80"){ // needs conversion
- if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases
+ } elseif (($c1 & "\xc0") == "\x80") { // needs conversion
+ if (isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases
$buf .= self::$win1252ToUtf8[ord($c1)];
} else {
$cc1 = (chr(ord($c1) / 64) | "\xc0");
@@ -244,41 +273,27 @@ class Encoding {
return $buf;
}
- static function toWin1252($text, $option = self::WITHOUT_ICONV) {
- if(is_array($text)) {
- foreach($text as $k => $v) {
- $text[$k] = self::toWin1252($v, $option);
- }
- return $text;
- } elseif(is_string($text)) {
- return static::utf8_decode($text, $option);
- } else {
- return $text;
- }
+ protected static function strlen($text)
+ {
+ return (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload')) & 2) ?
+ mb_strlen($text, '8bit') : strlen($text);
}
- static function toISO8859($text, $option = self::WITHOUT_ICONV) {
- return self::toWin1252($text, $option);
- }
-
- static function toLatin1($text, $option = self::WITHOUT_ICONV) {
- return self::toWin1252($text, $option);
- }
-
- static function fixUTF8($text, $option = self::WITHOUT_ICONV){
- if(is_array($text)) {
- foreach($text as $k => $v) {
+ static function fixUTF8($text, $option = self::WITHOUT_ICONV)
+ {
+ if (is_array($text)) {
+ foreach ($text as $k => $v) {
$text[$k] = self::fixUTF8($v, $option);
}
return $text;
}
- if(!is_string($text)) {
+ if (!is_string($text)) {
return $text;
}
$last = "";
- while($last <> $text){
+ while ($last <> $text) {
$last = $text;
$text = self::toUTF8(static::utf8_decode($text, $option));
}
@@ -286,7 +301,8 @@ class Encoding {
return $text;
}
- static function UTF8FixWin1252Chars($text){
+ static function UTF8FixWin1252Chars($text)
+ {
// If you received an UTF-8 string that was converted from Windows-1252 as it was ISO8859-1
// (ignoring Windows-1252 chars from 80 to 9F) use this function to fix it.
// See: http://en.wikipedia.org/wiki/Windows-1252
@@ -294,16 +310,19 @@ class Encoding {
return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text);
}
- static function removeBOM($str=""){
- if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) {
- $str=substr($str, 3);
+ static function removeBOM($str = "")
+ {
+ if (substr($str, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
+ $str = substr($str, 3);
}
return $str;
}
- protected static function strlen($text){
- return (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload')) & 2) ?
- mb_strlen($text,'8bit') : strlen($text);
+ public static function encode($encodingLabel, $text)
+ {
+ $encodingLabel = self::normalizeEncoding($encodingLabel);
+ if ($encodingLabel == 'ISO-8859-1') return self::toLatin1($text);
+ return self::toUTF8($text);
}
public static function normalizeEncoding($encodingLabel)
@@ -312,59 +331,50 @@ class Encoding {
$encoding = preg_replace('/[^a-zA-Z0-9\s]/', '', $encoding);
$equivalences = array(
'ISO88591' => 'ISO-8859-1',
- 'ISO8859' => 'ISO-8859-1',
- 'ISO' => 'ISO-8859-1',
- 'LATIN1' => 'ISO-8859-1',
- 'LATIN' => 'ISO-8859-1',
- 'UTF8' => 'UTF-8',
- 'UTF' => 'UTF-8',
- 'WIN1252' => 'ISO-8859-1',
+ 'ISO8859' => 'ISO-8859-1',
+ 'ISO' => 'ISO-8859-1',
+ 'LATIN1' => 'ISO-8859-1',
+ 'LATIN' => 'ISO-8859-1',
+ 'UTF8' => 'UTF-8',
+ 'UTF' => 'UTF-8',
+ 'WIN1252' => 'ISO-8859-1',
'WINDOWS1252' => 'ISO-8859-1'
);
- if(empty($equivalences[$encoding])){
+ if (empty($equivalences[$encoding])) {
return 'UTF-8';
}
return $equivalences[$encoding];
}
- public static function encode($encodingLabel, $text)
+ static function toLatin1($text, $option = self::WITHOUT_ICONV)
{
- $encodingLabel = self::normalizeEncoding($encodingLabel);
- if($encodingLabel == 'ISO-8859-1') return self::toLatin1($text);
- return self::toUTF8($text);
- }
-
- protected static function utf8_decode($text, $option = self::WITHOUT_ICONV)
- {
- if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) {
- $o = utf8_decode(
- str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text))
- );
- } else {
- $o = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text);
- }
- return $o;
+ return self::toWin1252($text, $option);
}
/****/
- public static function destructionH4x0RChaine($chaine){
+ public static function destructionH4x0RChaine($chaine)
+ {
return preg_replace('#[\x00-\x1F\x7F-\x9F/\\\\]#', '', $chaine);
}
- public static function protectionDoubleQuote($chaine){
+ public static function protectionDoubleQuote($chaine)
+ {
$chaine = preg_replace('/"(\w+)"/', '« ${1} »', $chaine);
$chaine = preg_replace('#"#', '_', $chaine);
return $chaine;
}
- public static function protectionSimpleQuote($chaine){
+
+ public static function protectionSimpleQuote($chaine)
+ {
$chaine = preg_replace("#'#", '_', $chaine);
return $chaine;
}
- public static function myUrlEncode($string) {
+ public static function myUrlEncode($string)
+ {
$replacements = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D'/*, '%2B'*/, '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
$entities = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "="/*, "+"*/, "$", ",", "/", "?", "%", "#", "[", "]");
$string = urlencode($string);
@@ -372,7 +382,8 @@ class Encoding {
return $string;
}
- public static function myUrlDecode($string) {
+ public static function myUrlDecode($string)
+ {
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D'/*, '%2B'*/, '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "="/*, "+"*/, "$", ",", "/", "?", "%", "#", "[", "]");
$string = str_replace($entities, $replacements, $string);
diff --git a/app/class/password.class.php b/app/class/password.class.php
index a18abc2..93ec641 100644
--- a/app/class/password.class.php
+++ b/app/class/password.class.php
@@ -27,18 +27,19 @@ namespace {
* Hash the password using the specified algorithm
*
* @param string $password The password to hash
- * @param int $algo The algorithm to use (Defined by PASSWORD_* constants)
- * @param array $options The options for the algorithm to use
+ * @param int $algo The algorithm to use (Defined by PASSWORD_* constants)
+ * @param array $options The options for the algorithm to use
*
* @return string|false The hashed password, or false on error.
*/
- function password_hash($password, $algo, array $options = array()) {
+ function password_hash($password, $algo, array $options = array())
+ {
if (!function_exists('crypt')) {
trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING);
return null;
}
if (is_null($password) || is_int($password)) {
- $password = (string) $password;
+ $password = (string)$password;
}
if (!is_string($password)) {
trigger_error("password_hash(): Password must be a string", E_USER_WARNING);
@@ -53,7 +54,7 @@ namespace {
case PASSWORD_BCRYPT:
$cost = PASSWORD_BCRYPT_DEFAULT_COST;
if (isset($options['cost'])) {
- $cost = (int) $options['cost'];
+ $cost = (int)$options['cost'];
if ($cost < 4 || $cost > 31) {
trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING);
return null;
@@ -79,11 +80,11 @@ namespace {
case 'integer':
case 'double':
case 'string':
- $salt = (string) $options['salt'];
+ $salt = (string)$options['salt'];
break;
case 'object':
if (method_exists($options['salt'], '__tostring')) {
- $salt = (string) $options['salt'];
+ $salt = (string)$options['salt'];
break;
}
case 'array':
@@ -180,7 +181,8 @@ namespace {
*
* @return array The array of information about the hash.
*/
- function password_get_info($hash) {
+ function password_get_info($hash)
+ {
$return = array(
'algo' => 0,
'algoName' => 'unknown',
@@ -200,20 +202,21 @@ namespace {
*
* If the answer is true, after validating the password using password_verify, rehash it.
*
- * @param string $hash The hash to test
- * @param int $algo The algorithm used for new password hashes
- * @param array $options The options array passed to password_hash
+ * @param string $hash The hash to test
+ * @param int $algo The algorithm used for new password hashes
+ * @param array $options The options array passed to password_hash
*
* @return boolean True if the password needs to be rehashed.
*/
- function password_needs_rehash($hash, $algo, array $options = array()) {
+ function password_needs_rehash($hash, $algo, array $options = array())
+ {
$info = password_get_info($hash);
- if ($info['algo'] !== (int) $algo) {
+ if ($info['algo'] !== (int)$algo) {
return true;
}
switch ($algo) {
case PASSWORD_BCRYPT:
- $cost = isset($options['cost']) ? (int) $options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
+ $cost = isset($options['cost']) ? (int)$options['cost'] : PASSWORD_BCRYPT_DEFAULT_COST;
if ($cost !== $info['options']['cost']) {
return true;
}
@@ -226,11 +229,12 @@ namespace {
* Verify a password against a hash using a timing attack resistant approach
*
* @param string $password The password to verify
- * @param string $hash The hash to verify against
+ * @param string $hash The hash to verify against
*
* @return boolean If the password matches the hash
*/
- function password_verify($password, $hash) {
+ function password_verify($password, $hash)
+ {
if (!function_exists('crypt')) {
trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING);
return false;
@@ -264,10 +268,11 @@ namespace PasswordCompat\binary {
*
* @param string $binary_string The input string
*
- * @internal
* @return int The number of bytes
+ * @internal
*/
- function _strlen($binary_string) {
+ function _strlen($binary_string)
+ {
if (function_exists('mb_strlen')) {
return mb_strlen($binary_string, '8bit');
}
@@ -277,16 +282,17 @@ namespace PasswordCompat\binary {
/**
* Get a substring based on byte limits
*
+ * @param string $binary_string The input string
+ * @param int $start
+ * @param int $length
+ *
+ * @return string The substring
+ * @internal
* @see _strlen()
*
- * @param string $binary_string The input string
- * @param int $start
- * @param int $length
- *
- * @internal
- * @return string The substring
*/
- function _substr($binary_string, $start, $length) {
+ function _substr($binary_string, $start, $length)
+ {
if (function_exists('mb_substr')) {
return mb_substr($binary_string, $start, $length, '8bit');
}
@@ -298,7 +304,8 @@ namespace PasswordCompat\binary {
*
* @return boolean the check result
*/
- function check() {
+ function check()
+ {
static $pass = NULL;
if (is_null($pass)) {
diff --git a/app/layout/footer.php b/app/layout/footer.php
index 0315e48..09db966 100644
--- a/app/layout/footer.php
+++ b/app/layout/footer.php
@@ -1,24 +1,27 @@
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+