예제 #1
0
 /**
  * Check the strength of a password
  *
  * @return  string
  */
 public function passwordstrengthTask()
 {
     // Incoming
     $no_html = Request::getInt('no_html', 0);
     $password = Request::getVar('pass', '', 'post');
     $username = Request::getVar('user', '', 'post');
     // Instantiate a new registration object
     $xregistration = new \Components\Members\Models\Registration();
     // Score the password
     $score = $xregistration->scorePassword($password, $username);
     // Determine strength
     if ($score < PASS_SCORE_MEDIOCRE) {
         $cls = 'bad';
         $txt = Lang::txt('COM_MEMBERS_REGISTER_PASS_BAD');
     } else {
         if ($score >= PASS_SCORE_MEDIOCRE && $score < PASS_SCORE_GOOD) {
             $cls = 'mediocre';
             $txt = Lang::txt('COM_MEMBERS_REGISTER_PASS_MEDIOCRE');
         } else {
             if ($score >= PASS_SCORE_GOOD && $score < PASS_SCORE_STRONG) {
                 $cls = 'good';
                 $txt = Lang::txt('COM_MEMBERS_REGISTER_PASS_GOOD');
             } else {
                 if ($score >= PASS_SCORE_STRONG) {
                     $cls = 'strong';
                     $txt = Lang::txt('COM_MEMBERS_REGISTER_PASS_STRONG');
                 }
             }
         }
     }
     // Build the HTML
     $html = '<span id="passwd-meter" style="width:' . $score . '%;" class="' . $cls . '"><span>' . Lang::txt($txt) . '</span></span>';
     // Return the HTML
     if ($no_html) {
         echo $html;
     }
     return $html;
 }