]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Administration/PasswordManager.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Administration / PasswordManager.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description: TODO:  To be written.
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46
47 if(!is_admin($current_user)){
48     sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
49 }
50 function clearPasswordSettings() {
51             $_POST['passwordsetting_SystemGeneratedPasswordON'] = '';
52             $_POST['passwordsetting_generatepasswordtmpl'] = '';
53             $_POST['passwordsetting_lostpasswordtmpl'] = '';
54             $_POST['passwordsetting_forgotpasswordON'] = '0';
55             $_POST['passwordsetting_linkexpiration'] = '1';
56             $_POST['passwordsetting_linkexpirationtime'] = '30';
57             $_POST['passwordsetting_linkexpirationtype'] = '1';
58             $_POST['passwordsetting_systexpiration'] = '0';
59             $_POST['passwordsetting_systexpirationtime'] = '';
60             $_POST['passwordsetting_systexpirationtype'] = '0';
61             $_POST['passwordsetting_systexpirationlogin'] = '';
62
63 }
64 require_once('modules/Administration/Forms.php');
65 echo get_module_title(
66                 $mod_strings['LBL_MODULE_NAME'], 
67                 $mod_strings['LBL_MANAGE_PASSWORD_TITLE'], 
68                 true
69                 );
70 require_once('modules/Configurator/Configurator.php');
71 $configurator = new Configurator();
72 $sugarConfig = SugarConfig::getInstance();
73 $focus = new Administration();
74 $configurator->parseLoggerSettings();
75 $valid_public_key= true;
76 if(!empty($_POST['saveConfig'])){
77     if ($_POST['captcha_on'] == '1'){
78                 $handle = @fopen("http://api.recaptcha.net/challenge?k=".$_POST['captcha_public_key']."&cachestop=35235354", "r");
79                 $buffer ='';
80                 if ($handle) {
81                     while (!feof($handle)) {
82                         $buffer .= fgets($handle, 4096);
83                     }
84                     fclose($handle);
85                 }
86                 $valid_public_key= substr($buffer, 1, 4) == 'var '? true : false;
87         }
88         if ($valid_public_key){
89                 if (isset($_REQUEST['system_ldap_enabled']) && $_REQUEST['system_ldap_enabled'] == 'on') {
90                         $_POST['system_ldap_enabled'] = 1;
91                         clearPasswordSettings();
92                 } 
93                 else 
94                         $_POST['system_ldap_enabled'] = 0;
95
96                         
97            
98                 if (isset($_REQUEST['authenticationClass'])) {
99                         
100                         $configurator->useAuthenticationClass = true;
101                 }
102           
103
104                 if (isset($_REQUEST['ldap_group_checkbox']) && $_REQUEST['ldap_group_checkbox'] == 'on') 
105                         $_POST['ldap_group'] = 1;
106                 else
107                         $_POST['ldap_group'] = 0;
108                         
109                 if (isset($_REQUEST['ldap_authentication_checkbox']) && $_REQUEST['ldap_authentication_checkbox'] == 'on') 
110                         $_POST['ldap_authentication'] = 1;
111                 else
112                     $_POST['ldap_authentication'] = 0;
113                 
114                 if( isset($_REQUEST['passwordsetting_lockoutexpirationtime']) && is_numeric($_REQUEST['passwordsetting_lockoutexpirationtime'])  )
115                     $_POST['passwordsetting_lockoutexpiration'] = 2;
116
117                 $configurator->saveConfig();
118                 
119                 $focus->saveConfig();
120                 
121                 header('Location: index.php?module=Administration&action=index');
122         }
123 }
124
125 $focus->retrieveSettings();
126
127
128 require_once('include/SugarLogger/SugarLogger.php');
129 $sugar_smarty = new Sugar_Smarty();
130
131 // if no IMAP libraries available, disable Save/Test Settings
132 if(!function_exists('imap_open')) $sugar_smarty->assign('IE_DISABLED', 'DISABLED');
133
134 $config_strings=return_module_language($GLOBALS['current_language'],'Configurator');
135 $sugar_smarty->assign('CONF', $config_strings);
136 $sugar_smarty->assign('MOD', $mod_strings);
137 $sugar_smarty->assign('APP', $app_strings);
138 $sugar_smarty->assign('APP_LIST', $app_list_strings);
139 $sugar_smarty->assign('config', $configurator->config);
140 $sugar_smarty->assign('error', $configurator->errors);
141 $sugar_smarty->assign('LANGUAGES', get_languages());
142 $sugar_smarty->assign("settings", $focus->settings);
143
144 $sugar_smarty->assign('saml_enabled_checked', false);
145
146 //echo "sugar_config[authenticationClass]: " . $sugar_config['authenticationClass'];
147 //if (array_key_exists('authenticationClass', $sugar_config) && $sugar_config['authenticationClass'] == 'SAMLAuthenticate') {
148 //   $sugar_smarty->assign('saml_enabled_checked', true);       
149 //} else {
150 //      $sugar_smarty->assign('saml_enabled_checked', false);
151 //}
152
153
154 if(!function_exists('mcrypt_cbc')){
155         $sugar_smarty->assign("LDAP_ENC_KEY_READONLY", 'readonly');
156         $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LDAP_ENC_KEY_NO_FUNC_DESC']);
157 }else{
158         $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LBL_LDAP_ENC_KEY_DESC']);
159 }
160 $sugar_smarty->assign("settings", $focus->settings);
161
162 if ($valid_public_key){
163         if(!empty($focus->settings['captcha_on'])){
164                 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
165         }else{
166                 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'none');
167         }
168 }else{
169         $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
170 }
171
172 $sugar_smarty->assign("VALID_PUBLIC_KEY", $valid_public_key);
173
174         
175
176 $res=$GLOBALS['sugar_config']['passwordsetting'];
177
178
179 require_once('include/SugarPHPMailer.php');   
180 $mail = new SugarPHPMailer();
181 $mail->setMailerForSystem();
182 if($mail->Mailer == 'smtp' && $mail->Host ==''){
183         $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '1');
184         }
185 else
186         $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '0');
187         
188 $focus = new InboundEmail();
189 $focus->checkImap();
190 $storedOptions = unserialize(base64_decode($focus->stored_options));    
191 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name', '','name',true);
192 $create_case_email_template = (isset($storedOptions['create_case_email_template'])) ? $storedOptions['create_case_email_template'] : "";
193 $TMPL_DRPDWN_LOST =get_select_options_with_id($email_templates_arr, $res['lostpasswordtmpl']); 
194 $TMPL_DRPDWN_GENERATE =get_select_options_with_id($email_templates_arr, $res['generatepasswordtmpl']);
195
196 $sugar_smarty->assign("TMPL_DRPDWN_LOST", $TMPL_DRPDWN_LOST);
197 $sugar_smarty->assign("TMPL_DRPDWN_GENERATE", $TMPL_DRPDWN_GENERATE);
198
199 $sugar_smarty->display('modules/Administration/PasswordManager.tpl');
200 ?>