commented out login failure reporting because it is very slow when the log table...
[openemr.git] / interface / login / login.php
blob3733d6801fdd9014114a27c4b7da3800342abb4d
1 <?php
2 $ignoreAuth=true;
3 include_once("../globals.php");
4 include_once("$srcdir/md5.js");
5 include_once("$srcdir/sql.inc");
6 ?>
7 <html>
8 <head>
9 <?php html_header_show(); ?>
10 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
12 <script language='JavaScript'>
14 function imsubmitted() {
15 <?php if (!empty($GLOBALS['restore_sessions'])) { ?>
16 // Delete the session cookie by setting its expiration date in the past.
17 // This forces the server to create a new session ID.
18 var olddate = new Date();
19 olddate.setFullYear(olddate.getFullYear() - 1);
20 document.cookie = '<?php echo session_name() . '=' . session_id() ?>; path=/; expires=' + olddate.toGMTString();
21 <?php } ?>
22 return true;
25 </script>
27 </head>
28 <body <?php echo $login_body_line;?> onload="javascript:document.login_form.authUser.focus();" >
30 <span class="text"></span>
32 <center>
34 <form method="POST" action="../main/main_screen.php?auth=login" target="_top"
35 name="login_form" onsubmit="return imsubmitted();">
37 <?php
38 // collect groups
39 $res = sqlStatement("select distinct name from groups");
40 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
41 $result[$iter] = $row;
42 if (count($result) == 1) {
43 $resvalue = $result[0]{"name"};
44 echo "<input type='hidden' name='authProvider' value='$resvalue' />\n";
46 // collect default language id
47 $res2 = sqlStatement("select * from lang_languages where lang_description = '".$GLOBALS['language_default']."'");
48 for ($iter = 0;$row = sqlFetchArray($res2);$iter++)
49 $result2[$iter] = $row;
50 if (count($result2) == 1) {
51 $defaultLangID = $result2[0]{"lang_id"};
52 $defaultLangName = $result2[0]{"lang_description"};
54 else {
55 //default to english if any problems
56 $defaultLangID = 1;
57 $defaultLangName = "English";
59 // set session variable to default so login information appears in default language
60 $_SESSION['language_choice'] = $defaultLangID;
61 // collect languages if showing language menu
62 if ($GLOBALS['language_menu_login']) {
63 $res3 = sqlStatement("select * from lang_languages order by lang_description");
64 for ($iter = 0;$row = sqlFetchArray($res3);$iter++)
65 $result3[$iter] = $row;
66 if (count($result3) == 1) {
67 //default to english if only return one language
68 echo "<input type='hidden' name='languageChoice' value='1' />\n";
71 else {
72 echo "<input type='hidden' name='languageChoice' value='".$defaultLanguage."' />\n";
76 <table width=100% height="90%">
77 <tr>
78 <td valign=middle width=33%>
79 <?php echo $logocode;?>
80 </td>
81 <td align='center' valign='middle' width=34%>
82 <table>
83 <?php if (count($result) != 1) { ?>
84 <tr>
85 <td><span class="text"><?php xl('Group:','e'); ?></span></td>
86 <td>
87 <select name=authProvider>
88 <?php
89 foreach ($result as $iter) {
90 echo "<option value='".$iter{"name"}."'>".$iter{"name"}."</option>\n";
93 </select>
94 </td></tr>
95 <?php } ?>
97 <?php if ($_SESSION['loginfailure'] == 1): ?>
98 <tr><td colspan='2' class='text' style='color:red'>
99 Invalid username or password
100 </td></tr>
101 <?php endif; ?>
103 <tr>
104 <td><span class="text"><?php xl('Username:','e'); ?></span></td>
105 <td>
106 <input type="text" size="10" name="authUser">
107 </td></tr><tr>
108 <td><span class="text"><?php xl('Password:','e'); ?></span></td>
109 <td>
110 <input type="password" size="10" name="clearPass">
111 </td></tr>
113 <?php
114 if ($GLOBALS['language_menu_login']) {
115 if (count($result3) != 1) { ?>
116 <tr>
117 <td><span class="text"><?php xl('Language:','e'); ?></span></td>
118 <td>
119 <select name=languageChoice size="1">
120 <?php
121 echo "<option selected='selected' value='".$defaultLangID."'>" . xl('Default','','',' -') . xl($defaultLangName,'',' ') . "</option>\n";
122 foreach ($result3 as $iter) {
123 if ($GLOBALS['language_menu_showall']) {
124 echo "<option value='".$iter[lang_id]."'>".xl($iter[lang_description])."</option>\n";
126 else {
127 if (in_array($iter[lang_description], $GLOBALS['language_menu_show'])) {
128 echo "<option value='".$iter[lang_id]."'>" . xl($iter[lang_description]) . "</option>\n";
133 </select>
134 </td></tr>
135 <?php }} ?>
137 <tr><td>&nbsp;</td><td>
138 <input type="hidden" name="authPass">
139 <?php if ($GLOBALS['use_adldap_auth'] == true): ?>
140 <input type="submit" onClick="javascript:this.form.authPass.value=MD5(this.form.clearPass.value);" value=<?php xl('Login','e');?>>
141 <?php else: ?>
142 <input type="submit" onClick="javascript:this.form.authPass.value=MD5(this.form.clearPass.value);this.form.clearPass.value='';" value=<?php xl('Login','e');?>>
143 <?php endif; ?>
144 </td></tr>
145 <tr><td colspan='2' class='text' style='color:red'>
146 <?php
147 $ip=$_SERVER['REMOTE_ADDR'];
149 // The following commented out because it is too slow when the log
150 // table is large. -- Rod 2009-11-11
151 /*********************************************************************
152 $query = "select user, date, comments from log where event like 'login' and comments like '%".$ip."' order by date desc limit 1";
153 $statement = sqlStatement($query);
154 if ($result = sqlFetchArray($statement)) {
155 if (strpos($result['comments'],"ailure")) {
156 echo $result['user']." attempted unauthorized login on this machine: ".$result['date'];
159 *********************************************************************/
162 </td></tr>
163 </table>
164 </td>
165 <td width=33%>
167 <!-- Uncomment this for the OpenEMR demo installation
168 <p><center>login = admin
169 <br>password = pass
172 </center></p>
174 </td>
175 </table>
177 </form>
179 <address>
180 <a href="copyright_notice.html" target="main"><?php xl('Copyright Notice','e'); ?></a><br />
181 </address>
183 </center>
184 </body>
185 </html>