bug fix for login.php (#325)
[openemr.git] / interface / login / login.php
blob10757bdd427ebbae403b3d3d056b7567a49963ec
1 <?php
2 /**
3 * Login screen.
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @package OpenEMR
17 * @author Rod Roark <rod@sunsetsystems.com>
18 * @author Brady Miller <brady@sparmy.com>
19 * @author Kevin Yeh <kevin.y@integralemr.com>
20 * @author Scott Wakefield <scott.wakefield@gmail.com>
21 * @author ViCarePlus <visolve_emr@visolve.com>
22 * @author Julia Longtin <julialongtin@diasp.org>
23 * @author cfapress
24 * @author markleeds
25 * @link http://www.open-emr.org
28 $fake_register_globals=false;
29 $sanitize_all_escapes=true;
31 $ignoreAuth=true;
32 include_once("../globals.php");
33 include_once("$srcdir/sql.inc");
35 <html>
36 <head>
37 <?php html_header_show();?>
38 <title><?php echo text($openemr_name) . " " . xlt('Login'); ?></title>
39 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
40 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-ui-1-11-4/themes/ui-darkness/jquery-ui.min.css" />
41 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
42 <link rel=stylesheet href="../themes/login.css" type="text/css">
43 <link rel="shortcut icon" href="<?php echo $webroot; ?>/interface/pic/favicon.ico" />
45 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-min-2-2-0/index.js"></script>
46 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-ui-1-11-4/jquery-ui.min.js"></script>
48 <script type="text/javascript">
49 var registrationTranslations = <?php echo json_encode(array(
50 'title' => xla('OpenEMR Product Registration'),
51 'pleaseProvideValidEmail' => xla('Please provide a valid email address'),
52 'success' => xla('Success'),
53 'registeredSuccess' => xla('Your installation of OpenEMR has been registered'),
54 'submit' => xla('Submit'),
55 'noThanks' => xla('No Thanks'),
56 'registeredEmail' => xla('Registered email'),
57 'registeredId' => xla('Registered id'),
58 'genericError' => xla('Error. Try again later')
59 ));
60 ?>;
62 var registrationConstants = <?php echo json_encode(array(
63 'webroot' => $GLOBALS['webroot']
65 ?>;
66 </script>
68 <script type="text/javascript" src="<?php echo $webroot ?>/interface/product_registration/product_registration_service.js?v=<?php echo $v_js_includes; ?>"></script>
69 <script type="text/javascript" src="<?php echo $webroot ?>/interface/product_registration/product_registration_controller.js?v=<?php echo $v_js_includes; ?>"></script>
71 <script type="text/javascript">
72 jQuery(document).ready(function() {
73 var productRegistrationController = new ProductRegistrationController();
74 productRegistrationController.getProductRegistrationStatus(function(err, data) {
75 if (err) { return; }
77 if (data.status === 'UNREGISTERED') {
78 productRegistrationController.showProductRegistrationModal();
80 });
81 });
82 </script>
84 <script language='JavaScript'>
85 function transmit_form()
87 document.forms[0].submit();
89 function imsubmitted() {
90 <?php if (!empty($GLOBALS['restore_sessions'])) { ?>
91 // Delete the session cookie by setting its expiration date in the past.
92 // This forces the server to create a new session ID.
93 var olddate = new Date();
94 olddate.setFullYear(olddate.getFullYear() - 1);
95 document.cookie = '<?php echo session_name() . '=' . session_id() ?>; path=/; expires=' + olddate.toGMTString();
96 <?php } ?>
97 return false; //Currently the submit action is handled by the encrypt_form().
99 </script>
101 </head>
102 <body onload="javascript:document.login_form.authUser.focus();" class="body_image">
103 <span class="text"></span>
104 <center>
106 <form method="POST"
107 action="../main/main_screen.php?auth=login&site=<?php echo attr($_SESSION['site_id']); ?>"
108 target="_top" name="login_form" onsubmit="return imsubmitted();">
110 <input type='hidden' name='new_login_session_management' value='1' />
112 <?php
113 // collect groups
114 $res = sqlStatement("select distinct name from groups");
115 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
116 $result[$iter] = $row;
117 if (count($result) == 1) {
118 $resvalue = $result[0]{"name"};
119 echo "<input type='hidden' name='authProvider' value='" . attr($resvalue) . "' />\n";
121 // collect default language id
122 $res2 = sqlStatement("select * from lang_languages where lang_description = ?",array($GLOBALS['language_default']));
123 for ($iter = 0;$row = sqlFetchArray($res2);$iter++)
124 $result2[$iter] = $row;
125 if (count($result2) == 1) {
126 $defaultLangID = $result2[0]{"lang_id"};
127 $defaultLangName = $result2[0]{"lang_description"};
129 else {
130 //default to english if any problems
131 $defaultLangID = 1;
132 $defaultLangName = "English";
134 // set session variable to default so login information appears in default language
135 $_SESSION['language_choice'] = $defaultLangID;
136 // collect languages if showing language menu
137 if ($GLOBALS['language_menu_login']) {
139 // sorting order of language titles depends on language translation options.
140 $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
141 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation']))
143 $sql = "SELECT *,lang_description as trans_lang_description FROM lang_languages ORDER BY lang_description, lang_id";
144 $res3=SqlStatement($sql);
146 else {
147 // Use and sort by the translated language name.
148 $sql = "SELECT ll.lang_id, " .
149 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " .
150 "ll.lang_description " .
151 "FROM lang_languages AS ll " .
152 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
153 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
154 "ld.lang_id = ? " .
155 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
156 $res3=SqlStatement($sql, array($mainLangID));
159 for ($iter = 0;$row = sqlFetchArray($res3);$iter++)
160 $result3[$iter] = $row;
161 if (count($result3) == 1) {
162 //default to english if only return one language
163 echo "<input type='hidden' name='languageChoice' value='1' />\n";
166 else {
167 echo "<input type='hidden' name='languageChoice' value='".attr($defaultLangID)."' />\n";
171 <table width="100%" height="99%">
172 <td align='center' valign='middle' width='34%'>
173 <div class="login-box" <?php if ($GLOBALS['extra_logo_login']) echo "style='width: 600px;'"; //enlarge width larger to fix the extra logo ?> >
174 <img class="logo-image" src="<?php echo $GLOBALS['webroot']?>/interface/pic/logo.png" />
176 <?php if ($GLOBALS['tiny_logo_1'] || $GLOBALS['tiny_logo_2']) { ?>
177 <div id='tinylogocontainer' class='tinylogocontainer'>
178 <?php if ($GLOBALS['tiny_logo_1']) {echo $tinylogocode1;} if ($GLOBALS['tiny_logo_2']) {echo $tinylogocode2;} ?>
179 </div>
180 <?php } ?>
182 <div class="title_name">
183 <?php if ($GLOBALS['show_label_login']) { ?>
184 <?php echo text($openemr_name); ?>
185 <?php } ?>
186 </div>
188 <?php if ($GLOBALS['extra_logo_login']) { ?>
189 <div class="logo-left"><?php echo $logocode;?></div>
190 <?php } ?>
192 <div class="table-right" <?php if ($GLOBALS['extra_logo_login']) echo "style='padding: 20px 20px;'"; //make room for the extra logo ?> >
193 <table width="100%">
194 <?php if (count($result) != 1) { ?>
195 <tr>
196 <td><span class="text"><?php echo xlt('Group:'); ?></span></td>
197 <td>
198 <select name=authProvider>
199 <?php
200 foreach ($result as $iter) {
201 echo "<option value='".attr($iter{"name"})."'>".text($iter{"name"})."</option>\n";
204 </select>
205 </td></tr>
206 <?php } ?>
208 <?php if (isset($_SESSION['loginfailure']) && ($_SESSION['loginfailure'] == 1)): ?>
209 <tr><td colspan='2' class='text' style='color:red'>
210 <?php echo xlt('Invalid username or password'); ?>
211 </td></tr>
212 <?php endif; ?>
214 <?php if (isset($_SESSION['relogin']) && ($_SESSION['relogin'] == 1)): ?>
215 <tr><td colspan='2' class='text' style='color:red;background-color:#dfdfdf;border:solid 1px #bfbfbf;text-align:center'>
216 <b><?php echo xlt('Password security has recently been upgraded.'); ?><br>
217 <?php echo xlt('Please login again.'); ?></b>
218 <?php unset($_SESSION['relogin']); ?>
219 </td></tr>
220 <?php endif; ?>
222 <tr>
223 <td><span class="text"><?php echo xlt('Username:'); ?></span></td>
224 <td>
225 <input class="entryfield" size="22" name="authUser">
226 </td></tr><tr>
227 <td><span class="text"><?php echo xlt('Password:'); ?></span></td>
228 <td>
229 <input class="entryfield" type="password" size="22" name="clearPass">
230 </td></tr>
232 <?php
233 if ($GLOBALS['language_menu_login']) {
234 if (count($result3) != 1) { ?>
235 <tr>
236 <td><span class="text"><?php echo xlt('Language'); ?>:</span></td>
237 <td>
238 <select class="entryfield" name=languageChoice size="1">
239 <?php
240 echo "<option selected='selected' value='" . attr($defaultLangID) . "'>" . xlt('Default') . " - " . xlt($defaultLangName) . "</option>\n";
241 foreach ($result3 as $iter) {
242 if ($GLOBALS['language_menu_showall']) {
243 if ( !$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') continue; // skip the dummy language
244 echo "<option value='".attr($iter['lang_id'])."'>".text($iter['trans_lang_description'])."</option>\n";
246 else {
247 if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
248 if ( !$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') continue; // skip the dummy language
249 echo "<option value='".attr($iter['lang_id'])."'>" . text($iter['trans_lang_description']) . "</option>\n";
254 </select>
255 </td></tr>
256 <?php }} ?>
258 <tr><td>&nbsp;</td><td>
259 <input class="button large" type="submit" onClick="transmit_form()" value="<?php echo xla('Login');?>">
261 </td></tr>
262 <tr><td colspan='2' class='text' style='color:red'>
263 <?php
264 $ip=$_SERVER['REMOTE_ADDR'];
266 </div>
267 </td></tr>
268 </table>
270 </div>
271 <div style="clear: both;"> </div>
272 <div class="version">
273 <a href="../../acknowledge_license_cert.html" target="main"><?php echo xlt('Acknowledgments, Licensing and Certification'); ?></a>
274 </div>
275 </div>
277 <div class="product-registration-modal" style="display: none">
278 <p class="context"><?php echo xlt("Register your installation with OEMR 501(c)(3) to receive important notifications, such as security fixes and new release announcements."); ?></p>
279 <input placeholder="<?php echo xlt('email'); ?>" type="email" class="email" style="width: 100%; color: black" />
280 <p class="message" style="font-style: italic"></p>
281 </div>
283 <div class="demo">
284 <!-- Uncomment this for the OpenEMR demo installation
285 <p><center>login = admin
286 <br>password = pass
288 </div>
289 </td>
290 </tr>
291 </table>
292 </form>
293 </center>
294 </body>
295 </html>