$score = 0;
if(!empty($_GET['value'])){
$str = $_GET['value'];
} else{
$str = '';
}
if(preg_match("/[0-9]+/",$str))
{
$score ++;
}
if(preg_match("/[0-9]{3,}/",$str))
{
$score ++;
}
if(preg_match("/[a-z]+/",$str))
{
$score ++;
}
if(preg_match("/[a-z]{3,}/",$str))
{
$score ++;
}
if(preg_match("/[A-Z]+/",$str))
{
$score ++;
}
if(preg_match("/[A-Z]{3,}/",$str))
{
$score ++;
}
if(preg_match("/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]+/",$str))
{
$score += 2;
}
if(preg_match("/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]{3,}/",$str))
{
$score ++ ;
}
if(strlen($str) >= 10)
{
$score ++;
}
echo $score;
exit;
public function checkPwLevel($pw){
if(empty($pw)){
return 0;
}
$pattern['weak'] = '/((^[0-9]{6,})|(^[a-z]{6,})|(^[A-Z]{6,}))$/';
$pattern['middle'] = '/((^[0-9,a-z]{6,})|(^[0-9,A-Z]{6,})|(^[a-z,A-Z]{6,}))$/';
$pattern['strong'] = '/^[\x21-\x7e,A-Za-z0-9]{6,}/';
$key ='';
foreach($pattern as $k=>$v){
$res = preg_match($v,$pw);
if($res){
$key = $k;
break;
}
}
switch ($key){
case 'weak':
return 3;
case 'middle':
return 2;
case 'strong':
return 1;
default:
return 0;
}
}