plugins/SpecialUserPrefs.php
changeset 133 af0f6ec48de3
parent 103 a8891e108c95
child 140 40f7fa5fd061
equal deleted inserted replaced
132:0ae1b281a884 133:af0f6ec48de3
   212           
   212           
   213           if ( strlen($newpass) > 0 )
   213           if ( strlen($newpass) > 0 )
   214           {
   214           {
   215             // Perform checks
   215             // Perform checks
   216             if ( strlen($newpass) < 6 )
   216             if ( strlen($newpass) < 6 )
   217               $errors .= '<div class="error-box">Password must be at least 6 characters. You hacked my script, darn you!</div>';
   217               $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">Password must be at least 6 characters. You hacked my script, darn you!</div>';
       
   218             if ( getConfig('pw_strength_enable') == '1' )
       
   219             {
       
   220               $score_inp = password_score($newpass);
       
   221               $score_min = intval( getConfig('pw_strength_minimum') );
       
   222               if ( $score_inp < $score_min )
       
   223                 $errors .= '<div class="error-box" style="margin: 0 0 10px 0;">Your password did not meet the complexity score requirement for this site. Your password scored '. $score_inp .', while a score of at least '. $score_min .' is needed.</div>';
       
   224             }
   218             // Encrypt new password
   225             // Encrypt new password
   219             if ( empty($errors) )
   226             if ( empty($errors) )
   220             {
   227             {
   221               $newpass_enc = $aes->encrypt($newpass, $session->private_key, ENC_HEX);
   228               $newpass_enc = $aes->encrypt($newpass, $session->private_key, ENC_HEX);
   222               // Perform the swap
   229               // Perform the swap
   302             <p>If you have not already done so, you are encouraged to make a $user_page and tell the other members of this site a little about yourself.</p>
   309             <p>If you have not already done so, you are encouraged to make a $user_page and tell the other members of this site a little about yourself.</p>
   303             <p>Use the menu at the top to navigate around. If you have any questions, you may contact the $site_admin.";
   310             <p>Use the menu at the top to navigate around. If you have any questions, you may contact the $site_admin.";
   304       break;
   311       break;
   305     case 'EmailPassword':
   312     case 'EmailPassword':
   306       
   313       
       
   314       $errors = trim($errors);
       
   315       if ( !empty($errors) )
       
   316       {
       
   317         echo $errors;
       
   318       }
       
   319       
   307       echo '<form action="' . makeUrlNS('Special', 'Preferences/EmailPassword') . '" method="post" onsubmit="return runEncryption();" name="empwform" >';
   320       echo '<form action="' . makeUrlNS('Special', 'Preferences/EmailPassword') . '" method="post" onsubmit="return runEncryption();" name="empwform" >';
   308       
   321       
   309       // Password change form
   322       // Password change form
   310       $pubkey = $session->rijndael_genkey();
   323       $pubkey = $session->rijndael_genkey();
   311       
   324       
   312       echo '<fieldset>
   325       echo '<fieldset>
   313         <legend>Change password</legend>
   326         <legend>Change password</legend>
   314         Type a new password:<br />
   327         Type a new password:<br />
   315           <input type="password" name="newpass" size="30" tabindex="1" />
   328           <input type="password" name="newpass" size="30" tabindex="1" ' . ( getConfig('pw_strength_enable') == '1' ? 'onkeyup="password_score_field(this);" ' : '' ) . '/>' . ( getConfig('pw_strength_enable') == '1' ? '<span class="password-checker" style="font-weight: bold; color: #aaaaaa;"> Loading...</span>' : '' ) . '
   316         <br />
   329         <br />
   317         <br />
   330         <br />
   318         Type the password again to confirm:<br />
   331         Type the password again to confirm:<br />
   319           <input type="password" name="newpass_conf" size="30" tabindex="2" />
   332         <input type="password" name="newpass_conf" size="30" tabindex="2" />
       
   333         ' . ( getConfig('pw_strength_enable') == '1' ? '<br /><br /><div id="pwmeter"></div>
       
   334         <small>Your password needs to score at least <b>'.getConfig('pw_strength_minimum').'</b> in order to be accepted.</small>' : '' ) . '
   320       </fieldset><br />
   335       </fieldset><br />
   321       <fieldset>
   336       <fieldset>
   322         <legend>Change e-mail address</legend>
   337         <legend>Change e-mail address</legend>
   323         New e-mail address:<br />
   338         New e-mail address:<br />
   324           <input type="text" name="newemail" size="30" tabindex="3" />
   339           <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail" size="30" tabindex="3" />
   325         <br />
   340         <br />
   326         <br />
   341         <br />
   327         Confirm e-mail address:<br />
   342         Confirm e-mail address:<br />
   328           <input type="text" name="newemail_conf" size="30" tabindex="4" />
   343           <input type="text" value="' . ( isset($_POST['newemail']) ? htmlspecialchars($_POST['newemail']) : '' ) . '" name="newemail_conf" size="30" tabindex="4" />
   329       </fieldset>
   344       </fieldset>
   330       <input type="hidden" name="use_crypt" value="no" />
   345       <input type="hidden" name="use_crypt" value="no" />
   331       <input type="hidden" name="crypt_key" value="' . $pubkey . '" />
   346       <input type="hidden" name="crypt_key" value="' . $pubkey . '" />
   332       <input type="hidden" name="crypt_data" value="" />
   347       <input type="hidden" name="crypt_data" value="" />
   333       <br />
   348       <br />
   336       echo '</form>';
   351       echo '</form>';
   337       
   352       
   338       // ENCRYPTION CODE
   353       // ENCRYPTION CODE
   339       ?>
   354       ?>
   340       <script type="text/javascript">
   355       <script type="text/javascript">
       
   356       <?php if ( getConfig('pw_strength_enable') == '1' ): ?>
       
   357       password_score_field(document.forms.empwform.newpass);
       
   358       <?php endif; ?>
   341         disableJSONExts();
   359         disableJSONExts();
   342         str = '';
   360         str = '';
   343         for(i=0;i<keySizeInBits/4;i++) str+='0';
   361         for(i=0;i<keySizeInBits/4;i++) str+='0';
   344         var key = hexToByteArray(str);
   362         var key = hexToByteArray(str);
   345         var pt = hexToByteArray(str);
   363         var pt = hexToByteArray(str);