[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/js/ -> server_privileges.js (source)

   1  /* $Id: server_privileges.js 7886 2005-11-23 19:10:30Z nijel $ */
   2  
   3  
   4  /**
   5   * Validates the password field in a form
   6   *
   7   * @param   object   the form
   8   *
   9   * @return  boolean  whether the field value is valid or not
  10   */
  11  function checkPassword(the_form)
  12  {
  13      // Did the user select 'no password'?
  14      if (typeof(the_form.elements['nopass']) != 'undefined' && the_form.elements['nopass'][0].checked) {
  15          return true;
  16      } else if (typeof(the_form.elements['pred_password']) != 'undefined' && (the_form.elements['pred_password'].value == 'none' || the_form.elements['pred_password'].value == 'keep')) {
  17          return true;
  18      }
  19  
  20      // Validates
  21      if (the_form.elements['pma_pw'].value == '') {
  22          alert(jsPasswordEmpty);
  23          the_form.elements['pma_pw2'].value = '';
  24          the_form.elements['pma_pw'].focus();
  25          return false;
  26      } else if (the_form.elements['pma_pw'].value != the_form.elements['pma_pw2'].value) {
  27          alert(jsPasswordNotSame);
  28          the_form.elements['pma_pw'].value  = '';
  29          the_form.elements['pma_pw2'].value = '';
  30          the_form.elements['pma_pw'].focus();
  31          return false;
  32      } // end if...else if
  33  
  34      return true;
  35  } // end of the 'checkPassword()' function
  36  
  37  
  38  /**
  39   * Validates the "add a user" form
  40   *
  41   * @return  boolean  whether the form is validated or not
  42   */
  43  function checkAddUser(the_form)
  44  {
  45      if (the_form.elements['pred_hostname'].value == 'userdefined' && the_form.elements['hostname'].value == '') {
  46          alert(jsHostEmpty);
  47          the_form.elements['hostname'].focus();
  48          return false;
  49      }
  50  
  51      if (the_form.elements['pred_username'].value == 'userdefined' && the_form.elements['username'].value == '') {
  52          alert(jsUserEmpty);
  53          the_form.elements['username'].focus();
  54          return false;
  55      }
  56  
  57      return checkPassword(the_form);
  58  } // end of the 'checkAddUser()' function
  59  
  60  
  61  /**
  62   * Generate a new password, which may then be copied to the form
  63   * with suggestPasswordCopy().
  64   *
  65   * @param   string   the form name
  66   *
  67   * @return  boolean  always true
  68   */
  69  function suggestPassword() {
  70      var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ.,:";
  71      var passwordlength = 16;    // do we want that to be dynamic?  no, keep it simple :)
  72      var passwd = document.getElementById('generated_pw');
  73      passwd.value = '';
  74  
  75      for ( i = 0; i < passwordlength; i++ ) {
  76          passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
  77      }
  78      return passwd.value;
  79  }
  80  
  81  
  82  /**
  83   * Copy the generated password (or anything in the field) to the form
  84   *
  85   * @param   string   the form name
  86   *
  87   * @return  boolean  always true
  88   */
  89  function suggestPasswordCopy() {
  90      document.getElementById('text_pma_pw').value = document.getElementById('generated_pw').value;
  91      document.getElementById('text_pma_pw2').value = document.getElementById('generated_pw').value;
  92      return true;
  93  }


Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics