Onsite Patient Portal:
[openemr.git] / patients / index.php
blob62548991e56f35201d3dc07b00e84166d57d44b8
1 <?php
2 // Copyright (C) 2011 Cassian LUP <cassi.lup@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 //setting the session & other config options
10 session_start();
12 //don't require standard openemr authorization in globals.php
13 $ignoreAuth = 1;
15 //SANITIZE ALL ESCAPES
16 $fake_register_globals=false;
18 //STOP FAKE REGISTER GLOBALS
19 $sanitize_all_escapes=true;
21 //includes
22 require_once('../interface/globals.php');
23 require_once("$srcdir/sha1.js");
24 //
26 //exit if portal is turned off
27 if ( !(isset($GLOBALS['portal_onsite_enable'])) || !($GLOBALS['portal_onsite_enable']) ) {
28 echo htmlspecialchars( xl('Patient Portal is turned off'), ENT_NOQUOTES);
29 exit;
32 // security measure -- will check on next page.
33 $_SESSION['itsme'] = 1;
34 //
37 <html>
38 <head>
39 <title><?php echo htmlspecialchars( xl('Access your patient information'), ENT_NOQUOTES); ?></title>
41 <script type="text/javascript" src="../library/js/jquery-1.5.js"></script>
42 <script type="text/javascript" src="../library/js/jquery.gritter.min.js"></script>
44 <link rel="stylesheet" type="text/css" href="css/jquery.gritter.css" />
45 <link rel="stylesheet" type="text/css" href="css/base.css" />
47 <script type="text/javascript">
48 function process() {
50 if (!(validate())) {
51 alert ('<?php echo addslashes( xl('Field(s) are missing!') ); ?>');
52 return false;
54 document.getElementById('code').value = SHA1(document.getElementById('pass').value);
55 document.getElementById('pass').value='';
57 function validate() {
58 var pass=true;
59 if (document.getElementById('uname').value == "") {
60 document.getElementById('uname').style.border = "1px solid red";
61 pass=false;
63 if (document.getElementById('pass').value == "") {
64 document.getElementById('pass').style.border = "1px solid red";
65 pass=false;
67 return pass;
69 function process_new_pass() {
71 if (!(validate_new_pass())) {
72 alert ('<?php echo addslashes( xl('Field(s) are missing!') ); ?>');
73 return false;
75 if (document.getElementById('pass_new').value != document.getElementById('pass_new_confirm').value) {
76 alert ('<?php echo addslashes( xl('The new password fields are not the same.') ); ?>');
77 return false;
79 if (document.getElementById('pass').value == document.getElementById('pass_new').value) {
80 alert ('<?php echo addslashes( xl('The new password can not be the same as the current password.') ); ?>');
81 return false;
83 document.getElementById('code').value = SHA1(document.getElementById('pass').value);
84 document.getElementById('pass').value='';
85 document.getElementById('code_new').value = SHA1(document.getElementById('pass_new').value);
86 document.getElementById('pass_new').value='';
87 document.getElementById('code_new_confirm').value = SHA1(document.getElementById('pass_new_confirm').value);
88 document.getElementById('pass_new_confirm').value='';
90 function validate_new_pass() {
91 var pass=true;
92 if (document.getElementById('uname').value == "") {
93 document.getElementById('uname').style.border = "1px solid red";
94 pass=false;
96 if (document.getElementById('pass').value == "") {
97 document.getElementById('pass').style.border = "1px solid red";
98 pass=false;
100 if (document.getElementById('pass_new').value == "") {
101 document.getElementById('pass_new').style.border = "1px solid red";
102 pass=false;
104 if (document.getElementById('pass_new_confirm').value == "") {
105 document.getElementById('pass_new_confirm').style.border = "1px solid red";
106 pass=false;
108 return pass;
110 </script>
111 <style type="text/css">
112 body {
113 font-family: sans-serif;
114 background-color: #638fd0;
116 background: -webkit-radial-gradient(circle, white, #638fd0);
117 background: -moz-radial-gradient(circle, white, #638fd0);
120 </style>
123 </head>
124 <body>
125 <br><br>
126 <center>
128 <?php if (isset($_SESSION['password_update'])) { ?>
129 <div id="wrapper" class="centerwrapper">
130 <h2 class="title"><?php echo htmlspecialchars( xl('Please Enter a New Password'), ENT_NOQUOTES); ?></h2>
131 <form action="get_patient_info.php" method="POST" onsubmit="return process_new_pass()" >
132 <table>
133 <tr>
134 <td class="algnRight"><?php echo htmlspecialchars( xl('User Name'), ENT_NOQUOTES); ?></td>
135 <td><input name="uname" id="uname" type="text" /></td>
136 </tr>
137 <tr>
138 <td class="algnRight"><?php echo htmlspecialchars( xl('Current Password'), ENT_NOQUOTES);?></>
139 <td>
140 <input name="pass" id="pass" type="password" />
141 <input type="hidden" id="code" name="code" type="hidden" />
142 </td>
143 </tr>
144 <tr>
145 <td class="algnRight"><?php echo htmlspecialchars( xl('New Password'), ENT_NOQUOTES);?></>
146 <td>
147 <input name="pass_new" id="pass_new" type="password" />
148 <input type="hidden" id="code_new" name="code_new" type="hidden" />
149 </td>
150 </tr>
151 <tr>
152 <td class="algnRight"><?php echo htmlspecialchars( xl('Confirm New Password'), ENT_NOQUOTES);?></>
153 <td>
154 <input name="pass_new_confirm" id="pass_new_confirm" type="password" />
155 <input type="hidden" id="code_new_confirm" name="code_new_confirm" type="hidden" />
156 </td>
157 </tr>
158 <tr>
159 <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars( xl('Log In'), ENT_QUOTES);?>" /></center></td>
160 </tr>
161 </table>
162 </form>
164 <div class="copyright"><?php echo htmlspecialchars( xl('Powered by'), ENT_NOQUOTES);?> <a href="../../">OpenEMR</a></div>
165 </div>
166 <?php } else { ?>
167 <div id="wrapper" class="centerwrapper">
168 <h2 class="title"><?php echo htmlspecialchars( xl('Access your patient information'), ENT_NOQUOTES); ?></h2>
169 <form action="get_patient_info.php" method="POST" onsubmit="return process()" >
170 <table>
171 <tr>
172 <td class="algnRight"><?php echo htmlspecialchars( xl('User Name'), ENT_NOQUOTES); ?></td>
173 <td><input name="uname" id="uname" type="text" /></td>
174 </tr>
175 <tr>
176 <td class="algnRight"><?php echo htmlspecialchars( xl('Password'), ENT_NOQUOTES);?></>
177 <td>
178 <input name="pass" id="pass" type="password" />
179 <input type="hidden" id="code" name="code" type="hidden" />
180 </td>
181 </tr>
182 <tr>
183 <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars( xl('Log In'), ENT_QUOTES);?>" /></center></td>
184 </tr>
185 </table>
186 </form>
188 <div class="copyright"><?php echo htmlspecialchars( xl('Powered by'), ENT_NOQUOTES);?> <a href="../../">OpenEMR</a></div>
189 </div>
190 <?php } ?>
192 </center>
194 <script type="text/javascript">
195 $(document).ready(function() {
197 <?php // if something went wrong
198 if (isset($_GET['w'])) { ?>
199 var unique_id = $.gritter.add({
200 title: '<span class="red"><?php echo htmlspecialchars( xl('Oops!'), ENT_QUOTES);?></span>',
201 text: '<?php echo htmlspecialchars( xl('Something went wrong. Please try again.', ENT_QUOTES)); ?>',
202 sticky: false,
203 time: '5000',
204 class_name: 'my-nonsticky-class'
205 });
206 <?php } ?>
208 <?php // if successfully logged out
209 if (isset($_GET['logout'])) { ?>
210 var unique_id = $.gritter.add({
211 title: '<span class="green"><?php echo htmlspecialchars( xl('Success'), ENT_QUOTES);?></span>',
212 text: '<?php echo htmlspecialchars( xl('You have been successfully logged out.'), ENT_QUOTES);?>',
213 sticky: false,
214 time: '5000',
215 class_name: 'my-nonsticky-class'
216 });
217 <?php } ?>
218 return false;
221 </script>
223 </body>
224 </html>