Consistent Excel Report download SOLVED!
First we need to include the fix in post 4 of this thread.
The issue of filenames starting with a hyphen or underscore may need to be addressed.
The function clean_file_name() in includes/main.inc can also do the job.
Since we are now allowing underscores(_) and hyphens (-) in the random_id()'s filenames, we need to allow it for excel filenames for download too.
Lines 30 to 55 in FA 2.3's reporting/prn_redirect.php:
if (isset($_GET['xls']))
{
$filename = $_GET['filename'];
$unique_name = preg_replace('/[^0-9a-z.]/i', '', $_GET['unique']);
$path = company_path(). '/pdf_files/';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$filename" );
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
echo file_get_contents($path.$unique_name);
exit();
}
elseif (isset($_GET['xml']))
{
$filename = $_GET['filename'];
$unique_name = preg_replace('/[^0-9a-z.]/i', '', $_GET['unique']);
$path = company_path(). '/pdf_files/';
header("content-type: text/xml");
header("Content-Disposition: attachment; filename=$filename");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
echo file_get_contents($path.$unique_name);
exit();
}
can be replaced with:
if (isset($_GET['xls']) || isset($_GET['xml']))
{
$filename = $_GET['filename'];
$unique_name = preg_replace("/[^0-9_a-z.\-]/i", '', $_GET['unique']);
$path = company_path(). '/pdf_files/';
if (isset($_GET['xls'])) header("Content-type: application/vnd.ms-excel");
else header("content-type: text/xml");
header("Content-Disposition: attachment; filename=$filename" );
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
echo file_get_contents($path.$unique_name);
exit();
}
@joe: please update both repos.
PHP PCRE (Regular Expressions) - CheatSheet | Tutorial.
Post's attachmentsFA23_excel_dl.diff 1.6 kb, 1 downloads since 2017-03-19
You don't have the permssions to download the attachments of this post.