Author: coudot
Date: 2010-02-12 17:08:11 +0100 (Fri, 12 Feb 2010)
New Revision: 52

Modified:
   self-service-password/trunk/config.inc.php
   self-service-password/trunk/functions.inc.php
   self-service-password/trunk/index.php
Log:
#175: add CRYPT hash possibility

Modified: self-service-password/trunk/config.inc.php
===================================================================
--- self-service-password/trunk/config.inc.php  2010-02-09 21:49:25 UTC (rev 51)
+++ self-service-password/trunk/config.inc.php  2010-02-12 16:08:11 UTC (rev 52)
@@ -39,6 +39,7 @@
 # SHA
 # SMD5
 # MD5
+# CRYPT
 # clear (the default)
 # This option is not used with ad_mode = on
 $hash = "clear";

Modified: self-service-password/trunk/functions.inc.php
===================================================================
--- self-service-password/trunk/functions.inc.php       2010-02-09 21:49:25 UTC 
(rev 51)
+++ self-service-password/trunk/functions.inc.php       2010-02-12 16:08:11 UTC 
(rev 52)
@@ -47,6 +47,25 @@
     return $hash;
 }
 
+# Create CRYPT password
+function make_crypt_password($password) {
+
+    // Generate salt
+    $possible = '0123456789'.
+               'abcdefghijklmnopqrstuvwxyz'.
+               'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
+               './';
+    $salt = "";
+
+    mt_srand((double)microtime() * 1000000);
+
+    while( strlen( $salt ) < 2 )
+               $salt .= substr( $possible, ( rand() % strlen( $possible ) ), 1 
);
+
+    $hash = '{CRYPT}' . crypt( $password,  $salt);
+    return $hash;
+}
+
 # Strip slashes added by PHP
 # Only if magic_quote_gpc is not set to off in php.ini
 function stripslashes_if_gpc_magic_quotes( $string ) {

Modified: self-service-password/trunk/index.php
===================================================================
--- self-service-password/trunk/index.php       2010-02-09 21:49:25 UTC (rev 51)
+++ self-service-password/trunk/index.php       2010-02-12 16:08:11 UTC (rev 52)
@@ -135,6 +135,9 @@
         if ( $hash == "MD5" ) {
             $newpassword = make_md5_password($newpassword);
         }
+        if ( $hash == "CRYPT" ) {
+            $newpassword = make_crypt_password($newpassword);
+        }
     }
 
     # Rebind as Manager if needed

_______________________________________________
ltb-changes mailing list
[email protected]
http://lists.ltb-project.org/listinfo/ltb-changes

Reply via email to