Changeset 1681


Ignore:
Timestamp:
11/19/09 13:59:58 (14 years ago)
Author:
rafaelraymundo
Message:

Ticket #770 - função em common_functions,inc.php determina include p/templates.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/login.php

    r1152 r1681  
    126126        } 
    127127 
    128 $login_include = $GLOBALS['phpgw_info']['server']['template_dir'] . '/login_' .  $GLOBALS['phpgw_info']['login_template_set'] . '.php'; 
    129  
    130 if(!$login_include || !file_exists($login_include)) 
    131         { 
    132                 $aux = explode('phpgwapi',$GLOBALS['phpgw_info']['server']['template_dir']); 
    133                 $login_include = $aux[0] . 'phpgwapi/templates/default/login_default.php'; 
    134         } 
    135  
    136 include($login_include); 
    137  
     128include(personalize_include_path('phpgwapi','login')); 
    138129?> 
    139130 
  • trunk/phpgwapi/inc/class.auth_ldap.inc.php

    r393 r1681  
    200200                } 
    201201 
     202                function change_password_user ($old_passwd, $new_passwd, $dn, $referrals=false) 
     203                { 
     204                        //Use with RHDS 
     205                        //system('echo "CP old_passwd: '.$old_passwd.'" >>/tmp/controle'); 
     206                        //system('echo "CP new_passwd: '.$new_passwd.'" >>/tmp/controle'); 
     207                        //system('echo "CP dn: '.$dn.'" >>/tmp/controle'); 
     208                        //system('echo "CP referrals: '.$referrals.'" >>/tmp/controle'); 
     209                        $ds=ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 
     210                        if (!$ds) 
     211                                { 
     212                                //system('echo "CP Nao conectou no ldap" >>/tmp/controle'); 
     213                                $this->auth_reason = ldap_errno($ldap); 
     214                                return False; 
     215                                } 
     216                        else 
     217                        { 
     218                                if ($referrals) 
     219                                        { 
     220                                        //system('echo "CP Entrou referrals" >>/tmp/controle'); 
     221                                        $this->passwd=$old_passwd; 
     222                                        $this->dn=$dn; 
     223                                        ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); 
     224                                        ldap_set_option($ds, LDAP_OPT_REFERRALS, 1); 
     225                                        if($GLOBALS['phpgw_info']['server']['diretorioescravo']) 
     226                                                { 
     227                                                ldap_set_rebind_proc($ds, array($this, '_rebindProc')); 
     228                                                } 
     229                                        } 
     230                                $modify["userpassword"]=$new_passwd; 
     231                                if (!@ldap_bind($ds,$dn,$old_passwd)) 
     232                                        { 
     233                                        //system('echo "CP nao conseguiu dar bind" >>/tmp/controle'); 
     234                                        //Se a politica estiver no diretorio eh necessario tentar alterar a senha mesmo que nao haja um bind, pois a negacao de bind pode ser proveniente de uma expiracao 
     235                                        if($GLOBALS['phpgw_info']['server']['politicasenhas']=='diretorio') 
     236                                                { 
     237                                                //system('echo "CP politica eh no diretorio" >>/tmp/controle'); 
     238                                                if (!@ldap_mod_replace($ds,$dn,$modify)) 
     239                                                        { 
     240                                                        //system('echo "CP nao conseguiu fazer replace!" >>/tmp/controle'); 
     241                                                        $this->auth_reason = ldap_errno($ds); 
     242                                                        return false; 
     243                                                        } 
     244                                                        else 
     245                                                        { 
     246                                                        //system('echo "CP replace funcionou!" >>/tmp/controle'); 
     247                                                        return $new_passwd; 
     248                                                        } 
     249                                                } 
     250                                        $this->auth_reason = ldap_errno($ds); 
     251                                        return False; 
     252                                        } 
     253                                        else 
     254                                        { 
     255                                        //system('echo "CP Conseguiu dar bind" >>/tmp/controle'); 
     256                                        if (!ldap_mod_replace($ds,$dn,$modify)) 
     257                                                { 
     258                                                $this->auth_reason = ldap_errno($ds); 
     259                                                return False; 
     260                                                } 
     261                                                else 
     262                                                { 
     263                                                return $new_passwd; 
     264                                                } 
     265                                        } 
     266                        } 
     267                } 
     268 
     269 
    202270                function update_lastlogin($_account_id, $ip) 
    203271                { 
  • trunk/phpgwapi/inc/common_functions.inc.php

    r1321 r1681  
    685685 
    686686        /*! 
     687         @function personalize_include_path 
     688         @abstract return path to include a "ile.php" 
     689         @author Serpro 
     690         @author Antonio Carlos da SIlva 
     691         @discussion This function is used to generate a path with $app and $prefix paramameters. 
     692         @example include(personalize_include_path('phpgwapi','login'); 
     693         @example Will generate : /var/www/expresso/phpgwapi/templates/default/login_default.php 
     694         @example if "default" is the 'login_template_set' . 
     695         @param $app : name of application 
     696         @param $prefix : value to affix in login_template_set 
     697         */ 
     698        function personalize_include_path($app,$prefix) 
     699        { 
     700                $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/' . $GLOBALS['phpgw_info']['login_template_set'] . '/' . $prefix . '_' . $GLOBALS['phpgw_info']['login_template_set'] . '.php'; 
     701                if(!$file_include || !file_exists($file_include)) 
     702                { 
     703                        $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/default/' . $prefix .'_default.php'; 
     704                } 
     705        return $file_include; 
     706        } 
     707 
     708        /*! 
    687709         @function CreateObject 
    688710         @abstract Load a class and include the class file if not done so already. 
  • trunk/preferences/changepassword.php

    r1174 r1681  
    2020        include('../header.inc.php'); 
    2121 
     22/* 
     23function path_template_include($app,$prefix) 
     24    { 
     25        $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/' . $GLOBALS['phpgw_info']['login_template_set'] . '/' . $prefix . '_' . $GLOBALS['phpgw_info']['login_template_set'] . '.php'; 
     26 
     27        if(!$file_include || !file_exists($file_include)) 
     28            { 
     29                $file_include = PHPGW_SERVER_ROOT . '/' . $app . '/templates/default/' . $prefix .'_default.php'; 
     30            } 
     31 
     32        return $file_include; 
     33    } 
     34*/ 
     35 
    2236function grava_senha_criptografada_com_certificado_no_ldap($aux_uid,$aux_senha) 
    23    {     
     37   { 
    2438        require_once('/var/www/expresso/security/classes/CertificadoB.php'); 
    2539        $ldap_context = $GLOBALS['phpgw_info']['server']['ldap_context']; 
     
    2842        $ldap_passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 
    2943 
    30         $cc=ldap_connect($ldap_servidor);  
     44        $cc=ldap_connect($ldap_servidor); 
    3145 
    3246        //  bind .. 
    33         $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd);   
     47        $sr=ldap_bind($cc,$ldap_dn,$ldap_passwd); 
    3448 
    3549        $filtro = 'uidNumber='.$aux_uid; 
    3650 
    3751        // Pesquisa uidNumber no LDAP 
    38         $sr=ldap_search($cc, $ldap_context,$filtro);   
     52        $sr=ldap_search($cc, $ldap_context,$filtro); 
    3953 
    4054        // Pega resultado .... 
    4155        $info = ldap_get_entries($cc, $sr); 
    42            
     56 
    4357        // Tem de achar só uma entrada.....ao menos uma.... 
    4458        if($info["count"]!=1) 
     
    5771        $a = new certificadoB(); 
    5872        $R = $a->encriptar_senha($aux_senha,$info[0]["usercertificate"][0]); 
    59         if(!$R)  
     73        if(!$R) 
    6074            { 
    6175                return false; 
     
    7084        return true; 
    7185   } 
    72  
    7386        $a_passwd   = $_POST['a_passwd']; 
    7487        $n_passwd   = $_POST['n_passwd']; 
     
    7992                if(($GLOBALS['phpgw_info']['user']['lastpasswd_change'] == '0') && (!$_POST['cancel'])) 
    8093                        $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/login.php','cd=6')); 
    81                  
     94 
    8295                if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) 
    8396                        Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); 
    8497                else 
    8598                        $GLOBALS['phpgw']->redirect_link('/preferences/index.php'); 
    86                  
     99 
    87100                $GLOBALS['phpgw']->common->phpgw_exit(); 
    88101        } 
     
    112125 
    113126        if ($_POST['change']) 
    114         { 
    115                 // Default number of letters = 3 
    116                 if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass']) 
    117                         $GLOBALS['phpgw_info']['server']['num_letters_userpass'] = 3; 
    118                 // Default number of special letters = 0 
    119                 if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) 
    120                         $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0; 
    121                 if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd)) 
    122                 { 
    123                         $errors[] = lang('Your actual password is wrong'); 
    124                 } 
    125                 else if ($n_passwd != $n_passwd_2) 
    126                 { 
    127                         $errors[] = lang('The two passwords are not the same'); 
    128                 } 
    129                 else if ($a_passwd == $n_passwd) 
    130                 { 
    131                         $errors[] = lang('Your old password and your new password are the same. Choose a different new password'); 
    132                 } 
    133                 else if (! $n_passwd) 
    134                 { 
    135                         $errors[] = lang('You must enter a password'); 
    136                 } 
    137                 else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] ) 
    138                 { 
    139                         $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']);                     
    140                 } 
    141                  
    142                 // Special Letters 
    143                 $speccial_letter = 0; 
    144                 for ($i=0; $i<strlen($n_passwd); $i++)  
    145                 { 
    146                         $letter = $n_passwd[$i]; 
    147                         if (! ereg ("[a-zA-Z]", $letter ) ) 
    148                                 $speccial_letter++; 
    149                 } 
    150                 if ($speccial_letter < $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']) 
    151                 { 
    152                         $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']); 
    153                 } 
    154                  
    155                 if(is_array($errors)) 
    156                 { 
    157                         $GLOBALS['phpgw']->common->phpgw_header(); 
    158                         echo parse_navbar(); 
    159                         $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); 
    160                         $GLOBALS['phpgw']->template->pfp('out','form'); 
    161                         $GLOBALS['phpgw']->common->phpgw_exit(True); 
    162                 } 
    163  
    164                 $o_passwd = $GLOBALS['phpgw_info']['user']['passwd']; 
    165                 $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); 
    166                 if(!$passwd_changed) 
    167                 { 
    168                         $errors[] = lang('Failed to change password') . ". " . lang('Please contact your administrator') . '.'; 
    169                         $GLOBALS['phpgw']->common->phpgw_header(); 
    170                         echo parse_navbar(); 
    171                         $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors)); 
    172                         $GLOBALS['phpgw']->template->pfp('out','form'); 
    173                         $GLOBALS['phpgw']->common->phpgw_exit(True); 
    174                 } 
    175                 else 
    176                 { 
    177                         $GLOBALS['phpgw_info']['user']['passwd'] = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd); 
    178                         $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id']; 
    179                         $GLOBALS['hook_values']['old_passwd'] = $o_passwd; 
    180                         $GLOBALS['hook_values']['new_passwd'] = $n_passwd; 
    181                         $GLOBALS['phpgw']->hooks->process('changepassword'); 
    182  
    183                         if($GLOBALS['phpgw_info']['server']['certificado']) 
    184                         { 
    185                         if(!$GLOBALS['phpgw_info']['server']['atributousuarios'] or $GLOBALS['phpgw_info']['server']['atributousuarios'] == "person") 
    186                                 { 
    187                                         $RR = grava_senha_criptografada_com_certificado_no_ldap($GLOBALS['phpgw_info']['user']['account_id'],$n_passwd); 
    188                                 } 
    189                         } 
    190                          
    191                         if ($GLOBALS['phpgw_info']['server']['use_https'] == 1) 
    192                                 Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php'); 
    193                         else 
    194                                 $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18'); 
    195                 } 
    196         } 
     127            { 
     128                include(personalize_include_path('preferences','changepassword')); 
     129            } 
    197130        else 
    198131        { 
Note: See TracChangeset for help on using the changeset viewer.