/**
* 检测密码强度
* 使用方法
* session('codes', $this->checkcode($this->iScodes($pass_old))); //密码强度检测
*/
public function iScodes($str){
$score = 0;
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 ++;
}
return $score;
}
public function checkcode($num){
if($num>=1 && $num<=3){
return 1;
}else if($num >= 4 && $num <=6){
return 2;
}else if($num>=7 && $num<=10){
return 3;
}
}