<?php
require_once('inc/error.php');
require_once('vendor/autoload.php');
function strong_password($password, $user = [])
{
$pwcheck = config('pwcheck');
$result = null;
if ($pwcheck) {
DEBUG($pwcheck);
$req = curl_init($pwcheck);
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($req, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($req, CURLOPT_SSL_VERIFYSTATUS, 1);
curl_setopt($req, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($req, CURLOPT_TIMEOUT, 5);
curl_setopt($req, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($req, CURLOPT_POST, 1);
curl_setopt($req, CURLOPT_POSTFIELDS, "password=" . urlencode($password));
$result = chop(curl_exec($req));
DEBUG($result);
}
if ($result === 'good') {
return true;
} elseif ($result === 'bad') {
return "Unsere Überprüfung hat ergeben, dass dieses Passwort in bisher veröffentlichten Passwortlisten enthalten ist. Es wird daher nicht akzeptiert.";
}
DEBUG('using Zxcvbn for password check!');
$passwordchecker = new ZxcvbnPhp\Zxcvbn();
if ($user) {
$strength = $passwordchecker->passwordStrength($password, $user);
} else {
$strength = $passwordchecker->passwordStrength($password);
}
DEBUG('password strength: ' . $strength['score']);
if ($strength['score'] < 2) {
return "Das Passwort ist zu einfach!";