source: trunk/preferences/templates/default/changepassword_default.php @ 2638

Revision 2638, 3.9 KB checked in by rafaelraymundo, 14 years ago (diff)

Ticket #1053 - Alterado o changepassword_default.php para não exibir header/navbar.

Line 
1<?php
2
3        /***************************************************************************
4        * Expresso Livre                                                           *
5        * http://www.expressolivre.org                                             *
6        * --------------------------------------------                             *
7        *  This program is free software; you can redistribute it and/or modify it *
8        *  under the terms of the GNU General Public License as published by the   *
9        *  Free Software Foundation; either version 2 of the License, or (at your  *
10        *  option) any later version.                                              *
11        \**************************************************************************/
12
13                // Default number of letters = 3
14                if (!$GLOBALS['phpgw_info']['server']['num_letters_userpass'])
15                        $GLOBALS['phpgw_info']['server']['num_letters_userpass'] = 3;
16                // Default number of special letters = 0
17                if (!$GLOBALS['phpgw_info']['server']['num_special_letters_userpass'])
18                        $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'] = 0;
19                if (! $GLOBALS['phpgw']->auth->authenticate($GLOBALS['phpgw_info']['user']['account_lid'], $a_passwd))
20                {
21                        $errors[] = lang('Your actual password is wrong');
22                }
23                else if ($n_passwd != $n_passwd_2)
24                {
25                        $errors[] = lang('The two passwords are not the same');
26                }
27                else if ($a_passwd == $n_passwd)
28                {
29                        $errors[] = lang('Your old password and your new password are the same. Choose a different new password');
30                }
31                else if (! $n_passwd)
32                {
33                        $errors[] = lang('You must enter a password');
34                }
35                else if ( strlen( $n_passwd ) < $GLOBALS['phpgw_info']['server']['num_letters_userpass'] )
36                {
37                        $errors[] = lang('Your password must contain %1 or more letters', $GLOBALS['phpgw_info']['server']['num_letters_userpass']);
38                }
39
40                // Special Letters
41                $speccial_letter = 0;
42                for ($i=0; $i<strlen($n_passwd); $i++)
43                {
44                        $letter = $n_passwd[$i];
45                        if (! ereg ("[a-zA-Z]", $letter ) )
46                                $speccial_letter++;
47                }
48                if ($speccial_letter < $GLOBALS['phpgw_info']['server']['num_special_letters_userpass'])
49                {
50                        $errors[] = lang('Your password must contain at least %1 numbers or characters special', $GLOBALS['phpgw_info']['server']['num_special_letters_userpass']);
51                }
52
53                if(is_array($errors))
54                {
55                        $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
56                        $GLOBALS['phpgw']->template->pfp('out','form');
57                        $GLOBALS['phpgw']->common->phpgw_exit(True);
58                }
59
60                $o_passwd = $GLOBALS['phpgw_info']['user']['passwd'];
61                $passwd_changed = $GLOBALS['phpgw']->auth->change_password($o_passwd, $n_passwd);
62                if(!$passwd_changed)
63                {
64                        $errors[] = lang('Failed to change password') . ". " . lang('Please contact your administrator') . '.';
65                        $GLOBALS['phpgw']->template->set_var('messages',$GLOBALS['phpgw']->common->error_list($errors));
66                        $GLOBALS['phpgw']->template->pfp('out','form');
67                        $GLOBALS['phpgw']->common->phpgw_exit(True);
68                }
69                else
70                {
71                        $GLOBALS['phpgw_info']['user']['passwd'] = $passwd_changed;
72                        $GLOBALS['hook_values']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id'];
73                        $GLOBALS['hook_values']['old_passwd'] = $o_passwd;
74                        $GLOBALS['hook_values']['new_passwd'] = $n_passwd;
75                        $GLOBALS['phpgw']->hooks->process('changepassword');
76
77                        if($GLOBALS['phpgw_info']['server']['certificado'])
78                        {
79                        if(!$GLOBALS['phpgw_info']['server']['atributousuarios'] or $GLOBALS['phpgw_info']['server']['atributousuarios'] == "person")
80                                {
81                                        $RR = grava_senha_criptografada_com_certificado_no_ldap($GLOBALS['phpgw_info']['user']['account_id'],$n_passwd);
82                                }
83                        }
84
85                        if ($GLOBALS['phpgw_info']['server']['use_https'] == 1)
86                                Header('Location: http://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . '/preferences/index.php');
87                        else
88                                $GLOBALS['phpgw']->redirect_link('/preferences/index.php','cd=18');
89                }
90
91?>
Note: See TracBrowser for help on using the repository browser.