3declare(strict_types=1);
12 if ($configured ===
null && function_exists(
'dbx')) {
13 $configured = (int)
dbx()->get_config(
15 'password_min_length',
19 $configured = $configured ?? 6;
20 return max(6, min(128, $configured > 0 ? $configured : 6));
28 ?
int $minimumLength =
null
31 $length = function_exists(
'mb_strlen')
35 if ($length < $minimumLength) {
36 $missing[] =
'mindestens ' . $minimumLength .
' Zeichen';
38 if (preg_match(
'/[A-Z]/',
$password) !== 1) {
41 if (preg_match(
'/[a-z]/',
$password) !== 1) {
44 if (preg_match(
'/[0-9]/',
$password) !== 1) {
47 if (preg_match(
'/[^A-Za-z0-9]/',
$password) !== 1) {
55 ?
int $minimumLength =
null
60 $minimumLength = self::minimumLength($minimumLength);
61 return 'Noch nicht erfüllt: ' . implode(
', ',
$missing) .
'.'
62 . ($minimumLength < 12
63 ?
' Empfohlen sind insgesamt 12 oder mehr Zeichen.'
74 ?
int $minimumLength =
null
79 $errors[
'repeat'] =
'Die beiden Passwörter stimmen nicht überein.';
83 $errors[
'password'] = self::missingMessage(
88 && password_get_info(
$currentHash)[
'algoName'] !==
'unknown'
91 $errors[
'password'] =
'Das neue Passwort muss sich vom bisherigen Passwort unterscheiden.';
Zentrale Passwortvorgaben für Installation, Login und Profilbearbeitung.
static missingCriteria(string $password, ?int $minimumLength=null)
static missingMessage(array $missing, ?int $minimumLength=null)
static errors(string $password, string $repeat, string $currentHash='', ?int $minimumLength=null)
static minimumLength(?int $configured=null)
if($out !==$expected) $missing
if(!defined( 'IMG_WEBP')) define( 'IMG_WEBP'
DBX schema administration.