@@ -1628,7 +1628,15 @@ public static function getRemoteContent($url)
1628
1628
}
1629
1629
}
1630
1630
1631
- public static function parseStandardFormParameters (&$ repDef , &$ options , $ userId = null , $ prefix = "DRIVER_OPTION_ " , $ binariesContext = null )
1631
+ public static function decypherStandardFormPassword ($ userId , $ password ){
1632
+ if (function_exists ('mcrypt_decrypt ' )) {
1633
+ // We have encoded as base64 so if we need to store the result in a database, it can be stored in text column
1634
+ $ password = trim (mcrypt_decrypt (MCRYPT_RIJNDAEL_256 , md5 ($ userId ."\1CDAFx¨op# " ), base64_decode ($ password ), MCRYPT_MODE_ECB ), "\0" );
1635
+ }
1636
+ return $ password ;
1637
+ }
1638
+
1639
+ public static function parseStandardFormParameters (&$ repDef , &$ options , $ userId = null , $ prefix = "DRIVER_OPTION_ " , $ binariesContext = null , $ cypheredPassPrefix = "" )
1632
1640
{
1633
1641
if ($ binariesContext === null ) {
1634
1642
$ binariesContext = array ("USER " => (AuthService::getLoggedUser ()!= null )?AuthService::getLoggedUser ()->getId ():"shared " );
@@ -1650,9 +1658,9 @@ public static function parseStandardFormParameters(&$repDef, &$options, $userId
1650
1658
} else if ($ type == "array " ) {
1651
1659
$ value = explode (", " , $ value );
1652
1660
} else if ($ type == "password " && $ userId !=null ) {
1653
- if (trim ($ value ) != "" && function_exists ('mcrypt_encrypt ' )) {
1661
+ if (trim ($ value ) != "" && $ value != " __AJXP_VALUE_SET__ " && function_exists ('mcrypt_encrypt ' )) {
1654
1662
// We encode as base64 so if we need to store the result in a database, it can be stored in text column
1655
- $ value = base64_encode (mcrypt_encrypt (MCRYPT_RIJNDAEL_256 , md5 ($ userId ."\1CDAFx¨op# " ), $ value , MCRYPT_MODE_ECB ));
1663
+ $ value = $ cypheredPassPrefix . base64_encode (mcrypt_encrypt (MCRYPT_RIJNDAEL_256 , md5 ($ userId ."\1CDAFx¨op# " ), $ value , MCRYPT_MODE_ECB ));
1656
1664
}
1657
1665
} else if ($ type == "binary " && $ binariesContext !== null ) {
1658
1666
if (!empty ($ value )) {
@@ -1929,11 +1937,12 @@ public static function pbkdf2_create_hash($password)
1929
1937
/**
1930
1938
* generates a random password, uses base64: 0-9a-zA-Z
1931
1939
* @param int [optional] $length length of password, default 24 (144 Bit)
1940
+ * @param bool $complexChars
1932
1941
* @return string password
1933
1942
*/
1934
- public static function generateRandomString ($ length = 24 )
1943
+ public static function generateRandomString ($ length = 24 , $ complexChars = false )
1935
1944
{
1936
- if (function_exists ('openssl_random_pseudo_bytes ' ) && USE_OPENSSL_RANDOM ) {
1945
+ if (function_exists ('openssl_random_pseudo_bytes ' ) && USE_OPENSSL_RANDOM && ! $ complexChars ) {
1937
1946
$ password = base64_encode (openssl_random_pseudo_bytes ($ length , $ strong ));
1938
1947
if ($ strong == TRUE )
1939
1948
return substr (str_replace (array ("/ " ,"+ " ), "" , $ password ), 0 , $ length ); //base64 is about 33% longer, so we need to truncate the result
@@ -1942,6 +1951,9 @@ public static function generateRandomString($length = 24)
1942
1951
//fallback to mt_rand if php < 5.3 or no openssl available
1943
1952
$ characters = '0123456789 ' ;
1944
1953
$ characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ' ;
1954
+ if ($ complexChars ){
1955
+ $ characters .= "!@#$%&*? " ;
1956
+ }
1945
1957
$ charactersLength = strlen ($ characters )-1 ;
1946
1958
$ password = '' ;
1947
1959
0 commit comments