Add optional tiny icons to the UI (#207)
[openemr.git] / interface / login / login.php
blob49462b8451ff9ac87f4c18fc53693575378d054f
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 $css_header;?>" type="text/css">
41 <link rel=stylesheet href="../themes/login.css" type="text/css">
43 <script language='JavaScript' src="../../library/js/jquery-1.4.3.min.js"></script>
44 <script language='JavaScript'>
45 function transmit_form()
47 document.forms[0].submit();
49 function imsubmitted() {
50 <?php if (!empty($GLOBALS['restore_sessions'])) { ?>
51 // Delete the session cookie by setting its expiration date in the past.
52 // This forces the server to create a new session ID.
53 var olddate = new Date();
54 olddate.setFullYear(olddate.getFullYear() - 1);
55 document.cookie = '<?php echo session_name() . '=' . session_id() ?>; path=/; expires=' + olddate.toGMTString();
56 <?php } ?>
57 return false; //Currently the submit action is handled by the encrypt_form().
59 </script>
61 </head>
62 <body onload="javascript:document.login_form.authUser.focus();">
63 <div class="logobar">
64 <img style="position:absolute;top:0;left:0;"src=" <?php echo $GLOBALS['webroot']?>/interface/pic/logo.gif" />
65 </div>
66 <div class="body_title">
67 <span class="title_bar">
68 <div id='tinylogocontainer' class='tinylogocontainer'>
69 <?php if ($GLOBALS['tiny_logo_1']) {echo $tinylogocode1;} if ($GLOBALS['tiny_logo_2']) {echo $tinylogocode2;} ?>
70 </div>
71 <div class="title_name"><?php echo text($openemr_name); ?></div>
72 </span>
73 <br>
74 </div>
75 <span class="text"></span>
76 <center>
78 <form method="POST"
79 action="../main/main_screen.php?auth=login&site=<?php echo attr($_SESSION['site_id']); ?>"
80 target="_top" name="login_form" onsubmit="return imsubmitted();">
82 <input type='hidden' name='new_login_session_management' value='1' />
84 <?php
85 // collect groups
86 $res = sqlStatement("select distinct name from groups");
87 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
88 $result[$iter] = $row;
89 if (count($result) == 1) {
90 $resvalue = $result[0]{"name"};
91 echo "<input type='hidden' name='authProvider' value='" . attr($resvalue) . "' />\n";
93 // collect default language id
94 $res2 = sqlStatement("select * from lang_languages where lang_description = ?",array($GLOBALS['language_default']));
95 for ($iter = 0;$row = sqlFetchArray($res2);$iter++)
96 $result2[$iter] = $row;
97 if (count($result2) == 1) {
98 $defaultLangID = $result2[0]{"lang_id"};
99 $defaultLangName = $result2[0]{"lang_description"};
101 else {
102 //default to english if any problems
103 $defaultLangID = 1;
104 $defaultLangName = "English";
106 // set session variable to default so login information appears in default language
107 $_SESSION['language_choice'] = $defaultLangID;
108 // collect languages if showing language menu
109 if ($GLOBALS['language_menu_login']) {
111 // sorting order of language titles depends on language translation options.
112 $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
113 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation']))
115 $sql = "SELECT *,lang_description as trans_lang_description FROM lang_languages ORDER BY lang_description, lang_id";
116 $res3=SqlStatement($sql);
118 else {
119 // Use and sort by the translated language name.
120 $sql = "SELECT ll.lang_id, " .
121 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " .
122 "ll.lang_description " .
123 "FROM lang_languages AS ll " .
124 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
125 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
126 "ld.lang_id = ? " .
127 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
128 $res3=SqlStatement($sql, array($mainLangID));
131 for ($iter = 0;$row = sqlFetchArray($res3);$iter++)
132 $result3[$iter] = $row;
133 if (count($result3) == 1) {
134 //default to english if only return one language
135 echo "<input type='hidden' name='languageChoice' value='1' />\n";
138 else {
139 echo "<input type='hidden' name='languageChoice' value='".attr($defaultLangID)."' />\n";
143 <table width="100%" height="90%">
144 <td align='center' valign='middle' width='34%'>
145 <div class="login-box">
146 <div class="logo-left"><?php echo $logocode;?></div>
148 <div class="table-right">
149 <table width="100%">
150 <?php if (count($result) != 1) { ?>
151 <tr>
152 <td><span class="text"><?php echo xlt('Group:'); ?></span></td>
153 <td>
154 <select name=authProvider>
155 <?php
156 foreach ($result as $iter) {
157 echo "<option value='".attr($iter{"name"})."'>".text($iter{"name"})."</option>\n";
160 </select>
161 </td></tr>
162 <?php } ?>
164 <?php if (isset($_SESSION['loginfailure']) && ($_SESSION['loginfailure'] == 1)): ?>
165 <tr><td colspan='2' class='text' style='color:red'>
166 <?php echo xlt('Invalid username or password'); ?>
167 </td></tr>
168 <?php endif; ?>
170 <?php if (isset($_SESSION['relogin']) && ($_SESSION['relogin'] == 1)): ?>
171 <tr><td colspan='2' class='text' style='color:red;background-color:#dfdfdf;border:solid 1px #bfbfbf;text-align:center'>
172 <b><?php echo xlt('Password security has recently been upgraded.'); ?><br>
173 <?php echo xlt('Please login again.'); ?></b>
174 <?php unset($_SESSION['relogin']); ?>
175 </td></tr>
176 <?php endif; ?>
178 <tr>
179 <td><span class="text"><?php echo xlt('Username:'); ?></span></td>
180 <td>
181 <input class="entryfield" type="text" size="10" name="authUser">
182 </td></tr><tr>
183 <td><span class="text"><?php echo xlt('Password:'); ?></span></td>
184 <td>
185 <input class="entryfield" type="password" size="10" name="clearPass">
186 </td></tr>
188 <?php
189 if ($GLOBALS['language_menu_login']) {
190 if (count($result3) != 1) { ?>
191 <tr>
192 <td><span class="text"><?php echo xlt('Language'); ?>:</span></td>
193 <td>
194 <select class="entryfield" name=languageChoice size="1">
195 <?php
196 echo "<option selected='selected' value='" . attr($defaultLangID) . "'>" . xlt('Default') . " - " . xlt($defaultLangName) . "</option>\n";
197 foreach ($result3 as $iter) {
198 if ($GLOBALS['language_menu_showall']) {
199 if ( !$GLOBALS['allow_debug_language'] && $iter[lang_description] == 'dummy') continue; // skip the dummy language
200 echo "<option value='".attr($iter['lang_id'])."'>".text($iter['trans_lang_description'])."</option>\n";
202 else {
203 if (in_array($iter[lang_description], $GLOBALS['language_menu_show'])) {
204 if ( !$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') continue; // skip the dummy language
205 echo "<option value='".attr($iter['lang_id'])."'>" . text($iter['trans_lang_description']) . "</option>\n";
210 </select>
211 </td></tr>
212 <?php }} ?>
214 <tr><td>&nbsp;</td><td>
215 <input class="button large" type="submit" onClick="transmit_form()" value="<?php echo xla('Login');?>">
216 </td></tr>
217 <tr><td colspan='2' class='text' style='color:red'>
218 <?php
219 $ip=$_SERVER['REMOTE_ADDR'];
221 </div>
222 </td></tr>
223 </table>
225 </div>
226 <div style="clear: both;"> </div>
227 <div class="version">
228 <a href="../../acknowledge_license_cert.html" target="main"><?php echo xlt('Acknowledgments, Licensing and Certification'); ?></a>
229 </div>
230 </div>
231 <div class="demo">
232 <!-- Uncomment this for the OpenEMR demo installation
233 <p><center>login = admin
234 <br>password = pass
236 </div>
237 </td>
238 </tr>
239 </table>
240 </form>
241 </center>
242 </body>
243 </html>