X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fusers%2Fmodels%2Ffuncs.php;h=a3a9928005c4994343e0417df54c94c2c7bdaaf2;hb=c93b3c1b0dc67d03e4f60d99785929b8c319ddb6;hp=021f3a0539a1beb8f353173f4db9ffa33a97320b;hpb=bd5fabfeabdd16cf38642c8cfb2232aab495de31;p=matches%2FMCTX3420.git diff --git a/testing/MCTXWeb/public_html/users/models/funcs.php b/testing/MCTXWeb/public_html/users/models/funcs.php index 021f3a0..a3a9928 100644 --- a/testing/MCTXWeb/public_html/users/models/funcs.php +++ b/testing/MCTXWeb/public_html/users/models/funcs.php @@ -71,14 +71,23 @@ function generateHash($plainText, $salt = null) { if ($salt === null) { - $salt = substr(md5(uniqid(rand(), true)), 0, 25); + //$salt = substr(md5(uniqid(rand(), true)), 0, 25); // Original UserCake + $random = file_get_contents("/dev/urandom", false, null, 0, 25); // Get random number + $salt = '$6$'.bin2hex($random).'$'; // Make hex salt + } - else - { - $salt = substr($salt, 0, 25); - } - - return $salt . sha1($salt . $plainText); + //return $salt . sha1($salt . $plainText); // Original UserCake + return crypt($plainText, $salt); +} + +/** + * Generates a random password for emailing to new users. + * User should be asked to change the password. + */ +function generatePassword() +{ + $random = file_get_contents("/dev/urandom", false, null, 0, 25); + return bin2hex($random); } //Checks if an email is valid @@ -145,31 +154,59 @@ function resultBlock($errors,$successes){ //Error block if(count($errors) > 0) { - echo "
".$error."
"; } - echo ""; echo "".$success.""; } - echo ""; echo "