1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<?php
/* -------------------------------------------------------------------
Copyright (c) 2004 Klaraelvdalens Datakonsult AB
Copyright (C) 2007 by Intevation GmbH
Author(s):
Sascha Wilde <wilde@intevation.de>
Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
This program is free software under the GNU GPL (>=v2)
Read the file COPYING coming with the software for details.
------------------------------------------------------------------- */
// Generate OpenLDAP style SSHA password strings
function ssha($string, $salt)
{
return "{SSHA}" . base64_encode(pack("H*", sha1($string . $salt)) . $salt);
}
// return 4 random bytes
function gensalt()
{
$salt = '';
while (strlen($salt) < 4)
$salt = $salt . chr(mt_rand(0,255));
return $salt;
}
// Check that passwords from form input match
function checkpw( $form, $key, $value ) {
global $action;
if( $action == 'firstsave' ) {
if( $key == 'password_0' ) {
if( $value == '' ) return _('Password is empty');
} else if( $key == 'password_1' ) {
if( $value != $_POST['password_0'] ) {
return _('Passwords dont match');
}
}
} else {
if( $value != $_POST['password_0'] ) {
return _('Passwords dont match');
}
}
return '';
}
?>
|