]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Administration/PasswordManager.php
Release 6.4.0
[Github/sugarcrm.git] / modules / Administration / PasswordManager.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition 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 getClassicModuleTitle(
66         "Administration", 
67         array(
68             "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
69            $mod_strings['LBL_MANAGE_PASSWORD_TITLE'],
70            ), 
71         false
72         );
73 require_once('modules/Configurator/Configurator.php');
74 $configurator = new Configurator();
75 $sugarConfig = SugarConfig::getInstance();
76 $focus = new Administration();
77 $configurator->parseLoggerSettings();
78 $valid_public_key= true;
79 if(!empty($_POST['saveConfig'])){
80     if ($_POST['captcha_on'] == '1'){
81                 $handle = @fopen("http://api.recaptcha.net/challenge?k=".$_POST['captcha_public_key']."&cachestop=35235354", "r");
82                 $buffer ='';
83                 if ($handle) {
84                     while (!feof($handle)) {
85                         $buffer .= fgets($handle, 4096);
86                     }
87                     fclose($handle);
88                 }
89                 $valid_public_key= substr($buffer, 1, 4) == 'var '? true : false;
90         }
91         if ($valid_public_key){
92                 if (isset($_REQUEST['system_ldap_enabled']) && $_REQUEST['system_ldap_enabled'] == 'on') {
93                         $_POST['system_ldap_enabled'] = 1;
94                         clearPasswordSettings();
95                 } 
96                 else 
97                         $_POST['system_ldap_enabled'] = 0;
98
99
100         if(isset($_REQUEST['authenticationClass']))
101         {
102                 $configurator->useAuthenticationClass = true;
103         } else {
104                 $configurator->useAuthenticationClass = false;
105             $_POST['authenticationClass'] = '';
106         }
107
108
109                 if (isset($_REQUEST['ldap_group_checkbox']) && $_REQUEST['ldap_group_checkbox'] == 'on') 
110                         $_POST['ldap_group'] = 1;
111                 else
112                         $_POST['ldap_group'] = 0;
113                         
114                 if (isset($_REQUEST['ldap_authentication_checkbox']) && $_REQUEST['ldap_authentication_checkbox'] == 'on') 
115                         $_POST['ldap_authentication'] = 1;
116                 else
117                     $_POST['ldap_authentication'] = 0;
118                 
119                 if( isset($_REQUEST['passwordsetting_lockoutexpirationtime']) && is_numeric($_REQUEST['passwordsetting_lockoutexpirationtime'])  )
120                     $_POST['passwordsetting_lockoutexpiration'] = 2;
121
122                 $configurator->saveConfig();
123                 
124                 $focus->saveConfig();
125                 
126                 header('Location: index.php?module=Administration&action=index');
127         }
128 }
129
130 $focus->retrieveSettings();
131
132
133 require_once('include/SugarLogger/SugarLogger.php');
134 $sugar_smarty = new Sugar_Smarty();
135
136 // if no IMAP libraries available, disable Save/Test Settings
137 if(!function_exists('imap_open')) $sugar_smarty->assign('IE_DISABLED', 'DISABLED');
138
139 $config_strings=return_module_language($GLOBALS['current_language'],'Configurator');
140 $sugar_smarty->assign('CONF', $config_strings);
141 $sugar_smarty->assign('MOD', $mod_strings);
142 $sugar_smarty->assign('APP', $app_strings);
143 $sugar_smarty->assign('APP_LIST', $app_list_strings);
144 $sugar_smarty->assign('config', $configurator->config);
145 $sugar_smarty->assign('error', $configurator->errors);
146 $sugar_smarty->assign('LANGUAGES', get_languages());
147 $sugar_smarty->assign("settings", $focus->settings);
148
149 $sugar_smarty->assign('saml_enabled_checked', false);
150
151 //echo "sugar_config[authenticationClass]: " . $sugar_config['authenticationClass'];
152 //if (array_key_exists('authenticationClass', $sugar_config) && $sugar_config['authenticationClass'] == 'SAMLAuthenticate') {
153 //   $sugar_smarty->assign('saml_enabled_checked', true);       
154 //} else {
155 //      $sugar_smarty->assign('saml_enabled_checked', false);
156 //}
157
158
159 if(!function_exists('mcrypt_cbc')){
160         $sugar_smarty->assign("LDAP_ENC_KEY_READONLY", 'readonly');
161         $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LDAP_ENC_KEY_NO_FUNC_DESC']);
162 }else{
163         $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LBL_LDAP_ENC_KEY_DESC']);
164 }
165 $sugar_smarty->assign("settings", $focus->settings);
166
167 if ($valid_public_key){
168         if(!empty($focus->settings['captcha_on'])){
169                 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
170         }else{
171                 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'none');
172         }
173 }else{
174         $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
175 }
176
177 $sugar_smarty->assign("VALID_PUBLIC_KEY", $valid_public_key);
178
179         
180
181 $res=$GLOBALS['sugar_config']['passwordsetting'];
182
183
184 require_once('include/SugarPHPMailer.php');   
185 $mail = new SugarPHPMailer();
186 $mail->setMailerForSystem();
187 if($mail->Mailer == 'smtp' && $mail->Host ==''){
188         $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '1');
189         }
190 else
191         $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '0');
192         
193 $focus = new InboundEmail();
194 $focus->checkImap();
195 $storedOptions = unserialize(base64_decode($focus->stored_options));    
196 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name', '','name',true);
197 $create_case_email_template = (isset($storedOptions['create_case_email_template'])) ? $storedOptions['create_case_email_template'] : "";
198 $TMPL_DRPDWN_LOST =get_select_options_with_id($email_templates_arr, $res['lostpasswordtmpl']); 
199 $TMPL_DRPDWN_GENERATE =get_select_options_with_id($email_templates_arr, $res['generatepasswordtmpl']);
200
201 $sugar_smarty->assign("TMPL_DRPDWN_LOST", $TMPL_DRPDWN_LOST);
202 $sugar_smarty->assign("TMPL_DRPDWN_GENERATE", $TMPL_DRPDWN_GENERATE);
203
204 $sugar_smarty->display('modules/Administration/PasswordManager.tpl');
205 ?>