fixed therapy groups permissions
[openemr.git] / portal / index.php
blobb18787534d5ab238083a96bd87b5c758d7c586ea
1 <?php
2 /**
4 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
5 * Copyright (C) 2011 Cassian LUP <cassi.lup@gmail.com>
7 * LICENSE: This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @package OpenEMR
21 * @author Jerry Padgett <sjpadgett@gmail.com>
22 * @author Cassian LUP <cassi.lup@gmail.com>
23 * @link http://www.open-emr.org
26 //setting the session & other config options
27 session_start();
29 //don't require standard openemr authorization in globals.php
30 $ignoreAuth = 1;
32 //For redirect if the site on session does not match
33 $landingpage = "index.php?site=".$_GET['site'];
35 //includes
36 require_once('../interface/globals.php');
38 ini_set("error_log", E_ERROR || ~E_NOTICE);
39 //exit if portal is turned off
40 if (!(isset($GLOBALS['portal_onsite_two_enable'])) || !($GLOBALS['portal_onsite_two_enable'])) {
41 echo htmlspecialchars(xl('Patient Portal is turned off'), ENT_NOQUOTES);
42 exit;
45 // security measure -- will check on next page.
46 $_SESSION['itsme'] = 1;
50 // Deal with language selection
52 // collect default language id (skip this if this is a password update)
53 if (!(isset($_SESSION['password_update']))) {
54 $res2 = sqlStatement("select * from lang_languages where lang_description = ?", array($GLOBALS['language_default']));
55 for ($iter = 0; $row = sqlFetchArray($res2); $iter++) {
56 $result2[$iter] = $row;
59 if (count($result2) == 1) {
60 $defaultLangID = $result2[0]{"lang_id"};
61 $defaultLangName = $result2[0]{"lang_description"};
62 } else {
63 //default to english if any problems
64 $defaultLangID = 1;
65 $defaultLangName = "English";
68 // set session variable to default so login information appears in default language
69 $_SESSION['language_choice'] = $defaultLangID;
70 // collect languages if showing language menu
71 if ($GLOBALS['language_menu_login']) {
72 // sorting order of language titles depends on language translation options.
73 $mainLangID = empty($_SESSION['language_choice']) ? '1' : $_SESSION['language_choice'];
74 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation'])) {
75 $sql = "SELECT * FROM lang_languages ORDER BY lang_description, lang_id";
76 $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 = ? " .
86 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
87 $res3=SqlStatement($sql, array($mainLangID));
90 for ($iter = 0; $row = sqlFetchArray($res3); $iter++) {
91 $result3[$iter] = $row;
94 if (count($result3) == 1) {
95 //default to english if only return one language
96 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='1' />\n";
98 } else {
99 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='".htmlspecialchars($defaultLangID, ENT_QUOTES)."' />\n";
105 <html>
106 <head>
107 <title><?php echo xlt('Patient Portal Login'); ?></title>
109 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-11-3/index.js"></script>
110 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/js/jquery.gritter.min.js"></script>
112 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/css/jquery.gritter.css" />
113 <link rel="stylesheet" type="text/css" href="assets/css/base.css?v=<?php echo $v_js_includes; ?>" />
115 <script type="text/javascript">
116 function process() {
118 if (!(validate())) {
119 alert ('<?php echo addslashes(xl('Field(s) are missing!')); ?>');
120 return false;
123 function validate() {
124 var pass=true;
125 if (document.getElementById('uname').value == "") {
126 document.getElementById('uname').style.border = "1px solid red";
127 pass=false;
129 if (document.getElementById('pass').value == "") {
130 document.getElementById('pass').style.border = "1px solid red";
131 pass=false;
133 return pass;
135 function process_new_pass() {
137 if (!(validate_new_pass())) {
138 alert ('<?php echo addslashes(xl('Field(s) are missing!')); ?>');
139 return false;
141 if (document.getElementById('pass_new').value != document.getElementById('pass_new_confirm').value) {
142 alert ('<?php echo addslashes(xl('The new password fields are not the same.')); ?>');
143 return false;
145 if (document.getElementById('pass').value == document.getElementById('pass_new').value) {
146 alert ('<?php echo addslashes(xl('The new password can not be the same as the current password.')); ?>');
147 return false;
151 function validate_new_pass() {
152 var pass=true;
153 if (document.getElementById('uname').value == "") {
154 document.getElementById('uname').style.border = "1px solid red";
155 pass=false;
157 if (document.getElementById('pass').value == "") {
158 document.getElementById('pass').style.border = "1px solid red";
159 pass=false;
161 if (document.getElementById('pass_new').value == "") {
162 document.getElementById('pass_new').style.border = "1px solid red";
163 pass=false;
165 if (document.getElementById('pass_new_confirm').value == "") {
166 document.getElementById('pass_new_confirm').style.border = "1px solid red";
167 pass=false;
169 return pass;
171 </script>
172 <style type="text/css">
173 body {
174 font-family: sans-serif;
175 background-color: #638fd0;
177 background: -webkit-radial-gradient(circle, white, #638fd0);
178 background: -moz-radial-gradient(circle, white, #638fd0);
181 </style>
184 </head>
185 <body>
186 <br><br>
187 <center>
189 <?php if (isset($_SESSION['password_update'])||isset($_GET['password_update'])) {
190 $_SESSION['password_update']=1;
192 <div id="wrapper" class="centerwrapper">
193 <h2 class="title"><?php echo xlt('Please Enter a New Password'); ?></h2>
194 <form action="get_patient_info.php" method="POST" onsubmit="return process_new_pass()" >
195 <table>
196 <tr>
197 <td class="algnRight"><?php echo xlt('User Name'); ?></td>
198 <td><input name="uname" id="uname" type="text" autocomplete="off" value="<?php echo attr($_SESSION['portal_username']); ?>"/></td>
199 </tr>
200 <tr>
201 <td class="algnRight"><?php echo xlt('Current Password');?></>
202 <td>
203 <input name="pass" id="pass" type="password" autocomplete="off" />
204 </td>
205 </tr>
206 <tr>
207 <td class="algnRight"><?php echo xlt('New Password');?></>
208 <td>
209 <input name="pass_new" id="pass_new" type="password" />
210 </td>
211 </tr>
212 <tr>
213 <td class="algnRight"><?php echo xlt('Confirm New Password');?></>
214 <td>
215 <input name="pass_new_confirm" id="pass_new_confirm" type="password" />
216 </td>
217 </tr>
218 <tr>
219 <td colspan=2><br><center><input type="submit" value="<?php echo xlt('Log In');?>" /></center></td>
220 </tr>
221 </table>
222 </form>
224 <div class="copyright"><?php echo xlt('Powered by');?> OpenEMR</div>
226 </div>
228 <?php } else { ?>
229 <div id="wrapper" class="centerwrapper">
230 <h2 class="title"><?php echo xlt('Patient Portal Login'); ?></h2>
231 <form action="get_patient_info.php" method="POST" onsubmit="return process()" >
232 <table>
233 <tr>
234 <td class="algnRight"><?php echo xlt('User Name'); ?></td>
235 <td><input name="uname" id="uname" type="text" autocomplete="on" /></td>
236 </tr>
237 <tr>
238 <td class="algnRight"><?php echo xlt('Password');?></>
239 <td>
240 <input name="pass" id="pass" type="password" required autocomplete="on" /><input name="passaddon" id="passaddon" placeholder="Email" type="email" autocomplete="on" />
241 </td>
242 </tr>
244 <?php if ($GLOBALS['language_menu_login']) { ?>
245 <?php if (count($result3) != 1) { ?>
246 <tr>
247 <td><span class="text"><?php echo xlt('Language'); ?></span></td>
248 <td>
249 <select name=languageChoice size="1">
250 <?php
251 echo "<option selected='selected' value='".htmlspecialchars($defaultLangID, ENT_QUOTES)."'>" . htmlspecialchars(xl('Default') . " - " . xl($defaultLangName), ENT_NOQUOTES) . "</option>\n";
252 foreach ($result3 as $iter) {
253 if ($GLOBALS['language_menu_showall']) {
254 if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
255 continue; // skip the dummy language
258 echo "<option value='".htmlspecialchars($iter['lang_id'], ENT_QUOTES)."'>".htmlspecialchars($iter['trans_lang_description'], ENT_NOQUOTES)."</option>\n";
259 } else {
260 if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
261 if (!$GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
262 continue; // skip the dummy language
265 echo "<option value='".htmlspecialchars($iter['lang_id'], ENT_QUOTES)."'>".htmlspecialchars($iter['trans_lang_description'], ENT_NOQUOTES)."</option>\n";
270 </select>
271 </td>
272 </tr>
273 <?php }
274 } ?>
276 <tr>
277 <td colspan=2><br><center><input type="submit" value="<?php echo xlt('Log In');?>" /></center></td>
278 </tr>
279 </table>
280 <?php if (!(empty($hiddenLanguageField))) {
281 echo $hiddenLanguageField;
282 } ?>
283 </form>
285 <div class="copyright"><?php echo xlt('Powered by');?> OpenEMR</div>
286 </div><div><img src='<?php echo $GLOBALS['images_static_relative']; ?>/logo-full-con.png'/></div>
287 <?php } ?>
289 </center>
291 <script type="text/javascript">
292 $(document).ready(function() {
294 <?php // if something went wrong
295 if (isset($_GET['w'])) { ?>
296 var unique_id = $.gritter.add({
297 title: '<span class="red"><?php echo xlt('Oops!');?></span>',
298 text: '<?php echo xlt('Something went wrong. Please try again.'); ?>',
299 sticky: false,
300 time: '5000',
301 class_name: 'my-nonsticky-class'
303 <?php } ?>
305 <?php // if successfully logged out
306 if (isset($_GET['logout'])) { ?>
307 var unique_id = $.gritter.add({
308 title: '<span class="green"><?php echo xlt('Success');?></span>',
309 text: '<?php echo xlt('You have been successfully logged out.');?>',
310 sticky: false,
311 time: '5000',
312 class_name: 'my-nonsticky-class'
314 <?php } ?>
315 return false;
318 </script>
320 </body>
321 </html>