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