fixes to prior statements improvements
[openemr.git] / interface / login / login.php
blob3c912126445862cbe3ac71109c2c200c9d469734
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 require_once("../globals.php");
34 <html>
35 <head>
36 <?php html_header_show();?>
37 <title><?php echo text($openemr_name) . " " . xlt('Login'); ?></title>
38 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
39 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css">
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 $GLOBALS['assets_static_relative']; ?>/font-awesome-4-6-3/css/font-awesome.min.css">
42 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
43 <link rel="stylesheet" href="../themes/login.css?v=<?php echo $v_js_includes; ?>" type="text/css">
45 <link rel="shortcut icon" href="<?php echo $GLOBALS['images_static_relative']; ?>/favicon.ico" />
47 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-min-2-2-0/index.js"></script>
48 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/js/bootstrap.min.js"></script>
49 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative'] ?>/jquery-ui-1-11-4/jquery-ui.min.js"></script>
51 <script type="text/javascript">
52 var registrationTranslations = <?php echo json_encode(array(
53 'title' => xla('OpenEMR Product Registration'),
54 'pleaseProvideValidEmail' => xla('Please provide a valid email address'),
55 'success' => xla('Success'),
56 'registeredSuccess' => xla('Your installation of OpenEMR has been registered'),
57 'submit' => xla('Submit'),
58 'noThanks' => xla('No Thanks'),
59 'registeredEmail' => xla('Registered email'),
60 'registeredId' => xla('Registered id'),
61 'genericError' => xla('Error. Try again later'),
62 'closeTooltip' => xla('Close')
63 ));
64 ?>;
66 var registrationConstants = <?php echo json_encode(array(
67 'webroot' => $GLOBALS['webroot']
69 ?>;
70 </script>
72 <script type="text/javascript" src="<?php echo $webroot ?>/interface/product_registration/product_registration_service.js?v=<?php echo $v_js_includes; ?>"></script>
73 <script type="text/javascript" src="<?php echo $webroot ?>/interface/product_registration/product_registration_controller.js?v=<?php echo $v_js_includes; ?>"></script>
75 <script type="text/javascript">
76 jQuery(document).ready(function() {
77 init();
79 var productRegistrationController = new ProductRegistrationController();
80 productRegistrationController.getProductRegistrationStatus(function(err, data) {
81 if (err) { return; }
83 if (data.status === 'UNREGISTERED') {
84 productRegistrationController.showProductRegistrationModal();
86 });
87 });
89 function init() {
90 $("#authUser").focus();
91 $("#login_form").submit(function(){return imsubmitted();});
94 function imsubmitted() {
95 <?php if (!empty($GLOBALS['restore_sessions'])) { ?>
96 // Delete the session cookie by setting its expiration date in the past.
97 // This forces the server to create a new session ID.
98 var olddate = new Date();
99 olddate.setFullYear(olddate.getFullYear() - 1);
100 document.cookie = '<?php echo session_name() . '=' . session_id() ?>; path=/; expires=' + olddate.toGMTString();
101 <?php } ?>
102 return false; //Currently the submit action is handled by the encrypt_form().
104 </script>
106 </head>
107 <body class="login">
108 <div class="container">
109 <form method="POST" id="loginForm"
110 action="../main/main_screen.php?auth=login&site=<?php echo attr($_SESSION['site_id']); ?>"
111 target="_top" name="login_form">
112 <div class="row">
113 <div class="col-sm-12">
114 <div>
115 <div class="center-block" style="max-width:400px">
116 <img class="img-responsive center-block" src="<?php echo $GLOBALS['webroot']?>/public/images/login-logo.png" />
117 </div>
119 <input type='hidden' name='new_login_session_management' value='1' />
121 <?php
122 // collect groups
123 $res = sqlStatement("select distinct name from groups");
124 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
125 $result[$iter] = $row;
126 if (count($result) == 1) {
127 $resvalue = $result[0]{"name"};
128 echo "<input type='hidden' name='authProvider' value='" . attr($resvalue) . "' />\n";
130 // collect default language id
131 $res2 = sqlStatement("select * from lang_languages where lang_description = ?",array($GLOBALS['language_default']));
132 for ($iter = 0;$row = sqlFetchArray($res2);$iter++)
133 $result2[$iter] = $row;
134 if (count($result2) == 1) {
135 $defaultLangID = $result2[0]{"lang_id"};
136 $defaultLangName = $result2[0]{"lang_description"};
138 else {
139 //default to english if any problems
140 $defaultLangID = 1;
141 $defaultLangName = "English";
143 // set session variable to default so login information appears in default language
144 $_SESSION['language_choice'] = $defaultLangID;
145 // collect languages if showing language menu
146 if ($GLOBALS['language_menu_login']) {
148 // sorting order of language titles depends on language translation options.
149 $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
150 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation']))
152 $sql = "SELECT *,lang_description as trans_lang_description FROM lang_languages ORDER BY lang_description, lang_id";
153 $res3=SqlStatement($sql);
155 else {
156 // Use and sort by the translated language name.
157 $sql = "SELECT ll.lang_id, " .
158 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " .
159 "ll.lang_description " .
160 "FROM lang_languages AS ll " .
161 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
162 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
163 "ld.lang_id = ? " .
164 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
165 $res3=SqlStatement($sql, array($mainLangID));
168 for ($iter = 0;$row = sqlFetchArray($res3);$iter++)
169 $result3[$iter] = $row;
170 if (count($result3) == 1) {
171 //default to english if only return one language
172 echo "<input type='hidden' name='languageChoice' value='1' />\n";
175 else {
176 echo "<input type='hidden' name='languageChoice' value='".attr($defaultLangID)."' />\n";
179 </div>
180 </div>
181 </div>
182 <?php if (isset($_SESSION['relogin']) && ($_SESSION['relogin'] == 1)) : // Begin relogin dialog ?>
183 <div class="row">
184 <div class="col-sm-12">
186 <strong><?php echo xlt('Password security has recently been upgraded.'); ?><br>
187 <?php echo xlt('Please login again.'); ?></strong>
188 </p>
189 <?php unset($_SESSION['relogin']); ?>
190 </div>
191 </div>
192 <?php endif; ?>
193 <?php if (isset($_SESSION['loginfailure']) && ($_SESSION['loginfailure'] == 1)) : // Begin login failure block ?>
194 <div class="row">
195 <div class="col-sm-12">
196 <div class="well well-lg login-failure">
197 <?php echo xlt('Invalid username or password'); ?>
198 </div>
199 </div>
200 </div>
201 <?php endif; // End login failure block?>
202 <div class="row">
203 <?php
204 $extraLogo = $GLOBALS['extra_logo_login'];
205 $loginFormColumnCount = ($extraLogo == 1) ? '6' : '12';
207 <?php if ($extraLogo) : ?>
208 <div class="col-sm-6">
209 <?php echo $logocode; ?>
210 </div>
211 <?php endif; ?>
212 <div class="col-sm-<?php echo $loginFormColumnCount;?>">
213 <div class="row">
214 <div class="center-block login-title-label">
215 <?php if ($GLOBALS['show_label_login']) : ?>
216 <?php echo text($openemr_name); ?>
217 <?php endif; ?>
218 </div>
219 <?php
220 // Figure out how to display the tiny logos
221 $t1 = $GLOBALS['tiny_logo_1'];
222 $t2 = $GLOBALS['tiny_logo_2'];
223 if ($t1 && !$t2) : ?>
224 <div class="col-sm-12 center-block">
225 <?php echo $tinylogocode1; ?>
226 </div>
227 <?php
228 endif;
229 if ($t2 && !$t1) : ?>
230 <div class="col-sm-12 center-block">
231 <?php echo $tinylogocode2; ?>
232 </div>
233 <?php
234 endif;
235 if ($t1 && $t2) : ?>
236 <div class="col-sm-6 center-block"><?php echo $tinylogocode1;?></div>
237 <div class="col-sm-6 center-block"><?php echo $tinylogocode2;?></div>
238 <?php
239 endif;
241 </div>
242 <?php if (count($result) > 1) : // Begin Display check for groups ?>
243 <div class="form-group">
244 <label for="group" class="control-label text-right"><?php echo xlt('Group:'); ?></label>
245 <div>
246 <select name="authProvider" class="form-control">
247 <?php
248 foreach ($result as $iter) {
249 echo "<option value='".attr($iter{"name"})."'>".text($iter{"name"})."</option>\n";
252 </select>
253 </div>
254 </div>
255 <?php endif; // End Display check for groups ?>
256 <div class="form-group">
257 <label for="authUser" class="control-label text-right"><?php echo xlt('Username:'); ?></label>
258 <input type="text" class="form-control" id="authUser" name="authUser" placeholder="<?php echo xla('Username:'); ?>">
259 </div>
260 <div class="form-group">
261 <label for="clearPass" class="control-label text-right"><?php echo xlt('Password:'); ?></label>
262 <input type="password" class="form-control" id="clearPass" name="clearPass" placeholder="<?php echo xla('Password:'); ?>">
263 </div>
264 <?php if ($GLOBALS['language_menu_login'] && (count($result3) != 1)) : // Begin language menu block ?>
265 <div class="form-group">
266 <label for="language" class="control-label text-right"><?php echo xlt('Language'); ?>:</label>
267 <div>
268 <select class="form-control" name="languageChoice" size="1">
269 <?php
270 echo "<option selected='selected' value='" . attr($defaultLangID) . "'>" . xlt('Default') . " - " . xlt($defaultLangName) . "</option>\n";
271 foreach ($result3 as $iter) :
272 if ($GLOBALS['language_menu_showall']) {
273 if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') continue; // skip the dummy language
274 echo "<option value='".attr($iter['lang_id'])."'>".text($iter['trans_lang_description'])."</option>\n";
275 } else {
276 if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
277 if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') continue; // skip the dummy language
278 echo "<option value='".attr($iter['lang_id'])."'>" . text($iter['trans_lang_description']) . "</option>\n";
281 endforeach; ?>
282 </select>
283 </div>
284 </div>
285 <?php endif; // End language menu block ?>
286 <div class="form-group">
287 <button type="submit" class="btn btn-block btn-large"><i class="fa fa-sign-in"></i>&nbsp;<?php echo xlt('Login');?></button>
288 </div>
289 </div>
290 <div class="col-sm-12 text-right">
291 <p class="small">
292 <a href="../../acknowledge_license_cert.html" target="main"><?php echo xlt('Acknowledgments, Licensing and Certification'); ?></a>
293 </p>
294 </div>
295 <div class="product-registration-modal" style="display: none">
296 <p class="context"><?php echo xlt("Register your installation with OEMR to receive important notifications, such as security fixes and new release announcements."); ?></p>
297 <input placeholder="<?php echo xlt('email'); ?>" type="email" class="email" style="width: 100%; color: black" />
298 <p class="message" style="font-style: italic"></p>
299 </div>
300 </div>
301 </form>
302 </div>
303 </body>
304 </html>