Index: password_strength.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/password_strength/password_strength.module,v
retrieving revision 1.3.2.2
diff -u -r1.3.2.2 password_strength.module
--- password_strength.module	16 Nov 2007 07:00:17 -0000	1.3.2.2
+++ password_strength.module	26 Mar 2008 16:32:39 -0000
@@ -3,31 +3,29 @@
 
 
 /**
-* Implementation of hook_perm().
-*/
+ * Implementation of hook_perm().
+ */
 function password_strength_perm() {
   return array('configure password strength');
 }
 
 
 
-
 /**
-* Implementation of hook_menu().
-*/
+ * Implementation of hook_menu().
+ */
 function password_strength_menu($may_cache) {
-  global $user;
   $items = array();
 
-  if ($may_cache) { 
-    
+  if ($may_cache) {
+
     $items[] = array(
-  		'path' => 'admin/settings/password_strength', 
-  		'title' => t('Password Strength'),
-  		'callback' => 'drupal_get_form', 
-  		'callback arguments' => array('password_strength_admin_settings'),
-  		'access' => user_access('configure password strength'),
-  	);
+      'path' => 'admin/settings/password_strength',
+      'title' => t('Password Strength'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('password_strength_admin_settings'),
+      'access' => user_access('configure password strength'),
+    );
   }
   return $items;
 }
@@ -73,28 +71,27 @@
 
 
 
-
 /**
  * Add the necessary classes, and validation to password_confirm elements
  */
 function password_strength_expand_password_confirm($element) {
   drupal_add_js(password_strength_js_settings(), 'setting');
-  drupal_add_js(drupal_get_path('module', 'password_strength'). '/password_strength.js');
-  drupal_add_css(drupal_get_path('module', 'password_strength'). '/password_strength.css');
+  drupal_add_js(drupal_get_path('module', 'password_strength') .'/password_strength.js');
+  drupal_add_css(drupal_get_path('module', 'password_strength') .'/password_strength.css');
   $levels = array(
     1 => t('none'),
     2 => t('low'),
     3 => t('medium'),
     4 => t('high'),
   );
-  
+
   $element = expand_password_confirm($element);
   $element['pass1']['#attributes'] = array('class' => 'password-field');
   $element['pass2']['#attributes'] = array('class' => 'password-confirm');
   if ($strength > 1) {
     $element['pass2']['#description'] = t('Your password must be at least @strength strength.', array('@strength' => $levels[$strength]));
   }
-  
+
   // Only validate on server if admins want it
   if (variable_get('password_strength_verify_on_server', 0)) {
     $element['#validate']['password_strength_confirm_validate'] = array();
@@ -131,7 +128,6 @@
 
 
 
-
 /**
  * Implementation of hook_elements
  */
@@ -143,7 +139,6 @@
 
 
 
-
 /**
  * @todo Validate password_confirm element strength using algorithm similar to JS algorithm
  * Confirmation that passwords match is already handled by password_confirm_validate
@@ -155,15 +150,15 @@
     $min_length = variable_get('password_strength_min_length', '6');
     $min_level = variable_get('password_strength_min_level', 4);
     $pass = $form['pass1']['#value'];
-  
-    $hasLetters = ereg("[a-zA-Z]", $pass);
-    $hasNumbers = ereg("[0-9]", $pass);
-    $hasPunctuation = ereg("[^a-zA-Z0-9]", $pass);
-    $hasCasing = ereg("[a-z]+.*[A-Z]+|[A-Z]+.*[a-z]", $pass);
-  
+
+    $has_letters = ereg("[a-zA-Z]", $pass);
+    $has_numbers = ereg("[0-9]", $pass);
+    $has_punctuation = ereg("[^a-zA-Z0-9]", $pass);
+    $has_casing = ereg("[a-z]+.*[A-Z]+|[A-Z]+.*[a-z]", $pass);
+
     // Check if length is less than 6 characters.
     if (strlen($pass) < $min_length) {
-      form_error($form, t('Password is not long enough.  Password must be at least @l characters.', array('@l' => $min_length)));
+      form_error($form, t('Password is not long enough. Password must be at least @l characters.', array('@l' => $min_length)));
     }
     // Check if password is the same as the username (convert both to lowercase).
     else if (strtolower($pass) == strtolower($user->name) && variable_get('password_strength_not_username', 1)) {
@@ -172,31 +167,31 @@
     // Password is not secure enough so construct the medium-strength message.
     else {
       // Extremely bad passwords still count as low.
-      $count = ($hasLetters ? 1 : 0) + ($hasNumbers ? 1 : 0) + ($hasPunctuation ? 1 : 0) + ($hasCasing ? 1 : 0);
+      $count = ($has_letters ? 1 : 0) + ($has_numbers ? 1 : 0) + ($has_punctuation ? 1 : 0) + ($has_casing ? 1 : 0);
       if ($count < $min_level) {
         $msgs = array();
-        if (!$hasLetters || !$hasCasing) {
+        if (!$has_letters || !$has_casing) {
           $msgs[] = t('Adding both upper and lowercase letters.');
         }
-        if (!$hasNumbers) {
+        if (!$has_numbers) {
           $msgs[] = t('Adding numbers.');
         }
-        if (!$hasPunctuation) {
+        if (!$has_punctuation) {
           $msgs[] = t('Adding punctuation.');
         }
         if (count($msgs)) {
-          $msg = 'The password does not include enough variation to be secure. Try:' . "<ul><li>" . implode("</li><li>", $msgs) . "</li></ul>";
+          $msg = 'The password does not include enough variation to be secure. Try:<ul><li>'. implode('</li><li>', $msgs) .'</li></ul>';
           form_error($form, $msg);
         }
       }
     }
   }
-  
+
   // Password field must be converted from a two-element array into a single
   // string regardless of validation results.
   form_set_value($form['pass1'], NULL);
   form_set_value($form['pass2'], NULL);
   form_set_value($form, $pass1);
-  
+
   return $form;
 }
\ No newline at end of file
