4 * interface/logview/erx_logview.php Display NewCrop errors.
8 * @link http://www.open-emr.org
9 * @author Eldho Chacko <eldho@zhservices.com>
10 * @author Vinish K <vinish@zhservices.com>
11 * @author Sam Likins <sam.likins@wsi-services.com>
12 * @author Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2011 ZMG LLC <sam@zhservices.com>
14 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
15 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
18 require_once(__DIR__
. '/../globals.php');
20 use OpenEMR\Common\Csrf\CsrfUtils
;
21 use OpenEMR\Core\Header
;
23 $error_log_path = $GLOBALS['OE_SITE_DIR'] . '/documents/erx_error';
25 if (array_key_exists('filename', $_GET)) {
26 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
27 CsrfUtils
::csrfNotVerified();
30 $filename = $_GET['filename'];
31 check_file_dir_name($filename);
36 if (array_key_exists('start_date', $_POST)) {
37 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
38 CsrfUtils
::csrfNotVerified();
41 $start_date = $_POST['start_date'];
42 check_file_dir_name($start_date); // this is incorporated into filename when seeking, so will check it
50 preg_match('/erx_error-\d{4}-\d{1,2}-\d{1,2}\.log/', $filename, $matches);
53 if ($fd = fopen($error_log_path . '/' . $filename, 'r')) {
54 $bat_content = fread($fd, filesize($error_log_path . '/' . $filename));
57 header('Pragma: public');
59 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
60 header('Content-Type: application/force-download');
61 header('Content-Disposition: attachment; filename=' . $filename);
62 header('Content-Description: File Transfer');
63 header('Content-Length: ' . strlen($bat_content));
74 <?php Header
::setupHeader('datetime-picker'); ?
>
78 $
('.datepicker').datetimepicker({
79 <?php
$datetimepicker_timepicker = false; ?
>
80 <?php
$datetimepicker_showseconds = false; ?
>
81 <?php
$datetimepicker_formatInput = false; ?
>
82 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
83 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
89 <body
class="body_top">
91 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
93 <span
class="title"><?php
echo xlt('eRx Logs'); ?
></span
><br
/><br
/>
97 <span
class="text"><?php
echo xlt('Date'); ?
>: </span
>
100 <input type
="text" size
="10" class='datepicker' name
="start_date" id
="start_date" value
="<?php echo $start_date ? attr(substr($start_date, 0, 10)) : date('Y-m-d'); ?>" title
="<?php echo xla('yyyy-mm-dd Date of service'); ?>" />
103 <input type
="submit" class="btn btn-primary btn-sm" name
="search_logs" value
="<?php echo xla('Search'); ?>" />
111 if (array_key_exists('search_logs', $_POST)) {
112 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
113 CsrfUtils
::csrfNotVerified();
116 if ($handle = opendir($error_log_path)) {
117 while (false !== ($file = readdir($handle))) {
118 $file_as_in_folder = 'erx_error-' . $start_date . '.log';
120 if ($file != '.' && $file != '..' && $file_as_in_folder == $file) {
122 $fd = fopen($error_log_path . '/' . $file, 'r');
123 $bat_content = fread($fd, filesize($error_log_path . '/' . $file));
125 <p
><?php
echo xlt('Download'); ?
>: <a href
="erx_logview.php?filename=<?php echo attr_url($file); ?>&csrf_token_form=<?php echo attr_url(CsrfUtils::collectCsrfToken()); ?>"><?php
echo text($file); ?
></a
></p
>
126 <textarea rows
="35" cols
="132"><?php
echo text($bat_content); ?
></textarea
>
132 if ($check_for_file == 0) {
133 echo xlt('No log file exist for the selected date') . ': ' . text($start_date);