lmhash($password); } function ntPassword($password) { $hash = new SmbHash(); return $hash->nthash($password); } function ssha($password) { return ssha_encode($password); /* $salt = sha1(rand()); $salt = substr($salt, 0, 4); $hash = base64_encode( sha1 ($password . $salt, true) . $salt ); return $hash;*/ } function ssha_encode($password) { $salt = ""; for ( $i=1;$i<=10;$i++ ) { $salt .= substr('0123456789abcdef', rand(0,15), 1); } $hash = base64_encode(pack("H*", sha1($password.$salt)).$salt); return $hash; } function debug($str) { $time = date("[Y-m-d H:i:s] "); echo $time . $str . "\n"; } function ldap_log($str) { $time = date("[Y-m-d H:i:s] "); //file_put_contents("/var/www/neuf.no/userinfo/log/user.log", $time . // $str . "\n", FILE_APPEND); } function _log_check($str) { $time = date("[Y-m-d H:i:s] "); // file_put_contents("/var/www/neuf.no/userinfo/log/integrity_check.log", $time . // $str . "\n", FILE_APPEND); debug($str); } function _log_check_error($str) { $time = date("[Y-m-d H:i:s] "); // file_put_contents("/var/www/neuf.no/userinfo/log/integrity_check.log", $time . "[ERROR] " . // $str . "\n", FILE_APPEND); debug($str); } function mail_admins($str) { _log_check("Mailing admins..."); } function validate_user_info($user) { if( !is_array($user) ) { throw new Exception("ERROR: user array is not an array"); } if( preg_match(USERNAME_REGEXP, $user['username']) == 0 ) { throw new Exception("ERROR: username did not validate"); } if( empty($user['firstname']) ) { throw new Exception("ERROR: firstname missing"); } if( empty($user['lastname']) ) { throw new Exception("ERROR: lastname missing"); } if( empty($user['email']) ) { throw new Exception("ERROR: email missing"); } if( empty($user['password']) ) { throw new Exception("ERROR: password missing"); } }