]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Administration/PasswordManager.php
Release 6.5.12
[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-2013 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         if (isset($_REQUEST['ldap_group_attr_req_dn']) && $_REQUEST['ldap_group_attr_req_dn'] == 'on')
109             $_POST['ldap_group_attr_req_dn'] = 1;
110         else
111             $_POST['ldap_group_attr_req_dn'] = 0;
112
113                 if (isset($_REQUEST['ldap_group_checkbox']) && $_REQUEST['ldap_group_checkbox'] == 'on') 
114                         $_POST['ldap_group'] = 1;
115                 else
116                         $_POST['ldap_group'] = 0;
117                         
118                 if (isset($_REQUEST['ldap_authentication_checkbox']) && $_REQUEST['ldap_authentication_checkbox'] == 'on') 
119                         $_POST['ldap_authentication'] = 1;
120                 else
121                     $_POST['ldap_authentication'] = 0;
122                 
123                 if( isset($_REQUEST['passwordsetting_lockoutexpirationtime']) && is_numeric($_REQUEST['passwordsetting_lockoutexpirationtime'])  )
124                     $_POST['passwordsetting_lockoutexpiration'] = 2;
125
126                 $configurator->saveConfig();
127                 
128                 $focus->saveConfig();
129                 
130                 header('Location: index.php?module=Administration&action=index');
131         }
132 }
133
134 $focus->retrieveSettings();
135
136
137 require_once('include/SugarLogger/SugarLogger.php');
138 $sugar_smarty = new Sugar_Smarty();
139
140 // if no IMAP libraries available, disable Save/Test Settings
141 if(!function_exists('imap_open')) $sugar_smarty->assign('IE_DISABLED', 'DISABLED');
142
143 $config_strings=return_module_language($GLOBALS['current_language'],'Configurator');
144 $sugar_smarty->assign('CONF', $config_strings);
145 $sugar_smarty->assign('MOD', $mod_strings);
146 $sugar_smarty->assign('APP', $app_strings);
147 $sugar_smarty->assign('APP_LIST', $app_list_strings);
148 $sugar_smarty->assign('config', $configurator->config);
149 $sugar_smarty->assign('error', $configurator->errors);
150 $sugar_smarty->assign('LANGUAGES', get_languages());
151 $sugar_smarty->assign("settings", $focus->settings);
152
153 $sugar_smarty->assign('saml_enabled_checked', false);
154
155 //echo "sugar_config[authenticationClass]: " . $sugar_config['authenticationClass'];
156 //if (array_key_exists('authenticationClass', $sugar_config) && $sugar_config['authenticationClass'] == 'SAMLAuthenticate') {
157 //   $sugar_smarty->assign('saml_enabled_checked', true);       
158 //} else {
159 //      $sugar_smarty->assign('saml_enabled_checked', false);
160 //}
161
162
163 if(!function_exists('mcrypt_cbc')){
164         $sugar_smarty->assign("LDAP_ENC_KEY_READONLY", 'readonly');
165         $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LDAP_ENC_KEY_NO_FUNC_DESC']);
166 }else{
167         $sugar_smarty->assign("LDAP_ENC_KEY_DESC", $config_strings['LBL_LDAP_ENC_KEY_DESC']);
168 }
169 $sugar_smarty->assign("settings", $focus->settings);
170
171 if ($valid_public_key){
172         if(!empty($focus->settings['captcha_on'])){
173                 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
174         }else{
175                 $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'none');
176         }
177 }else{
178         $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
179 }
180
181 $sugar_smarty->assign("VALID_PUBLIC_KEY", $valid_public_key);
182
183         
184
185 $res=$GLOBALS['sugar_config']['passwordsetting'];
186
187
188 require_once('include/SugarPHPMailer.php');   
189 $mail = new SugarPHPMailer();
190 $mail->setMailerForSystem();
191 if($mail->Mailer == 'smtp' && $mail->Host ==''){
192         $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '1');
193         }
194 else
195         $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '0');
196         
197 $focus = new InboundEmail();
198 $focus->checkImap();
199 $storedOptions = unserialize(base64_decode($focus->stored_options));    
200 $email_templates_arr = get_bean_select_array(true, 'EmailTemplate','name', '','name',true);
201 $create_case_email_template = (isset($storedOptions['create_case_email_template'])) ? $storedOptions['create_case_email_template'] : "";
202 $TMPL_DRPDWN_LOST =get_select_options_with_id($email_templates_arr, $res['lostpasswordtmpl']); 
203 $TMPL_DRPDWN_GENERATE =get_select_options_with_id($email_templates_arr, $res['generatepasswordtmpl']);
204
205 $sugar_smarty->assign("TMPL_DRPDWN_LOST", $TMPL_DRPDWN_LOST);
206 $sugar_smarty->assign("TMPL_DRPDWN_GENERATE", $TMPL_DRPDWN_GENERATE);
207
208 $sugar_smarty->display('modules/Administration/PasswordManager.tpl');
209 ?>