migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / logview / erx_logview.php
blobdff90594fa318711fec6dd0eebf374ea20dc2ff5
1 <?php
3 /**
4 * interface/logview/erx_logview.php Display NewCrop errors.
6 * Copyright (C) 2011 ZMG LLC <sam@zhservices.com>
8 * LICENSE: This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at your option) any
11 * later version. This program is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details. You should have received a copy of the GNU
15 * General Public License along with this program.
16 * If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @subpackage NewCrop
20 * @author Eldho Chacko <eldho@zhservices.com>
21 * @author Vinish K <vinish@zhservices.com>
22 * @author Sam Likins <sam.likins@wsi-services.com>
23 * @link http://www.open-emr.org
26 $sanitize_all_escapes = true; // SANITIZE ALL ESCAPES
28 $fake_register_globals = false; // STOP FAKE REGISTER GLOBALS
30 require_once(__DIR__.'/../globals.php');
31 require_once($srcdir.'/log.inc');
32 require_once($srcdir.'/formatting.inc.php');
34 $error_log_path = $GLOBALS['OE_SITE_DIR'].'/documents/erx_error';
36 if(array_key_exists('filename', $_REQUEST)) {
37 $filename = $_REQUEST['filename'];
38 } else {
39 $filename = '';
42 if(array_key_exists('start_date', $_REQUEST)) {
43 $start_date = $_REQUEST['start_date'];
44 } else {
45 $start_date = '';
48 if($filename) {
49 $bat_content = '';
51 preg_match('/erx_error-\d{4}-\d{1,2}-\d{1,2}\.log/', $filename, $matches);
53 if($matches) {
54 if($fd = fopen($error_log_path.'/'.$filename, 'r')) {
55 $bat_content = fread($fd, filesize($error_log_path.'/'.$filename));
58 header('Pragma: public');
59 header('Expires: 0');
60 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
61 header('Content-Type: application/force-download');
62 header('Content-Disposition: attachment; filename='.$filename);
63 header('Content-Description: File Transfer');
64 header('Content-Length: '.strlen($bat_content));
66 echo $bat_content;
68 die;
73 <html>
74 <head>
75 <?php html_header_show(); ?>
76 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
77 <link rel="stylesheet" href="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar.css" type="text/css">
78 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
79 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar.js"></script>
80 <?php include_once($GLOBALS['srcdir'].'/dynarch_calendar_en.inc.php'); ?>
81 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar_setup.js"></script>
82 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
83 </head>
84 <body class="body_top">
85 <form method="post">
86 <font class="title"><?php echo xlt('eRx Logs'); ?></font><br><br>
87 <table>
88 <tr>
89 <td>
90 <span class="text"><?php echo xlt('Date'); ?>: </span>
91 </td>
92 <td>
93 <input type="text" size="10" 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'); ?>" onkeyup="datekeyup(this, mypcc)" onblur="dateblur(this, mypcc)" />
94 <img src="<?php echo $GLOBALS['webroot']; ?>/interface/pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_begin_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php echo xlt('Click here to choose a date'); ?>">&nbsp;
95 </td>
96 <td>
97 <input type="submit" name="search_logs" value="<?php echo xlt('Search'); ?>">
98 </td>
99 </tr>
100 </table>
101 </form>
102 <?php
104 $check_for_file = 0;
105 if(array_key_exists('search_logs', $_REQUEST)) {
106 if ($handle = opendir($error_log_path)) {
107 while(false !== ($file = readdir($handle))) {
108 $file_as_in_folder = 'erx_error-'.$start_date.'.log';
110 if($file != '.' && $file != '..' && $file_as_in_folder == $file) {
111 $check_for_file = 1;
112 $fd = fopen ($error_log_path.'/'.$file, 'r');
113 $bat_content = fread($fd, filesize($error_log_path.'/'.$file));
115 <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>
116 <textarea rows="35" cols="132"><?php echo htmlspecialchars($bat_content, ENT_QUOTES); ?></textarea>
117 <?php
121 if($check_for_file == 0) {
122 echo xlt('No log file exist for the selected date').': '.$start_date;
127 </body>
128 <script type="text/javascript">
129 Calendar.setup({inputField:"start_date", ifFormat:"%Y-%m-%d", button:"img_begin_date"});
130 </script>
131 </html>