Moved recent v5.0.0 statement fix to current master.
[openemr.git] / interface / logview / erx_logview.php
blobc25d4fa0a9bf8881740a86c6b943fb035b30fb97
1 <?php
2 /**
3 * interface/logview/erx_logview.php Display NewCrop errors.
5 * @package OpenEMR
6 * @subpackage NewCrop
7 * @link http://www.open-emr.org
8 * @author Eldho Chacko <eldho@zhservices.com>
9 * @author Vinish K <vinish@zhservices.com>
10 * @author Sam Likins <sam.likins@wsi-services.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2011 ZMG LLC <sam@zhservices.com>
13 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once(__DIR__.'/../globals.php');
18 require_once($srcdir.'/log.inc');
20 $error_log_path = $GLOBALS['OE_SITE_DIR'].'/documents/erx_error';
22 if (array_key_exists('filename', $_REQUEST)) {
23 $filename = $_REQUEST['filename'];
24 } else {
25 $filename = '';
28 if (array_key_exists('start_date', $_REQUEST)) {
29 $start_date = $_REQUEST['start_date'];
30 } else {
31 $start_date = '';
34 if ($filename) {
35 $bat_content = '';
37 preg_match('/erx_error-\d{4}-\d{1,2}-\d{1,2}\.log/', $filename, $matches);
39 if ($matches) {
40 if ($fd = fopen($error_log_path.'/'.$filename, 'r')) {
41 $bat_content = fread($fd, filesize($error_log_path.'/'.$filename));
44 header('Pragma: public');
45 header('Expires: 0');
46 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
47 header('Content-Type: application/force-download');
48 header('Content-Disposition: attachment; filename='.$filename);
49 header('Content-Description: File Transfer');
50 header('Content-Length: '.strlen($bat_content));
52 echo $bat_content;
54 die;
59 <html>
60 <head>
61 <?php html_header_show(); ?>
62 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
63 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
65 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
66 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
67 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
69 <script language="JavaScript">
70 $(document).ready(function(){
71 $('.datepicker').datetimepicker({
72 <?php $datetimepicker_timepicker = false; ?>
73 <?php $datetimepicker_showseconds = false; ?>
74 <?php $datetimepicker_formatInput = false; ?>
75 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
76 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
77 });
78 });
79 </script>
81 </head>
82 <body class="body_top">
83 <form method="post">
84 <font class="title"><?php echo xlt('eRx Logs'); ?></font><br><br>
85 <table>
86 <tr>
87 <td>
88 <span class="text"><?php echo xlt('Date'); ?>: </span>
89 </td>
90 <td>
91 <input type="text" size="10" class='datepicker' name="start_date" id="start_date" value="<?php echo $start_date ? substr($start_date, 0, 10) : date('Y-m-d'); ?>" title="<?php echo xlt('yyyy-mm-dd Date of service'); ?>" />
92 </td>
93 <td>
94 <input type="submit" name="search_logs" value="<?php echo xlt('Search'); ?>">
95 </td>
96 </tr>
97 </table>
98 </form>
99 <?php
101 $check_for_file = 0;
102 if (array_key_exists('search_logs', $_REQUEST)) {
103 if ($handle = opendir($error_log_path)) {
104 while (false !== ($file = readdir($handle))) {
105 $file_as_in_folder = 'erx_error-'.$start_date.'.log';
107 if ($file != '.' && $file != '..' && $file_as_in_folder == $file) {
108 $check_for_file = 1;
109 $fd = fopen($error_log_path.'/'.$file, 'r');
110 $bat_content = fread($fd, filesize($error_log_path.'/'.$file));
112 <p><?php echo xlt('Download'); ?>: <a href="erx_logview.php?filename=<?php echo htmlspecialchars($file, ENT_QUOTES); ?>"><?php echo htmlspecialchars($file, ENT_NOQUOTES); ?></a></p>
113 <textarea rows="35" cols="132"><?php echo htmlspecialchars($bat_content, ENT_QUOTES); ?></textarea>
114 <?php
119 if ($check_for_file == 0) {
120 echo xlt('No log file exist for the selected date').': '.$start_date;
125 </body>
126 </html>