Changeset 35 for trunk/preferences


Ignore:
Timestamp:
06/29/07 15:18:40 (17 years ago)
Author:
niltonneto
Message:

Melhoria na segurança, na parte de alteração de senha.

Location:
trunk/preferences
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/preferences/changepassword.php

    r32 r35  
    2626        if(!$GLOBALS['phpgw']->acl->check('changepassword', 1) || $_POST['cancel']) 
    2727        { 
    28                 $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); 
     28                if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) 
     29                        Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); 
     30                else 
     31                        $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); 
     32                 
    2933                $GLOBALS['phpgw']->common->phpgw_exit(); 
    3034        } 
     
    4852        if ($_POST['change']) 
    4953        { 
    50                 if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd)) 
    51                 { 
    52                         $errors[] = lang('Your actual password is wrong'); 
    53                 } 
    54  
    55                 if ($n_passwd != $n_passwd_2) 
    56                 { 
    57                         $errors[] = lang('The two passwords are not the same'); 
    58                 } 
    59  
    60                 if (! $n_passwd) 
    61                 { 
    62                         $errors[] = lang('You must enter a password'); 
    63                 } 
    64                  
    6554                // Default number of letters = 3 
    6655                if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass']) 
     
    6958                if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) 
    7059                        $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0; 
    71  
    72                 if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] ) 
     60                if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd)) 
    7361                { 
    74                         $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']); 
     62                        $errors[] = lang('Your actual password is wrong'); 
    7563                } 
    76                  
     64                else if ($n_passwd != $n_passwd_2) 
     65                { 
     66                        $errors[] = lang('The two passwords are not the same'); 
     67                } 
     68                else if (! $n_passwd) 
     69                { 
     70                        $errors[] = lang('You must enter a password'); 
     71                } 
     72                else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] ) 
     73                { 
     74                        $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']);                     
     75                }                
    7776                # password that start with a-Z or 0-9 and contain _.-!@#$%&*+=| will be accepted. 
    78                 if (! ereg ("^([-a-zA-Z0-9_.\-!@#$%&*+=|])*$", $n_passwd ) ) 
    79                 { 
     77                else if (! ereg ("(^[a-zA-Z0-9_.\-\!@#$%&*+=|]*)$", $n_passwd ) ) 
     78                {                        
    8079                        $errors[] = lang('Your password contains characters not allowed'); 
    81                 } 
    82                  
     80                }                
    8381                # password must contain 2 special letters, numbers or special characters 
    84                 if (! ereg ("([0-9_.\-!@#$%&*+=|]){".$GLOBALS['phpgw_info']['server']['num_special_letters_userpass'].",}", $n_passwd ) ) 
     82                else if ($GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] && ! ereg ("([0-9_.\-!@#$%&*+=|]){".$GLOBALS['phpgw_info']['server']['num_special_letters_userpass'].",}", $n_passwd ) ) 
    8583                { 
    8684                        $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']); 
     
    114112                        $GLOBALS['hook_values']['new_passwd'] = $n_passwd; 
    115113                        $GLOBALS['phpgw']->hooks->process('changepassword'); 
    116                         $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); 
     114                         
     115                        if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) 
     116                                Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); 
     117                        else 
     118                                $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); 
    117119                } 
    118120        } 
  • trunk/preferences/index.php

    r2 r35  
    132132                while(list($text,$url) = each($file)) 
    133133                { 
     134                        if (($text == 'Change your Password') && ($GLOBALS['phpgw_info']['server']['use_https'] == 1)) 
     135                        { 
     136                                $url = 'https://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/changepassword.php'; 
     137                        } 
    134138                        section_item($url,lang($text)); 
    135139                } 
Note: See TracChangeset for help on using the changeset viewer.