PageRenderTime 50ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/portal/account/verify.php

https://github.com/bradymiller/openemr
PHP | 197 lines | 161 code | 18 blank | 18 comment | 26 complexity | 75710553bf940249b7f9ad2bcdce3395 MD5 | raw file
Possible License(s): GPL-3.0, Apache-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /**
  3. * Portal Verify Email
  4. *
  5. * @package OpenEMR
  6. * @link http://www.open-emr.org
  7. * @author Jerry Padgett <sjpadgett@gmail.com>
  8. * @author Brady Miller <brady.g.miller@gmail.com>
  9. * @copyright Copyright (c) 2017-2019 Jerry Padgett <sjpadgett@gmail.com>
  10. * @copyright Copyright (c) 2019-2022 Brady Miller <brady.g.miller@gmail.com>
  11. * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
  12. */
  13. use OpenEMR\Common\Csrf\CsrfUtils;
  14. use OpenEMR\Core\Header;
  15. use OpenEMR\Common\Logging\SystemLogger;
  16. // Will start the (patient) portal OpenEMR session/cookie.
  17. require_once(dirname(__FILE__) . "/../../src/Common/Session/SessionUtil.php");
  18. OpenEMR\Common\Session\SessionUtil::portalSessionStart();
  19. session_regenerate_id(true);
  20. unset($_SESSION['itsme']);
  21. $_SESSION['verifyPortalEmail'] = true;
  22. $ignoreAuth_onsite_portal = true;
  23. require_once("../../interface/globals.php");
  24. $landingpage = "../index.php?site=" . urlencode($_SESSION['site_id']);
  25. if (empty($GLOBALS['portal_onsite_two_register']) || empty($GLOBALS['google_recaptcha_site_key']) || empty($GLOBALS['google_recaptcha_secret_key'])) {
  26. OpenEMR\Common\Session\SessionUtil::portalSessionCookieDestroy();
  27. echo xlt("Not Authorized");
  28. header('HTTP/1.1 401 Unauthorized');
  29. die();
  30. }
  31. // set up csrf
  32. CsrfUtils::setupCsrfKey();
  33. $res2 = sqlStatement("select * from lang_languages where lang_description = ?", array(
  34. $GLOBALS['language_default']
  35. ));
  36. for ($iter = 0; $row = sqlFetchArray($res2); $iter++) {
  37. $result2[$iter] = $row;
  38. }
  39. if (count($result2) == 1) {
  40. $defaultLangID = $result2[0]["lang_id"];
  41. $defaultLangName = $result2[0]["lang_description"];
  42. } else {
  43. // default to english if any problems
  44. $defaultLangID = 1;
  45. $defaultLangName = "English";
  46. }
  47. if (!isset($_SESSION['language_choice'])) {
  48. $_SESSION['language_choice'] = $defaultLangID;
  49. }
  50. // collect languages if showing language menu
  51. if ($GLOBALS['language_menu_login']) {
  52. // sorting order of language titles depends on language translation options.
  53. $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
  54. // Use and sort by the translated language name.
  55. $sql = "SELECT ll.lang_id, " . "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " . "ll.lang_description " .
  56. "FROM lang_languages AS ll " . "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
  57. "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " . "ld.lang_id = ? " .
  58. "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
  59. $res3 = SqlStatement($sql, array(
  60. $mainLangID
  61. ));
  62. for ($iter = 0; $row = sqlFetchArray($res3); $iter++) {
  63. $result3[$iter] = $row;
  64. }
  65. if (count($result3) == 1) {
  66. // default to english if only return one language
  67. $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='1' />\n";
  68. }
  69. } else {
  70. $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='" . attr($defaultLangID) . "' />\n";
  71. }
  72. ?>
  73. <!DOCTYPE html>
  74. <html>
  75. <head>
  76. <title><?php echo xlt('New Patient'); ?> | <?php echo xlt('Register'); ?></title>
  77. <meta name="description" content="Developed By sjpadgett@gmail.com" />
  78. <?php Header::setupHeader(['no_main-theme', 'datetime-picker', 'patientportal-style', 'patientportal-register']); ?>
  79. <script src="https://www.google.com/recaptcha/api.js" async defer></script>
  80. <script>
  81. function enableVerifyBtn(){
  82. document.getElementById("verifyBtn").disabled = false;
  83. }
  84. </script>
  85. </head>
  86. <body class="mt-4 skin-blue">
  87. <div class="container-lg">
  88. <h1 class="text-center"><?php echo xlt('Account Registration'); ?></h1>
  89. <div class="stepwiz">
  90. <div class="stepwiz-row setup-panel">
  91. <div class="stepwiz-step">
  92. <a href="#step-1" type="button" class="btn btn-primary btn-circle">1</a>
  93. <p><?php echo xlt('Verify Email') ?></p>
  94. </div>
  95. <div class="stepwiz-step">
  96. <a href="#step-2" type="button" class="btn btn-light btn-circle disabled">2</a>
  97. <p><?php echo xlt('Profile') ?></p>
  98. </div>
  99. <div class="stepwiz-step">
  100. <a href="#step-3" type="button" class="btn btn-light btn-circle disabled">3</a>
  101. <p><?php echo xlt('Insurance') ?></p>
  102. </div>
  103. <div class="stepwiz-step">
  104. <a href="#step-4" type="button" class="btn btn-light btn-circle disabled">4</a>
  105. <p><?php echo xlt('Register') ?></p>
  106. </div>
  107. </div>
  108. </div>
  109. <!-- // Start Forms // -->
  110. <form id="startForm" role="form" action="account.php?action=verify_email" method="post">
  111. <input type='hidden' name='csrf_token_form' value='<?php echo attr(CsrfUtils::collectCsrfToken('verifyEmailCsrf')); ?>' />
  112. <div class="text-center setup-content" id="step-1">
  113. <legend class="bg-primary text-white"><?php echo xlt('Contact Information') ?></legend>
  114. <div class="jumbotron">
  115. <?php if ($GLOBALS['language_menu_login'] && (count($result3) != 1)) { ?>
  116. <div class="form-group">
  117. <label class="col-form-label" for="selLanguage"><?php echo xlt('Language'); ?></label>
  118. <select class="form-control" id="selLanguage" name="languageChoice">
  119. <?php
  120. echo "<option selected='selected' value='" . attr($defaultLangID) . "'>" .
  121. text(xl('Default') . " - " . xl($defaultLangName)) . "</option>\n";
  122. foreach ($result3 as $iter) {
  123. if ($GLOBALS['language_menu_showall']) {
  124. if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
  125. continue; // skip the dummy language
  126. }
  127. echo "<option value='" . attr($iter['lang_id']) . "'>" .
  128. text($iter['trans_lang_description']) . "</option>\n";
  129. } else {
  130. if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
  131. if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
  132. continue; // skip the dummy language
  133. }
  134. echo "<option value='" . attr($iter['lang_id']) . "'>" .
  135. text($iter['trans_lang_description']) . "</option>\n";
  136. }
  137. }
  138. }
  139. ?>
  140. </select>
  141. </div>
  142. <?php } else {
  143. echo $hiddenLanguageField;
  144. }
  145. ?>
  146. <div class="form-row">
  147. <div class="col-12 col-md-6 col-lg-3 form-group">
  148. <label for="fname"><?php echo xlt('First Name') ?></label>
  149. <input type="text" class="form-control" id="fname" name="fname" required placeholder="<?php echo xla('First Name'); ?>" />
  150. </div>
  151. <div class="col-12 col-md-6 col-lg-3 form-group">
  152. <label for="mname"><?php echo xlt('Middle Name') ?></label>
  153. <input type="text" class="form-control" id="mname" name="mname" placeholder="<?php echo xla('Full or Initial'); ?>" />
  154. </div>
  155. <div class="col-12 col-md-6 col-lg-3 form-group">
  156. <label for="lname"><?php echo xlt('Last Name') ?></label>
  157. <input type="text" class="form-control" id="lname" name="lname" required placeholder="<?php echo xla('Enter Last'); ?>" />
  158. </div>
  159. <div class="col-12 col-md-6 col-lg-3 form-group">
  160. <label for="dob"><?php echo xlt('Birth Date') ?></label>
  161. <input id="dob" type="text" required class="form-control datepicker" name="dob" placeholder="<?php echo xla('YYYY-MM-DD'); ?>" />
  162. </div>
  163. </div>
  164. <div class="form-group">
  165. <label class="col-form-label" for="emailInput"><?php echo xlt('Enter E-Mail Address') ?></label>
  166. <input id="emailInput" type="email" class="reg-email form-control" name="email" required placeholder="<?php echo xla('Enter email address to receive registration.'); ?>" maxlength="100" />
  167. </div>
  168. <div class="form-group">
  169. <div class="d-flex justify-content-center">
  170. <div class="g-recaptcha" data-sitekey="<?php echo attr($GLOBALS['google_recaptcha_site_key']); ?>" data-callback="enableVerifyBtn"></div>
  171. </div>
  172. </div>
  173. </div>
  174. <button type="submit" id="verifyBtn" class="btn btn-primary pull-right mb-5" type="button" disabled="disabled"><?php echo xlt('Verify Email') ?></button>
  175. </div>
  176. </form>
  177. </div>
  178. </body>
  179. </html>