Author Topic: [MOD] Password lenght - SOLVED  (Read 5726 times)

0 Members and 1 Guest are viewing this topic.

Offline clubbu

  • Newbie
  • *
  • Posts: 47
    • View Profile
[MOD] Password lenght - SOLVED
« on: August 09, 2011, 01:33:37 PM »
Hello,
I need to set the rule for the composition of the password:

minimum 8 characters
1 numeric character

To set the length of the password so I tried:

I haveif((strlen($password) < 8 || strlen($password) > 15) && $password!='')

setting a minimum length of 8 and a maximum of 15...

Unfortunately does not work

This control should work in register.php and update profile

You can also set the password expiration? (from code or admin panel?

Thanks for all

Paolo.


« Last Edit: August 09, 2011, 03:37:26 PM by clubbu »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Password lenght
« Reply #1 on: August 09, 2011, 02:59:09 PM »
in member.php find:
  if ($current_user_password != $user_info['user_password']) {
    
$msg .= (($msg != "") ? "<br />" "").$lang['update_password_error'];
    
$error 1;
  }


Insert below:
  if (strlen($HTTP_POST_VARS['user_password']) < || !preg_match("#[0-9]#"$HTTP_POST_VARS['user_password']))
  {
    
$msg .= (($msg != "") ? "<br />" "").$lang['update_password_minimum_error'];
    
$error 1;
  }



In register.php find:
    if ($user_password == "") {
      
$msg .= (($msg != "") ? "<br />" "").$field_error preg_replace("/".$site_template->start."field_name".$site_template->end."/siU"str_replace(":"""$lang['password']), $lang['field_required']);
      
$error 1;
    }


Insert below:
    if (strlen($user_password) < || !preg_match("#[0-9]#"$user_password)) {
      
$msg .= (($msg != "") ? "<br />" "").$lang['update_password_minimum_error'];
      
$error 1;
    }



In lang/<your language>/main.php at the end add:
$lang['update_password_minimum_error'] = "Password must be minimum 8 characters long and contain at least one numeric character";


P.S.
Personally I don't understand the reason behind limiting maximum length of a password....I used to have a bank account where password requirement was 6 to 12 characters long...wtf? bank? seriously?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline clubbu

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: Password lenght
« Reply #2 on: August 09, 2011, 03:11:29 PM »
Hello,
thank you for your help.

In Italy there is a specific regulation for the privacy of institutional website.

The Red Cross is part of these.

There are specific laws on password length, composition and encryption.

 :D

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Password lenght
« Reply #3 on: August 09, 2011, 03:18:09 PM »
There are specific laws on password length, composition and encryption.
I just hope there is no law for the maximum length of a password...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.806
  • I ♥ 4I
    • View Profile
Re: Password lenght
« Reply #4 on: August 09, 2011, 03:26:08 PM »
Thank you!!

Offline clubbu

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: Password lenght
« Reply #5 on: August 09, 2011, 03:35:52 PM »
There are specific laws on password length, composition and encryption.
I just hope there is no law for the maximum length of a password...

Ahahah  :D

No no