Hanno Böck
Spaces between string concat (.) operator, new PER codingstyle
Hanno Böck commited 354c05a at 2023-10-31 17:49:30
<?php
/*
This file belongs to the Webinterface of schokokeks.org Hosting
Written by schokokeks.org Hosting, namely
Bernd Wurst <bernd@schokokeks.org>
Hanno Böck <hanno@schokokeks.org>
This code is published under a 0BSD license.
Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
*/
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.";
}
// Kein Online-Check eingerichtet oder der request war nicht erfolgreich
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!";
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX