Internationalization Project: Improving the translation pipeline.
[openemr.git] / interface / login / login.php
blob1723fbbc9b087d72f5685a40aa62f95fe48c1634
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 $ignoreAuth=true;
8 include_once("../globals.php");
9 include_once("$srcdir/md5.js");
10 include_once("$srcdir/sql.inc");
12 <html>
13 <head>
14 <?php html_header_show(); ?>
15 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
17 <script language='JavaScript'>
19 function imsubmitted() {
20 <?php if (!empty($GLOBALS['restore_sessions'])) { ?>
21 // Delete the session cookie by setting its expiration date in the past.
22 // This forces the server to create a new session ID.
23 var olddate = new Date();
24 olddate.setFullYear(olddate.getFullYear() - 1);
25 document.cookie = '<?php echo session_name() . '=' . session_id() ?>; path=/; expires=' + olddate.toGMTString();
26 <?php } ?>
27 return true;
30 </script>
32 </head>
33 <body <?php echo $login_body_line;?> onload="javascript:document.login_form.authUser.focus();" >
35 <span class="text"></span>
37 <center>
39 <form method="POST"
40 action="../main/main_screen.php?auth=login&site=<?php echo htmlspecialchars($_SESSION['site_id']); ?>"
41 target="_top" name="login_form" onsubmit="return imsubmitted();">
43 <?php
44 // collect groups
45 $res = sqlStatement("select distinct name from groups");
46 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
47 $result[$iter] = $row;
48 if (count($result) == 1) {
49 $resvalue = $result[0]{"name"};
50 echo "<input type='hidden' name='authProvider' value='$resvalue' />\n";
52 // collect default language id
53 $res2 = sqlStatement("select * from lang_languages where lang_description = '".$GLOBALS['language_default']."'");
54 for ($iter = 0;$row = sqlFetchArray($res2);$iter++)
55 $result2[$iter] = $row;
56 if (count($result2) == 1) {
57 $defaultLangID = $result2[0]{"lang_id"};
58 $defaultLangName = $result2[0]{"lang_description"};
60 else {
61 //default to english if any problems
62 $defaultLangID = 1;
63 $defaultLangName = "English";
65 // set session variable to default so login information appears in default language
66 $_SESSION['language_choice'] = $defaultLangID;
67 // collect languages if showing language menu
68 if ($GLOBALS['language_menu_login']) {
70 // sorting order of language titles depends on language translation options.
71 $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
72 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation']))
74 $sql = "SELECT * FROM lang_languages ORDER BY lang_description, lang_id";
75 $res3=SqlStatement($sql);
77 else {
78 // Use and sort by the translated language name.
79 $sql = "SELECT ll.lang_id, " .
80 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " .
81 "ll.lang_description " .
82 "FROM lang_languages AS ll " .
83 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
84 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
85 "ld.lang_id = '$mainLangID' " .
86 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
87 $res3=SqlStatement($sql);
90 for ($iter = 0;$row = sqlFetchArray($res3);$iter++)
91 $result3[$iter] = $row;
92 if (count($result3) == 1) {
93 //default to english if only return one language
94 echo "<input type='hidden' name='languageChoice' value='1' />\n";
97 else {
98 echo "<input type='hidden' name='languageChoice' value='".$defaultLanguage."' />\n";
102 <table width=100% height="90%">
103 <tr>
104 <td valign=middle width=33%>
105 <?php echo $logocode;?>
106 </td>
107 <td align='center' valign='middle' width=34%>
108 <table>
109 <?php if (count($result) != 1) { ?>
110 <tr>
111 <td><span class="text"><?php xl('Group:','e'); ?></span></td>
112 <td>
113 <select name=authProvider>
114 <?php
115 foreach ($result as $iter) {
116 echo "<option value='".$iter{"name"}."'>".$iter{"name"}."</option>\n";
119 </select>
120 </td></tr>
121 <?php } ?>
123 <?php if ($_SESSION['loginfailure'] == 1): ?>
124 <tr><td colspan='2' class='text' style='color:red'>
125 Invalid username or password
126 </td></tr>
127 <?php endif; ?>
129 <tr>
130 <td><span class="text"><?php xl('Username:','e'); ?></span></td>
131 <td>
132 <input type="text" size="10" name="authUser">
133 </td></tr><tr>
134 <td><span class="text"><?php xl('Password:','e'); ?></span></td>
135 <td>
136 <input type="password" size="10" name="clearPass">
137 </td></tr>
139 <?php
140 if ($GLOBALS['language_menu_login']) {
141 if (count($result3) != 1) { ?>
142 <tr>
143 <td><span class="text"><?php xl('Language','e'); ?>:</span></td>
144 <td>
145 <select name=languageChoice size="1">
146 <?php
147 echo "<option selected='selected' value='".$defaultLangID."'>" . xl('Default','','',' -') . xl($defaultLangName,'',' ') . "</option>\n";
148 foreach ($result3 as $iter) {
149 if ($GLOBALS['language_menu_showall']) {
150 if ( !$GLOBALS['allow_debug_language'] && $iter[lang_description] == 'dummy') continue; // skip the dummy language
151 echo "<option value='".$iter[lang_id]."'>".$iter[trans_lang_description]."</option>\n";
153 else {
154 if (in_array($iter[lang_description], $GLOBALS['language_menu_show'])) {
155 if ( !$GLOBALS['allow_debug_language'] && $iter[lang_description] == 'dummy') continue; // skip the dummy language
156 echo "<option value='".$iter[lang_id]."'>" . $iter[trans_lang_description] . "</option>\n";
161 </select>
162 </td></tr>
163 <?php }} ?>
165 <tr><td>&nbsp;</td><td>
166 <input type="hidden" name="authPass">
167 <?php if ($GLOBALS['use_adldap_auth'] == true): ?>
168 <input type="submit" onClick="javascript:this.form.authPass.value=MD5(this.form.clearPass.value);" value=<?php xl('Login','e');?>>
169 <?php else: ?>
170 <input type="submit" onClick="javascript:this.form.authPass.value=MD5(this.form.clearPass.value);this.form.clearPass.value='';" value=<?php xl('Login','e');?>>
171 <?php endif; ?>
172 </td></tr>
173 <tr><td colspan='2' class='text' style='color:red'>
174 <?php
175 $ip=$_SERVER['REMOTE_ADDR'];
177 // The following commented out because it is too slow when the log
178 // table is large. -- Rod 2009-11-11
179 /*********************************************************************
180 $query = "select user, date, comments from log where event like 'login' and comments like '%".$ip."' order by date desc limit 1";
181 $statement = sqlStatement($query);
182 if ($result = sqlFetchArray($statement)) {
183 if (strpos($result['comments'],"ailure")) {
184 echo $result['user']." attempted unauthorized login on this machine: ".$result['date'];
187 *********************************************************************/
190 </td></tr>
191 </table>
192 </td>
193 <td width=33%>
195 <!-- Uncomment this for the OpenEMR demo installation
196 <p><center>login = admin
197 <br>password = pass
200 </center></p>
202 </td>
203 </table>
205 </form>
207 <address>
208 <a href="../../copyright_notice.html" target="main"><?php xl('Copyright Notice','e'); ?></a><br />
209 </address>
211 </center>
212 </body>
213 </html>