7 * @link https://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author ophthal <magauran@ophthal.org>
10 * @author JP-DEV\sjpad <sjpadgett@gmail.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2007-2015 Rod Roark <rod@sunsetsystems.com>
13 * @copyright Copyright (c) 2016 ophthal <magauran@ophthal.org>
14 * @copyright Copyright (c) 2017 JP-DEV\sjpad <sjpadgett@gmail.com>
15 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
16 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
19 use OpenEMR\Common\Csrf\CsrfUtils
;
22 // login.php makes sure the session ID captured here is different for each
23 // new login. We maintain it here because most browsers do not have separate
24 // cookie storage for different top-level windows. This function should be
25 // called just prior to invoking any server script that requires correct
26 // session data. onclick="top.restoreSession()" usually does the job.
28 var oemr_session_name
= <?php
echo json_encode(urlencode(session_name())); ?
>;
29 var oemr_session_id
= <?php
echo json_encode(urlencode(session_id())); ?
>;
30 var oemr_dialog_close_msg
= <?php
echo (function_exists('xlj')) ?
xlj("OK to close this other popup window?") : json_encode("OK to close this other popup window?"); ?
>;
32 function restoreSession() {
33 <?php
if (!empty($GLOBALS['restore_sessions'])) { ?
>
34 var ca
= document
.cookie
.split('; ');
35 for (var i
= 0; i
< ca
.length
; ++i
) {
36 var c
= ca
[i
].split('=');
37 if (c
[0] == oemr_session_name
&& c
[1] != oemr_session_id
) {
38 <?php
if ($GLOBALS['restore_sessions'] == 2) { ?
>
39 alert('Changing session ID from\n"' + c
[1] +
'" to\n"' + oemr_session_id +
'"');
41 <?php
if (version_compare(phpversion(), '7.3.0', '>=')) { ?
>
42 // Using the SameSite setting when using php version 7.3.0 or above
43 document
.cookie
= oemr_session_name +
'=' + oemr_session_id +
'; path=<?php echo($web_root ? $web_root : '/'); ?>' +
'; SameSite=Strict';
45 document
.cookie
= oemr_session_name +
'=' + oemr_session_id +
'; path=<?php echo($web_root ? $web_root : '/'); ?>';
53 // Pages that have a Print button or link should call this to initialize it for logging.
54 // This is done at page load time in case we want to hide or disable the element.
55 // The second argument, if present, specifies a log message to be used instead of logging
56 // the entire document and will always prevent hiding of the button or link.
58 function printLogSetup(elem
, logdata
) {
59 if (elem
== null) return;
60 var doc
= elem
.ownerDocument
;
61 var win
= doc
.defaultView || doc
.parentWindow
;
62 if (typeof(logdata
) == 'undefined') logdata
= null;
63 <?php
if ($GLOBALS['gbl_print_log_option'] == 1) { ?
>
64 if (logdata
== null) {
65 elem
.style
.display
= 'none';
69 win
.printlogdata
= logdata
;
70 elem
.onclick
= function () {
71 // This is a function definition and variables here will be evaluated when the function executes.
72 top
.printLogPrint(this
);
76 // Pages that would otherwise call window.print() at load time should call this instead
77 // to support print logging. In this case the passed argument is normally the window,
78 // and data to log, if specified, should be in the caller's window.printlogdata.
79 // If no log data is specified and the global option to hide the print feature is set,
80 // then no printing is done and the function returns false.
82 function printLogPrint(elem
) {
84 if (elem
.ownerDocument
) {
85 var doc
= elem
.ownerDocument
;
86 win
= doc
.defaultView || doc
.parentWindow
;
88 <?php
if ($GLOBALS['gbl_print_log_option'] == 1) { ?
>
89 // Returning false means we didn't print.
90 if (!win
.printlogdata
) return false;
92 if (win
.printlog_before_print
) win
.printlog_before_print();
94 <?php
if (!empty($GLOBALS['gbl_print_log_option'])) { ?
>
95 comments
= win
.printlogdata || win
.document
.body
.innerHTML
;
97 $
.post("<?php echo $GLOBALS['webroot']; ?>/library/ajax/log_print_action_ajax.php",
100 csrf_token_form
: <?php
echo json_encode(CsrfUtils
::collectCsrfToken()); ?
>