Merge pull request #1128 from bradymiller/unique-insurance-report-cleanup_1
[openemr.git] / interface / billing / get_claim_file.php
blob4af5c0f3acc24a8da420f10a964422d906a2556a
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 require_once(dirname(__FILE__) . "/../globals.php");
8 require_once $GLOBALS['OE_SITE_DIR'] . "/config.php";
10 $content_type = "text/plain";
11 $claim_file_dir = $GLOBALS['OE_SITE_DIR'] . "/edi/";
13 $fname = $_GET['key'];
14 $fname = preg_replace("[/]", "", $fname);
15 $fname = preg_replace("[\.\.]", "", $fname);
16 $fname = preg_replace("[\\\\]", "", $fname);
18 if (strtolower(substr($fname, (strlen($fname)-4))) == ".pdf") {
19 $content_type = "application/pdf";
22 $fname = $claim_file_dir . $fname;
24 if (!file_exists($fname)) {
25 echo xl("The claim file: ") . $_GET['key'] . xl(" could not be accessed.");
26 } else {
27 $fp = fopen($fname, 'r');
29 header("Pragma: public");
30 header("Expires: 0");
31 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
32 header("Content-Type: $content_type");
33 header("Content-Length: " . filesize($fname));
34 header("Content-Disposition: attachment; filename=" . basename($fname));
36 // dump the picture and stop the script
37 fpassthru($fp);
40 exit;