]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/Login.php
Release 6.5.10
[Github/sugarcrm.git] / modules / Users / Login.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 /** @var AuthenticationController $authController */
46 $authController->authController->pre_login();
47
48 global $current_language, $mod_strings, $app_strings;
49 if(isset($_REQUEST['login_language'])){
50     $lang = $_REQUEST['login_language'];
51     $_REQUEST['ck_login_language_20'] = $lang;
52         $current_language = $lang;
53     $_SESSION['authenticated_user_language'] = $lang;
54     $mod_strings = return_module_language($lang, "Users");
55     $app_strings = return_application_language($lang);
56 }
57 $sugar_smarty = new Sugar_Smarty();
58 echo '<link rel="stylesheet" type="text/css" media="all" href="'.getJSPath('modules/Users/login.css').'">';
59 echo '<script type="text/javascript" src="'.getJSPath('modules/Users/login.js').'"></script>';
60 global $app_language, $sugar_config;
61 //we don't want the parent module's string file, but rather the string file specifc to this subpanel
62 global $current_language;
63
64 // Get the login page image
65 if ( sugar_is_file('custom/include/images/sugar_md.png') ) {
66     $login_image = '<IMG src="custom/include/images/sugar_md.png" alt="Sugar" width="340" height="25">';
67 }
68 else {
69     $login_image = '<IMG src="include/images/sugar_md_open.png" alt="Sugar" width="340" height="25" style="margin: 5px 0;">';
70 }
71 $sugar_smarty->assign('LOGIN_IMAGE',$login_image);
72
73 // See if any messages were passed along to display to the user.
74 if(isset($_COOKIE['loginErrorMessage'])) {
75     if ( !isset($_REQUEST['loginErrorMessage']) ) {
76         $_REQUEST['loginErrorMessage'] = $_COOKIE['loginErrorMessage'];
77     }
78     SugarApplication::setCookie('loginErrorMessage', '', time()-42000, '/');
79 }
80 if(isset($_REQUEST['loginErrorMessage'])) {
81     if (isset($mod_strings[$_REQUEST['loginErrorMessage']])) {
82         echo "<p align='center' class='error' > ". $mod_strings[$_REQUEST['loginErrorMessage']]. "</p>";
83     } else if (isset($app_strings[$_REQUEST['loginErrorMessage']])) {
84         echo "<p align='center' class='error' > ". $app_strings[$_REQUEST['loginErrorMessage']]. "</p>";
85     }
86 }
87
88 $lvars = $GLOBALS['app']->getLoginVars();
89 $sugar_smarty->assign("LOGIN_VARS", $lvars);
90 foreach($lvars as $k => $v) {
91     $sugar_smarty->assign(strtoupper($k), $v);
92 }
93
94 // Retrieve username from the session if possible.
95 if(isset($_SESSION["login_user_name"])) {
96         if (isset($_REQUEST['default_user_name']))
97                 $login_user_name = $_REQUEST['default_user_name'];
98         else
99                 $login_user_name = $_SESSION['login_user_name'];
100 } else {
101         if(isset($_REQUEST['default_user_name'])) {
102                 $login_user_name = $_REQUEST['default_user_name'];
103         } elseif(isset($_REQUEST['ck_login_id_20'])) {
104                 $login_user_name = get_user_name($_REQUEST['ck_login_id_20']);
105         } else {
106                 $login_user_name = $sugar_config['default_user_name'];
107         }
108         $_SESSION['login_user_name'] = $login_user_name;
109 }
110 $sugar_smarty->assign('LOGIN_USER_NAME', $login_user_name);
111
112 $mod_strings['VLD_ERROR'] = $GLOBALS['app_strings']["\x4c\x4f\x47\x49\x4e\x5f\x4c\x4f\x47\x4f\x5f\x45\x52\x52\x4f\x52"];
113
114 // Retrieve password from the session if possible.
115 if(isset($_SESSION["login_password"])) {
116         $login_password = $_SESSION['login_password'];
117 } else {
118         $login_password = $sugar_config['default_password'];
119         $_SESSION['login_password'] = $login_password;
120 }
121 $sugar_smarty->assign('LOGIN_PASSWORD', $login_password);
122
123 if(isset($_SESSION["login_error"])) {
124         $sugar_smarty->assign('LOGIN_ERROR', $_SESSION['login_error']);
125 }
126 if(isset($_SESSION["waiting_error"])) {
127     $sugar_smarty->assign('WAITING_ERROR', $_SESSION['waiting_error']);
128 }
129
130 if (isset($_REQUEST['ck_login_language_20'])) {
131         $display_language = $_REQUEST['ck_login_language_20'];
132 } else {
133         $display_language = $sugar_config['default_language'];
134 }
135
136 if (empty($GLOBALS['sugar_config']['passwordsetting']['forgotpasswordON']))
137         $sugar_smarty->assign('DISPLAY_FORGOT_PASSWORD_FEATURE','none');
138
139 $the_languages = get_languages();
140 if ( count($the_languages) > 1 )
141     $sugar_smarty->assign('SELECT_LANGUAGE', get_select_options_with_id($the_languages, $display_language));
142 $the_themes = SugarThemeRegistry::availableThemes();
143 if ( !empty($logindisplay) )
144         $sugar_smarty->assign('LOGIN_DISPLAY', $logindisplay);;
145
146 // RECAPTCHA
147
148         $admin = new Administration();
149         $admin->retrieveSettings('captcha');
150         $captcha_privatekey = "";
151         $captcha_publickey="";
152         $captcha_js = "";
153         $Captcha='';
154
155         // if the admin set the captcha stuff, assign javascript and div
156         if(isset($admin->settings['captcha_on'])&& $admin->settings['captcha_on']=='1' && !empty($admin->settings['captcha_private_key']) && !empty($admin->settings['captcha_public_key'])){
157
158                         $captcha_privatekey = $admin->settings['captcha_private_key'];
159                         $captcha_publickey = $admin->settings['captcha_public_key'];
160                         $captcha_js .="<script type='text/javascript' src='" . getJSPath('cache/include/javascript/sugar_grp1_yui.js') . "'></script><script type='text/javascript' src='" . getJSPath('cache/include/javascript/sugar_grp_yui2.js') . "'></script>
161                         <script type='text/javascript' src='http://api.recaptcha.net/js/recaptcha_ajax.js'></script>
162                         <script>
163                         function initCaptcha(){
164                         Recaptcha.create('$captcha_publickey' ,'captchaImage',{theme:'custom'});
165                         }
166                         window.onload=initCaptcha;
167
168                         var handleFailure=handleSuccess;
169                         var handleSuccess = function(o){
170                                 if(o.responseText!==undefined && o.responseText =='Success'){
171                                         generatepwd();
172                                         Recaptcha.reload();
173                                 }
174                                 else{
175                                         if(o.responseText!='')
176                                                 document.getElementById('generate_success').innerHTML =o.responseText;
177                                         Recaptcha.reload();
178                                 }
179                         }
180                         var callback2 ={ success:handleSuccess, failure: handleFailure };
181
182                         function validateAndSubmit(){
183                                         var form = document.getElementById('form');
184                                         var url = '&to_pdf=1&module=Home&action=index&entryPoint=Changenewpassword&recaptcha_challenge_field='+Recaptcha.get_challenge()+'&recaptcha_response_field='+ Recaptcha.get_response();
185                                         YAHOO.util.Connect.asyncRequest('POST','index.php',callback2,url);
186                         }</script>";
187                 $Captcha.="<tr>
188                         <td scope='row' width='20%'>".$mod_strings['LBL_RECAPTCHA_INSTRUCTION'].":</td>
189                     <td width='70%'><input type='text' size='26' id='recaptcha_response_field' value=''></td>
190
191                 </tr>
192                 <tr>
193
194                         <td colspan='2'><div style='margin-left:2px'class='x-sqs-list' id='recaptcha_image'></div></td>
195                 </tr>
196                 <tr>
197                         <td colspan='2' align='right'><a href='javascript:Recaptcha.reload()'>".$mod_strings['LBL_RECAPTCHA_NEW_CAPTCHA']."</a>&nbsp;&nbsp;
198                                         <a class='recaptcha_only_if_image' href='javascript:Recaptcha.switch_type(\"audio\")'>".$mod_strings['LBL_RECAPTCHA_SOUND']."</a>
199                                         <a class='recaptcha_only_if_audio' href='javascript:Recaptcha.switch_type(\"image\")'> ".$mod_strings['LBL_RECAPTCHA_IMAGE']."</a>
200                         </td>
201                 </tr>";
202                 $sugar_smarty->assign('CAPTCHA', $Captcha);
203                 echo $captcha_js;
204
205         }else{
206                 echo "<script>
207                 function validateAndSubmit(){generatepwd();}
208                 </script>";
209         }
210
211 $sugar_smarty->display('modules/Users/login.tpl'); ?>