PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/patients/index.php

https://github.com/HanPH/openemr
PHP | 224 lines | 183 code | 26 blank | 15 comment | 24 complexity | b62bbc50894badc9688ac13c7756546a MD5 | raw file
  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.
  8. //setting the session & other config options
  9. session_start();
  10. //don't require standard openemr authorization in globals.php
  11. $ignoreAuth = 1;
  12. //SANITIZE ALL ESCAPES
  13. $fake_register_globals=false;
  14. //STOP FAKE REGISTER GLOBALS
  15. $sanitize_all_escapes=true;
  16. //includes
  17. require_once('../interface/globals.php');
  18. require_once("$srcdir/sha1.js");
  19. //
  20. //exit if portal is turned off
  21. if ( !(isset($GLOBALS['portal_onsite_enable'])) || !($GLOBALS['portal_onsite_enable']) ) {
  22. echo htmlspecialchars( xl('Patient Portal is turned off'), ENT_NOQUOTES);
  23. exit;
  24. }
  25. // security measure -- will check on next page.
  26. $_SESSION['itsme'] = 1;
  27. //
  28. ?>
  29. <html>
  30. <head>
  31. <title><?php echo htmlspecialchars( xl('Patient Portal Login'), ENT_NOQUOTES); ?></title>
  32. <script type="text/javascript" src="../library/js/jquery-1.5.js"></script>
  33. <script type="text/javascript" src="../library/js/jquery.gritter.min.js"></script>
  34. <link rel="stylesheet" type="text/css" href="css/jquery.gritter.css" />
  35. <link rel="stylesheet" type="text/css" href="css/base.css" />
  36. <script type="text/javascript">
  37. function process() {
  38. if (!(validate())) {
  39. alert ('<?php echo addslashes( xl('Field(s) are missing!') ); ?>');
  40. return false;
  41. }
  42. document.getElementById('code').value = SHA1(document.getElementById('pass').value);
  43. document.getElementById('pass').value='';
  44. }
  45. function validate() {
  46. var pass=true;
  47. if (document.getElementById('uname').value == "") {
  48. document.getElementById('uname').style.border = "1px solid red";
  49. pass=false;
  50. }
  51. if (document.getElementById('pass').value == "") {
  52. document.getElementById('pass').style.border = "1px solid red";
  53. pass=false;
  54. }
  55. return pass;
  56. }
  57. function process_new_pass() {
  58. if (!(validate_new_pass())) {
  59. alert ('<?php echo addslashes( xl('Field(s) are missing!') ); ?>');
  60. return false;
  61. }
  62. if (document.getElementById('pass_new').value != document.getElementById('pass_new_confirm').value) {
  63. alert ('<?php echo addslashes( xl('The new password fields are not the same.') ); ?>');
  64. return false;
  65. }
  66. if (document.getElementById('pass').value == document.getElementById('pass_new').value) {
  67. alert ('<?php echo addslashes( xl('The new password can not be the same as the current password.') ); ?>');
  68. return false;
  69. }
  70. document.getElementById('code').value = SHA1(document.getElementById('pass').value);
  71. document.getElementById('pass').value='';
  72. document.getElementById('code_new').value = SHA1(document.getElementById('pass_new').value);
  73. document.getElementById('pass_new').value='';
  74. document.getElementById('code_new_confirm').value = SHA1(document.getElementById('pass_new_confirm').value);
  75. document.getElementById('pass_new_confirm').value='';
  76. }
  77. function validate_new_pass() {
  78. var pass=true;
  79. if (document.getElementById('uname').value == "") {
  80. document.getElementById('uname').style.border = "1px solid red";
  81. pass=false;
  82. }
  83. if (document.getElementById('pass').value == "") {
  84. document.getElementById('pass').style.border = "1px solid red";
  85. pass=false;
  86. }
  87. if (document.getElementById('pass_new').value == "") {
  88. document.getElementById('pass_new').style.border = "1px solid red";
  89. pass=false;
  90. }
  91. if (document.getElementById('pass_new_confirm').value == "") {
  92. document.getElementById('pass_new_confirm').style.border = "1px solid red";
  93. pass=false;
  94. }
  95. return pass;
  96. }
  97. </script>
  98. <style type="text/css">
  99. body {
  100. font-family: sans-serif;
  101. background-color: #638fd0;
  102. background: -webkit-radial-gradient(circle, white, #638fd0);
  103. background: -moz-radial-gradient(circle, white, #638fd0);
  104. }
  105. </style>
  106. </head>
  107. <body>
  108. <br><br>
  109. <center>
  110. <?php if (isset($_SESSION['password_update'])) { ?>
  111. <div id="wrapper" class="centerwrapper">
  112. <h2 class="title"><?php echo htmlspecialchars( xl('Please Enter a New Password'), ENT_NOQUOTES); ?></h2>
  113. <form action="get_patient_info.php" method="POST" onsubmit="return process_new_pass()" >
  114. <table>
  115. <tr>
  116. <td class="algnRight"><?php echo htmlspecialchars( xl('User Name'), ENT_NOQUOTES); ?></td>
  117. <td><input name="uname" id="uname" type="text" /></td>
  118. </tr>
  119. <tr>
  120. <td class="algnRight"><?php echo htmlspecialchars( xl('Current Password'), ENT_NOQUOTES);?></>
  121. <td>
  122. <input name="pass" id="pass" type="password" />
  123. <input type="hidden" id="code" name="code" type="hidden" />
  124. </td>
  125. </tr>
  126. <tr>
  127. <td class="algnRight"><?php echo htmlspecialchars( xl('New Password'), ENT_NOQUOTES);?></>
  128. <td>
  129. <input name="pass_new" id="pass_new" type="password" />
  130. <input type="hidden" id="code_new" name="code_new" type="hidden" />
  131. </td>
  132. </tr>
  133. <tr>
  134. <td class="algnRight"><?php echo htmlspecialchars( xl('Confirm New Password'), ENT_NOQUOTES);?></>
  135. <td>
  136. <input name="pass_new_confirm" id="pass_new_confirm" type="password" />
  137. <input type="hidden" id="code_new_confirm" name="code_new_confirm" type="hidden" />
  138. </td>
  139. </tr>
  140. <tr>
  141. <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars( xl('Log In'), ENT_QUOTES);?>" /></center></td>
  142. </tr>
  143. </table>
  144. </form>
  145. <div class="copyright"><?php echo htmlspecialchars( xl('Powered by'), ENT_NOQUOTES);?> <a href="../../">OpenEMR</a></div>
  146. </div>
  147. <?php } else { ?>
  148. <div id="wrapper" class="centerwrapper">
  149. <h2 class="title"><?php echo htmlspecialchars( xl('Patient Portal Login'), ENT_NOQUOTES); ?></h2>
  150. <form action="get_patient_info.php" method="POST" onsubmit="return process()" >
  151. <table>
  152. <tr>
  153. <td class="algnRight"><?php echo htmlspecialchars( xl('User Name'), ENT_NOQUOTES); ?></td>
  154. <td><input name="uname" id="uname" type="text" /></td>
  155. </tr>
  156. <tr>
  157. <td class="algnRight"><?php echo htmlspecialchars( xl('Password'), ENT_NOQUOTES);?></>
  158. <td>
  159. <input name="pass" id="pass" type="password" />
  160. <input type="hidden" id="code" name="code" type="hidden" />
  161. </td>
  162. </tr>
  163. <tr>
  164. <td colspan=2><br><center><input type="submit" value="<?php echo htmlspecialchars( xl('Log In'), ENT_QUOTES);?>" /></center></td>
  165. </tr>
  166. </table>
  167. </form>
  168. <div class="copyright"><?php echo htmlspecialchars( xl('Powered by'), ENT_NOQUOTES);?> <a href="../../">OpenEMR</a></div>
  169. </div>
  170. <?php } ?>
  171. </center>
  172. <script type="text/javascript">
  173. $(document).ready(function() {
  174. <?php // if something went wrong
  175. if (isset($_GET['w'])) { ?>
  176. var unique_id = $.gritter.add({
  177. title: '<span class="red"><?php echo htmlspecialchars( xl('Oops!'), ENT_QUOTES);?></span>',
  178. text: '<?php echo htmlspecialchars( xl('Something went wrong. Please try again.', ENT_QUOTES)); ?>',
  179. sticky: false,
  180. time: '5000',
  181. class_name: 'my-nonsticky-class'
  182. });
  183. <?php } ?>
  184. <?php // if successfully logged out
  185. if (isset($_GET['logout'])) { ?>
  186. var unique_id = $.gritter.add({
  187. title: '<span class="green"><?php echo htmlspecialchars( xl('Success'), ENT_QUOTES);?></span>',
  188. text: '<?php echo htmlspecialchars( xl('You have been successfully logged out.'), ENT_QUOTES);?>',
  189. sticky: false,
  190. time: '5000',
  191. class_name: 'my-nonsticky-class'
  192. });
  193. <?php } ?>
  194. return false;
  195. });
  196. </script>
  197. </body>
  198. </html>