/** * This function is supposed to allow the downloading of a file. * * Not used or tested -- do not use. Since the users cannot scan the directories, * the file to be downloaded would have to be selected from a csv table display * or some other listing produced by reading the directories. * * @todo implement this function * @param string $filename * @return void --save file dialogue */ function csv_download_file($filename) { // adapted from http://php.net/manual/en/function.header.php // phpnet at holodyn dot com 31-Jan-2011 01:01 // Must be fresh start // ///////////////////// this function not used as of now and probably doesn't work ////////////////////////////////////////////////////////////////////////////////////// // but a "view file" function will be made, probably as a separate page // links in csv file // <a href='edi_view_file.php?key=filename' target='_blank'>filename</a> // OpenEMR open log link: <a href='../../library/freeb/process_bills.log' target='_blank' class='link_submit' title=''>[View Log]</a> if (headers_sent()) { csv_edihist_log("csv_download_file: error headers already sent"); return FALSE; } //FILTER_SANITIZE_URL //$filename = $_GET['dlkey']; // $filename = filter_input(INPUT_GET, 'dlkey', FILTER_SANITIZE_STRING); $fp = csv_check_filepath($filename); if (!fp) { csv_edihist_log("csv_download_file: invalid filename for download {$filename}"); //echo "csv_download_file: invalid filename for download $filename <br />" . PHP_EOL; return FALSE; // no -- httpd error code 504 } // $file_html = csv_filetohtml($fp); // if ($file_html) { $bn = basename($filename) . '.html'; $ctype = "text/html"; $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); header("Location: http://{$host}{$uri}/{$extra}"); file_put_contents($host . $uri . DIRECTROY_SEPARATOR . $bn, $file_html); $fsize = filesize($host . $uri . DIRECTROY_SEPARATOR . $bn); // } else { csv_edihist_log("csv_download_file: file was not converted to html {$filename}"); //echo "csv_download_file: file was not converted to html $filename <br />" . PHP_EOL; return FALSE; } // Required for some browsers if (ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } $ctype = "application/pdf"; // header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header("Content-Type: {$ctype}"); header("Content-Disposition: attachment; filename=\"" . basename($fp) . "\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $fsize); ob_clean(); flush(); readfile($fp); // exit; }
/** * filter input and generate display of x12 file * * @uses csv_filetohtml() * @uses ibr_upload_files() * @uses ibr_ebr_ebt_name() * @return string */ function ibr_disp_fileText() { // $str_html = ''; //isset($_POST['fileX12']) && isset($_FILES['fileUplx12']) if (count($_FILES) && isset($_FILES['fileUplx12'])) { $fn = htmlentities($_FILES['fileUplx12']['name']); $str_html = ibr_html_heading('newfiles', $fn); $f_array = ibr_upload_files($str_html); if (is_array($f_array) && count($f_array)) { $str_html .= csv_filetohtml($f_array); } else { $str_html = ibr_html_heading('error'); $str_html .= "no files accepted <br />" . PHP_EOL; } } elseif (isset($_GET['fvkey'])) { $fn = filter_input(INPUT_GET, 'fvkey', FILTER_SANITIZE_STRING); // Availity 'readable' versions ibr, ebr, dpr $ishr = isset($_GET['readable']) && $_GET['readable'] == 'yes' ? true : false; if (!$fn) { $str_html = ibr_html_heading('error'); } elseif ($ishr && $fn) { $ftxt = ibr_ebr_ebt_name($fn); $str_html = ibr_html_heading('textdisplay', $ftxt); $str_html .= csv_filetohtml($ftxt); } else { $bn = basename($fn); $str_html = ibr_html_heading('textdisplay', $bn); $str_html .= csv_filetohtml($fn); } } elseif (isset($_GET['btctln'])) { $btisa13 = filter_input(INPUT_GET, 'btctln', FILTER_SANITIZE_STRING); if ($btisa13) { //$btname = ibr_batch_find_file_with_controlnum($btisa13); $btname = csv_file_by_controlnum('batch', $btisa13); $str_html = ibr_html_heading('textdisplay', $btname); if ($btname) { $str_html .= csv_filetohtml($btname); } else { $str_html .= "Failed to identify file with control number {$btisa13} <br />" . PHP_EOL; } } else { $str_html .= "error in file display <br />"; } } else { $str_html = ibr_html_heading('error'); $str_html .= "error in file display <br />"; } return $str_html; }