Changeset 35


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
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/login.php

    r25 r35  
    273273                        // the users browser accepts. 
    274274                        list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']); 
     275                        /* 
    275276                        if(strlen($lang) > 2) 
    276277                        { 
    277278                                $lang = substr($lang,0,2); 
    278279                        } 
     280                        */ 
    279281                        $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang; 
    280282                } 
  • trunk/phpgwapi/inc/class.sector_search_ldap.inc.php

    r31 r35  
    139139                                array_pop ( $array_dn_reverse ); 
    140140 
    141                                 $inverted_dn[$dn] = implode ( ";", $array_dn_reverse ); 
     141                                $inverted_dn[$dn] = implode ( "#", $array_dn_reverse ); 
    142142                        } 
    143143 
     
    151151                $display = ''; 
    152152 
    153                 $array_dn_reverse = explode ( ";", $invert_ufn ); 
     153                $array_dn_reverse = explode ( "#", $invert_ufn ); 
    154154                $array_dn  = array_reverse ( $array_dn_reverse, true ); 
    155155 
     
    158158                if ($level == 0) 
    159159                        $display .= '+'; 
    160                 else { 
    161                         for ($i=0; $i<$level; $i++) 
    162                                 $display .= '---'; 
     160                else  
     161                { 
     162                                        for ($i=0; $i<$level; $i++) 
     163                                                $display .= '---'; 
    163164                } 
    164165 
     
    181182            return $options; 
    182183                } 
     184                 
     185                // Retorna os setores (somente OUs de primeiro nivel) com as options prontas 
     186                function get_sectors($selected='', $referral=false ,$show_invisible_ou=false) 
     187                { 
     188                        $dn                     = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 
     189                        $passwd         = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 
     190                        $context        = $GLOBALS['phpgw_info']['server']['ldap_context']; 
     191                        $ldap_conn      = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 
     192                         
     193                        ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 
     194                         
     195                        if ($referral) 
     196                                ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 1); 
     197                        else 
     198                                ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 
     199                         
     200                        ldap_bind($ldap_conn,$dn,$passwd); 
     201                         
     202                        $justthese = array("dn", "ou"); 
     203                        $filter = $show_invisible_ou ? "(ou=*)" : "(&(ou=*)(!(phpgwAccountVisible=-1)))"; 
     204                         
     205                        $search=ldap_list($ldap_conn, $context, $filter, $justthese); 
     206                 
     207                ldap_sort($ldap_conn, $search, "ou"); 
     208                $info = ldap_get_entries($ldap_conn, $search); 
     209                 
     210                        ldap_close($ldap_conn); 
     211                $options = ''; 
     212                for ($i=0; $i<$info["count"]; $i++) 
     213            { 
     214                $dn = trim(strtolower($info[$i]['dn'])); 
     215                                if ( $dn == $selected ) 
     216                                        $select = ' selected'; 
     217                                else 
     218                                        $select = ''; 
     219                                $display = strtoupper($info[$i]['ou'][0]); 
     220                                $options .= "<option value='$dn'$select>$display </option>"; 
     221            } 
     222                 
     223                        return $options; 
     224                } 
    183225        } 
    184226?> 
  • 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.